accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject accumulo git commit: ACCUMULO-2002 Add a convenience method to ScannerBase to fetch column by IteratorSetting.Column
Date Tue, 07 Apr 2015 03:50:29 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master e16c96842 -> 2b1b10720


ACCUMULO-2002 Add a convenience method to ScannerBase to fetch column by IteratorSetting.Column

Rebased on top of master by elserj.


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

Branch: refs/heads/master
Commit: 2b1b107200398c33e12481fe43a6ac2983feadc5
Parents: e16c968
Author: Vikram Srivastava <vikrams@cloudera.com>
Authored: Mon Apr 6 23:49:49 2015 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Mon Apr 6 23:49:49 2015 -0400

----------------------------------------------------------------------
 .../accumulo/core/client/ScannerBase.java       | 10 ++++++++
 .../core/client/impl/ScannerOptions.java        |  6 +++++
 .../core/client/impl/ScannerOptionsTest.java    | 24 ++++++++++++++++++++
 .../monitor/servlets/trace/NullScanner.java     |  4 ++++
 4 files changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2b1b1072/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java b/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
index 667f423..92ab551 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
@@ -20,6 +20,7 @@ import java.util.Iterator;
 import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.accumulo.core.client.IteratorSetting.Column;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
@@ -87,6 +88,15 @@ public interface ScannerBase extends Iterable<Entry<Key,Value>>
{
   void fetchColumn(Text colFam, Text colQual);
 
   /**
+   * Adds a column to the list of columns that will be fetch by this scanner.
+   *
+   * @param column
+   *          the {@link Column} to fetch
+   * @since 1.7.0
+   */
+  void fetchColumn(Column column);
+
+  /**
    * Clears the columns to be fetched (useful for resetting the scanner for reuse). Once
cleared, the scanner will fetch all columns.
    */
   void clearColumns();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2b1b1072/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
index f4a6176..3d486d2 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
@@ -139,6 +139,12 @@ public class ScannerOptions implements ScannerBase {
   }
 
   @Override
+  public void fetchColumn(IteratorSetting.Column column) {
+    checkArgument(column != null, "Column is null");
+    fetchColumn(column.getColumnFamily(), column.getColumnQualifier());
+  }
+
+  @Override
   public synchronized void clearColumns() {
     fetchedColumns.clear();
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2b1b1072/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
b/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
index 123509a..920d687 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
@@ -19,9 +19,13 @@ package org.apache.accumulo.core.client.impl;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
+import java.util.SortedSet;
+
 import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.data.Column;
 import org.apache.accumulo.core.iterators.DebugIterator;
 import org.apache.accumulo.core.iterators.user.WholeRowIterator;
+import org.apache.hadoop.io.Text;
 import org.junit.Test;
 
 /**
@@ -54,4 +58,24 @@ public class ScannerOptionsTest {
       fail();
     } catch (IllegalArgumentException e) {}
   }
+
+  @Test
+  public void testFetchColumn() {
+    ScannerOptions options = new ScannerOptions();
+    assertEquals(0, options.getFetchedColumns().size());
+    IteratorSetting.Column col = new IteratorSetting.Column(new Text("family"), new Text("qualifier"));
+    options.fetchColumn(col);
+    SortedSet<Column> fetchedColumns = options.getFetchedColumns();
+    assertEquals(1, fetchedColumns.size());
+    Column fetchCol = fetchedColumns.iterator().next();
+    assertEquals(col.getColumnFamily(), new Text(fetchCol.getColumnFamily()));
+    assertEquals(col.getColumnQualifier(), new Text(fetchCol.getColumnQualifier()));
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testFetchNullColumn() {
+    ScannerOptions options = new ScannerOptions();
+    // Require a non-null instance of Column
+    options.fetchColumn((IteratorSetting.Column) null);
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2b1b1072/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java
b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java
index 5dae2f7..252334d 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java
@@ -21,6 +21,7 @@ import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.IteratorSetting.Column;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
@@ -43,6 +44,9 @@ public class NullScanner implements Scanner {
   public void fetchColumn(Text colFam, Text colQual) {}
 
   @Override
+  public void fetchColumn(Column column) {}
+
+  @Override
   public void clearColumns() {}
 
   @Override


Mime
View raw message