accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject [2/3] git commit: Merge remote-tracking branch 'origin/1.5.1-SNAPSHOT' into 1.6.0-SNAPSHOT
Date Wed, 29 Jan 2014 20:16:15 GMT
Merge remote-tracking branch 'origin/1.5.1-SNAPSHOT' into 1.6.0-SNAPSHOT

Conflicts:
	core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d22816cb
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d22816cb
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d22816cb

Branch: refs/heads/master
Commit: d22816cb435bbdef8512dc67454e492a373d0dda
Parents: 3f92e01 cabdbe8
Author: John Vines <vines@apache.org>
Authored: Wed Jan 29 15:15:54 2014 -0500
Committer: John Vines <vines@apache.org>
Committed: Wed Jan 29 15:15:54 2014 -0500

----------------------------------------------------------------------
 .../core/iterators/user/RegExFilterTest.java    | 149 ++++++++++++-------
 1 file changed, 98 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/d22816cb/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
index 6d2b36b,cdfa772..73edd04
--- a/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
@@@ -23,10 -23,21 +23,22 @@@ import java.util.TreeMap
  
  import junit.framework.TestCase;
  
 +import org.apache.accumulo.core.Constants;
+ import org.apache.accumulo.core.client.AccumuloException;
+ import org.apache.accumulo.core.client.AccumuloSecurityException;
+ import org.apache.accumulo.core.client.BatchWriter;
+ import org.apache.accumulo.core.client.BatchWriterConfig;
+ import org.apache.accumulo.core.client.Connector;
+ import org.apache.accumulo.core.client.Instance;
  import org.apache.accumulo.core.client.IteratorSetting;
+ import org.apache.accumulo.core.client.Scanner;
+ import org.apache.accumulo.core.client.TableExistsException;
+ import org.apache.accumulo.core.client.TableNotFoundException;
+ import org.apache.accumulo.core.client.mock.MockInstance;
+ import org.apache.accumulo.core.client.security.tokens.PasswordToken;
  import org.apache.accumulo.core.data.ByteSequence;
  import org.apache.accumulo.core.data.Key;
+ import org.apache.accumulo.core.data.Mutation;
  import org.apache.accumulo.core.data.Range;
  import org.apache.accumulo.core.data.Value;
  import org.apache.accumulo.core.iterators.DefaultIteratorEnvironment;
@@@ -219,21 -232,54 +233,54 @@@ public class RegExFilterTest extends Te
      // -----------------------------------------------------
      String multiByteText = new String("\u6d67" + "\u6F68" + "\u7067");
      String multiByteRegex = new String(".*" + "\u6F68" + ".*");
-     
+ 
      Key k4 = new Key("boo4".getBytes(), "hoo".getBytes(), "20080203".getBytes(), "".getBytes(),
1l);
 -    Value inVal = new Value(multiByteText.getBytes("UTF-8"));
 +    Value inVal = new Value(multiByteText.getBytes(Constants.UTF8));
      tm.put(k4, inVal);
-     
+ 
      is.clearOptions();
-     
+ 
      RegExFilter.setRegexs(is, null, null, null, multiByteRegex, true);
      rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
      rei.seek(new Range(), EMPTY_COL_FAMS, false);
-     
+ 
      assertTrue(rei.hasTop());
      Value outValue = rei.getTopValue();
 -    String outVal = new String(outValue.get(), "UTF-8");
 +    String outVal = new String(outValue.get(), Constants.UTF8);
      assertTrue(outVal.equals(multiByteText));
-     
+ 
+   }
+ 
+   @Test
+   public void testNullByteInKey() throws AccumuloException, AccumuloSecurityException, TableExistsException,
TableNotFoundException {
+     String table = "nullRegexTest";
+ 
+     String s1 = "first", s2 = "second";
+     byte[] b1 = s1.getBytes(), b2 = s2.getBytes(), ball;
+     ball = new byte[b1.length + b2.length + 1];
+     System.arraycopy(b1, 0, ball, 0, b1.length);
+     ball[b1.length] = (byte) 0;
+     System.arraycopy(b2, 0, ball, b1.length + 1, b2.length);
+ 
+     Instance instance = new MockInstance();
+     Connector conn = instance.getConnector("root", new PasswordToken(new byte[0]));
+ 
+     conn.tableOperations().create(table);
+     BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig());
+     Mutation m = new Mutation(ball);
+     m.put(new byte[0], new byte[0], new byte[0]);
+     bw.addMutation(m);
+     bw.close();
+ 
+     IteratorSetting is = new IteratorSetting(5, RegExFilter.class);
+     RegExFilter.setRegexs(is, s2, null, null, null, true, true);
+ 
+     Scanner scanner = conn.createScanner(table, new Authorizations());
+     scanner.addScanIterator(is);
+ 
+     assertTrue("Client side iterator couldn't find a match when it should have", scanner.iterator().hasNext());
+ 
+     conn.tableOperations().attachIterator(table, is);
+     assertTrue("server side iterator couldn't find a match when it should have", conn.createScanner(table,
new Authorizations()).iterator().hasNext());
    }
  }


Mime
View raw message