cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r816381 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: db/ColumnFamilyStore.java db/filter/QueryFilter.java utils/ReducingIterator.java
Date Thu, 17 Sep 2009 21:10:03 GMT
Author: jbellis
Date: Thu Sep 17 21:10:03 2009
New Revision: 816381

URL: http://svn.apache.org/viewvc?rev=816381&view=rev
Log:
allow ReducingIterator to reduce from one type to a different one
patch by jbellis; reviewed by goffinet for CASSANDRA-436

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ReducingIterator.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=816381&r1=816380&r2=816381&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Thu
Sep 17 21:10:03 2009
@@ -1361,7 +1361,7 @@
         }
 
         Iterator<String> collated = IteratorUtils.collatedIterator(comparator, iterators);
-        Iterable<String> reduced = new ReducingIterator<String>(collated) {
+        Iterable<String> reduced = new ReducingIterator<String, String>(collated)
{
             String current;
 
             public void reduce(String current)

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java?rev=816381&r1=816380&r2=816381&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java Thu
Sep 17 21:10:03 2009
@@ -82,7 +82,7 @@
     {
         // define a 'reduced' iterator that merges columns w/ the same name, which
         // greatly simplifies computing liveColumns in the presence of tombstones.
-        ReducingIterator<IColumn> reduced = new ReducingIterator<IColumn>(collatedColumns)
+        ReducingIterator<IColumn, IColumn> reduced = new ReducingIterator<IColumn,
IColumn>(collatedColumns)
         {
             ColumnFamily curCF = returnCF.cloneMeShallow();
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ReducingIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ReducingIterator.java?rev=816381&r1=816380&r2=816381&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ReducingIterator.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ReducingIterator.java Thu
Sep 17 21:10:03 2009
@@ -28,29 +28,29 @@
 /**
  * reduces equal values from the source iterator to a single (optionally transformed) instance.
  */
-public abstract class ReducingIterator<T> extends AbstractIterator<T> implements
Iterator<T>, Iterable<T>
+public abstract class ReducingIterator<T1, T2> extends AbstractIterator<T2> implements
Iterator<T2>, Iterable<T2>
 {
-    protected Iterator<T> source;
-    protected T last;
+    protected Iterator<T1> source;
+    protected T1 last;
 
-    public ReducingIterator(Iterator<T> source)
+    public ReducingIterator(Iterator<T1> source)
     {
         this.source = source;
     }
 
     /** combine this object with the previous ones.  intermediate state is up to your implementation.
*/
-    public abstract void reduce(T current);
+    public abstract void reduce(T1 current);
 
     /** return the last object computed by reduce */
-    protected abstract T getReduced();
+    protected abstract T2 getReduced();
 
     /** override this if the keys you want to base the reduce on are not the same as the
object itself (but can be generated from it) */
-    protected boolean isEqual(T o1, T o2)
+    protected boolean isEqual(T1 o1, T1 o2)
     {
         return o1.equals(o2);
     }
 
-    protected T computeNext()
+    protected T2 computeNext()
     {
         if (last == null && !source.hasNext())
             return endOfData();
@@ -65,7 +65,7 @@
                 last = null;
                 break;
             }
-            T current = source.next();
+            T1 current = source.next();
             if (last != null && !isEqual(current, last))
                 keyChanged = true;
             last = current;
@@ -73,7 +73,7 @@
         return getReduced();
     }
 
-    public Iterator<T> iterator()
+    public Iterator<T2> iterator()
     {
         return this;
     }



Mime
View raw message