Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 88F76200CA3 for ; Tue, 2 May 2017 20:56:21 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 87B66160BAB; Tue, 2 May 2017 18:56:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 32C5A160B9D for ; Tue, 2 May 2017 20:56:20 +0200 (CEST) Received: (qmail 7654 invoked by uid 500); 2 May 2017 18:56:19 -0000 Mailing-List: contact commits-help@beam.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@beam.apache.org Delivered-To: mailing list commits@beam.apache.org Received: (qmail 7641 invoked by uid 99); 2 May 2017 18:56:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 May 2017 18:56:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 32111DFE8F; Tue, 2 May 2017 18:56:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kenn@apache.org To: commits@beam.apache.org Date: Tue, 02 May 2017 18:56:20 -0000 Message-Id: <01f0fd1f4c3a49589539cd5fc87513a1@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/6] beam git commit: Simplify type parameters of StateSpec and related archived-at: Tue, 02 May 2017 18:56:21 -0000 http://git-wip-us.apache.org/repos/asf/beam/blob/8fe59c35/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java ---------------------------------------------------------------------- diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java index 52b2f5e..26904aa 100644 --- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java +++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java @@ -1625,7 +1625,7 @@ public class ParDoTest implements Serializable { new DoFn, Integer>() { @StateId(stateId) - private final StateSpec> intState = + private final StateSpec> intState = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -1654,7 +1654,7 @@ public class ParDoTest implements Serializable { new DoFn, Integer>() { @StateId(stateId) - private final StateSpec> seenSpec = + private final StateSpec> seenSpec = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -1704,7 +1704,7 @@ public class ParDoTest implements Serializable { new DoFn, MyInteger>() { @StateId(stateId) - private final StateSpec> intState = + private final StateSpec> intState = StateSpecs.value(); @ProcessElement @@ -1734,7 +1734,7 @@ public class ParDoTest implements Serializable { new DoFn, MyInteger>() { @StateId(stateId) - private final StateSpec> intState = + private final StateSpec> intState = StateSpecs.value(); @ProcessElement @@ -1765,7 +1765,7 @@ public class ParDoTest implements Serializable { new DoFn, MyInteger>() { @StateId(stateId) - private final StateSpec> intState = + private final StateSpec> intState = StateSpecs.value(); @ProcessElement @@ -1797,7 +1797,7 @@ public class ParDoTest implements Serializable { new DoFn, List>() { @StateId(stateId) - private final StateSpec>> intState = + private final StateSpec>> intState = StateSpecs.value(); @ProcessElement @@ -1828,7 +1828,7 @@ public class ParDoTest implements Serializable { new DoFn, Integer>() { @StateId(stateId) - private final StateSpec> intState = + private final StateSpec> intState = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -1876,7 +1876,7 @@ public class ParDoTest implements Serializable { new DoFn, KV>() { @StateId(stateId) - private final StateSpec> intState = + private final StateSpec> intState = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -1892,7 +1892,7 @@ public class ParDoTest implements Serializable { new DoFn, Integer>() { @StateId(stateId) - private final StateSpec> intState = + private final StateSpec> intState = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -1929,7 +1929,7 @@ public class ParDoTest implements Serializable { new DoFn, Integer>() { @StateId(stateId) - private final StateSpec> intState = + private final StateSpec> intState = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -1976,7 +1976,7 @@ public class ParDoTest implements Serializable { new DoFn, List>() { @StateId(stateId) - private final StateSpec> bufferState = + private final StateSpec> bufferState = StateSpecs.bag(VarIntCoder.of()); @ProcessElement @@ -2013,7 +2013,7 @@ public class ParDoTest implements Serializable { new DoFn, List>() { @StateId(stateId) - private final StateSpec> bufferState = + private final StateSpec> bufferState = StateSpecs.bag(); @ProcessElement @@ -2051,7 +2051,7 @@ public class ParDoTest implements Serializable { new DoFn, List>() { @StateId(stateId) - private final StateSpec> bufferState = + private final StateSpec> bufferState = StateSpecs.bag(); @ProcessElement @@ -2088,10 +2088,10 @@ public class ParDoTest implements Serializable { new DoFn, Set>() { @StateId(stateId) - private final StateSpec> setState = + private final StateSpec> setState = StateSpecs.set(VarIntCoder.of()); @StateId(countStateId) - private final StateSpec> + private final StateSpec> countState = StateSpecs.combiningFromInputInternal(VarIntCoder.of(), Sum.ofIntegers()); @@ -2132,10 +2132,10 @@ public class ParDoTest implements Serializable { new DoFn, Set>() { @StateId(stateId) - private final StateSpec> setState = StateSpecs.set(); + private final StateSpec> setState = StateSpecs.set(); @StateId(countStateId) - private final StateSpec> + private final StateSpec> countState = StateSpecs.combiningFromInputInternal(VarIntCoder.of(), Sum.ofIntegers()); @@ -2175,10 +2175,10 @@ public class ParDoTest implements Serializable { new DoFn, Set>() { @StateId(stateId) - private final StateSpec> setState = StateSpecs.set(); + private final StateSpec> setState = StateSpecs.set(); @StateId(countStateId) - private final StateSpec> + private final StateSpec> countState = StateSpecs.combiningFromInputInternal(VarIntCoder.of(), Sum.ofIntegers()); @@ -2217,10 +2217,10 @@ public class ParDoTest implements Serializable { new DoFn>, KV>() { @StateId(stateId) - private final StateSpec> mapState = + private final StateSpec> mapState = StateSpecs.map(StringUtf8Coder.of(), VarIntCoder.of()); @StateId(countStateId) - private final StateSpec> + private final StateSpec> countState = StateSpecs.combiningFromInputInternal(VarIntCoder.of(), Sum.ofIntegers()); @@ -2264,9 +2264,10 @@ public class ParDoTest implements Serializable { new DoFn>, KV>() { @StateId(stateId) - private final StateSpec> mapState = StateSpecs.map(); + private final StateSpec> mapState = StateSpecs.map(); + @StateId(countStateId) - private final StateSpec> + private final StateSpec> countState = StateSpecs.combiningFromInputInternal(VarIntCoder.of(), Sum.ofIntegers()); @@ -2310,9 +2311,10 @@ public class ParDoTest implements Serializable { new DoFn>, KV>() { @StateId(stateId) - private final StateSpec> mapState = StateSpecs.map(); + private final StateSpec> mapState = StateSpecs.map(); + @StateId(countStateId) - private final StateSpec> + private final StateSpec> countState = StateSpecs.combiningFromInputInternal(VarIntCoder.of(), Sum.ofIntegers()); @@ -2356,16 +2358,13 @@ public class ParDoTest implements Serializable { private static final double EPSILON = 0.0001; @StateId(stateId) - private final StateSpec< - Object, CombiningState, Double>> - combiningState = - StateSpecs.combining(new Mean.CountSumCoder(), Mean.of()); + private final StateSpec, Double>> combiningState = + StateSpecs.combining(new Mean.CountSumCoder(), Mean.of()); @ProcessElement public void processElement( ProcessContext c, - @StateId(stateId) - CombiningState, Double> state) { + @StateId(stateId) CombiningState, Double> state) { state.add(c.element().getValue()); Double currentValue = state.read(); if (Math.abs(currentValue - 0.5) < EPSILON) { @@ -2396,40 +2395,38 @@ public class ParDoTest implements Serializable { private static final int EXPECTED_SUM = 16; @StateId(stateId) - private final StateSpec< - Object, CombiningState> - combiningState = - StateSpecs.combining(new Combine.CombineFn() { - @Override - public MyInteger createAccumulator() { - return new MyInteger(0); - } - - @Override - public MyInteger addInput(MyInteger accumulator, Integer input) { - return new MyInteger(accumulator.getValue() + input); - } - - @Override - public MyInteger mergeAccumulators(Iterable accumulators) { - int newValue = 0; - for (MyInteger myInteger : accumulators) { - newValue += myInteger.getValue(); - } - return new MyInteger(newValue); - } + private final StateSpec> combiningState = + StateSpecs.combining( + new Combine.CombineFn() { + @Override + public MyInteger createAccumulator() { + return new MyInteger(0); + } + + @Override + public MyInteger addInput(MyInteger accumulator, Integer input) { + return new MyInteger(accumulator.getValue() + input); + } + + @Override + public MyInteger mergeAccumulators(Iterable accumulators) { + int newValue = 0; + for (MyInteger myInteger : accumulators) { + newValue += myInteger.getValue(); + } + return new MyInteger(newValue); + } - @Override - public Integer extractOutput(MyInteger accumulator) { - return accumulator.getValue(); - } - }); + @Override + public Integer extractOutput(MyInteger accumulator) { + return accumulator.getValue(); + } + }); @ProcessElement public void processElement( ProcessContext c, - @StateId(stateId) - CombiningState state) { + @StateId(stateId) CombiningState state) { state.add(c.element().getValue()); Integer currentValue = state.read(); if (currentValue == EXPECTED_SUM) { @@ -2458,40 +2455,38 @@ public class ParDoTest implements Serializable { private static final int EXPECTED_SUM = 16; @StateId(stateId) - private final StateSpec< - Object, CombiningState> - combiningState = - StateSpecs.combining(new Combine.CombineFn() { - @Override - public MyInteger createAccumulator() { - return new MyInteger(0); - } - - @Override - public MyInteger addInput(MyInteger accumulator, Integer input) { - return new MyInteger(accumulator.getValue() + input); - } - - @Override - public MyInteger mergeAccumulators(Iterable accumulators) { - int newValue = 0; - for (MyInteger myInteger : accumulators) { - newValue += myInteger.getValue(); - } - return new MyInteger(newValue); - } + private final StateSpec> combiningState = + StateSpecs.combining( + new Combine.CombineFn() { + @Override + public MyInteger createAccumulator() { + return new MyInteger(0); + } + + @Override + public MyInteger addInput(MyInteger accumulator, Integer input) { + return new MyInteger(accumulator.getValue() + input); + } + + @Override + public MyInteger mergeAccumulators(Iterable accumulators) { + int newValue = 0; + for (MyInteger myInteger : accumulators) { + newValue += myInteger.getValue(); + } + return new MyInteger(newValue); + } - @Override - public Integer extractOutput(MyInteger accumulator) { - return accumulator.getValue(); - } - }); + @Override + public Integer extractOutput(MyInteger accumulator) { + return accumulator.getValue(); + } + }); @ProcessElement public void processElement( ProcessContext c, - @StateId(stateId) - CombiningState state) { + @StateId(stateId) CombiningState state) { state.add(c.element().getValue()); Integer currentValue = state.read(); if (currentValue == EXPECTED_SUM) { @@ -2523,7 +2518,7 @@ public class ParDoTest implements Serializable { new DoFn, List>() { @StateId(stateId) - private final StateSpec> bufferState = + private final StateSpec> bufferState = StateSpecs.bag(VarIntCoder.of()); @ProcessElement @@ -2697,7 +2692,7 @@ public class ParDoTest implements Serializable { private final TimerSpec spec = TimerSpecs.timer(TimeDomain.EVENT_TIME); @StateId(stateId) - private final StateSpec> stateSpec = + private final StateSpec> stateSpec = StateSpecs.value(StringUtf8Coder.of()); @ProcessElement http://git-wip-us.apache.org/repos/asf/beam/blob/8fe59c35/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnInvokersTest.java ---------------------------------------------------------------------- diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnInvokersTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnInvokersTest.java index 5732438..c16eea2 100644 --- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnInvokersTest.java +++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnInvokersTest.java @@ -188,7 +188,7 @@ public class DoFnInvokersTest { class MockFn extends DoFn { @StateId(stateId) - private final StateSpec> spec = + private final StateSpec> spec = StateSpecs.value(VarIntCoder.of()); @ProcessElement http://git-wip-us.apache.org/repos/asf/beam/blob/8fe59c35/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnSignaturesTest.java ---------------------------------------------------------------------- diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnSignaturesTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnSignaturesTest.java index e1fa2d1..d6cc4f6 100644 --- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnSignaturesTest.java +++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/reflect/DoFnSignaturesTest.java @@ -542,11 +542,11 @@ public class DoFnSignaturesTest { DoFnSignatures.getSignature( new DoFn, Long>() { @StateId("my-id") - private final StateSpec> myfield1 = + private final StateSpec> myfield1 = StateSpecs.value(VarIntCoder.of()); @StateId("my-id") - private final StateSpec> myfield2 = + private final StateSpec> myfield2 = StateSpecs.value(VarLongCoder.of()); @ProcessElement @@ -565,7 +565,7 @@ public class DoFnSignaturesTest { DoFnSignatures.getSignature( new DoFn, Long>() { @StateId("my-id") - private StateSpec> myfield = + private StateSpec> myfield = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -618,7 +618,7 @@ public class DoFnSignaturesTest { DoFnSignatures.getSignature( new DoFn, Long>() { @StateId("my-id") - private final StateSpec> myfield = + private final StateSpec> myfield = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -644,7 +644,7 @@ public class DoFnSignaturesTest { DoFnSignatures.getSignature( new DoFn, Long>() { @StateId("my-id") - private final StateSpec> myfield = + private final StateSpec> myfield = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -668,7 +668,7 @@ public class DoFnSignaturesTest { DoFnSignatures.getSignature( new DoFn, Long>() { @StateId("my-id") - private final StateSpec> myfield = + private final StateSpec> myfield = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -683,7 +683,7 @@ public class DoFnSignaturesTest { DoFnSignatures.getSignature( new DoFn, Long>() { @StateId("foo") - private final StateSpec> bizzle = + private final StateSpec> bizzle = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -728,7 +728,7 @@ public class DoFnSignaturesTest { DoFnSignatures.getSignature( new DoFnUsingState() { @StateId(DoFnUsingState.STATE_ID) - private final StateSpec> spec = + private final StateSpec> spec = StateSpecs.value(VarIntCoder.of()); }.getClass()); } @@ -770,7 +770,7 @@ public class DoFnSignaturesTest { DoFnSignatures.getSignature( new DoFn, Long>() { @StateId("foo") - private final StateSpec> bizzleDecl = + private final StateSpec> bizzleDecl = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -803,7 +803,7 @@ public class DoFnSignaturesTest { public void testSimpleStateIdNamedDoFn() throws Exception { class DoFnForTestSimpleStateIdNamedDoFn extends DoFn, Long> { @StateId("foo") - private final StateSpec> bizzle = + private final StateSpec> bizzle = StateSpecs.value(VarIntCoder.of()); @ProcessElement @@ -831,7 +831,7 @@ public class DoFnSignaturesTest { // Note that in order to have a coder for T it will require initialization in the constructor, // but that isn't important for this test @StateId("foo") - private final StateSpec> bizzle = null; + private final StateSpec> bizzle = null; @ProcessElement public void foo(ProcessContext context) {} @@ -866,7 +866,7 @@ public class DoFnSignaturesTest { public static final String STATE_ID = "my-state-id"; @StateId(STATE_ID) - private final StateSpec> bizzle = + private final StateSpec> bizzle = StateSpecs.value(VarIntCoder.of()); } @@ -882,7 +882,7 @@ public class DoFnSignaturesTest { public static final String STATE_ID = "my-state-id"; @StateId(STATE_ID) - private final StateSpec> myStateSpec = + private final StateSpec> myStateSpec = StateSpecs.value(StringUtf8Coder.of()); @ProcessElement http://git-wip-us.apache.org/repos/asf/beam/blob/8fe59c35/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/fake/FakeStepContext.java ---------------------------------------------------------------------- diff --git a/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/fake/FakeStepContext.java b/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/fake/FakeStepContext.java index 9714d72..9b79d11 100644 --- a/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/fake/FakeStepContext.java +++ b/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/fake/FakeStepContext.java @@ -59,7 +59,7 @@ public class FakeStepContext implements StepContext { } @Override - public StateInternals stateInternals() { + public StateInternals stateInternals() { throw new UnsupportedOperationException(); }