- sys.stdout.write "Saving {edges.length} edges...{save_cursor} "
- push_all(edges)
- end
-
- # Save `neo_entities` in the database using batch mode.
- private fun push_all(neo_entities: Collection[NeoEntity]) do
- var batch = new NeoBatch(client)
- var len = neo_entities.length
- var sum = 0
- var i = 1
-
- for nentity in neo_entities do
- batch.save_entity(nentity)
- if i == batch_max_size then
- do_batch(batch)
- sum += batch_max_size
- sys.stdout.write("{reset_line} {sum * 100 / len}% ")
- batch = new NeoBatch(client)
- i = 1
- else
- i += 1
- end
- end
- do_batch(batch)
- print("{reset_line} Done.")
- end
-
- # Execute `batch` and check for errors.
- #
- # Abort if `batch.execute` returns errors.
- private fun do_batch(batch: NeoBatch) do
- var errors = batch.execute
- if not errors.is_empty then
- for e in errors do sys.stderr.write("{sys.program_name}: {e}\n")
- exit(1)
- end