accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1229738 - /incubator/accumulo/branches/1.4/src/examples/src/main/java/org/apache/accumulo/examples/shard/ContinuousQuery.java
Date Tue, 10 Jan 2012 21:11:24 GMT
Author: kturner
Date: Tue Jan 10 21:11:24 2012
New Revision: 1229738

URL: http://svn.apache.org/viewvc?rev=1229738&view=rev
Log:
ACCUMULO-281 Fixed array index out of bound and batch scanner usage in shard continuous query
example

Modified:
    incubator/accumulo/branches/1.4/src/examples/src/main/java/org/apache/accumulo/examples/shard/ContinuousQuery.java

Modified: incubator/accumulo/branches/1.4/src/examples/src/main/java/org/apache/accumulo/examples/shard/ContinuousQuery.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/examples/src/main/java/org/apache/accumulo/examples/shard/ContinuousQuery.java?rev=1229738&r1=1229737&r2=1229738&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/examples/src/main/java/org/apache/accumulo/examples/shard/ContinuousQuery.java
(original)
+++ incubator/accumulo/branches/1.4/src/examples/src/main/java/org/apache/accumulo/examples/shard/ContinuousQuery.java
Tue Jan 10 21:11:24 2012
@@ -43,7 +43,7 @@ import org.apache.hadoop.io.Text;
 public class ContinuousQuery {
   public static void main(String[] args) throws Exception {
     
-    if (args.length < 7) {
+    if (args.length != 7 && args.length != 8) {
       System.err.println("Usage : " + ContinuousQuery.class.getName()
           + " <instance> <zoo keepers> <shard table> <doc2word table>
<user> <pass> <num query terms> [iterations]");
       System.exit(-1);
@@ -57,7 +57,7 @@ public class ContinuousQuery {
     String pass = args[5];
     int numTerms = Integer.parseInt(args[6]);
     long iterations = Long.MAX_VALUE;
-    if (args.length >= 7)
+    if (args.length > 7)
       iterations = Long.parseLong(args[7]);
     
     ZooKeeperInstance zki = new ZooKeeperInstance(instance, zooKeepers);
@@ -67,10 +67,14 @@ public class ContinuousQuery {
     
     Random rand = new Random();
     
+    BatchScanner bs = conn.createBatchScanner(table, Constants.NO_AUTHS, 20);
+
     for (long i = 0; i < iterations; i += 1) {
       Text[] columns = randTerms.get(rand.nextInt(randTerms.size()));
       
-      BatchScanner bs = conn.createBatchScanner(table, Constants.NO_AUTHS, 20);
+      bs.clearScanIterators();
+      bs.clearColumns();
+
       IteratorSetting ii = new IteratorSetting(20, "ii", IntersectingIterator.class);
       IntersectingIterator.setColumnFamilies(ii, columns);
       bs.addScanIterator(ii);
@@ -85,9 +89,10 @@ public class ContinuousQuery {
       long t2 = System.currentTimeMillis();
       
       System.out.printf("  %s %,d %6.3f\n", Arrays.asList(columns), count, (t2 - t1) / 1000.0);
-      
     }
     
+    bs.close();
+
   }
   
   private static ArrayList<Text[]> findRandomTerms(Scanner scanner, int numTerms) {



Mime
View raw message