crunch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gr...@apache.org
Subject crunch git commit: CRUNCH-576 Add multi-scan methods to FromHBase
Date Mon, 16 Nov 2015 13:47:05 GMT
Repository: crunch
Updated Branches:
  refs/heads/master 85f24c5c8 -> ccad69448


CRUNCH-576 Add multi-scan methods to FromHBase

Add factory methods which allow reading a PCollection from HBase
that uses multiple Scans.


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

Branch: refs/heads/master
Commit: ccad69448c020172cfa3ecc442c089e83b0e31de
Parents: 85f24c5
Author: Gabriel Reid <greid@apache.org>
Authored: Fri Nov 6 14:25:21 2015 +0100
Committer: Gabriel Reid <greid@apache.org>
Committed: Mon Nov 16 14:46:34 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/crunch/io/hbase/FromHBase.java  | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/crunch/blob/ccad6944/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/FromHBase.java
----------------------------------------------------------------------
diff --git a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/FromHBase.java b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/FromHBase.java
index 16f6694..114fc93 100644
--- a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/FromHBase.java
+++ b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/FromHBase.java
@@ -17,6 +17,9 @@
  */
 package org.apache.crunch.io.hbase;
 
+import java.util.List;
+
+import com.google.common.collect.ImmutableList;
 import org.apache.crunch.Source;
 import org.apache.crunch.TableSource;
 import org.apache.hadoop.fs.Path;
@@ -39,12 +42,23 @@ public class FromHBase {
     return table(TableName.valueOf(table), scan);
   }
 
+  public static TableSource<ImmutableBytesWritable, Result> table(String table, List<Scan>
scans) {
+    return table(TableName.valueOf(table), scans);
+  }
+
   public static TableSource<ImmutableBytesWritable, Result> table(TableName table)
{
     return table(table, new Scan());
   }
 
   public static TableSource<ImmutableBytesWritable, Result> table(TableName table,
Scan scan) {
-    return new HBaseSourceTarget(table, scan);
+    return table(table, ImmutableList.of(scan));
+  }
+
+  public static TableSource<ImmutableBytesWritable, Result> table(TableName table,
List<Scan> scans) {
+    if (scans.isEmpty()) {
+      throw new IllegalArgumentException("Must supply at least one scan");
+    }
+    return new HBaseSourceTarget(table, scans.toArray(new Scan[scans.size()]));
   }
 
   public static Source<KeyValue> hfile(String path) {


Mime
View raw message