accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r1230622 - /incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
Date Thu, 12 Jan 2012 16:27:13 GMT
Author: vines
Date: Thu Jan 12 16:27:13 2012
New Revision: 1230622

URL: http://svn.apache.org/viewvc?rev=1230622&view=rev
Log:
ACCUMULO-309 - changed MockBatchScanner to more closely emulate TabletServerBatchScanner behavior

Modified:
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java?rev=1230622&r1=1230621&r2=1230622&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
Thu Jan 12 16:27:13 2012
@@ -34,7 +34,7 @@ import org.apache.accumulo.core.security
 
 public class MockBatchScanner extends MockScannerBase implements BatchScanner {
   
-  final List<Range> ranges = new ArrayList<Range>();
+  List<Range> ranges = null;
   
   public MockBatchScanner(MockTable mockTable, Authorizations authorizations) {
     super(mockTable, authorizations);
@@ -42,8 +42,11 @@ public class MockBatchScanner extends Mo
   
   @Override
   public void setRanges(Collection<Range> ranges) {
-    this.ranges.clear();
-    this.ranges.addAll(ranges);
+    if (ranges == null || ranges.size() == 0) {
+      throw new IllegalArgumentException("ranges must be non null and contain at least 1
range");
+    }
+    
+    this.ranges = new ArrayList<Range>(ranges);
   }
   
   static class RangesFilter extends Filter {
@@ -66,6 +69,10 @@ public class MockBatchScanner extends Mo
   
   @Override
   public Iterator<Entry<Key,Value>> iterator() {
+    if (ranges == null) {
+      throw new IllegalStateException("ranges not set");
+    }
+
     SortedKeyValueIterator<Key,Value> i = new SortedMapIterator(table.table);
     try {
       i = new RangesFilter(createFilter(i), ranges);



Mime
View raw message