Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Kristian Klausen
aurweb
Commits
3062a78a
Commit
3062a78a
authored
Sep 04, 2020
by
Jakub Klinkovský
Committed by
Lukas Fleischer
Feb 20, 2021
Browse files
gendummydata.py: optimize iteration for big numbers of pkgs
Signed-off-by:
Lukas Fleischer
<
lfleischer@archlinux.org
>
parent
51a35358
Changes
1
Hide whitespace changes
Inline
Side-by-side
schema/gendummydata.py
View file @
3062a78a
...
...
@@ -259,20 +259,23 @@ for p in list(track_votes.keys()):
# Create package dependencies and sources
#
log
.
debug
(
"Creating statements for package depends/sources."
)
for
p
in
list
(
seen_pkgs
.
keys
()):
# the keys of seen_pkgs are accessed many times by random.choice,
# so the list has to be created outside the loops to keep it efficient
seen_pkgs_keys
=
list
(
seen_pkgs
.
keys
())
for
p
in
seen_pkgs_keys
:
num_deps
=
random
.
randrange
(
PKG_DEPS
[
0
],
PKG_DEPS
[
1
])
for
i
in
range
(
0
,
num_deps
):
dep
=
random
.
choice
(
[
k
for
k
in
seen_pkgs
]
)
dep
=
random
.
choice
(
seen_pkgs
_keys
)
deptype
=
random
.
randrange
(
1
,
5
)
if
deptype
==
4
:
dep
+=
": for "
+
random
.
choice
(
[
k
for
k
in
seen_pkgs
]
)
dep
+=
": for "
+
random
.
choice
(
seen_pkgs
_keys
)
s
=
"INSERT INTO PackageDepends(PackageID, DepTypeID, DepName) VALUES (%d, %d, '%s');
\n
"
s
=
s
%
(
seen_pkgs
[
p
],
deptype
,
dep
)
out
.
write
(
s
)
num_rels
=
random
.
randrange
(
PKG_RELS
[
0
],
PKG_RELS
[
1
])
for
i
in
range
(
0
,
num_deps
):
rel
=
random
.
choice
(
[
k
for
k
in
seen_pkgs
]
)
rel
=
random
.
choice
(
seen_pkgs
_keys
)
reltype
=
random
.
randrange
(
1
,
4
)
s
=
"INSERT INTO PackageRelations(PackageID, RelTypeID, RelName) VALUES (%d, %d, '%s');
\n
"
s
=
s
%
(
seen_pkgs
[
p
],
reltype
,
rel
)
...
...
Write
Preview
Supports
Markdown
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