beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lc...@apache.org
Subject [5/8] beam git commit: [BEAM-1186] Fixed some stuff following reviews.
Date Wed, 28 Dec 2016 19:41:38 GMT
[BEAM-1186] Fixed some stuff following reviews.


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

Branch: refs/heads/master
Commit: 7302732e5ba43ee3def776a82e1d5ba16fcf6c62
Parents: 239848c
Author: Stas Levin <staslevin@gmail.com>
Authored: Thu Dec 22 21:50:46 2016 +0200
Committer: Luke Cwik <lcwik@google.com>
Committed: Wed Dec 28 11:40:33 2016 -0800

----------------------------------------------------------------------
 .../apache/beam/sdk/io/AvroIOTransformTest.java | 47 ++++++++------------
 .../sdk/transforms/ApproximateUniqueTest.java   |  8 ++--
 2 files changed, 21 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/7302732e/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTransformTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTransformTest.java
b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTransformTest.java
index cc1b3ad..3cf52a4 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTransformTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTransformTest.java
@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import javax.annotation.Nullable;
 import org.apache.avro.Schema;
 import org.apache.avro.file.DataFileReader;
 import org.apache.avro.file.DataFileWriter;
@@ -136,7 +137,7 @@ public class AvroIOTransformTest {
       }
     }
 
-    private <T> void runTestRead(final String applyName,
+    private <T> void runTestRead(@Nullable final String applyName,
                                  final AvroIO.Read.Bound<T> readBuilder,
                                  final String expectedName,
                                  final T[] expectedOutput) throws Exception {
@@ -145,7 +146,7 @@ public class AvroIOTransformTest {
       generateAvroFile(generateAvroObjects(), avroFile);
       final AvroIO.Read.Bound<T> read = readBuilder.from(avroFile.getPath());
       final PCollection<T> output =
-          applyName.equals("") ? pipeline.apply(read) : pipeline.apply(applyName, read);
+          applyName == null ? pipeline.apply(read) : pipeline.apply(applyName, read);
 
       PAssert.that(output).containsInAnyOrder(expectedOutput);
 
@@ -164,8 +165,10 @@ public class AvroIOTransformTest {
       return
           ImmutableList.<Object[]>builder()
               .add(
+
+                  // test read using generated class
                   new Object[] {
-                      "",
+                      null,
                       AvroIO.Read.withSchema(AvroGeneratedUser.class),
                       "AvroIO.Read/Read.out",
                       generateAvroObjects(),
@@ -176,16 +179,12 @@ public class AvroIOTransformTest {
                       AvroIO.Read.withSchema(AvroGeneratedUser.class),
                       "MyRead/Read.out",
                       generateAvroObjects(),
-                      generatedClass,
-                      },
+                      generatedClass
+                  },
+
+                  // test read using schema object
                   new Object[] {
-                      "HerRead",
-                      AvroIO.Read.withSchema(AvroGeneratedUser.class),
-                      "HerRead/Read.out",
-                      generateAvroObjects(),
-                      generatedClass,
-                      }, new Object[] {
-                      "",
+                      null,
                       AvroIO.Read.withSchema(SCHEMA),
                       "AvroIO.Read/Read.out",
                       generateAvroGenericRecords(),
@@ -198,15 +197,10 @@ public class AvroIOTransformTest {
                       generateAvroGenericRecords(),
                       fromSchema
                   },
+
+                  // test read using schema string
                   new Object[] {
-                      "HerRead",
-                      AvroIO.Read.withSchema(SCHEMA),
-                      "HerRead/Read.out",
-                      generateAvroGenericRecords(),
-                      fromSchema
-                  },
-                  new Object[] {
-                      "",
+                      null,
                       AvroIO.Read.withSchema(SCHEMA_STRING),
                       "AvroIO.Read/Read.out",
                       generateAvroGenericRecords(),
@@ -218,18 +212,12 @@ public class AvroIOTransformTest {
                       "MyRead/Read.out",
                       generateAvroGenericRecords(),
                       fromSchemaString
-                  },
-                  new Object[] {
-                      "HerRead",
-                      AvroIO.Read.withSchema(SCHEMA_STRING),
-                      "HerRead/Read.out",
-                      generateAvroGenericRecords(),
-                      fromSchemaString
                   })
               .build();
     }
 
-    @Parameterized.Parameter()
+    @SuppressWarnings("DefaultAnnotationParam")
+    @Parameterized.Parameter(0)
     public String transformName;
 
     @Parameterized.Parameter(1)
@@ -298,7 +286,8 @@ public class AvroIOTransformTest {
               .build();
     }
 
-    @Parameterized.Parameter()
+    @SuppressWarnings("DefaultAnnotationParam")
+    @Parameterized.Parameter(0)
     public AvroIO.Write.Bound writeTransform;
 
     @Parameterized.Parameter(1)

http://git-wip-us.apache.org/repos/asf/beam/blob/7302732e/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateUniqueTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateUniqueTest.java
b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateUniqueTest.java
index 77bbcfa..72c33fb 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateUniqueTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateUniqueTest.java
@@ -95,10 +95,10 @@ public class ApproximateUniqueTest implements Serializable {
     final double error = 100.0 * Math.abs(estimate - uniqueCount) / uniqueCount;
     final double maxError = 100.0 * 2 / Math.sqrt(sampleSize);
 
-    assertTrue("Estimate= " + estimate + " Actual=" + uniqueCount + " Error="
+    assertTrue("Estimate=" + estimate + " Actual=" + uniqueCount + " Error="
                    + error + "%, MaxError=" + maxError + "%.", error < maxError);
 
-    assertTrue("Estimate= " + estimate + " Actual=" + uniqueCount + " Error="
+    assertTrue("Estimate=" + estimate + " Actual=" + uniqueCount + " Error="
                    + error + "%, MaxError=" + maxError + "%.", error < maxError);
   }
 
@@ -185,8 +185,7 @@ public class ApproximateUniqueTest implements Serializable {
    * Tests for ApproximateUnique with different sample sizes.
    */
   @RunWith(Parameterized.class)
-  public static class ApproximateUniqueVariationsTest extends
-                                                      ApproximateUniqueTest {
+  public static class ApproximateUniqueVariationsTest extends ApproximateUniqueTest {
 
     private static final int TEST_PAGES = 100;
     private static final List<String> TEST_LINES =
@@ -277,7 +276,6 @@ public class ApproximateUniqueTest implements Serializable {
         } catch (final IllegalArgumentException e) {
           assertTrue("Expected an exception due to sampleSize < 16",
                      e.getMessage().startsWith("ApproximateUnique needs a sampleSize >=
16"));
-
         }
       }
     }


Mime
View raw message