infra: fix cassandra (prepared stmt) + neo4j (drop APOC, grouped MERGE) generators
This commit is contained in:
@@ -51,37 +51,18 @@ def main():
|
||||
print(f"Generating {TARGET_ROWS} device metrics...")
|
||||
print(f"Batch size: {BATCH_SIZE}")
|
||||
|
||||
insert_stmt = session.prepare(
|
||||
f"INSERT INTO {KEYSPACE}.{TABLE_NAME} (device_id, metric_ts, metric_type, metric_value, payload) "
|
||||
f"VALUES (?, ?, ?, ?, ?)"
|
||||
)
|
||||
|
||||
total_generated = 0
|
||||
batch = []
|
||||
|
||||
for i in range(TARGET_ROWS):
|
||||
batch.append(generate_fake_device_metric())
|
||||
|
||||
if len(batch) >= BATCH_SIZE:
|
||||
session.execute(
|
||||
f"""
|
||||
INSERT INTO {KEYSPACE}.{TABLE_NAME} (device_id, metric_ts, metric_type, metric_value, payload)
|
||||
VALUES (%s, %s, %s, %s, %s)
|
||||
""",
|
||||
batch
|
||||
)
|
||||
total_generated += len(batch)
|
||||
batch = []
|
||||
|
||||
if total_generated % 100000 == 0:
|
||||
print(f"Generated {total_generated} rows...")
|
||||
|
||||
# Insert remaining rows
|
||||
if batch:
|
||||
session.execute(
|
||||
f"""
|
||||
INSERT INTO {KEYSPACE}.{TABLE_NAME} (device_id, metric_ts, metric_type, metric_value, payload)
|
||||
VALUES (%s, %s, %s, %s, %s)
|
||||
""",
|
||||
batch
|
||||
)
|
||||
total_generated += len(batch)
|
||||
|
||||
session.execute(insert_stmt, generate_fake_device_metric())
|
||||
total_generated += 1
|
||||
if total_generated % 1000 == 0:
|
||||
print(f"Generated {total_generated} rows...")
|
||||
|
||||
session.shutdown()
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user