Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
31dfd3a1
Commit
31dfd3a1
authored
Mar 01, 2013
by
Arjen Lentz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding deterministic graph generator for oqgraph
Adding social test suite
parent
1a11797f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
0 deletions
+127
-0
mysql-test/suite/oqgraph/randgraphproc.inc
mysql-test/suite/oqgraph/randgraphproc.inc
+62
-0
mysql-test/suite/oqgraph/social.test
mysql-test/suite/oqgraph/social.test
+65
-0
No files found.
mysql-test/suite/oqgraph/randgraphproc.inc
0 → 100644
View file @
31dfd3a1
# SQL implementation of randsocial.c for OQGRAPH
# Copyright (C) by Arjen Lentz <arjen@openquery.com> for Open Query
# GPL v2+ licensed with the rest of OQGRAPH
# for use in mysql-test
# 2013-03-01 first implementation based on randsocial.c in old oqgraph v2 tree
delimiter
|
;
--
disable_warnings
DROP
PROCEDURE
IF
EXISTS
randnotx
|
--
enable_warnings
CREATE
PROCEDURE
randnotx
(
INOUT
rseed
INT
,
IN
items
INT
,
IN
x
INT
,
OUT
rval
INT
)
BEGIN
REPEAT
# Simple LCG (BSD)
SET
rseed
=
(
rseed
*
1103515245
+
12345
)
&
2147483647
;
SET
rval
=
((
rseed
>>
16
)
&
32767
)
MOD
items
;
UNTIL
rval
<>
x
END
REPEAT
;
END
|
--
disable_warnings
DROP
PROCEDURE
IF
EXISTS
randgraphproc
|
--
enable_warnings
# this procedure is deterministic with its private seeded random generator
CREATE
PROCEDURE
randgraphproc
(
IN
items
INT
,
IN
friends
INT
,
IN
fanof
INT
,
IN
maxweight
INT
)
BEGIN
DECLARE
i
,
j
,
weight
,
rseed
,
rval
INT
;
# we need repeatability even in multi-threading
SET
rseed
=
items
;
SET
i
=
0
;
WHILE
i
<
items
DO
SET
j
=
0
;
WHILE
j
<
(
friends
+
fanof
)
DO
CALL
randnotx
(
rseed
,
items
,
i
,
rval
);
IF
(
maxweight
>
0
)
THEN
# Use -1 as we don't need to exclude anything
CALL
randnotx
(
rseed
,
items
,
-
1
,
weight
);
SET
weight
=
weight
MOD
maxweight
;
ELSE
SET
weight
=
0
;
END
IF
;
# SELECT CONCAT('INSERT IGNORE rsb VALUES (',i,',',rval,',',weight,');');
INSERT
IGNORE
rsb
VALUES
(
i
,
rval
,
weight
);
# only create backlinks for friends, not fans
IF
(
j
<
friends
)
THEN
# SELECT CONCAT('INSERT IGNORE rsb VALUES (',rval,',',i,',',weight,');');
INSERT
IGNORE
rsb
VALUES
(
rval
,
i
,
weight
);
END
IF
;
SET
j
=
j
+
1
;
END
WHILE
;
SET
i
=
i
+
1
;
END
WHILE
;
END
|
DELIMITER
;;
mysql-test/suite/oqgraph/social.test
0 → 100644
View file @
31dfd3a1
CREATE
TABLE
rsb
(
f
INT
UNSIGNED
NOT
NULL
,
t
INT
UNSIGNED
NOT
NULL
,
weight
FLOAT
NOT
NULL
,
PRIMARY
KEY
(
`f`
,
`t`
),
KEY
`t`
(
`t`
)
)
ENGINE
=
MyISAM
;
CREATE
TABLE
rsb_graph
(
latch
SMALLINT
UNSIGNED
DEFAULT
NULL
,
origid
BIGINT
UNSIGNED
DEFAULT
NULL
,
destid
BIGINT
UNSIGNED
DEFAULT
NULL
,
weight
DOUBLE
DEFAULT
NULL
,
seq
BIGINT
UNSIGNED
DEFAULT
NULL
,
linkid
BIGINT
UNSIGNED
DEFAULT
NULL
,
KEY
(
latch
,
origid
,
destid
)
USING
HASH
,
KEY
(
latch
,
destid
,
origid
)
USING
HASH
)
ENGINE
=
OQGRAPH
data_table
=
'rsb'
origid
=
'f'
destid
=
't'
weight
=
'weight'
;
# this graph generator is designed to be deterministic
# (so we don't need to ship a large test dataset)
--
source
suite
/
oqgraph
/
randgraphproc
.
inc
# generate social graph of 10000 people having 5 friends (two-way) and being fan of 2 others (one-way)), max weight 3
CALL
randgraphproc
(
10000
,
5
,
2
,
3
);
# some random paths
SELECT
GROUP_CONCAT
(
linkid
ORDER
BY
seq
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
1
AND
destid
=
20
;
SELECT
GROUP_CONCAT
(
linkid
ORDER
BY
seq
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
1595
AND
destid
=
8358
;
SELECT
GROUP_CONCAT
(
linkid
ORDER
BY
seq
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
1
AND
destid
=
9999
;
SELECT
GROUP_CONCAT
(
linkid
ORDER
BY
seq
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
6841
AND
destid
=
615
;
SELECT
GROUP_CONCAT
(
linkid
ORDER
BY
seq
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
369
AND
destid
=
1845
;
SELECT
GROUP_CONCAT
(
linkid
ORDER
BY
seq
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
73
AND
destid
=
914
;
# nonexistent origin
SELECT
GROUP_CONCAT
(
linkid
ORDER
BY
seq
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
12345
AND
destid
=
500
;
# noexistent destination
SELECT
GROUP_CONCAT
(
linkid
ORDER
BY
seq
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
300
AND
destid
=
54321
;
# how many possible destinations from here
SELECT
COUNT
(
*
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
1
;
SELECT
COUNT
(
*
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
8365
;
SELECT
COUNT
(
*
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
976
;
SELECT
COUNT
(
*
)
FROM
rsb_graph
WHERE
latch
=
1
AND
origid
=
74
;
# how many possible sources to here
# this doesn't appear to work right now in v3 ? comes up empty but the dataset is not
SELECT
COUNT
(
*
)
FROM
rsb_graph
WHERE
latch
=
1
AND
destid
=
1
;
SELECT
COUNT
(
*
)
FROM
rsb_graph
WHERE
latch
=
1
AND
destid
=
9999
;
SELECT
COUNT
(
*
)
FROM
rsb_graph
WHERE
latch
=
1
AND
destid
=
52
;
SELECT
COUNT
(
*
)
FROM
rsb_graph
WHERE
latch
=
1
AND
destid
=
6483
;
# breadth first
# other algorithms
# joins
# cleaning up our tables
DROP
TABLE
IF
EXISTS
rsb_graph
;
DROP
TABLE
IF
EXISTS
rsb
;
# cleaning up procs from randgraphproc.inc
DROP
PROCEDURE
randgraphproc
;
DROP
PROCEDURE
randnotx
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment