Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
commoncrawl_graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephen D
commoncrawl_graph
Commits
a31068ce
Commit
a31068ce
authored
3 months ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
fix maxxing out the node id seq
parent
d7b7011b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bin/import.rs
+14
-77
14 additions, 77 deletions
src/bin/import.rs
with
14 additions
and
77 deletions
src/bin/import.rs
+
14
−
77
View file @
a31068ce
...
...
@@ -138,7 +138,20 @@ async fn get_nodes(
.unzip
();
query!
(
"INSERT INTO nodes(name) SELECT UNNEST($1::text[]) ON CONFLICT DO NOTHING;"
,
r#"
WITH unique_names AS (
SELECT UNNEST($1::text[]) AS name
)
INSERT INTO nodes(name)
SELECT un.name
FROM unique_names un
WHERE NOT EXISTS (
SELECT 1
FROM nodes n
WHERE n.name = un.name
)
ON CONFLICT DO NOTHING;
"#
,
&
names
)
.execute
(
&
p
)
...
...
@@ -429,79 +442,3 @@ async fn populate_tables(
Ok
(())
}
async
fn
create_indexes
(
pool
:
&
Pool
<
Postgres
>
)
->
anyhow
::
Result
<
()
>
{
query!
(
"ALTER TABLE nodes_dupe ADD CONSTRAINT nodes_dupe_pkey PRIMARY KEY (id);"
)
.execute
(
pool
)
.await
?
;
query!
(
"ALTER TABLE edges_dupe ADD CONSTRAINT edges_dupe_pkey PRIMARY KEY (from_id, to_id);"
)
.execute
(
pool
)
.await
?
;
query!
(
"CREATE INDEX nodes_text_idx_dupe ON nodes_dupe(name text_pattern_ops);"
)
.execute
(
pool
)
.await
?
;
query!
(
"CREATE INDEX edges_from_id_idx_dupe ON edges_dupe(from_id);"
)
.execute
(
pool
)
.await
?
;
query!
(
"CREATE INDEX edges_to_id_idx_dupe ON edges_dupe(to_id);"
)
.execute
(
pool
)
.await
?
;
Ok
(())
}
async
fn
swap_tables
(
pool
:
&
Pool
<
Postgres
>
)
->
anyhow
::
Result
<
()
>
{
let
mut
tx
=
pool
.begin
()
.await
?
;
query!
(
"DROP TABLE nodes"
)
.execute
(
&
mut
*
tx
)
.await
?
;
query!
(
"DROP TABLE edges"
)
.execute
(
&
mut
*
tx
)
.await
?
;
query!
(
"ALTER TABLE nodes_dupe RENAME TO nodes"
)
.execute
(
&
mut
*
tx
)
.await
?
;
query!
(
"ALTER TABLE edges_dupe RENAME TO edges"
)
.execute
(
&
mut
*
tx
)
.await
?
;
query!
(
"ALTER INDEX nodes_text_idx_dupe RENAME TO nodes_text_idx"
)
.execute
(
&
mut
*
tx
)
.await
?
;
query!
(
"ALTER INDEX edges_from_id_idx_dupe RENAME TO edges_from_id_idx"
)
.execute
(
&
mut
*
tx
)
.await
?
;
query!
(
"ALTER INDEX edges_to_id_idx_dupe RENAME TO edges_to_id_idx"
)
.execute
(
&
mut
*
tx
)
.await
?
;
tx
.commit
()
.await
?
;
Ok
(())
}
async
fn
create_tables
(
pool
:
&
Pool
<
Postgres
>
)
->
anyhow
::
Result
<
()
>
{
query!
(
"
CREATE TABLE nodes_dupe(
id INT NOT NULL,
name TEXT NOT NULL
);
"
)
.execute
(
pool
)
.await
?
;
query!
(
"
CREATE TABLE edges_dupe(
from_id INT NOT NULL,
to_id INT NOT NULL
);
"
)
.execute
(
pool
)
.await
?
;
Ok
(())
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment