From d74de57df9845fec557d248dde78070f6405ca11 Mon Sep 17 00:00:00 2001 From: Masum Date: Thu, 25 May 2017 20:51:42 +0600 Subject: [PATCH] Fix import chunkbatch inconsistency --- import.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/import.js b/import.js index 11ecffb..1adf5c1 100644 --- a/import.js +++ b/import.js @@ -79,17 +79,18 @@ function processTableImport(table) { var query = buildTableQueryForDataRow(tableInfo, row); queries.push(query); processed++; - if (processed%1000 === 0) { - console.log('Streaming ' + processed + ' rows to table: ' + table); - } if (queries.length === 10) { chunkBatch.push(client.batch(queries, { prepare: true, logged: false })); queries = []; + } + + if (processed%1000 === 0) { + console.log('Streaming ' + processed + ' rows to table: ' + table); jsonfile.pause(); Promise.all(chunkBatch) .then(function (){ - chunkBatch = []; + chunkBatch = chunkBatch.slice(100); jsonfile.resume(); }) .catch(function (err){ @@ -156,17 +157,15 @@ systemClient.connect() }) .then(function (){ console.log('=================================================='); - console.log('Completed importing all tables to keyspace: ' + KEYSPACE); var gracefulShutdown = []; gracefulShutdown.push(systemClient.shutdown()); gracefulShutdown.push(client.shutdown()); Promise.all(gracefulShutdown) .then(function (){ - process.exit(); + console.log('Completed importing to keyspace: ' + KEYSPACE); }) .catch(function (err){ console.log(err); - process.exit(1); }); }) .catch(function (err){