cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: Rewrite, and always call, ABSC#localCopy
Date Thu, 27 Mar 2014 15:01:31 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 07a451ea0 -> 6d796c795


Rewrite, and always call, ABSC#localCopy


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

Branch: refs/heads/cassandra-2.1
Commit: 6d796c7956e0b1bc49a11a54e761d123cc53f966
Parents: 07a451e
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Mar 27 18:01:08 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Mar 27 18:01:08 2014 +0300

----------------------------------------------------------------------
 .../cassandra/db/ArrayBackedSortedColumns.java  | 20 ++++++++------------
 src/java/org/apache/cassandra/db/Memtable.java  |  9 +++++----
 2 files changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d796c79/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java b/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
index 4a83901..dcdffc8 100644
--- a/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
+++ b/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
@@ -34,7 +34,7 @@ import org.apache.cassandra.db.composites.CellName;
 import org.apache.cassandra.db.composites.CellNameType;
 import org.apache.cassandra.db.composites.Composite;
 import org.apache.cassandra.db.filter.ColumnSlice;
-import org.apache.cassandra.utils.memory.HeapAllocator;
+import org.apache.cassandra.utils.memory.AbstractAllocator;
 
 /**
  * A ColumnFamily backed by an array.
@@ -86,18 +86,14 @@ public class ArrayBackedSortedColumns extends ColumnFamily
         this.isSorted = original.isSorted;
     }
 
-    public static ColumnFamily cloneToHeap(ColumnFamily value, ColumnFamilyStore cfs)
+    public static ArrayBackedSortedColumns localCopy(ColumnFamily original, AbstractAllocator
allocator)
     {
-        if (value.getColumnCount() == 0)
-            return value;
-        // we skip anything
-        final Cell[] cells = new Cell[value.getColumnCount()];
-        int i = 0;
-        for (Cell cell : value)
-            cells[i++] = cell.localCopy(HeapAllocator.instance);
-        ColumnFamily r = new ArrayBackedSortedColumns(cfs.metadata, value.isInsertReversed(),
cells, i, i);
-        r.delete(value);
-        return r;
+        ArrayBackedSortedColumns copy = new ArrayBackedSortedColumns(original.metadata, false,
new Cell[original.getColumnCount()], 0, 0);
+        for (Cell cell : original)
+            copy.internalAdd(cell.localCopy(allocator));
+        copy.sortedSize = copy.size; // internalAdd doesn't update sortedSize.
+        copy.delete(original);
+        return copy;
     }
 
     public ColumnFamily.Factory getFactory()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d796c79/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 91dcf2d..85ab3df 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -241,8 +241,9 @@ public class Memtable
         return new Iterator<Map.Entry<DecoratedKey, ColumnFamily>>()
         {
             private Iterator<? extends Map.Entry<? extends RowPosition, AtomicBTreeColumns>>
iter = stopAt.isMinimum(cfs.partitioner)
-                                                                                        ?
rows.tailMap(startWith).entrySet().iterator()
-                                                                                        :
rows.subMap(startWith, true, stopAt, true).entrySet().iterator();
+                    ? rows.tailMap(startWith).entrySet().iterator()
+                    : rows.subMap(startWith, true, stopAt, true).entrySet().iterator();
+
             private Map.Entry<? extends RowPosition, ? extends ColumnFamily> currentEntry;
 
             public boolean hasNext()
@@ -259,8 +260,8 @@ public class Memtable
                 {
                     DecoratedKey key = (DecoratedKey) entry.getKey();
                     key = new DecoratedKey(key.token, HeapAllocator.instance.clone(key.key));
-                    ColumnFamily columns = ArrayBackedSortedColumns.cloneToHeap(entry.getValue(),
cfs);
-                    entry = new AbstractMap.SimpleImmutableEntry<>(key, columns);
+                    ColumnFamily cells = ArrayBackedSortedColumns.localCopy(entry.getValue(),
HeapAllocator.instance);
+                    entry = new AbstractMap.SimpleImmutableEntry<>(key, cells);
                 }
                 // Store the reference to the current entry so that remove() can update the
current size.
                 currentEntry = entry;


Mime
View raw message