beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhalp...@apache.org
Subject [1/2] incubator-beam git commit: Added Bigtable Read DisplayData
Date Fri, 29 Jul 2016 22:59:16 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/master b1ecf2461 -> 8b1e64a66


Added Bigtable Read DisplayData


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/14bac44c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/14bac44c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/14bac44c

Branch: refs/heads/master
Commit: 14bac44c7295095bedcfc30cae3fa8b04fe5a88e
Parents: b1ecf24
Author: Ian Zhou <ianzhou@google.com>
Authored: Thu Jul 28 17:46:21 2016 -0700
Committer: Dan Halperin <dhalperi@google.com>
Committed: Fri Jul 29 15:59:01 2016 -0700

----------------------------------------------------------------------
 .../beam/sdk/io/gcp/bigtable/BigtableIO.java    | 13 ++++++++++
 .../sdk/io/gcp/bigtable/BigtableIOTest.java     | 25 ++++++++++++++++++++
 2 files changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/14bac44c/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
----------------------------------------------------------------------
diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
index 84d52f6..f4082d4 100644
--- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
+++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
@@ -811,6 +811,19 @@ public class BigtableIO {
     }
 
     @Override
+    public void populateDisplayData(DisplayData.Builder builder) {
+      super.populateDisplayData(builder);
+
+      builder.add(DisplayData.item("tableId", tableId)
+          .withLabel("Table ID"));
+
+      if (filter != null) {
+        builder.add(DisplayData.item("rowFilter", filter.toString())
+            .withLabel("Table Row Filter"));
+      }
+    }
+
+    @Override
     public Coder<Row> getDefaultOutputCoder() {
       return ProtoCoder.of(Row.class);
     }

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/14bac44c/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIOTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIOTest.java
b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIOTest.java
index f5f0682..adf45a4 100644
--- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIOTest.java
+++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIOTest.java
@@ -45,6 +45,7 @@ import org.apache.beam.sdk.testing.PAssert;
 import org.apache.beam.sdk.testing.TestPipeline;
 import org.apache.beam.sdk.transforms.Create;
 import org.apache.beam.sdk.transforms.display.DisplayData;
+import org.apache.beam.sdk.transforms.display.DisplayDataEvaluator;
 import org.apache.beam.sdk.values.KV;
 import org.apache.beam.sdk.values.PCollection;
 import org.apache.beam.sdk.values.TypeDescriptor;
@@ -86,6 +87,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
@@ -428,6 +430,29 @@ public class BigtableIOTest {
     assertThat(displayData, hasDisplayItem("bigtableOptions"));
   }
 
+  @Test
+  public void testReadingPrimitiveDisplayData() throws IOException, InterruptedException
{
+    final String table = "fooTable";
+    service.createTable(table);
+
+    RowFilter rowFilter = RowFilter.newBuilder()
+        .setRowKeyRegexFilter(ByteString.copyFromUtf8("foo.*"))
+        .build();
+
+    DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
+    BigtableIO.Read read = BigtableIO.read()
+        .withBigtableOptions(BIGTABLE_OPTIONS)
+        .withTableId(table)
+        .withRowFilter(rowFilter)
+        .withBigtableService(service);
+
+    Set<DisplayData> displayData = evaluator.displayDataForPrimitiveSourceTransforms(read);
+    assertThat("BigtableIO.Read should include the table id in its primitive display data",
+        displayData, Matchers.hasItem(hasDisplayItem("tableId")));
+    assertThat("BigtableIO.Read should include the row filter, if it exists, in its primitive
"
+        + "display data", displayData, Matchers.hasItem(hasDisplayItem("rowFilter")));
+  }
+
   /** Tests that a record gets written to the service and messages are logged. */
   @Test
   public void testWriting() throws Exception {


Mime
View raw message