Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ databases/metadata_inventory.md
bin/issundb-mcp
bin/issundb-rest
bin/issundb-cli
*.cache
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COMP_DB ?= databases/comp-kg
KERNELS_PER_COMPETITION ?= 50
ISSUNDB_CLI ?= bin/issundb-cli
ISSUNDB_MCP ?= bin/issundb-mcp
MAP_SIZE_GB ?= 8
MAP_SIZE_GB ?= 12

# Kernel knowledge graph build settings
KERNEL_DB ?= databases/kernel-kg
Expand Down
1 change: 1 addition & 0 deletions scripts/issundb_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def build_script(
lines.append(f"CREATE INDEX FOR (n:{label}) ON (n.{prop})")

lines.append("rebuild-csr")
lines.append("materialize-columns")
lines.append("stats")
lines.append("quit")
return "\n".join(lines) + "\n", expected_nodes
Expand Down
18 changes: 17 additions & 1 deletion scripts/stage_competition_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,24 @@ def csv(meta_dir: Path, name: str) -> str:


def copy_parquet(con: duckdb.DuckDBPyConnection, query: str, output: Path) -> None:
"""Write `query` to a Parquet file, ordered by its first column.

Every node query selects `Id` first and every edge query selects its source
first, so one `ORDER BY 1` sorts both usefully. It is a load-time
optimization rather than a cosmetic one, and the two halves only pay off
together: the importer allocates node ids in file order, so sorting the node
files makes an IssunDB id ascend with the domain `Id`, and sorting the edge
files by source then makes the `out_adj` writes land in ascending key order
instead of scattering across the tree. Measured on a synthetic 1 M-node,
4 M-edge graph, that took the edge phase from 19.5 s to 14.0 s.

Sorting costs a little here, where DuckDB is doing it over a columnar batch,
and saves more there, where the alternative is random B-tree page access.
"""
output.parent.mkdir(parents=True, exist_ok=True)
con.execute(f"COPY ({query}) TO {sql_literal(output)} (FORMAT PARQUET)")
con.execute(
f"COPY (SELECT * FROM ({query}) ORDER BY 1) TO {sql_literal(output)} (FORMAT PARQUET)"
)


def warn_on_unparseable_enabled_dates(con: duckdb.DuckDBPyConnection, meta_dir: Path) -> None:
Expand Down
7 changes: 6 additions & 1 deletion tests/test_issundb_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def test_orders_nodes_before_edges_and_appends_constraints(self, tmp_path: Path)
assert lines[1] == f":import-edges {(tmp_path / 'edges_a.parquet').resolve()} A A SELF"
assert "CREATE CONSTRAINT ON (n:A) ASSERT n.Id IS UNIQUE" in lines
assert "CREATE INDEX FOR (n:A) ON (n.Name)" in lines
assert lines[-3:] == ["rebuild-csr", "stats", "quit"]
assert lines[-4:] == [
"rebuild-csr",
"materialize-columns",
"stats",
"quit",
]
assert expected_nodes == {"nodes_a.parquet": 2}

def test_missing_node_file_raises_with_hint(self, tmp_path: Path) -> None:
Expand Down
Loading
Loading