accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1422040 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/iterators/Combiner.java test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java
Date Fri, 14 Dec 2012 18:59:36 GMT
Author: ecn
Date: Fri Dec 14 18:59:34 2012
New Revision: 1422040

URL: http://svn.apache.org/viewvc?rev=1422040&view=rev
Log:
ACCUMULO-907 fix combiners over iterators that mutate their top key

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java?rev=1422040&r1=1422039&r2=1422040&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java Fri
Dec 14 18:59:34 2012
@@ -63,7 +63,7 @@ public abstract class Combiner extends W
      */
     public ValueIterator(SortedKeyValueIterator<Key,Value> source) {
       this.source = source;
-      topKey = source.getTopKey();
+      topKey = new Key(source.getTopKey());
       hasNext = _hasNext();
     }
     

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java?rev=1422040&r1=1422039&r2=1422040&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java
(original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/CombinerTest.java
Fri Dec 14 18:59:34 2012
@@ -569,6 +569,42 @@ public class CombinerTest {
   }
   
   @Test
+  public void sumAllColumns() throws IOException {
+    TreeMap<Key,Value> tm = new TreeMap<Key,Value>();
+    tm.put(new Key("r", "count", "a", 1), new Value("1".getBytes()));
+    tm.put(new Key("r", "count", "a", 2), new Value("1".getBytes()));
+    tm.put(new Key("r", "count", "b", 3), new Value("1".getBytes()));
+    tm.put(new Key("r", "count", "b", 4), new Value("1".getBytes()));
+    tm.put(new Key("r", "count", "b", 5), new Value("1".getBytes()));
+    tm.put(new Key("r", "count", "c", 6), new Value("1".getBytes()));
+    SortedMapIterator smi = new SortedMapIterator(tm);
+    Combiner iter = new SummingCombiner();
+    IteratorSetting s = new IteratorSetting(10, "s", SummingCombiner.class);
+    SummingCombiner.setColumns(s, Collections.singletonList(new IteratorSetting.Column("count")));
+    SummingCombiner.setEncodingType(s, LongCombiner.StringEncoder.class);
+    iter.init(smi, s.getOptions(), new DefaultIteratorEnvironment());
+    Combiner iter2 = new SummingCombiner();
+    IteratorSetting s2 = new IteratorSetting(10, "s2", SummingCombiner.class);
+    SummingCombiner.setColumns(s2, Collections.singletonList(new IteratorSetting.Column("count","a")));
+    SummingCombiner.setEncodingType(s2, LongCombiner.StringEncoder.class);
+    iter2.init(iter, s.getOptions(), new DefaultIteratorEnvironment());
+    iter2.seek(new Range(), EMPTY_COL_FAMS, false);
+    
+    assertTrue(iter2.hasTop());
+    assertEquals("2", iter2.getTopValue().toString());
+    iter2.next();
+    assertTrue(iter2.hasTop());
+    assertEquals("3", iter2.getTopValue().toString());
+    iter2.next();
+    assertTrue(iter2.hasTop());
+    assertEquals("1", iter2.getTopValue().toString());
+    iter2.next();
+    assertFalse(iter2.hasTop());
+  }
+  
+
+  
+  @Test
   public void maxMinTest() throws IOException {
     Encoder<Long> encoder = LongCombiner.VAR_LEN_ENCODER;
     



Mime
View raw message