incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1245716 - in /incubator/accumulo/trunk/src/core/src: main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java
Date Fri, 17 Feb 2012 19:26:04 GMT
Author: billie
Date: Fri Feb 17 19:26:03 2012
New Revision: 1245716

URL: http://svn.apache.org/viewvc?rev=1245716&view=rev
Log:
ACCUMULO-414 made GrepIterator a Filter to handle deletions - trunk

Modified:
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
    incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java?rev=1245716&r1=1245715&r2=1245716&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
Fri Feb 17 19:26:03 2012
@@ -17,35 +17,27 @@
 package org.apache.accumulo.core.iterators.user;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Map;
 
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.Filter;
 import org.apache.accumulo.core.iterators.IteratorEnvironment;
-import org.apache.accumulo.core.iterators.SkippingIterator;
 import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 
 /**
  * This iterator provides exact string matching. It searches both the Key and Value for the
string. The string to match is specified by the "term" option.
  */
-public class GrepIterator extends SkippingIterator {
+public class GrepIterator extends Filter {
   
   private byte term[];
   
   @Override
-  protected void consume() throws IOException {
-    while (getSource().hasTop()) {
-      Key k = getSource().getTopKey();
-      Value v = getSource().getTopValue();
-      
-      if (match(v.get()) || match(k.getRowData()) || match(k.getColumnFamilyData()) || match(k.getColumnQualifierData()))
{
-        break;
-      }
-      
-      getSource().next();
-    }
+  public boolean accept(Key k, Value v) {
+    return match(v.get()) || match(k.getRowData()) || match(k.getColumnFamilyData()) || match(k.getColumnQualifierData());
   }
   
   private boolean match(ByteSequence bs) {
@@ -88,7 +80,9 @@ public class GrepIterator extends Skippi
   
   @Override
   public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
-    throw new UnsupportedOperationException();
+    GrepIterator copy = (GrepIterator) super.deepCopy(env);
+    copy.term = Arrays.copyOf(term, term.length);
+    return copy;
   }
   
   @Override

Modified: incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java?rev=1245716&r1=1245715&r2=1245716&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java
(original)
+++ incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java
Fri Feb 17 19:26:03 2012
@@ -61,6 +61,11 @@ public class GrepIteratorTest {
     input.put(new Key("dfh", "xyz", "xyz", 0), new Value("abcdef".getBytes()));
     output.put(new Key("dfh", "xyz", "xyz", 0), new Value("abcdef".getBytes()));
     input.put(new Key("dfh", "xyz", "xyz", 1), new Value("xyz".getBytes()));
+    
+    Key k = new Key("dfh", "xyz", "xyz", 1);
+    k.setDeleted(true);
+    input.put(k, new Value("xyz".getBytes()));
+    output.put(k, new Value("xyz".getBytes()));
   }
   
   public static void checkEntries(SortedKeyValueIterator<Key,Value> skvi, SortedMap<Key,Value>
map) throws IOException {
@@ -83,6 +88,7 @@ public class GrepIteratorTest {
     checkEntries(gi, output);
     GrepIterator.setTerm(is, "cde");
     gi.init(new SortedMapIterator(input), is.getProperties(), null);
+    gi.deepCopy(null);
     gi.seek(new Range(), EMPTY_COL_FAMS, false);
     checkEntries(gi, output);
     GrepIterator.setTerm(is, "def");



Mime
View raw message