accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r1427856 - /accumulo/trunk/test/system/auto/simple/dynamic.py
Date Wed, 02 Jan 2013 16:43:24 GMT
Author: vines
Date: Wed Jan  2 16:43:23 2013
New Revision: 1427856

URL: http://svn.apache.org/viewvc?rev=1427856&view=rev
Log:
ACCUMULO-609 - tested and applying patch by Chris McCubbin


Modified:
    accumulo/trunk/test/system/auto/simple/dynamic.py

Modified: accumulo/trunk/test/system/auto/simple/dynamic.py
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/system/auto/simple/dynamic.py?rev=1427856&r1=1427855&r2=1427856&view=diff
==============================================================================
--- accumulo/trunk/test/system/auto/simple/dynamic.py (original)
+++ accumulo/trunk/test/system/auto/simple/dynamic.py Wed Jan  2 16:43:23 2013
@@ -41,28 +41,31 @@ class DynamicClassloader(AggregationTest
         #Make sure paths exists for test
         if not os.path.exists(os.path.join(ACCUMULO_HOME, 'target','dynamictest%s' % rand,
'accumulo','test')):
           os.makedirs(os.path.join(ACCUMULO_HOME, 'target', 'dynamictest%s' % rand, 'accumulo',
'test'))
-        fp = open(os.path.join(ACCUMULO_HOME, 'target', 'dynamictest%s' % rand, 'accumulo',
'test', 'StringSummation%s.java' % rand), 'wb')
+        fp = open(os.path.join(ACCUMULO_HOME, 'target', 'dynamictest%s' % rand, 'accumulo',
'test', 'SummingCombiner%s.java' % rand), 'wb')
         fp.write('''
 package accumulo.test;
 
-import org.apache.accumulo.core.data.Value;
-
-public class StringSummation%s implements org.apache.accumulo.core.iterators.aggregation.Aggregator
{
-
-	long sum = 0;
-	
-	public Value aggregate() {
-		return new Value(Long.toString(sum).getBytes());
-	}
-
-	public void collect(Value value) {
-		sum += Long.parseLong(new String(value.get()));
-	}
-
-	public void reset() {
-		sum = 0;
-		
-	}
+import java.util.Iterator;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.iterators.LongCombiner;
+
+public class SummingCombiner%s extends LongCombiner {
+  @Override
+  public Long typedReduce(Key key, Iterator<Long> iter) {
+    long sum = 0;
+    while (iter.hasNext()) {
+      sum = safeAdd(sum, iter.next());
+    }
+    return sum;
+  }
+  
+  @Override
+  public IteratorOptions describeOptions() {
+    IteratorOptions io = super.describeOptions();
+    io.setName("sum");
+    io.setDescription("SummingCombiner interprets Values as Longs and adds them together.
 A variety of encodings (variable length, fixed length, or string) are available");
+    return io;
+  }
 }
 ''' % rand)
         fp.close()
@@ -74,7 +77,7 @@ public class StringSummation%s implement
         self.runWait("javac -cp %s:%s %s" % (
             path,
             os.path.join(ACCUMULO_HOME,'src','core','target','classes'),
-            os.path.join(ACCUMULO_HOME,'target','dynamictest%s' % rand,'accumulo','test','StringSummation%s.java'
% rand)
+            os.path.join(ACCUMULO_HOME,'target','dynamictest%s' % rand,'accumulo','test','SummingCombiner%s.java'
% rand)
             ))
         self.runWait("jar -cf %s -C %s accumulo/" % (
             os.path.join(ACCUMULO_HOME,'lib','ext','Aggregator%s.jar' % rand),
@@ -84,8 +87,8 @@ public class StringSummation%s implement
         self.sleep(1)
 
         # initialize the database
-        aggregator = 'accumulo.test.StringSummation%s' % rand
-        cmd = 'createtable test\nsetiter -agg -minc -majc -scan -p 10 -t test\ncf ' + aggregator
+ '\n\n'
+        combiner = 'accumulo.test.SummingCombiner%s' % rand
+        cmd = 'createtable --no-default-iterators test\nsetiter -t test -p 10 -scan -minc
-majc -n testcombineriter -class '+ combiner+'\n\ncf\n\nSTRING'
         out, err, code = self.rootShell(self.masterHost(),"%s\n" % cmd)
         self.assert_(code == 0)
 



Mime
View raw message