X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-batch%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fbatch%2Fhelpers%2FCQLBatchLoop.java;h=945fe0b344b09a43789c0d50cbba029e0abae726;hb=9dc1cd2632d1dda9c8f072e99616e73e0517f1aa;hp=ca264d14764a5fe9c505e254c578e0b498a0c90c;hpb=4c709df6500a95057a92ec3ea5c739738764388d;p=aaf%2Fauthz.git diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java index ca264d14..945fe0b3 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java @@ -27,10 +27,13 @@ public class CQLBatchLoop { private final StringBuilder sb; private final boolean dryRun; private int i; + private int count; + private int batches; public CQLBatchLoop(CQLBatch cb, int max, boolean dryRun) { cqlBatch = cb; i=0; + count = 0; maxBatch = max; sb = cqlBatch.begin(); this.dryRun = dryRun; @@ -43,10 +46,11 @@ public class CQLBatchLoop { public void preLoop() { if(i<0) { cqlBatch.begin(); - } else if(i>=maxBatch) { + } else if(i>=maxBatch || sb.length()>24000) { cqlBatch.execute(dryRun); cqlBatch.begin(); i=0; + ++batches; } } @@ -56,6 +60,7 @@ public class CQLBatchLoop { */ public StringBuilder inc() { ++i; + ++count; return sb; } @@ -63,7 +68,24 @@ public class CQLBatchLoop { * Close up when done. However, can go back to "preLoop" safely. */ public void flush() { - cqlBatch.execute(dryRun); + if(i>0) { + cqlBatch.execute(dryRun); + ++batches; + } i=-1; } + + public int total() { + return count; + } + + public int batches() { + return batches; + } + + public void reset() { + count = 0; + batches = 0; + i = -1; + } }