cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [5/6] git commit: inline SimpleAbstractColumnIterator
Date Wed, 15 May 2013 23:04:05 GMT
inline SimpleAbstractColumnIterator


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

Branch: refs/heads/trunk
Commit: b397187850f6e6a131d5d418473cc68ebe5ed5ea
Parents: a3d6433
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed May 15 17:42:35 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed May 15 17:43:15 2013 -0500

----------------------------------------------------------------------
 .../apache/cassandra/db/CollationController.java   |    2 -
 src/java/org/apache/cassandra/db/Memtable.java     |   66 +++++++++------
 .../db/columniterator/SSTableNamesIterator.java    |    6 +-
 3 files changed, 45 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3971878/src/java/org/apache/cassandra/db/CollationController.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/CollationController.java b/src/java/org/apache/cassandra/db/CollationController.java
index 1bb09ce..f1f560e 100644
--- a/src/java/org/apache/cassandra/db/CollationController.java
+++ b/src/java/org/apache/cassandra/db/CollationController.java
@@ -25,7 +25,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.db.columniterator.OnDiskAtomIterator;
-import org.apache.cassandra.db.columniterator.SimpleAbstractColumnIterator;
 import org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy;
 import org.apache.cassandra.db.filter.NamesQueryFilter;
 import org.apache.cassandra.db.filter.QueryFilter;
@@ -34,7 +33,6 @@ import org.apache.cassandra.io.sstable.SSTable;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.tracing.Tracing;
-import org.apache.cassandra.utils.CloseableIterator;
 import org.apache.cassandra.utils.HeapAllocator;
 
 public class CollationController

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3971878/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index df5f6d7..0874829 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicLong;
 
 import com.google.common.base.Function;
 import com.google.common.base.Throwables;
+import com.google.common.collect.AbstractIterator;
 
 import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor;
 import org.apache.cassandra.concurrent.StageManager;
@@ -379,32 +380,7 @@ public class Memtable
     {
         assert cf != null;
 
-        return new SimpleAbstractColumnIterator()
-        {
-            private Iterator<ByteBuffer> iter = filter.columns.iterator();
-
-            public ColumnFamily getColumnFamily()
-            {
-                return cf;
-            }
-
-            public DecoratedKey getKey()
-            {
-                return key;
-            }
-
-            protected OnDiskAtom computeNext()
-            {
-                while (iter.hasNext())
-                {
-                    ByteBuffer current = iter.next();
-                    Column column = cf.getColumn(current);
-                    if (column != null)
-                        return column;
-                }
-                return endOfData();
-            }
-        };
+        return new ByNameColumnIterator(filter.columns.iterator(), cf, key);
     }
 
     public ColumnFamily getColumnFamily(DecoratedKey key)
@@ -417,6 +393,44 @@ public class Memtable
         return creationTime;
     }
 
+    private static class ByNameColumnIterator extends AbstractIterator<OnDiskAtom>
implements OnDiskAtomIterator
+    {
+        private final ColumnFamily cf;
+        private final DecoratedKey key;
+        private final Iterator<ByteBuffer> iter;
+
+        public ByNameColumnIterator(Iterator<ByteBuffer> iter, ColumnFamily cf, DecoratedKey
key)
+        {
+            this.iter = iter;
+            this.cf = cf;
+            this.key = key;
+        }
+
+        public ColumnFamily getColumnFamily()
+        {
+            return cf;
+        }
+
+        public DecoratedKey getKey()
+        {
+            return key;
+        }
+
+        protected OnDiskAtom computeNext()
+        {
+            while (iter.hasNext())
+            {
+                ByteBuffer current = iter.next();
+                Column column = cf.getColumn(current);
+                if (column != null)
+                    return column;
+            }
+            return endOfData();
+        }
+
+        public void close() throws IOException { }
+    }
+
     class FlushRunnable extends DiskAwareRunnable
     {
         private final CountDownLatch latch;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3971878/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java b/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
index 36f240d..20ca0cb 100644
--- a/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
+++ b/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
@@ -24,6 +24,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.SortedSet;
 
+import com.google.common.collect.AbstractIterator;
+
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.AbstractType;
@@ -35,7 +37,7 @@ import org.apache.cassandra.io.util.FileMark;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
-public class SSTableNamesIterator extends SimpleAbstractColumnIterator implements OnDiskAtomIterator
+public class SSTableNamesIterator extends AbstractIterator<OnDiskAtom> implements OnDiskAtomIterator
 {
     private ColumnFamily cf;
     private final SSTableReader sstable;
@@ -240,4 +242,6 @@ public class SSTableNamesIterator extends SimpleAbstractColumnIterator
implement
             return endOfData();
         return iter.next();
     }
+
+    public void close() throws IOException { }
 }


Mime
View raw message