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: AvroIO.Write: minor doc and test fixes
Date Mon, 17 Oct 2016 21:38:40 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/master e849d95d1 -> cc3e53f32


AvroIO.Write: minor doc and test fixes

* Document the defualt codec.
* Minor docfix in the SerializableAvroCodecFactory.
* Swap the order of assertEquals in tests to match the expected pattern (expected, actual).


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

Branch: refs/heads/master
Commit: 95ce636f985e471a9803762d2c4236165a51f6db
Parents: e849d95
Author: Dan Halperin <dhalperi@google.com>
Authored: Wed Oct 12 18:10:25 2016 -0700
Committer: Dan Halperin <dhalperi@google.com>
Committed: Mon Oct 17 14:38:32 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/beam/sdk/io/AvroIO.java    |  4 ++++
 .../beam/sdk/io/SerializableAvroCodecFactory.java       |  2 +-
 .../test/java/org/apache/beam/sdk/io/AvroIOTest.java    | 12 ++++++------
 .../beam/sdk/io/SerializableAvroCodecFactoryTest.java   |  8 ++++----
 4 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/95ce636f/sdks/java/core/src/main/java/org/apache/beam/sdk/io/AvroIO.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/io/AvroIO.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/io/AvroIO.java
index eeb4bb7..d912ff7 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/io/AvroIO.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/io/AvroIO.java
@@ -110,6 +110,10 @@ import org.apache.beam.sdk.values.PDone;
  *     .withSuffix(".avro"));
  * } </pre>
  *
+ * <p>By default, {@link AvroIO.Write} produces output files that are compressed using
the
+ * {@link org.apache.avro.file.DeflateCodec CodecFactory.deflateCodec(6)}. This default can
+ * be changed or overridden using {@link AvroIO.Write#withCodec}.
+ *
  * <p><h3>Permissions</h3>
  * Permission requirements depend on the {@link PipelineRunner} that is used to execute the
  * Dataflow job. Please refer to the documentation of corresponding {@link PipelineRunner}s
for

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/95ce636f/sdks/java/core/src/main/java/org/apache/beam/sdk/io/SerializableAvroCodecFactory.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/io/SerializableAvroCodecFactory.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/io/SerializableAvroCodecFactory.java
index ce52e99..92c2a64 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/io/SerializableAvroCodecFactory.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/io/SerializableAvroCodecFactory.java
@@ -37,7 +37,7 @@ import java.util.regex.Pattern;
 import org.apache.avro.file.CodecFactory;
 
 /**
- * A wrapper allows  {@link org.apache.avro.file.CodecFactory}s to be serialized using Java's
+ * A wrapper that allows {@link org.apache.avro.file.CodecFactory}s to be serialized using
Java's
  * standard serialization mechanisms.
  */
 class SerializableAvroCodecFactory implements Externalizable {

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/95ce636f/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTest.java
index 1b1b1fa..4825875 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/AvroIOTest.java
@@ -178,7 +178,7 @@ public class AvroIOTest {
     p.run();
     DataFileStream dataFileStream = new DataFileStream(new FileInputStream(outputFile),
         new GenericDatumReader());
-    assertEquals(dataFileStream.getMetaString("avro.codec"), "deflate");
+    assertEquals("deflate", dataFileStream.getMetaString("avro.codec"));
   }
 
   @Test
@@ -207,7 +207,7 @@ public class AvroIOTest {
     p.run();
     DataFileStream dataFileStream = new DataFileStream(new FileInputStream(outputFile),
         new GenericDatumReader());
-    assertEquals(dataFileStream.getMetaString("avro.codec"), "null");
+    assertEquals("null", dataFileStream.getMetaString("avro.codec"));
   }
 
   @DefaultCoder(AvroCoder.class)
@@ -280,7 +280,7 @@ public class AvroIOTest {
   public void testWriteWithDefaultCodec() throws Exception {
     AvroIO.Write.Bound<GenericRecord> write = AvroIO.Write
         .to("gs://bucket/foo/baz");
-    assertEquals(write.getCodec().toString(), CodecFactory.deflateCodec(6).toString());
+    assertEquals(CodecFactory.deflateCodec(6).toString(), write.getCodec().toString());
   }
 
   @Test
@@ -288,7 +288,7 @@ public class AvroIOTest {
     AvroIO.Write.Bound<GenericRecord> write = AvroIO.Write
         .to("gs://bucket/foo/baz")
         .withCodec(CodecFactory.snappyCodec());
-    assertEquals(write.getCodec().toString(), SNAPPY_CODEC);
+    assertEquals(SNAPPY_CODEC, write.getCodec().toString());
   }
 
   @Test
@@ -300,7 +300,7 @@ public class AvroIOTest {
 
     AvroIO.Write.Bound<GenericRecord> serdeWrite = SerializableUtils.clone(write);
 
-    assertEquals(serdeWrite.getCodec().toString(), CodecFactory.deflateCodec(9).toString());
+    assertEquals(CodecFactory.deflateCodec(9).toString(), serdeWrite.getCodec().toString());
   }
 
   @Test
@@ -312,7 +312,7 @@ public class AvroIOTest {
 
     AvroIO.Write.Bound<GenericRecord> serdeWrite = SerializableUtils.clone(write);
 
-    assertEquals(serdeWrite.getCodec().toString(), CodecFactory.xzCodec(9).toString());
+    assertEquals(CodecFactory.xzCodec(9).toString(), serdeWrite.getCodec().toString());
   }
 
   @SuppressWarnings("deprecation") // using AvroCoder#createDatumReader for tests.

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/95ce636f/sdks/java/core/src/test/java/org/apache/beam/sdk/io/SerializableAvroCodecFactoryTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/SerializableAvroCodecFactoryTest.java
b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/SerializableAvroCodecFactoryTest.java
index 3fe8740..d367d8c 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/SerializableAvroCodecFactoryTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/SerializableAvroCodecFactoryTest.java
@@ -50,7 +50,7 @@ public class SerializableAvroCodecFactoryTest {
       SerializableAvroCodecFactory codecFactory = new SerializableAvroCodecFactory(
           CodecFactory.fromString(codec));
 
-      assertEquals(codecFactory.getCodec().toString(), (CodecFactory.fromString(codec).toString()));
+      assertEquals((CodecFactory.fromString(codec).toString()), codecFactory.getCodec().toString());
     }
   }
 
@@ -62,7 +62,7 @@ public class SerializableAvroCodecFactoryTest {
 
       SerializableAvroCodecFactory serdeC = SerializableUtils.clone(codecFactory);
 
-      assertEquals(serdeC.getCodec().toString(), CodecFactory.fromString(codec).toString());
+      assertEquals(CodecFactory.fromString(codec).toString(), serdeC.getCodec().toString());
     }
   }
 
@@ -74,7 +74,7 @@ public class SerializableAvroCodecFactoryTest {
 
       SerializableAvroCodecFactory serdeC = SerializableUtils.clone(codecFactory);
 
-      assertEquals(serdeC.getCodec().toString(), CodecFactory.deflateCodec(i).toString());
+      assertEquals(CodecFactory.deflateCodec(i).toString(), serdeC.getCodec().toString());
     }
   }
 
@@ -86,7 +86,7 @@ public class SerializableAvroCodecFactoryTest {
 
       SerializableAvroCodecFactory serdeC = SerializableUtils.clone(codecFactory);
 
-      assertEquals(serdeC.getCodec().toString(), CodecFactory.xzCodec(i).toString());
+      assertEquals(CodecFactory.xzCodec(i).toString(), serdeC.getCodec().toString());
     }
   }
 


Mime
View raw message