This is an automated email from the ASF dual-hosted git repository. lcwik pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
commit 7f99628784c53c1b28e38bb4bfd9448c94021011 Author: ArnaudFnr <[email protected]> AuthorDate: Wed Jan 17 08:32:27 2018 +0100 Optimize coder memory use --- .../beam/sdk/extensions/sketching/SketchFrequencies.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/sdks/java/extensions/sketching/src/main/java/org/apache/beam/sdk/extensions/sketching/SketchFrequencies.java b/sdks/java/extensions/sketching/src/main/java/org/apache/beam/sdk/extensions/sketching/SketchFrequencies.java index bb62053..a318473 100644 --- a/sdks/java/extensions/sketching/src/main/java/org/apache/beam/sdk/extensions/sketching/SketchFrequencies.java +++ b/sdks/java/extensions/sketching/src/main/java/org/apache/beam/sdk/extensions/sketching/SketchFrequencies.java @@ -29,7 +29,6 @@ import java.io.Serializable; import java.util.Iterator; import org.apache.beam.sdk.annotations.Experimental; -import org.apache.beam.sdk.coders.BigEndianIntegerCoder; import org.apache.beam.sdk.coders.ByteArrayCoder; import org.apache.beam.sdk.coders.Coder; import org.apache.beam.sdk.coders.CoderException; @@ -438,13 +437,6 @@ public final class SketchFrequencies { new CountMinSketch(depth, width, SEED)); } - static <T> Sketch<T> create(int depth, int width, CountMinSketch sketch) { - return new AutoValue_SketchFrequencies_Sketch<T>( - depth, - width, - sketch); - } - static <T> Sketch<T> create(CountMinSketch sketch) { int width = (int) Math.ceil(2 / sketch.getRelativeError()); int depth = (int) Math.ceil(-Math.log(1 - sketch.getConfidence()) / Math.log(2)); @@ -491,26 +483,20 @@ public final class SketchFrequencies { static class CountMinSketchCoder<T> extends CustomCoder<Sketch<T>> { private static final ByteArrayCoder BYTE_ARRAY_CODER = ByteArrayCoder.of(); - private static final BigEndianIntegerCoder INT_CODER = BigEndianIntegerCoder.of(); - @Override public void encode(Sketch<T> value, OutputStream outStream) throws IOException { if (value == null) { throw new CoderException("cannot encode a null Count-min Sketch"); } - INT_CODER.encode(value.width(), outStream); - INT_CODER.encode(value.depth(), outStream); BYTE_ARRAY_CODER.encode(CountMinSketch.serialize(value.sketch()), outStream); } @Override public Sketch<T> decode(InputStream inStream) throws IOException { - int width = INT_CODER.decode(inStream); - int depth = INT_CODER.decode(inStream); byte[] sketchBytes = BYTE_ARRAY_CODER.decode(inStream); CountMinSketch sketch = CountMinSketch.deserialize(sketchBytes); - return Sketch.<T>create(depth, width, sketch); + return Sketch.<T>create(sketch); } @Override -- To stop receiving notification emails like this one, please contact [email protected].
