This is an automated email from the ASF dual-hosted git repository.

mwalch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new e0e7916  Add ScannerBase.fetchColumn/Family using CharSequence (#939)
e0e7916 is described below

commit e0e791609f3048ba5d6af8ab2dbcd754ad1ad848
Author: Mike Walch <mwa...@apache.org>
AuthorDate: Wed Feb 6 15:40:31 2019 -0500

    Add ScannerBase.fetchColumn/Family using CharSequence (#939)
    
    * Modified some but not all tests to use new method
---
 .../apache/accumulo/core/client/ScannerBase.java   | 33 ++++++++++++++++++++++
 .../accumulo/core/clientImpl/ScannerOptions.java   | 15 ++++++++++
 .../apache/accumulo/test/ClientSideIteratorIT.java |  4 +--
 .../apache/accumulo/test/ConditionalWriterIT.java  | 14 ++++-----
 4 files changed, 57 insertions(+), 9 deletions(-)

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 7d200bf..a490f16 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
@@ -91,6 +91,25 @@ public interface ScannerBase extends 
Iterable<Entry<Key,Value>>, AutoCloseable {
   void fetchColumnFamily(Text col);
 
   /**
+   * Adds a column family to the list of columns that will be fetched by this 
scanner. By default
+   * when no columns have been added the scanner fetches all columns. To fetch 
multiple column
+   * families call this function multiple times.
+   *
+   * <p>
+   * This can help limit which locality groups are read on the server side.
+   *
+   * <p>
+   * When used in conjunction with custom iterators, the set of column 
families fetched is passed to
+   * the top iterator's seek method. Custom iterators may change this set of 
column families when
+   * calling seek on their source.
+   *
+   * @param colFam
+   *          the column family to be fetched
+   * @since 2.0.0
+   */
+  void fetchColumnFamily(CharSequence colFam);
+
+  /**
    * Adds a column to the list of columns that will be fetched by this 
scanner. The column is
    * identified by family and qualifier. By default when no columns have been 
added the scanner
    * fetches all columns.
@@ -122,6 +141,20 @@ public interface ScannerBase extends 
Iterable<Entry<Key,Value>>, AutoCloseable {
   void fetchColumn(Text colFam, Text colQual);
 
   /**
+   * Adds a column to the list of columns that will be fetched by this 
scanner. The column is
+   * identified by family and qualifier. By default when no columns have been 
added the scanner
+   * fetches all columns. See the warning on {@link #fetchColumn(Text, Text)}
+   *
+   *
+   * @param colFam
+   *          the column family of the column to be fetched
+   * @param colQual
+   *          the column qualifier of the column to be fetched
+   * @since 2.0.0
+   */
+  void fetchColumn(CharSequence colFam, CharSequence colQual);
+
+  /**
    * Adds a column to the list of columns that will be fetch by this scanner.
    *
    * @param column
diff --git 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
index 71c7900..a9d45f2 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
@@ -140,6 +140,13 @@ public class ScannerOptions implements ScannerBase {
   }
 
   @Override
+  public void fetchColumnFamily(CharSequence colFam) {
+    checkArgument(colFam != null, "colFam is null");
+    Column c = new Column(colFam.toString().getBytes(), null, null);
+    fetchedColumns.add(c);
+  }
+
+  @Override
   public synchronized void fetchColumn(Text colFam, Text colQual) {
     checkArgument(colFam != null, "colFam is null");
     checkArgument(colQual != null, "colQual is null");
@@ -148,6 +155,14 @@ public class ScannerOptions implements ScannerBase {
   }
 
   @Override
+  public void fetchColumn(CharSequence colFam, CharSequence colQual) {
+    checkArgument(colFam != null, "colFam is null");
+    checkArgument(colQual != null, "colQual is null");
+    Column c = new Column(colFam.toString().getBytes(), 
colQual.toString().getBytes(), null);
+    fetchedColumns.add(c);
+  }
+
+  @Override
   public void fetchColumn(IteratorSetting.Column column) {
     checkArgument(column != null, "Column is null");
     fetchColumn(column.getColumnFamily(), column.getColumnQualifier());
diff --git 
a/test/src/main/java/org/apache/accumulo/test/ClientSideIteratorIT.java 
b/test/src/main/java/org/apache/accumulo/test/ClientSideIteratorIT.java
index c727e68..3569c60 100644
--- a/test/src/main/java/org/apache/accumulo/test/ClientSideIteratorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ClientSideIteratorIT.java
@@ -145,10 +145,10 @@ public class ClientSideIteratorIT extends 
AccumuloClusterHarness {
       checkResults(csis, resultSet1, 
PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
       checkResults(scanner, resultSet2, 
PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
 
-      csis.fetchColumnFamily(new Text("colf"));
+      csis.fetchColumnFamily("colf");
       checkResults(csis, resultSet1, 
PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
       csis.clearColumns();
-      csis.fetchColumnFamily(new Text("none"));
+      csis.fetchColumnFamily("none");
       assertFalse(csis.iterator().hasNext());
     }
   }
diff --git 
a/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java 
b/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java
index b4b4940..1bf4911 100644
--- a/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java
@@ -203,7 +203,7 @@ public class ConditionalWriterIT extends 
AccumuloClusterHarness {
         assertEquals(Status.REJECTED, cw.write(cm5).getStatus());
 
         // ensure rejected mutations did not write
-        scanner.fetchColumn(new Text("name"), new Text("last"));
+        scanner.fetchColumn("name", "last");
         scanner.setRange(new Range("99006"));
         Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
         assertEquals("Doe", entry.getValue().toString());
@@ -282,7 +282,7 @@ public class ConditionalWriterIT extends 
AccumuloClusterHarness {
 
           scanner.setRange(new Range("99006"));
           // TODO verify all columns
-          scanner.fetchColumn(new Text("tx"), new Text("seq"));
+          scanner.fetchColumn("tx", "seq");
           Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
           assertEquals("1", entry.getValue().toString());
           long ts = entry.getKey().getTimestamp();
@@ -538,7 +538,7 @@ public class ConditionalWriterIT extends 
AccumuloClusterHarness {
       try (Scanner scanner = client.createScanner(tableName, new 
Authorizations())) {
         scanner.addScanIterator(iterConfig);
         scanner.setRange(new Range("ACCUMULO-1000"));
-        scanner.fetchColumn(new Text("count"), new Text("comments"));
+        scanner.fetchColumn("count", "comments");
 
         Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
         assertEquals("3", entry.getValue().toString());
@@ -689,7 +689,7 @@ public class ConditionalWriterIT extends 
AccumuloClusterHarness {
         assertEquals(Status.ACCEPTED, cw.write(cm6).getStatus());
 
         scanner.setRange(new Range("ACCUMULO-1000"));
-        scanner.fetchColumn(new Text("count"), new Text("comments"));
+        scanner.fetchColumn("count", "comments");
 
         Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
         assertEquals("9", entry.getValue().toString());
@@ -792,7 +792,7 @@ public class ConditionalWriterIT extends 
AccumuloClusterHarness {
 
         assertEquals(3, count);
 
-        scanner.fetchColumn(new Text("tx"), new Text("seq"));
+        scanner.fetchColumn("tx", "seq");
 
         for (String row : new String[] {"99006", "59056", "19059"}) {
           scanner.setRange(new Range(row));
@@ -853,7 +853,7 @@ public class ConditionalWriterIT extends 
AccumuloClusterHarness {
         assertEquals("2", entry.getValue().toString());
 
         scanner.clearColumns();
-        scanner.fetchColumn(new Text("name"), new Text("last"));
+        scanner.fetchColumn("name", "last");
         entry = Iterables.getOnlyElement(scanner);
         assertEquals("Doe", entry.getValue().toString());
       }
@@ -1014,7 +1014,7 @@ public class ConditionalWriterIT extends 
AccumuloClusterHarness {
 
         assertEquals(4, rows.size());
 
-        scanner.fetchColumn(new Text("tx"), new Text("seq"));
+        scanner.fetchColumn("tx", "seq");
         Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
         assertEquals("1", entry.getValue().toString());
       }

Reply via email to