beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pabl...@apache.org
Subject [beam] branch master updated: [BEAM-5685] Improving comparator for TopWikipediaSessions (#6611)
Date Tue, 09 Oct 2018 18:27:40 GMT
This is an automated email from the ASF dual-hosted git repository.

pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new ac21fff  [BEAM-5685] Improving comparator for TopWikipediaSessions (#6611)
ac21fff is described below

commit ac21fff3b78f377ca0077ad1b4fe3c666858b0d6
Author: Pablo <pabloem@users.noreply.github.com>
AuthorDate: Tue Oct 9 11:27:34 2018 -0700

    [BEAM-5685] Improving comparator for TopWikipediaSessions (#6611)
    
    * Improving comparator for TopWikipediaSessions
---
 .../org/apache/beam/examples/complete/TopWikipediaSessions.java    | 7 ++++++-
 .../org/apache/beam/examples/complete/TopWikipediaSessionsIT.java  | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java
b/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java
index b33bbc0..5eb747f 100644
--- a/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java
+++ b/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java
@@ -18,6 +18,7 @@
 package org.apache.beam.examples.complete;
 
 import com.google.api.services.bigquery.model.TableRow;
+import com.google.common.collect.ComparisonChain;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.List;
@@ -112,7 +113,11 @@ public class TopWikipediaSessions {
     @Override
     public PCollection<List<KV<String, Long>>> expand(PCollection<KV<String,
Long>> sessions) {
       SerializableComparator<KV<String, Long>> comparator =
-          (o1, o2) -> Long.compare(o1.getValue(), o2.getValue());
+          (o1, o2) ->
+              ComparisonChain.start()
+                  .compare(o1.getValue(), o2.getValue())
+                  .compare(o1.getKey(), o2.getKey())
+                  .result();
       return sessions
           .apply(Window.into(CalendarWindows.months(1)))
           .apply(Top.of(1, comparator).withoutDefaults());
diff --git a/examples/java/src/test/java/org/apache/beam/examples/complete/TopWikipediaSessionsIT.java
b/examples/java/src/test/java/org/apache/beam/examples/complete/TopWikipediaSessionsIT.java
index 1f278e7..aa32b48 100644
--- a/examples/java/src/test/java/org/apache/beam/examples/complete/TopWikipediaSessionsIT.java
+++ b/examples/java/src/test/java/org/apache/beam/examples/complete/TopWikipediaSessionsIT.java
@@ -36,7 +36,7 @@ public class TopWikipediaSessionsIT {
 
   private static final String DEFAULT_INPUT_10_FILES =
       "gs://apache-beam-samples/wikipedia_edits/wiki_data-00000000000*.json";
-  private static final String DEFAULT_OUTPUT_CHECKSUM = "a7f0c50b895d0a2e37b78c3f94eadcfb11a647a6";
+  private static final String DEFAULT_OUTPUT_CHECKSUM = "61262b08503338bfe4e36b0791958d65e6070933";
 
   /** PipelineOptions for the TopWikipediaSessions integration test. */
   public interface TopWikipediaSessionsITOptions


Mime
View raw message