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: [BEAM-697] TextIO.Write: Preserve validation in withHeader/withFooter
Date Tue, 18 Oct 2016 00:02:55 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/master 129c9bc17 -> 7ac725583


[BEAM-697] TextIO.Write: Preserve validation in withHeader/withFooter

now use the current value of validate for the returned Bound instance,
added supporting tests


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

Branch: refs/heads/master
Commit: b202548323b4d59b11bbdf06c99d0f99e6a947ef
Parents: 129c9bc
Author: Jeffrey Scott Keone Payne <jeffkpayne@gmail.com>
Authored: Fri Oct 14 13:33:16 2016 -0700
Committer: Dan Halperin <dhalperi@google.com>
Committed: Mon Oct 17 17:01:57 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/beam/sdk/io/TextIO.java     |  4 ++--
 .../java/org/apache/beam/sdk/io/TextIOTest.java | 25 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/b2025483/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java
index 3ae2a0c..fbff3ba 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java
@@ -667,7 +667,7 @@ public class TextIO {
        */
       public Bound<T> withHeader(@Nullable String header) {
         return new Bound<>(name, filenamePrefix, filenameSuffix, header, footer, coder,
numShards,
-            shardTemplate, false, writableByteChannelFactory);
+            shardTemplate, validate, writableByteChannelFactory);
       }
 
       /**
@@ -682,7 +682,7 @@ public class TextIO {
        */
       public Bound<T> withFooter(@Nullable String footer) {
         return new Bound<>(name, filenamePrefix, filenameSuffix, header, footer, coder,
numShards,
-            shardTemplate, false, writableByteChannelFactory);
+            shardTemplate, validate, writableByteChannelFactory);
       }
 
       /**

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/b2025483/sdks/java/core/src/test/java/org/apache/beam/sdk/io/TextIOTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/TextIOTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/TextIOTest.java
index 2131ece..dc71693 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/TextIOTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/TextIOTest.java
@@ -35,6 +35,7 @@ import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.not;
 import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -557,6 +558,30 @@ public class TextIOTest {
   }
 
   @Test
+  public void testWriteDisplayDataValidateThenHeader() {
+    TextIO.Write.Bound<?> write = TextIO.Write
+        .to("foo")
+        .withHeader("myHeader");
+
+    DisplayData displayData = DisplayData.from(write);
+
+    assertThat(displayData, hasDisplayItem("fileHeader", "myHeader"));
+    assertThat(displayData, not(hasDisplayItem("validation", false)));
+  }
+
+  @Test
+  public void testWriteDisplayDataValidateThenFooter() {
+    TextIO.Write.Bound<?> write = TextIO.Write
+        .to("foo")
+        .withFooter("myFooter");
+
+    DisplayData displayData = DisplayData.from(write);
+
+    assertThat(displayData, hasDisplayItem("fileFooter", "myFooter"));
+    assertThat(displayData, not(hasDisplayItem("validation", false)));
+  }
+
+  @Test
   @Category(RunnableOnService.class)
   @Ignore("[BEAM-436] DirectRunner RunnableOnService tempLocation configuration insufficient")
   public void testPrimitiveWriteDisplayData() throws IOException {


Mime
View raw message