Skip to content

Commit

Permalink
Fix import chunkbatch inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
masumsoft committed May 25, 2017
1 parent 746a374 commit d74de57
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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){
Expand Down

0 comments on commit d74de57

Please sign in to comment.