beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject [2/3] incubator-beam git commit: Updated complete examples to use TypeDescriptors.
Date Mon, 13 Jun 2016 18:04:41 GMT
Updated complete examples to use TypeDescriptors.


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

Branch: refs/heads/master
Commit: 50c0ed04784cff0454d89fcacab24e2a4f051edb
Parents: f0e266b
Author: Jesse Anderson <jesse@smokinghand.com>
Authored: Mon May 16 14:09:18 2016 -0700
Committer: Jesse Anderson <jesse@smokinghand.com>
Committed: Sat Jun 11 08:02:55 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/beam/examples/complete/game/GameStats.java  | 5 +++--
 .../java/org/apache/beam/examples/complete/game/UserScore.java  | 5 +++--
 .../apache/beam/examples/complete/game/HourlyTeamScoreTest.java | 5 +++--
 .../org/apache/beam/examples/complete/game/UserScoreTest.java   | 5 +++--
 4 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/50c0ed04/examples/java8/src/main/java/org/apache/beam/examples/complete/game/GameStats.java
----------------------------------------------------------------------
diff --git a/examples/java8/src/main/java/org/apache/beam/examples/complete/game/GameStats.java
b/examples/java8/src/main/java/org/apache/beam/examples/complete/game/GameStats.java
index 7814eb1..c557913 100644
--- a/examples/java8/src/main/java/org/apache/beam/examples/complete/game/GameStats.java
+++ b/examples/java8/src/main/java/org/apache/beam/examples/complete/game/GameStats.java
@@ -44,7 +44,7 @@ import org.apache.beam.sdk.transforms.windowing.Window;
 import org.apache.beam.sdk.values.KV;
 import org.apache.beam.sdk.values.PCollection;
 import org.apache.beam.sdk.values.PCollectionView;
-import org.apache.beam.sdk.values.TypeDescriptor;
+import org.apache.beam.sdk.values.TypeDescriptors;
 
 import org.joda.time.DateTimeZone;
 import org.joda.time.Duration;
@@ -255,7 +255,8 @@ public class GameStats extends LeaderBoard {
     PCollection<KV<String, Integer>> userEvents =
         rawEvents.apply("ExtractUserScore",
           MapElements.via((GameActionInfo gInfo) -> KV.of(gInfo.getUser(), gInfo.getScore()))
-            .withOutputType(new TypeDescriptor<KV<String, Integer>>() {}));
+            .withOutputType(
+                TypeDescriptors.kvs(TypeDescriptors.strings(), TypeDescriptors.integers())));
 
     // Calculate the total score per user over fixed windows, and
     // cumulative updates for late data.

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/50c0ed04/examples/java8/src/main/java/org/apache/beam/examples/complete/game/UserScore.java
----------------------------------------------------------------------
diff --git a/examples/java8/src/main/java/org/apache/beam/examples/complete/game/UserScore.java
b/examples/java8/src/main/java/org/apache/beam/examples/complete/game/UserScore.java
index 866adef..de049e8 100644
--- a/examples/java8/src/main/java/org/apache/beam/examples/complete/game/UserScore.java
+++ b/examples/java8/src/main/java/org/apache/beam/examples/complete/game/UserScore.java
@@ -35,7 +35,7 @@ import org.apache.beam.sdk.transforms.ParDo;
 import org.apache.beam.sdk.transforms.Sum;
 import org.apache.beam.sdk.values.KV;
 import org.apache.beam.sdk.values.PCollection;
-import org.apache.beam.sdk.values.TypeDescriptor;
+import org.apache.beam.sdk.values.TypeDescriptors;
 
 import org.apache.avro.reflect.Nullable;
 import org.slf4j.Logger;
@@ -168,7 +168,8 @@ public class UserScore {
       return gameInfo
         .apply(MapElements
             .via((GameActionInfo gInfo) -> KV.of(gInfo.getKey(field), gInfo.getScore()))
-            .withOutputType(new TypeDescriptor<KV<String, Integer>>() {}))
+            .withOutputType(
+                TypeDescriptors.kvs(TypeDescriptors.strings(), TypeDescriptors.integers())))
         .apply(Sum.<String>integersPerKey());
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/50c0ed04/examples/java8/src/test/java/org/apache/beam/examples/complete/game/HourlyTeamScoreTest.java
----------------------------------------------------------------------
diff --git a/examples/java8/src/test/java/org/apache/beam/examples/complete/game/HourlyTeamScoreTest.java
b/examples/java8/src/test/java/org/apache/beam/examples/complete/game/HourlyTeamScoreTest.java
index aa11c6c..5ff615a 100644
--- a/examples/java8/src/test/java/org/apache/beam/examples/complete/game/HourlyTeamScoreTest.java
+++ b/examples/java8/src/test/java/org/apache/beam/examples/complete/game/HourlyTeamScoreTest.java
@@ -30,7 +30,7 @@ import org.apache.beam.sdk.transforms.MapElements;
 import org.apache.beam.sdk.transforms.ParDo;
 import org.apache.beam.sdk.values.KV;
 import org.apache.beam.sdk.values.PCollection;
-import org.apache.beam.sdk.values.TypeDescriptor;
+import org.apache.beam.sdk.values.TypeDescriptors;
 
 import org.joda.time.Instant;
 import org.junit.Test;
@@ -102,7 +102,8 @@ public class HourlyTeamScoreTest implements Serializable {
       // run a map to access the fields in the result.
       .apply(MapElements
           .via((GameActionInfo gInfo) -> KV.of(gInfo.getUser(), gInfo.getScore()))
-          .withOutputType(new TypeDescriptor<KV<String, Integer>>() {}));
+          .withOutputType(
+              TypeDescriptors.kvs(TypeDescriptors.strings(), TypeDescriptors.integers())));
 
       PAssert.that(output).containsInAnyOrder(FILTERED_EVENTS);
 

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/50c0ed04/examples/java8/src/test/java/org/apache/beam/examples/complete/game/UserScoreTest.java
----------------------------------------------------------------------
diff --git a/examples/java8/src/test/java/org/apache/beam/examples/complete/game/UserScoreTest.java
b/examples/java8/src/test/java/org/apache/beam/examples/complete/game/UserScoreTest.java
index 842ea30..6f58114 100644
--- a/examples/java8/src/test/java/org/apache/beam/examples/complete/game/UserScoreTest.java
+++ b/examples/java8/src/test/java/org/apache/beam/examples/complete/game/UserScoreTest.java
@@ -31,7 +31,7 @@ import org.apache.beam.sdk.transforms.MapElements;
 import org.apache.beam.sdk.transforms.ParDo;
 import org.apache.beam.sdk.values.KV;
 import org.apache.beam.sdk.values.PCollection;
-import org.apache.beam.sdk.values.TypeDescriptor;
+import org.apache.beam.sdk.values.TypeDescriptors;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -146,7 +146,8 @@ public class UserScoreTest implements Serializable {
       .apply(ParDo.of(new ParseEventFn()))
       .apply(
           MapElements.via((GameActionInfo gInfo) -> KV.of(gInfo.getUser(), gInfo.getScore()))
-          .withOutputType(new TypeDescriptor<KV<String, Integer>>() {}));
+          .withOutputType(
+              TypeDescriptors.kvs(TypeDescriptors.strings(), TypeDescriptors.integers())));
 
     PAssert.that(extract).empty();
 


Mime
View raw message