Repository: beam
Updated Branches:
  refs/heads/master 086148fa9 -> 64cea06b1


[BEAM-2293] Rename Top.{Largest,Smallest=>Natural,Reversed}

 - [x] Make sure the PR title is formatted like:
   `[BEAM-<Jira issue #>] Description of pull request`
 - [x] Make sure tests pass via `mvn clean verify`. (Even better, enable
       Travis-CI on your fork and ensure the whole test matrix passes).
 - [x] Replace `<Jira issue #>` in the title with the actual Jira issue
       number, if there is one.
 - [x] If this contribution is large, please file an Apache
       [Individual Contributor License 
Agreement](https://www.apache.org/licenses/icla.pdf).

---


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

Branch: refs/heads/master
Commit: 6c6d7877620af5265ed5ca14dd2ed7cd905b7404
Parents: 086148f
Author: wtanaka.com <wtan...@yahoo.com>
Authored: Thu May 18 20:42:46 2017 -1000
Committer: Luke Cwik <lc...@google.com>
Committed: Fri May 19 14:10:28 2017 -0700

----------------------------------------------------------------------
 .../sdk/transforms/ApproximateQuantiles.java    |  4 +--
 .../org/apache/beam/sdk/transforms/Max.java     |  4 +--
 .../org/apache/beam/sdk/transforms/Min.java     |  4 +--
 .../org/apache/beam/sdk/transforms/Top.java     | 36 ++++++++++++++++----
 .../transforms/ApproximateQuantilesTest.java    |  2 +-
 .../org/apache/beam/sdk/transforms/MaxTest.java |  2 +-
 .../org/apache/beam/sdk/transforms/MinTest.java |  2 +-
 .../org/apache/beam/sdk/transforms/TopTest.java | 10 +++---
 8 files changed, 44 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/6c6d7877/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/ApproximateQuantiles.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/ApproximateQuantiles.java
 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/ApproximateQuantiles.java
index d12d193..e952af2 100644
--- 
a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/ApproximateQuantiles.java
+++ 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/ApproximateQuantiles.java
@@ -283,8 +283,8 @@ public class ApproximateQuantiles {
      * Like {@link #create(int, Comparator)}, but sorts values using their 
natural ordering.
      */
     public static <T extends Comparable<T>>
-        ApproximateQuantilesCombineFn<T, Top.Largest<T>> create(int 
numQuantiles) {
-      return create(numQuantiles, new Top.Largest<T>());
+        ApproximateQuantilesCombineFn<T, Top.Natural<T>> create(int 
numQuantiles) {
+      return create(numQuantiles, new Top.Natural<T>());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/beam/blob/6c6d7877/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Max.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Max.java 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Max.java
index 91851bc..710fe77 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Max.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Max.java
@@ -158,11 +158,11 @@ public class Max {
   }
 
   public static <T extends Comparable<? super T>> BinaryCombineFn<T> 
naturalOrder(T identity) {
-    return new MaxFn<T>(identity, new Top.Largest<T>());
+    return new MaxFn<T>(identity, new Top.Natural<T>());
   }
 
   public static <T extends Comparable<? super T>> BinaryCombineFn<T> 
naturalOrder() {
-    return new MaxFn<T>(null, new Top.Largest<T>());
+    return new MaxFn<T>(null, new Top.Natural<T>());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/beam/blob/6c6d7877/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Min.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Min.java 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Min.java
index 109f4e5..c566fb3 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Min.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Min.java
@@ -158,11 +158,11 @@ public class Min {
   }
 
   public static <T extends Comparable<? super T>> BinaryCombineFn<T> 
naturalOrder(T identity) {
-    return new MinFn<T>(identity, new Top.Largest<T>());
+    return new MinFn<T>(identity, new Top.Natural<T>());
   }
 
   public static <T extends Comparable<? super T>> BinaryCombineFn<T> 
naturalOrder() {
-    return new MinFn<T>(null, new Top.Largest<T>());
+    return new MinFn<T>(null, new Top.Natural<T>());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/beam/blob/6c6d7877/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Top.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Top.java 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Top.java
index 99ec49b..319f779 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Top.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Top.java
@@ -144,7 +144,7 @@ public class Top {
    * {@code KV}s and return the top values associated with each key.
    */
   public static <T extends Comparable<T>> Combine.Globally<T, List<T>> 
smallest(int count) {
-    return Combine.globally(new TopCombineFn<>(count, new Smallest<T>()));
+    return Combine.globally(new TopCombineFn<>(count, new Reversed<T>()));
   }
 
   /**
@@ -188,7 +188,7 @@ public class Top {
    * {@code KV}s and return the top values associated with each key.
    */
   public static <T extends Comparable<T>> Combine.Globally<T, List<T>> 
largest(int count) {
-    return Combine.globally(new TopCombineFn<>(count, new Largest<T>()));
+    return Combine.globally(new TopCombineFn<>(count, new Natural<T>()));
   }
 
   /**
@@ -281,7 +281,7 @@ public class Top {
   public static <K, V extends Comparable<V>>
       PTransform<PCollection<KV<K, V>>, PCollection<KV<K, List<V>>>>
       smallestPerKey(int count) {
-    return Combine.perKey(new TopCombineFn<>(count, new Smallest<V>()));
+    return Combine.perKey(new TopCombineFn<>(count, new Reversed<V>()));
   }
 
   /**
@@ -327,14 +327,26 @@ public class Top {
   public static <K, V extends Comparable<V>>
       PerKey<K, V, List<V>>
       largestPerKey(int count) {
-    return Combine.perKey(new TopCombineFn<>(count, new Largest<V>()));
+    return Combine.perKey(new TopCombineFn<>(count, new Natural<V>()));
+  }
+
+  /**
+   * @deprecated use {@link Natural} instead
+   */
+  @Deprecated
+  public static class Largest<T extends Comparable<? super T>>
+      implements Comparator<T>, Serializable {
+    @Override
+    public int compare(T a, T b) {
+      return a.compareTo(b);
+    }
   }
 
   /**
    * A {@code Serializable} {@code Comparator} that that uses the compared 
elements' natural
    * ordering.
    */
-  public static class Largest<T extends Comparable<? super T>>
+  public static class Natural<T extends Comparable<? super T>>
       implements Comparator<T>, Serializable {
     @Override
     public int compare(T a, T b) {
@@ -343,10 +355,22 @@ public class Top {
   }
 
   /**
+   * @deprecated use {@link Reversed} instead
+   */
+  @Deprecated
+  public static class Smallest<T extends Comparable<? super T>>
+      implements Comparator<T>, Serializable {
+    @Override
+    public int compare(T a, T b) {
+      return b.compareTo(a);
+    }
+  }
+
+  /**
    * {@code Serializable} {@code Comparator} that that uses the reverse of the 
compared elements'
    * natural ordering.
    */
-  public static class Smallest<T extends Comparable<? super T>>
+  public static class Reversed<T extends Comparable<? super T>>
       implements Comparator<T>, Serializable {
     @Override
     public int compare(T a, T b) {

http://git-wip-us.apache.org/repos/asf/beam/blob/6c6d7877/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateQuantilesTest.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateQuantilesTest.java
 
b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateQuantilesTest.java
index cd7898b..9e0b3cc 100644
--- 
a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateQuantilesTest.java
+++ 
b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ApproximateQuantilesTest.java
@@ -236,7 +236,7 @@ public class ApproximateQuantilesTest {
 
   @Test
   public void testDisplayData() {
-    Top.Largest<Integer> comparer = new Top.Largest<Integer>();
+    Top.Natural<Integer> comparer = new Top.Natural<Integer>();
     PTransform<?, ?> approxQuanitiles = ApproximateQuantiles.globally(20, 
comparer);
     DisplayData displayData = DisplayData.from(approxQuanitiles);
 

http://git-wip-us.apache.org/repos/asf/beam/blob/6c6d7877/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MaxTest.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MaxTest.java 
b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MaxTest.java
index 2b43560..52043e1 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MaxTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MaxTest.java
@@ -69,7 +69,7 @@ public class MaxTest {
 
   @Test
   public void testDisplayData() {
-    Top.Largest<Integer> comparer = new Top.Largest<>();
+    Top.Natural<Integer> comparer = new Top.Natural<>();
 
     Combine.Globally<Integer, Integer> max = Max.globally(comparer);
     assertThat(DisplayData.from(max), hasDisplayItem("comparer", 
comparer.getClass()));

http://git-wip-us.apache.org/repos/asf/beam/blob/6c6d7877/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MinTest.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MinTest.java 
b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MinTest.java
index e89b223..1ece09b 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MinTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MinTest.java
@@ -69,7 +69,7 @@ public class MinTest {
 
   @Test
   public void testDisplayData() {
-    Top.Smallest<Integer> comparer = new Top.Smallest<>();
+    Top.Reversed<Integer> comparer = new Top.Reversed<>();
 
     Combine.Globally<Integer, Integer> min = Min.globally(comparer);
     assertThat(DisplayData.from(min), hasDisplayItem("comparer", 
comparer.getClass()));

http://git-wip-us.apache.org/repos/asf/beam/blob/6c6d7877/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/TopTest.java
----------------------------------------------------------------------
diff --git 
a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/TopTest.java 
b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/TopTest.java
index 9b0b27d..a7f439c 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/TopTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/TopTest.java
@@ -231,17 +231,17 @@ public class TopTest {
   @Test
   public void testTopGetNames() {
     assertEquals("Combine.globally(Top(OrderByLength))", Top.of(1, new 
OrderByLength()).getName());
-    assertEquals("Combine.globally(Top(Smallest))", Top.smallest(1).getName());
-    assertEquals("Combine.globally(Top(Largest))", Top.largest(2).getName());
+    assertEquals("Combine.globally(Top(Reversed))", Top.smallest(1).getName());
+    assertEquals("Combine.globally(Top(Natural))", Top.largest(2).getName());
     assertEquals("Combine.perKey(Top(IntegerComparator))",
         Top.perKey(1, new IntegerComparator()).getName());
-    assertEquals("Combine.perKey(Top(Smallest))", Top.<String, 
Integer>smallestPerKey(1).getName());
-    assertEquals("Combine.perKey(Top(Largest))", Top.<String, 
Integer>largestPerKey(2).getName());
+    assertEquals("Combine.perKey(Top(Reversed))", Top.<String, 
Integer>smallestPerKey(1).getName());
+    assertEquals("Combine.perKey(Top(Natural))", Top.<String, 
Integer>largestPerKey(2).getName());
   }
 
   @Test
   public void testDisplayData() {
-    Top.Largest<Integer> comparer = new Top.Largest<Integer>();
+    Top.Natural<Integer> comparer = new Top.Natural<Integer>();
     Combine.Globally<Integer, List<Integer>> top = Top.of(1234, comparer);
     DisplayData displayData = DisplayData.from(top);
 

Reply via email to