accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1457724 - in /accumulo/branches/1.5/proxy/src: main/java/org/apache/accumulo/proxy/ProxyServer.java test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
Date Mon, 18 Mar 2013 12:02:59 GMT
Author: ecn
Date: Mon Mar 18 12:02:58 2013
New Revision: 1457724

URL: http://svn.apache.org/r1457724
Log:
ACCUMULO-1183 applying patch from Corey Nolet

Modified:
    accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
    accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java

Modified: accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java?rev=1457724&r1=1457723&r2=1457724&view=diff
==============================================================================
--- accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java (original)
+++ accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java Mon
Mar 18 12:02:58 2013
@@ -819,7 +819,17 @@ public class ProxyServer implements Accu
           }
         }
         scanner.setRanges(ranges);
+
+        if (opts.columns != null) {
+          for (ScanColumn col : opts.columns) {
+            if (col.isSetColQualifier())
+              scanner.fetchColumn(ByteBufferUtil.toText(col.colFamily), ByteBufferUtil.toText(col.colQualifier));
+            else
+              scanner.fetchColumnFamily(ByteBufferUtil.toText(col.colFamily));
+          }
+        }
       }
+
       UUID uuid = UUID.randomUUID();
       
       ScannerPlusIterator spi = new ScannerPlusIterator();

Modified: accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java?rev=1457724&r1=1457723&r2=1457724&view=diff
==============================================================================
--- accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
(original)
+++ accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
Mon Mar 18 12:02:58 2013
@@ -31,6 +31,7 @@ import java.util.TreeMap;
 import org.apache.accumulo.core.iterators.user.RegExFilter;
 import org.apache.accumulo.proxy.thrift.BatchScanOptions;
 import org.apache.accumulo.proxy.thrift.ColumnUpdate;
+import org.apache.accumulo.proxy.thrift.ScanColumn;
 import org.apache.accumulo.proxy.thrift.IteratorSetting;
 import org.apache.accumulo.proxy.thrift.Key;
 import org.apache.accumulo.proxy.thrift.KeyValue;
@@ -139,7 +140,92 @@ public class TestProxyReadWrite {
     }
     assertEquals(i, 50000);
   }
-  
+
+  /**
+   * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Set a columnFamily
so only the entries with specified column family come back (there should be
+   * 50,000)
+   * 
+   * @throws Exception
+   */
+  @Test
+  public void readWriteBatchOneShotWithColumnFamilyOnly() throws Exception {
+    int maxInserts = 100000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    for (int i = 0; i < maxInserts; i++) {
+	
+      addMutation(mutations, String.format(format, i), "cf" + (i % 2) , "cq" + (i % 2), Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().updateAndFlush(userpass, testtable, mutations);
+        mutations.clear();
+      }
+    }
+    
+    BatchScanOptions options = new BatchScanOptions();
+
+	ScanColumn sc = new ScanColumn();
+	sc.colFamily = ByteBuffer.wrap("cf0".getBytes());
+
+    options.columns = Collections.singletonList(sc);
+    String cookie = tpc.proxy().createBatchScanner(userpass, testtable, options);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      i += kvList.getResultsSize();
+      hasNext = kvList.isMore();
+    }
+    assertEquals(i, 50000);
+  }
+
+
+  /**
+   * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Set a columnFamily
+ columnQualififer so only the entries with specified column 
+   * come back (there should be 50,000)
+   * 
+   * @throws Exception
+   */
+  @Test
+  public void readWriteBatchOneShotWithFullColumn() throws Exception {
+    int maxInserts = 100000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    for (int i = 0; i < maxInserts; i++) {
+	
+      addMutation(mutations, String.format(format, i), "cf" + (i % 2) , "cq" + (i % 2), Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().updateAndFlush(userpass, testtable, mutations);
+        mutations.clear();
+      }
+    }
+    
+    BatchScanOptions options = new BatchScanOptions();
+
+	ScanColumn sc = new ScanColumn();
+	sc.colFamily = ByteBuffer.wrap("cf0".getBytes());
+	sc.colQualifier = ByteBuffer.wrap("cq0".getBytes());
+
+    options.columns = Collections.singletonList(sc);
+    String cookie = tpc.proxy().createBatchScanner(userpass, testtable, options);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      i += kvList.getResultsSize();
+      hasNext = kvList.isMore();
+    }
+    assertEquals(i, 50000);
+  }
+
+
   /**
    * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Filter the
results so only the even numbers come back.
    * 



Mime
View raw message