incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1208599 - in /incubator/accumulo/branches/1.4/src/core/src: main/java/org/apache/accumulo/core/iterators/aggregation/ test/java/org/apache/accumulo/core/iterators/user/
Date Wed, 30 Nov 2011 18:06:04 GMT
Author: billie
Date: Wed Nov 30 18:06:00 2011
New Revision: 1208599

URL: http://svn.apache.org/viewvc?rev=1208599&view=rev
Log:
ACCUMULO-155 added tests for compatibility between long encodings for combiners and aggregators

Modified:
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java
    incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java?rev=1208599&r1=1208598&r2=1208599&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java
Wed Nov 30 18:06:00 2011
@@ -23,7 +23,7 @@ import org.apache.log4j.Logger;
 
 /**
  * @deprecated since 1.4
- * @use org.apache.accumulo.core.iterators.user.SummingCombiner with SummingCombiner.Type.LONG
+ * @use org.apache.accumulo.core.iterators.user.SummingCombiner with SummingCombiner.Type.FIXEDLEN
  */
 public class LongSummation implements Aggregator {
   private static final Logger log = Logger.getLogger(LongSummation.class);

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java?rev=1208599&r1=1208598&r2=1208599&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java
Wed Nov 30 18:06:00 2011
@@ -27,7 +27,7 @@ import org.apache.hadoop.io.WritableUtil
 
 /**
  * @deprecated since 1.4
- * @use org.apache.accumulo.core.iterators.user.SummingArrayCombiner with SummingArrayCombiner.Type.VARNUM
+ * @use org.apache.accumulo.core.iterators.user.SummingArrayCombiner with SummingArrayCombiner.Type.VARLONG
  */
 public class NumArraySummation implements Aggregator {
   long[] sum = new long[0];

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java?rev=1208599&r1=1208598&r2=1208599&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java
Wed Nov 30 18:06:00 2011
@@ -27,7 +27,7 @@ import org.apache.hadoop.io.WritableUtil
 
 /**
  * @deprecated since 1.4
- * @use org.apache.accumulo.core.iterators.user.SummingCombiner with SummingCombiner.Type.VARNUM
+ * @use org.apache.accumulo.core.iterators.user.SummingCombiner with SummingCombiner.Type.VARLEN
  */
 public class NumSummation implements Aggregator {
   long sum = 0l;

Modified: incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java?rev=1208599&r1=1208598&r2=1208599&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java
Wed Nov 30 18:06:00 2011
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTru
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -42,10 +43,14 @@ import org.apache.accumulo.core.iterator
 import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 import org.apache.accumulo.core.iterators.SortedMapIterator;
 import org.apache.accumulo.core.iterators.TypedValueCombiner.Encoder;
+import org.apache.accumulo.core.iterators.aggregation.LongSummation;
+import org.apache.accumulo.core.iterators.aggregation.NumArraySummation;
+import org.apache.accumulo.core.iterators.aggregation.NumSummation;
 import org.apache.accumulo.core.iterators.system.MultiIterator;
 import org.apache.hadoop.io.Text;
 import org.junit.Test;
 
+@SuppressWarnings("deprecation")
 public class CombinerTest {
   
   private static final Collection<ByteSequence> EMPTY_COL_FAMS = new ArrayList<ByteSequence>();
@@ -590,4 +595,34 @@ public class CombinerTest {
     sumArray(SummingArrayCombiner.FixedLongArrayEncoder.class, SummingArrayCombiner.Type.FIXEDLEN);
     sumArray(SummingArrayCombiner.StringArrayEncoder.class, SummingArrayCombiner.Type.STRING);
   }
+  
+  /**
+   * @throws IOException
+   * @deprecated since 1.4
+   */
+  public void testCombinerCompatibility() throws IOException {
+    long[] la = {1l, 2l, 3l};
+    List<Long> ll = new ArrayList<Long>(Arrays.asList((Long) 1l, (Long) 2l, (Long)
3l));
+    assertEquals(ll, SummingArrayCombiner.VAR_LONG_ARRAY_ENCODER.decode(NumArraySummation.longArrayToBytes(la)));
+    assertEquals(la, NumArraySummation.bytesToLongArray(SummingArrayCombiner.VAR_LONG_ARRAY_ENCODER.encode(ll)));
+    testLongEncoding(42l);
+    testLongEncoding(Long.MAX_VALUE);
+    testLongEncoding(Long.MIN_VALUE);
+    testLongEncoding(0l);
+  }
+  
+  /**
+   * @throws IOException
+   * @deprecated since 1.4
+   */
+  public void testLongEncoding(long l) throws IOException {
+    assertEquals((Long) l, SummingCombiner.FIXED_LEN_ENCODER.decode(LongSummation.longToBytes(l)));
+    assertEquals(l, LongSummation.bytesToLong(SummingCombiner.FIXED_LEN_ENCODER.encode(l)));
+    
+    assertEquals((Long) l, SummingCombiner.VAR_LEN_ENCODER.decode(NumSummation.longToBytes(l)));
+    assertEquals(l, NumSummation.bytesToLong(SummingCombiner.VAR_LEN_ENCODER.encode(l)));
+    
+    assertEquals((Long) l, SummingCombiner.STRING_ENCODER.decode(Long.toString(l).getBytes()));
+    assertEquals(l, Long.parseLong(new String(SummingCombiner.STRING_ENCODER.encode(l))));
+  }
 }



Mime
View raw message