accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1400171 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/client/mock/ test/java/org/apache/accumulo/core/client/ test/java/org/apache/accumulo/core/client/mock/
Date Fri, 19 Oct 2012 17:12:42 GMT
Author: ecn
Date: Fri Oct 19 17:12:42 2012
New Revision: 1400171

URL: http://svn.apache.org/viewvc?rev=1400171&view=rev
Log:
ACCUMULO-821 unit test out-of-range keys returned from an iterator stack

Added:
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java
  (with props)
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TransformIterator.java
  (with props)
Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java?rev=1400171&r1=1400170&r2=1400171&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
Fri Oct 19 17:12:42 2012
@@ -24,10 +24,12 @@ import java.util.List;
 import java.util.Map.Entry;
 
 import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.mock.MockScanner.RangeFilter;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
 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.SortedKeyValueIterator;
 import org.apache.accumulo.core.iterators.SortedMapIterator;
 import org.apache.accumulo.core.security.Authorizations;
@@ -53,7 +55,11 @@ public class MockBatchScanner extends Mo
   static class RangesFilter extends Filter {
     List<Range> ranges;
     
-    RangesFilter(SortedKeyValueIterator<Key,Value> iterator, List<Range> ranges)
{
+    public RangesFilter deepCopy(IteratorEnvironment env) {
+      return new RangesFilter(getSource().deepCopy(env), ranges);
+    }
+    
+    public RangesFilter(SortedKeyValueIterator<Key,Value> iterator, List<Range>
ranges) {
       setSource(iterator);
       this.ranges = ranges;
     }
@@ -77,9 +83,9 @@ public class MockBatchScanner extends Mo
 
     IteratorChain chain = new IteratorChain();
     for (Range range : ranges) {
-      SortedKeyValueIterator<Key,Value> i = new SortedMapIterator(table.table);
+      SortedKeyValueIterator<Key,Value> i = new RangesFilter(new SortedMapIterator(table.table),
ranges);
       try {
-        i = new RangesFilter(createFilter(i), ranges);
+        i = createFilter(i);
         i.seek(range, createColumnBSS(fetchedColumns), !fetchedColumns.isEmpty());
         chain.addIterator(new IteratorAdapter(i));
       } catch (IOException e) {

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java?rev=1400171&r1=1400170&r2=1400171&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java
Fri Oct 19 17:12:42 2012
@@ -26,8 +26,10 @@ import org.apache.accumulo.core.data.Key
 import org.apache.accumulo.core.data.Range;
 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.SortedKeyValueIterator;
 import org.apache.accumulo.core.iterators.SortedMapIterator;
+import org.apache.accumulo.core.iterators.system.DeletingIterator;
 import org.apache.accumulo.core.security.Authorizations;
 
 public class MockScanner extends MockScannerBase implements Scanner {

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java?rev=1400171&r1=1400170&r2=1400171&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java
(original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java
Fri Oct 19 17:12:42 2012
@@ -1,11 +1,12 @@
 package org.apache.accumulo.core.client;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 
-import org.junit.Test;
 import org.apache.accumulo.core.client.impl.thrift.ThriftTest;
 import org.apache.accumulo.core.security.thrift.ThriftSecurityException;
 import org.apache.accumulo.core.util.UtilWaitThread;
@@ -17,7 +18,7 @@ import org.apache.thrift.server.TThreadP
 import org.apache.thrift.transport.TServerSocket;
 import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
+import org.junit.Test;
 
 public class TestThrift1474 {
   

Added: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java?rev=1400171&view=auto
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java
(added)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java
Fri Oct 19 17:12:42 2012
@@ -0,0 +1,48 @@
+package org.apache.accumulo.core.client.mock;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Collections;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.BatchScanner;
+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.IteratorSetting;
+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.junit.Test;
+
+public class TestBatchScanner821 {
+  
+  @Test
+  public void test() throws Exception {
+    MockInstance inst = new MockInstance();
+    Connector conn = inst.getConnector("root", "");
+    conn.tableOperations().create("test");
+    BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig());
+    for (String row : "A,B,C,D".split(",")) {
+      Mutation m = new Mutation(row);
+      m.put("cf", "cq", "");
+      bw.addMutation(m);
+    }
+    bw.flush();
+    BatchScanner bs = conn.createBatchScanner("test", Constants.NO_AUTHS, 1);
+    IteratorSetting cfg = new IteratorSetting(100, TransformIterator.class);
+    bs.addScanIterator(cfg);
+    bs.setRanges(Collections.singletonList(new Range("A", "Z")));
+    StringBuilder sb = new StringBuilder();
+    String comma = "";
+    for (Entry<Key,Value>  entry : bs) {
+      sb.append(comma);
+      sb.append(entry.getKey().getRow());
+      comma = ",";
+    }
+    assertEquals("a,b,c,d", sb.toString());
+  }
+  
+}

Propchange: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TransformIterator.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TransformIterator.java?rev=1400171&view=auto
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TransformIterator.java
(added)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TransformIterator.java
Fri Oct 19 17:12:42 2012
@@ -0,0 +1,16 @@
+package org.apache.accumulo.core.client.mock;
+
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.iterators.WrappingIterator;
+import org.apache.hadoop.io.Text;
+
+public class TransformIterator extends WrappingIterator {
+
+  @Override
+  public Key getTopKey() {
+    Key k = getSource().getTopKey();
+    return new Key(new Text(k.getRow().toString().toLowerCase()), k.getColumnFamily(), k.getColumnQualifier(),
k.getColumnVisibility(), k.getTimestamp());
+  }
+}
+
+

Propchange: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/TransformIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message