accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject git commit: ACCUMULO-1661 Handle empty column family correctly for AccumuloInputFormat
Date Wed, 22 Jan 2014 19:03:07 GMT
Updated Branches:
  refs/heads/1.5.1-SNAPSHOT a43848849 -> 13eb19c2b


ACCUMULO-1661 Handle empty column family correctly for AccumuloInputFormat

Signed-off-by: Eric Newton <eric.newton@gmail.com>


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

Branch: refs/heads/1.5.1-SNAPSHOT
Commit: 13eb19c2b92180bc4752d75dd74b76d036eb38e2
Parents: a438488
Author: Vikram Srivastava <vikrams@cloudera.com>
Authored: Wed Jan 22 10:36:51 2014 -0800
Committer: Eric Newton <eric.newton@gmail.com>
Committed: Wed Jan 22 13:52:31 2014 -0500

----------------------------------------------------------------------
 .../mapreduce/lib/util/InputConfigurator.java       | 11 +++++++++--
 .../client/mapreduce/AccumuloInputFormatTest.java   | 16 ++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/13eb19c2/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
index ff14107..b0e649b 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
@@ -238,8 +238,15 @@ public class InputConfigurator extends ConfiguratorBase {
    */
   public static Set<Pair<Text,Text>> getFetchedColumns(Class<?> implementingClass,
Configuration conf) {
     ArgumentChecker.notNull(conf);
-
-    return deserializeFetchedColumns(conf.getStringCollection(enumToConfKey(implementingClass,
ScanOpts.COLUMNS)));
+    String confValue = conf.get(enumToConfKey(implementingClass, ScanOpts.COLUMNS));
+    List<String> serialized = new ArrayList<String>();
+    if (confValue != null) {
+      // Split and include any trailing empty strings to allow empty column families
+      for (String val : confValue.split(",", -1)) {
+        serialized.add(val);
+      }
+    }
+    return deserializeFetchedColumns(serialized);
   }
 
   public static Set<Pair<Text,Text>> deserializeFetchedColumns(Collection<String>
serialized) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/13eb19c2/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
index d826895..f4408f5 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
@@ -25,7 +25,9 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
@@ -443,4 +445,18 @@ public class AccumuloInputFormatTest {
     assertNull(e1);
     assertNull(e2);
   }
+
+  @Test
+  public void testEmptyColumnFamily() throws IOException {
+    Job job = new Job();
+    Set<Pair<Text,Text>> cols = new HashSet<Pair<Text,Text>>();
+    cols.add(new Pair<Text,Text>(new Text(""), null));
+    cols.add(new Pair<Text,Text>(new Text("foo"), new Text("bar")));
+    cols.add(new Pair<Text,Text>(new Text(""), new Text("bar")));
+    cols.add(new Pair<Text,Text>(new Text(""), new Text("")));
+    cols.add(new Pair<Text,Text>(new Text("foo"), new Text("")));
+    AccumuloInputFormat.fetchColumns(job, cols);
+    Set<Pair<Text,Text>> setCols = AccumuloInputFormat.getFetchedColumns(job);
+    assertEquals(cols, setCols);
+  }
 }


Mime
View raw message