cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [06/15] git commit: RIE.DeletionInfo -> DeletionTime
Date Wed, 24 Apr 2013 01:15:18 GMT
RIE.DeletionInfo -> DeletionTime


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

Branch: refs/heads/cassandra-1.2
Commit: 573ddbfb057ac1858e910f569d7204df1d87519e
Parents: e30c730
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Mon Apr 22 08:47:08 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Tue Apr 23 10:21:42 2013 -0500

----------------------------------------------------------------------
 .../cassandra/db/AbstractColumnContainer.java      |    5 ++
 src/java/org/apache/cassandra/db/DeletionInfo.java |   13 ++----
 src/java/org/apache/cassandra/db/DeletionTime.java |    4 +-
 .../org/apache/cassandra/db/RowIndexEntry.java     |   30 +++++++-------
 .../db/columniterator/IndexedSliceReader.java      |    2 +-
 .../db/columniterator/SSTableNamesIterator.java    |    2 +-
 .../apache/cassandra/io/sstable/SSTableWriter.java |    2 +-
 .../org/apache/cassandra/cache/ObjectSizeTest.java |    3 +-
 8 files changed, 33 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/573ddbfb/src/java/org/apache/cassandra/db/AbstractColumnContainer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/AbstractColumnContainer.java b/src/java/org/apache/cassandra/db/AbstractColumnContainer.java
index 09d0a38..3bb8590 100644
--- a/src/java/org/apache/cassandra/db/AbstractColumnContainer.java
+++ b/src/java/org/apache/cassandra/db/AbstractColumnContainer.java
@@ -51,6 +51,11 @@ public abstract class AbstractColumnContainer implements IColumnContainer,
IIter
         columns.delete(delInfo);
     }
 
+    public void delete(DeletionTime deletionTime)
+    {
+        delete(new DeletionInfo(deletionTime));
+    }
+
     // Contrarily to delete(), this will use the provided info even if those
     // are older that the current ones. Used for SuperColumn in QueryFilter.
     // delete() is probably the right method in all other cases.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/573ddbfb/src/java/org/apache/cassandra/db/DeletionInfo.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DeletionInfo.java b/src/java/org/apache/cassandra/db/DeletionInfo.java
index 405645f..9cd4545 100644
--- a/src/java/org/apache/cassandra/db/DeletionInfo.java
+++ b/src/java/org/apache/cassandra/db/DeletionInfo.java
@@ -67,6 +67,11 @@ public class DeletionInfo
         assert comparator != null;
     }
 
+    public DeletionInfo(DeletionTime topLevel)
+    {
+        this(topLevel, IntervalTree.<ByteBuffer, DeletionTime, RangeTombstone>emptyTree());
+    }
+
     private DeletionInfo(DeletionTime topLevel, IntervalTree<ByteBuffer, DeletionTime,
RangeTombstone> ranges)
     {
         this.topLevel = topLevel;
@@ -258,14 +263,6 @@ public class DeletionInfo
         return topLevel.equals(that.topLevel) && ranges.equals(that.ranges);
     }
 
-    public long memorySize()
-    {
-        long fields = topLevel.memorySize() + (2 * ObjectSizes.getReferenceSize());
-        if (ranges != null && !ranges.isEmpty())
-            fields += ObjectSizes.measureDeep(ranges);
-        return ObjectSizes.getFieldSize(fields);
-    }
-
     @Override
     public final int hashCode()
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/573ddbfb/src/java/org/apache/cassandra/db/DeletionTime.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DeletionTime.java b/src/java/org/apache/cassandra/db/DeletionTime.java
index 5f39071..bcb1b01 100644
--- a/src/java/org/apache/cassandra/db/DeletionTime.java
+++ b/src/java/org/apache/cassandra/db/DeletionTime.java
@@ -21,6 +21,7 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Objects;
 
 import org.apache.cassandra.io.ISerializer;
@@ -35,7 +36,8 @@ public class DeletionTime implements Comparable<DeletionTime>
 
     public static final ISerializer<DeletionTime> serializer = new Serializer();
 
-    DeletionTime(long markedForDeleteAt, int localDeletionTime)
+    @VisibleForTesting
+    public DeletionTime(long markedForDeleteAt, int localDeletionTime)
     {
         this.markedForDeleteAt = markedForDeleteAt;
         this.localDeletionTime = localDeletionTime;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/573ddbfb/src/java/org/apache/cassandra/db/RowIndexEntry.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RowIndexEntry.java b/src/java/org/apache/cassandra/db/RowIndexEntry.java
index 2444bcb..fefa45d 100644
--- a/src/java/org/apache/cassandra/db/RowIndexEntry.java
+++ b/src/java/org/apache/cassandra/db/RowIndexEntry.java
@@ -53,16 +53,16 @@ public class RowIndexEntry implements IMeasurableMemory
         return 0;
     }
 
-    public static RowIndexEntry create(long position, DeletionInfo deletionInfo, ColumnIndex
index)
+    public static RowIndexEntry create(long position, DeletionTime deletionTime, ColumnIndex
index)
     {
         assert index != null;
-        assert deletionInfo != null;
+        assert deletionTime != null;
 
         // we only consider the columns summary when determining whether to create an IndexedEntry,
         // since if there are insufficient columns to be worth indexing we're going to seek
to
         // the beginning of the row anyway, so we might as well read the tombstone there
as well.
         if (index.columnsIndex.size() > 1)
-            return new IndexedEntry(position, deletionInfo, index.columnsIndex, index.bloomFilter);
+            return new IndexedEntry(position, deletionTime, index.columnsIndex, index.bloomFilter);
         else
             return new RowIndexEntry(position);
     }
@@ -76,7 +76,7 @@ public class RowIndexEntry implements IMeasurableMemory
         return !columnsIndex().isEmpty();
     }
 
-    public DeletionInfo deletionInfo()
+    public DeletionTime deletionTime()
     {
         throw new UnsupportedOperationException();
     }
@@ -105,7 +105,7 @@ public class RowIndexEntry implements IMeasurableMemory
             if (rie.isIndexed())
             {
                 dos.writeInt(rie.promotedSize());
-                DeletionInfo.serializer().serializeForSSTable(rie.deletionInfo(), dos);
+                DeletionTime.serializer.serialize(rie.deletionTime(), dos);
                 dos.writeInt(rie.columnsIndex().size());
                 for (IndexHelper.IndexInfo info : rie.columnsIndex())
                     info.serialize(dos);
@@ -125,13 +125,13 @@ public class RowIndexEntry implements IMeasurableMemory
                 int size = dis.readInt();
                 if (size > 0)
                 {
-                    DeletionInfo delInfo = DeletionInfo.serializer().deserializeFromSSTable(dis,
version);
+                    DeletionTime deletionTime = DeletionTime.serializer.deserialize(dis);
                     int entries = dis.readInt();
                     List<IndexHelper.IndexInfo> columnsIndex = new ArrayList<IndexHelper.IndexInfo>(entries);
                     for (int i = 0; i < entries; i++)
                         columnsIndex.add(IndexHelper.IndexInfo.deserialize(dis));
                     IFilter bf = FilterFactory.deserialize(dis, version.filterType, false);
-                    return new IndexedEntry(position, delInfo, columnsIndex, bf);
+                    return new IndexedEntry(position, deletionTime, columnsIndex, bf);
                 }
                 else
                 {
@@ -166,24 +166,24 @@ public class RowIndexEntry implements IMeasurableMemory
      */
     private static class IndexedEntry extends RowIndexEntry
     {
-        private final DeletionInfo deletionInfo;
+        private final DeletionTime deletionTime;
         private final List<IndexHelper.IndexInfo> columnsIndex;
         private final IFilter bloomFilter;
 
-        private IndexedEntry(long position, DeletionInfo deletionInfo, List<IndexHelper.IndexInfo>
columnsIndex, IFilter bloomFilter)
+        private IndexedEntry(long position, DeletionTime deletionTime, List<IndexHelper.IndexInfo>
columnsIndex, IFilter bloomFilter)
         {
             super(position);
-            assert deletionInfo != null;
+            assert deletionTime != null;
             assert columnsIndex != null && columnsIndex.size() > 1;
-            this.deletionInfo = deletionInfo;
+            this.deletionTime = deletionTime;
             this.columnsIndex = columnsIndex;
             this.bloomFilter = bloomFilter;
         }
 
         @Override
-        public DeletionInfo deletionInfo()
+        public DeletionTime deletionTime()
         {
-            return deletionInfo;
+            return deletionTime;
         }
 
         @Override
@@ -202,7 +202,7 @@ public class RowIndexEntry implements IMeasurableMemory
         public int promotedSize()
         {
             TypeSizes typeSizes = TypeSizes.NATIVE;
-            long size = DeletionTime.serializer.serializedSize(deletionInfo.getTopLevelDeletion(),
typeSizes);
+            long size = DeletionTime.serializer.serializedSize(deletionTime, typeSizes);
             size += typeSizes.sizeof(columnsIndex.size()); // number of entries
             for (IndexHelper.IndexInfo info : columnsIndex)
                 size += info.serializedSize(typeSizes);
@@ -218,7 +218,7 @@ public class RowIndexEntry implements IMeasurableMemory
             for (IndexHelper.IndexInfo idx : columnsIndex)
                 internal += idx.memorySize();
             long listSize = ObjectSizes.getFieldSize(ObjectSizes.getArraySize(columnsIndex.size(),
internal) + 4);
-            return ObjectSizes.getFieldSize(deletionInfo.memorySize() + listSize);
+            return ObjectSizes.getFieldSize(deletionTime.memorySize() + listSize);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/573ddbfb/src/java/org/apache/cassandra/db/columniterator/IndexedSliceReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/columniterator/IndexedSliceReader.java b/src/java/org/apache/cassandra/db/columniterator/IndexedSliceReader.java
index 7289ab0..1c3ff3e 100644
--- a/src/java/org/apache/cassandra/db/columniterator/IndexedSliceReader.java
+++ b/src/java/org/apache/cassandra/db/columniterator/IndexedSliceReader.java
@@ -89,7 +89,7 @@ class IndexedSliceReader extends AbstractIterator<OnDiskAtom> implements
OnDiskA
                 else
                 {
                     this.emptyColumnFamily = ColumnFamily.create(sstable.metadata);
-                    emptyColumnFamily.delete(indexEntry.deletionInfo());
+                    emptyColumnFamily.delete(indexEntry.deletionTime());
                     fetcher = new IndexedBlockFetcher(indexEntry.position);
                 }
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/573ddbfb/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 da4631d..5495458 100644
--- a/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
+++ b/src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
@@ -155,7 +155,7 @@ public class SSTableNamesIterator extends SimpleAbstractColumnIterator
implement
         else
         {
             cf = ColumnFamily.create(sstable.metadata);
-            cf.delete(indexEntry.deletionInfo());
+            cf.delete(indexEntry.deletionTime());
         }
 
         List<OnDiskAtom> result = new ArrayList<OnDiskAtom>();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/573ddbfb/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
index c64fd27..2422f70 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
@@ -143,7 +143,7 @@ public class SSTableWriter extends SSTable
 
         if (logger.isTraceEnabled())
             logger.trace("wrote " + decoratedKey + " at " + dataPosition);
-        RowIndexEntry entry = RowIndexEntry.create(dataPosition, delInfo, index);
+        RowIndexEntry entry = RowIndexEntry.create(dataPosition, delInfo.getTopLevelDeletion(),
index);
         iwriter.append(decoratedKey, entry);
         dbuilder.addPotentialBoundary(dataPosition);
         return entry;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/573ddbfb/test/unit/org/apache/cassandra/cache/ObjectSizeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cache/ObjectSizeTest.java b/test/unit/org/apache/cassandra/cache/ObjectSizeTest.java
index 398b395..d925295 100644
--- a/test/unit/org/apache/cassandra/cache/ObjectSizeTest.java
+++ b/test/unit/org/apache/cassandra/cache/ObjectSizeTest.java
@@ -6,6 +6,7 @@ import java.util.UUID;
 import junit.framework.Assert;
 
 import org.apache.cassandra.db.DeletionInfo;
+import org.apache.cassandra.db.DeletionTime;
 import org.apache.cassandra.db.RowIndexEntry;
 import org.apache.cassandra.utils.ObjectSizes;
 import org.github.jamm.MemoryMeter;
@@ -56,7 +57,7 @@ public class ObjectSizeTest
     @Test
     public void testKeyCacheValueWithDelInfo()
     {
-        RowIndexEntry entry = RowIndexEntry.create(123, new DeletionInfo(123, 123), null);
+        RowIndexEntry entry = RowIndexEntry.create(123, new DeletionTime(123, 123), null);
         long size = entry.memorySize();
         long size2 = meter.measureDeep(entry);
         Assert.assertEquals(size, size2);


Mime
View raw message