Skip to content

Commit a9013ab

Browse files
committed
Refactor SQLite integration in Python examples
- Renamed functions and variables to remove the "native" suffix from SQLite-related methods for consistency and clarity. - Updated example scripts and benchmark results to reflect the new naming conventions for SQLite. - Adjusted dataset and memory limits in various scripts to use "stackoverflow-tiny" and reduced memory limits for testing. - Ensured all references to SQLite in documentation and scripts are consistent with the new naming. - Improved overall readability and maintainability of the codebase by standardizing function names and parameters.
1 parent 5b309fa commit a9013ab

14 files changed

Lines changed: 127 additions & 129 deletions

bindings/python/examples/09_stackoverflow_graph_oltp.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4834,7 +4834,7 @@ def _configure_sqlite_connection(
48344834
}
48354835

48364836

4837-
def _connect_sqlite_native(
4837+
def _connect_sqlite(
48384838
db_file: Path,
48394839
sqlite_profile: str,
48404840
) -> Tuple[sqlite3.Connection, Dict[str, Any]]:
@@ -4843,7 +4843,7 @@ def _connect_sqlite_native(
48434843
return conn, pragma_config
48444844

48454845

4846-
def _create_sqlite_native_schema(conn: sqlite3.Connection) -> float:
4846+
def _create_sqlite_schema(conn: sqlite3.Connection) -> float:
48474847
statements = [
48484848
"CREATE TABLE IF NOT EXISTS User(Id INTEGER PRIMARY KEY, DisplayName TEXT, Reputation INTEGER, CreationDate INTEGER, Views INTEGER, UpVotes INTEGER, DownVotes INTEGER)",
48494849
"CREATE TABLE IF NOT EXISTS Question(Id INTEGER PRIMARY KEY, Title TEXT, Body TEXT, Score INTEGER, ViewCount INTEGER, CreationDate INTEGER, AnswerCount INTEGER, CommentCount INTEGER, FavoriteCount INTEGER)",
@@ -4889,7 +4889,7 @@ def _create_sqlite_native_schema(conn: sqlite3.Connection) -> float:
48894889
return index_time_s
48904890

48914891

4892-
def _load_stackoverflow_sqlite_native(
4892+
def _load_stackoverflow_sqlite(
48934893
conn: sqlite3.Connection,
48944894
data_dir: Path,
48954895
batch_size: int,
@@ -5314,7 +5314,7 @@ def flush(batch: List[Tuple[Any, ...]], table: str, columns: List[str]) -> None:
53145314
return load_info, load_stats
53155315

53165316

5317-
def _count_sqlite_native_by_type(
5317+
def _count_sqlite_by_type(
53185318
conn: sqlite3.Connection,
53195319
vertex_types: List[str],
53205320
edge_types: List[str],
@@ -6239,7 +6239,7 @@ def worker(ops: List[str], worker_id: int) -> Dict[str, List[float]]:
62396239
}
62406240

62416241

6242-
def run_graph_oltp_sqlite_native(
6242+
def run_graph_oltp_sqlite(
62436243
db_path: Path,
62446244
data_dir: Path,
62456245
batch_size: int,
@@ -6252,18 +6252,18 @@ def run_graph_oltp_sqlite_native(
62526252
shutil.rmtree(db_path)
62536253
db_path.mkdir(parents=True, exist_ok=True)
62546254

6255-
db_file = db_path / "sqlite_native.sqlite"
6256-
conn, sqlite_pragmas = _connect_sqlite_native(db_file, sqlite_profile)
6255+
db_file = db_path / "sqlite.sqlite"
6256+
conn, sqlite_pragmas = _connect_sqlite(db_file, sqlite_profile)
62576257

62586258
print("Creating schema...")
62596259
schema_start = time.time()
6260-
index_time_s = _create_sqlite_native_schema(conn)
6260+
index_time_s = _create_sqlite_schema(conn)
62616261
schema_total_time = time.time() - schema_start
62626262
schema_time = max(0.0, schema_total_time - index_time_s)
62636263

62646264
print("Loading graph...")
62656265
load_start = time.time()
6266-
load_info, load_stats = _load_stackoverflow_sqlite_native(
6266+
load_info, load_stats = _load_stackoverflow_sqlite(
62676267
conn,
62686268
data_dir,
62696269
batch_size=max(1, batch_size),
@@ -6286,7 +6286,7 @@ def run_graph_oltp_sqlite_native(
62866286
)
62876287
load_counts_time = time.time() - load_counts_start
62886288

6289-
load_node_counts_by_type, load_edge_counts_by_type = _count_sqlite_native_by_type(
6289+
load_node_counts_by_type, load_edge_counts_by_type = _count_sqlite_by_type(
62906290
conn,
62916291
ARCADE_VERTEX_TYPES,
62926292
ARCADE_EDGE_TYPES,
@@ -6313,7 +6313,7 @@ def worker(ops: List[str], worker_id: int) -> Dict[str, List[float]]:
63136313
nonlocal next_answer_id
63146314
nonlocal next_badge_id
63156315
nonlocal next_comment_id
6316-
local_conn, _ = _connect_sqlite_native(db_file, sqlite_profile)
6316+
local_conn, _ = _connect_sqlite(db_file, sqlite_profile)
63176317

63186318
def safe_execute(statement: str, params: Tuple[Any, ...] = ()) -> None:
63196319
try:
@@ -6871,7 +6871,7 @@ def safe_execute(statement: str, params: Tuple[Any, ...] = ()) -> None:
68716871
)
68726872
counts_time = time.time() - counts_start
68736873

6874-
node_counts_by_type, edge_counts_by_type = _count_sqlite_native_by_type(
6874+
node_counts_by_type, edge_counts_by_type = _count_sqlite_by_type(
68756875
conn,
68766876
ARCADE_VERTEX_TYPES,
68776877
ARCADE_EDGE_TYPES,
@@ -7839,7 +7839,7 @@ def main():
78397839
"ladybug",
78407840
"ladybugdb",
78417841
"graphqlite",
7842-
"sqlite_native",
7842+
"sqlite",
78437843
"python_memory",
78447844
],
78457845
default="arcadedb_cypher",
@@ -7944,7 +7944,7 @@ def main():
79447944
print("=" * 80)
79457945
print(f"Dataset: {args.dataset}")
79467946
print(f"DB: {args.db}")
7947-
if args.db in ("sqlite_native", "graphqlite"):
7947+
if args.db in ("sqlite", "graphqlite"):
79487948
print(f"SQLite profile: {args.sqlite_profile}")
79497949
print(f"Threads: {args.threads}")
79507950
print(f"Operations: {args.transactions:,}")
@@ -7987,8 +7987,8 @@ def main():
79877987
seed=args.seed,
79887988
sqlite_profile=args.sqlite_profile,
79897989
)
7990-
elif args.db == "sqlite_native":
7991-
summary = run_graph_oltp_sqlite_native(
7990+
elif args.db == "sqlite":
7991+
summary = run_graph_oltp_sqlite(
79927992
db_path=db_path,
79937993
data_dir=data_dir,
79947994
batch_size=args.batch_size,
@@ -8008,7 +8008,7 @@ def main():
80088008
)
80098009
else:
80108010
raise NotImplementedError(
8011-
"Only arcadedb, ladybugdb, graphqlite, sqlite_native, and python_memory are supported"
8011+
"Only arcadedb, ladybugdb, graphqlite, sqlite, and python_memory are supported"
80128012
)
80138013

80148014
print("\nResults")

bindings/python/examples/10_stackoverflow_graph_olap.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,7 @@ def query_name_from_cypher(cypher: str) -> str:
25762576
raise ValueError("Unsupported query for this backend")
25772577

25782578

2579-
def execute_sqlite_native_olap_query(
2579+
def execute_sqlite_olap_query(
25802580
conn: sqlite3.Connection, query_name: str
25812581
) -> List[Dict[str, Any]]:
25822582
sql_by_name = {
@@ -2692,7 +2692,7 @@ def execute_sqlite_native_olap_query(
26922692
}
26932693
sql = sql_by_name.get(query_name)
26942694
if not sql:
2695-
raise ValueError(f"Unsupported sqlite-native query: {query_name}")
2695+
raise ValueError(f"Unsupported sqlite query: {query_name}")
26962696
cursor = conn.execute(sql)
26972697
cols = [desc[0] for desc in cursor.description]
26982698
return [dict(zip(cols, row)) for row in cursor.fetchall()]
@@ -3224,7 +3224,7 @@ def _clean_props(props: Dict[str, Any]) -> Dict[str, Any]:
32243224
return {key: value for key, value in props.items() if value is not None}
32253225

32263226

3227-
def _connect_sqlite_native(
3227+
def _connect_sqlite(
32283228
db_file: Path,
32293229
sqlite_profile: str,
32303230
) -> Tuple[sqlite3.Connection, Dict[str, Any]]:
@@ -3233,7 +3233,7 @@ def _connect_sqlite_native(
32333233
return conn, pragma_config
32343234

32353235

3236-
def _create_sqlite_native_schema(conn: sqlite3.Connection) -> float:
3236+
def _create_sqlite_schema(conn: sqlite3.Connection) -> float:
32373237
statements = [
32383238
"CREATE TABLE IF NOT EXISTS User(Id INTEGER PRIMARY KEY, DisplayName TEXT, Reputation INTEGER, CreationDate INTEGER, Views INTEGER, UpVotes INTEGER, DownVotes INTEGER)",
32393239
"CREATE TABLE IF NOT EXISTS Question(Id INTEGER PRIMARY KEY, Title TEXT, Body TEXT, Score INTEGER, ViewCount INTEGER, CreationDate INTEGER, AnswerCount INTEGER, CommentCount INTEGER, FavoriteCount INTEGER)",
@@ -3279,7 +3279,7 @@ def _create_sqlite_native_schema(conn: sqlite3.Connection) -> float:
32793279
return index_time_s
32803280

32813281

3282-
def _load_stackoverflow_sqlite_native(
3282+
def _load_stackoverflow_sqlite(
32833283
conn: sqlite3.Connection,
32843284
data_dir: Path,
32853285
batch_size: int,
@@ -3704,7 +3704,7 @@ def flush(batch: List[Tuple[Any, ...]], table: str, columns: List[str]) -> None:
37043704
return load_info, load_stats
37053705

37063706

3707-
def _count_sqlite_native_by_type(
3707+
def _count_sqlite_by_type(
37083708
conn: sqlite3.Connection,
37093709
vertex_types: List[str],
37103710
edge_types: List[str],
@@ -4428,7 +4428,7 @@ def _load_stackoverflow_python_memory(
44284428
return load_info, load_stats
44294429

44304430

4431-
def run_olap_sqlite_native(
4431+
def run_olap_sqlite(
44324432
db_path: Path,
44334433
data_dir: Path,
44344434
batch_size: int,
@@ -4442,19 +4442,19 @@ def run_olap_sqlite_native(
44424442
if db_path.exists():
44434443
shutil.rmtree(db_path)
44444444
db_path.mkdir(parents=True, exist_ok=True)
4445-
db_file = db_path / "sqlite_native.sqlite"
4445+
db_file = db_path / "sqlite.sqlite"
44464446

4447-
conn, sqlite_pragmas = _connect_sqlite_native(db_file, sqlite_profile)
4447+
conn, sqlite_pragmas = _connect_sqlite(db_file, sqlite_profile)
44484448

44494449
print("Creating schema...")
44504450
schema_start = time.time()
4451-
index_time = _create_sqlite_native_schema(conn)
4451+
index_time = _create_sqlite_schema(conn)
44524452
schema_total_time = time.time() - schema_start
44534453
schema_time = max(0.0, schema_total_time - index_time)
44544454

44554455
print("Loading graph...")
44564456
load_start = time.time()
4457-
_, load_stats = _load_stackoverflow_sqlite_native(
4457+
_, load_stats = _load_stackoverflow_sqlite(
44584458
conn,
44594459
data_dir,
44604460
batch_size=max(1, batch_size),
@@ -4463,7 +4463,7 @@ def run_olap_sqlite_native(
44634463
load_time = load_time_including_index
44644464

44654465
load_counts_start = time.time()
4466-
load_node_counts_by_type, load_edge_counts_by_type = _count_sqlite_native_by_type(
4466+
load_node_counts_by_type, load_edge_counts_by_type = _count_sqlite_by_type(
44674467
conn,
44684468
VERTEX_TYPES,
44694469
EDGE_TYPES,
@@ -4478,9 +4478,7 @@ def run_olap_sqlite_native(
44784478

44794479
print("Running OLAP queries...")
44804480
query_results, query_time = run_queries(
4481-
lambda cypher: execute_sqlite_native_olap_query(
4482-
conn, query_name_from_cypher(cypher)
4483-
),
4481+
lambda cypher: execute_sqlite_olap_query(conn, query_name_from_cypher(cypher)),
44844482
only_query=only_query,
44854483
query_runs=query_runs,
44864484
query_order=query_order,
@@ -4490,7 +4488,7 @@ def run_olap_sqlite_native(
44904488
if manual_checks:
44914489
manual_results = [
44924490
compute_manual_total_comments(
4493-
lambda cypher: execute_sqlite_native_olap_query(
4491+
lambda cypher: execute_sqlite_olap_query(
44944492
conn, query_name_from_cypher(cypher)
44954493
)
44964494
)
@@ -4499,7 +4497,7 @@ def run_olap_sqlite_native(
44994497
disk_after_queries = get_dir_size_bytes(db_path)
45004498

45014499
counts_start = time.time()
4502-
node_counts_by_type, edge_counts_by_type = _count_sqlite_native_by_type(
4500+
node_counts_by_type, edge_counts_by_type = _count_sqlite_by_type(
45034501
conn,
45044502
VERTEX_TYPES,
45054503
EDGE_TYPES,
@@ -5038,7 +5036,7 @@ def main():
50385036
"ladybug",
50395037
"ladybugdb",
50405038
"graphqlite",
5041-
"sqlite_native",
5039+
"sqlite",
50425040
"python_memory",
50435041
],
50445042
default="arcadedb_cypher",
@@ -5072,7 +5070,7 @@ def main():
50725070
"--sqlite-profile",
50735071
choices=SQLITE_PROFILE_CHOICES,
50745072
default="olap",
5075-
help="SQLite profile for sqlite-native/graphqlite backends (default: olap)",
5073+
help="SQLite profile for sqlite/graphqlite backends (default: olap)",
50765074
)
50775075
parser.add_argument(
50785076
"--docker-image",
@@ -5159,7 +5157,7 @@ def main():
51595157
print(f"DB: {args.db}")
51605158
if args.db in ("arcadedb_sql", "arcadedb_cypher"):
51615159
print(f"ArcadeDB OLAP language: {args.arcadedb_olap_language}")
5162-
if args.db in ("sqlite_native", "graphqlite", "python_memory"):
5160+
if args.db in ("sqlite", "graphqlite", "python_memory"):
51635161
print(f"SQLite profile: {args.sqlite_profile}")
51645162
print(f"Batch size: {args.batch_size}")
51655163
print(f"Query runs: {args.query_runs}")
@@ -5198,8 +5196,8 @@ def main():
51985196
query_order=args.query_order,
51995197
seed=args.seed,
52005198
)
5201-
elif args.db == "sqlite_native":
5202-
summary = run_olap_sqlite_native(
5199+
elif args.db == "sqlite":
5200+
summary = run_olap_sqlite(
52035201
db_path=db_path,
52045202
data_dir=data_dir,
52055203
batch_size=args.batch_size,

bindings/python/examples/benchmark_results/summary_09_graph_oltp_all_datasets.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
| arcadedb_cypher | sweep09_t08_r01_arcadedb_cypher_s00000_m16g | 0 | 8 | 250,000 | 10,000 | 16g | 7,782,816 | 9,770,001 | 0.187 | 136.272 | 6,441.466 | 0.001 | 392.245 | 637.357 | 34.938 | 13,287.195 | 4,057.117 |
3030
| ladybug | sweep09_t01_r01_ladybug_s00002_m16g | 2 | 1 | 250,000 | 10,000 | 16g | 7,782,816 | 9,770,001 | 0.082 | | 350.137 | 1.09 | 5,028.21 | 49.719 | 84.881 | 11,859.805 | 6,104.633 |
3131
| python_memory | sweep09_t01_r01_python_memory_s00003_m16g | 3 | 1 | 250,000 | 10,000 | 16g | 7,782,816 | 9,770,001 | 0 | 0 | 158.887 | 1.419 | 13,752.43 | 18.179 | 181.45 | 9,033.387 | 3,002.098 |
32-
| sqlite_native | sweep09_t01_r01_sqlite_native_s00003_m8g | 3 | 1 | 250,000 | 10,000 | 8g | 7,782,816 | 9,770,001 | 0.006 | 0.001 | 324.433 | 4.797 | 176.24 | 1,418.523 | 0.117 | 730.355 | 3,465.57 |
33-
| sqlite_native | sweep09_t04_r01_sqlite_native_s00003_m8g | 3 | 4 | 250,000 | 10,000 | 8g | 7,782,816 | 9,770,001 | 0.979 | 0.001 | 272.435 | 0.951 | 141.632 | 1,765.143 | 1.112 | 739.402 | 3,465.59 |
34-
| sqlite_native | sweep09_t08_r01_sqlite_native_s00003_m8g | 3 | 8 | 250,000 | 10,000 | 8g | 7,782,816 | 9,770,001 | 0.013 | 0.001 | 248.3 | 0.791 | 127.271 | 1,964.32 | 3.2 | 748.355 | 3,465.574 |
32+
| sqlite | sweep09_t01_r01_sqlite_s00003_m8g | 3 | 1 | 250,000 | 10,000 | 8g | 7,782,816 | 9,770,001 | 0.006 | 0.001 | 324.433 | 4.797 | 176.24 | 1,418.523 | 0.117 | 730.355 | 3,465.57 |
33+
| sqlite | sweep09_t04_r01_sqlite_s00003_m8g | 3 | 4 | 250,000 | 10,000 | 8g | 7,782,816 | 9,770,001 | 0.979 | 0.001 | 272.435 | 0.951 | 141.632 | 1,765.143 | 1.112 | 739.402 | 3,465.59 |
34+
| sqlite | sweep09_t08_r01_sqlite_s00003_m8g | 3 | 8 | 250,000 | 10,000 | 8g | 7,782,816 | 9,770,001 | 0.013 | 0.001 | 248.3 | 0.791 | 127.271 | 1,964.32 | 3.2 | 748.355 | 3,465.574 |
3535

3636
### Per-operation OLTP details
3737

@@ -53,15 +53,15 @@
5353
| python_memory | sweep09_t01_r01_python_memory_s00003_m16g | insert | 25,102 | 1.825 | 0.015 | 0.025 | 0.03 |
5454
| python_memory | sweep09_t01_r01_python_memory_s00003_m16g | read | 149,761 | 10.89 | 42.695 | 171.426 | 203.898 |
5555
| python_memory | sweep09_t01_r01_python_memory_s00003_m16g | update | 50,062 | 3.64 | 0.008 | 0.016 | 0.02 |
56-
| sqlite_native | sweep09_t01_r01_sqlite_native_s00003_m8g | delete | 25,075 | 142.278 | 0.014 | 17.148 | 24.015 |
57-
| sqlite_native | sweep09_t01_r01_sqlite_native_s00003_m8g | insert | 25,102 | 142.431 | 0.03 | 0.101 | 0.163 |
58-
| sqlite_native | sweep09_t01_r01_sqlite_native_s00003_m8g | read | 149,761 | 849.758 | 0.011 | 0.055 | 0.115 |
59-
| sqlite_native | sweep09_t01_r01_sqlite_native_s00003_m8g | update | 50,062 | 284.056 | 0.01 | 0.026 | 0.096 |
60-
| sqlite_native | sweep09_t04_r01_sqlite_native_s00003_m8g | delete | 25,075 | 177.044 | 0.018 | 23.349 | 40.331 |
61-
| sqlite_native | sweep09_t04_r01_sqlite_native_s00003_m8g | insert | 25,102 | 177.234 | 0.02 | 0.159 | 13.099 |
62-
| sqlite_native | sweep09_t04_r01_sqlite_native_s00003_m8g | read | 149,761 | 1,057.398 | 0.013 | 0.073 | 7.885 |
63-
| sqlite_native | sweep09_t04_r01_sqlite_native_s00003_m8g | update | 50,062 | 353.466 | 0.008 | 0.043 | 0.141 |
64-
| sqlite_native | sweep09_t08_r01_sqlite_native_s00003_m8g | delete | 25,075 | 197.021 | 0.018 | 19.096 | 31.176 |
65-
| sqlite_native | sweep09_t08_r01_sqlite_native_s00003_m8g | insert | 25,102 | 197.233 | 0.022 | 0.146 | 12.888 |
66-
| sqlite_native | sweep09_t08_r01_sqlite_native_s00003_m8g | read | 149,761 | 1,176.714 | 0.015 | 0.099 | 13.004 |
67-
| sqlite_native | sweep09_t08_r01_sqlite_native_s00003_m8g | update | 50,062 | 393.351 | 0.008 | 0.045 | 1.575 |
56+
| sqlite | sweep09_t01_r01_sqlite_s00003_m8g | delete | 25,075 | 142.278 | 0.014 | 17.148 | 24.015 |
57+
| sqlite | sweep09_t01_r01_sqlite_s00003_m8g | insert | 25,102 | 142.431 | 0.03 | 0.101 | 0.163 |
58+
| sqlite | sweep09_t01_r01_sqlite_s00003_m8g | read | 149,761 | 849.758 | 0.011 | 0.055 | 0.115 |
59+
| sqlite | sweep09_t01_r01_sqlite_s00003_m8g | update | 50,062 | 284.056 | 0.01 | 0.026 | 0.096 |
60+
| sqlite | sweep09_t04_r01_sqlite_s00003_m8g | delete | 25,075 | 177.044 | 0.018 | 23.349 | 40.331 |
61+
| sqlite | sweep09_t04_r01_sqlite_s00003_m8g | insert | 25,102 | 177.234 | 0.02 | 0.159 | 13.099 |
62+
| sqlite | sweep09_t04_r01_sqlite_s00003_m8g | read | 149,761 | 1,057.398 | 0.013 | 0.073 | 7.885 |
63+
| sqlite | sweep09_t04_r01_sqlite_s00003_m8g | update | 50,062 | 353.466 | 0.008 | 0.043 | 0.141 |
64+
| sqlite | sweep09_t08_r01_sqlite_s00003_m8g | delete | 25,075 | 197.021 | 0.018 | 19.096 | 31.176 |
65+
| sqlite | sweep09_t08_r01_sqlite_s00003_m8g | insert | 25,102 | 197.233 | 0.022 | 0.146 | 12.888 |
66+
| sqlite | sweep09_t08_r01_sqlite_s00003_m8g | read | 149,761 | 1,176.714 | 0.015 | 0.099 | 13.004 |
67+
| sqlite | sweep09_t08_r01_sqlite_s00003_m8g | update | 50,062 | 393.351 | 0.008 | 0.045 | 1.575 |

0 commit comments

Comments
 (0)