cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/2] git commit: make dataSize TypeSizes-independent, and remove 25% fudge factor in liveRatio usage patch by jbellis; reviewed by Vijay for CASSANDRA-4215
Date Tue, 15 May 2012 04:05:39 GMT
Updated Branches:
  refs/heads/trunk 19ce000b2 -> ad72c578e


make dataSize TypeSizes-independent, and remove 25% fudge factor in liveRatio usage
patch by jbellis; reviewed by Vijay for CASSANDRA-4215


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

Branch: refs/heads/trunk
Commit: ad72c578ea8daed05f987ae1933276fa4a8ea5bf
Parents: 6633eb4
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu May 3 10:58:15 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Mon May 14 23:05:05 2012 -0500

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/Column.java       |   22 +++++++-------
 src/java/org/apache/cassandra/db/ColumnFamily.java |    6 ++--
 .../org/apache/cassandra/db/CounterColumn.java     |   10 +++++-
 .../org/apache/cassandra/db/ExpiringColumn.java    |   20 ++++++++-----
 src/java/org/apache/cassandra/db/IColumn.java      |    3 +-
 src/java/org/apache/cassandra/db/Memtable.java     |    6 +---
 src/java/org/apache/cassandra/db/SuperColumn.java  |   22 +++++++-------
 7 files changed, 49 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad72c578/src/java/org/apache/cassandra/db/Column.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Column.java b/src/java/org/apache/cassandra/db/Column.java
index c0c6dfb..9416fbb 100644
--- a/src/java/org/apache/cassandra/db/Column.java
+++ b/src/java/org/apache/cassandra/db/Column.java
@@ -124,7 +124,16 @@ public class Column implements IColumn
         return timestamp;
     }
 
-    public int dataSize(TypeSizes typeSizes)
+    public int dataSize()
+    {
+        return name().remaining() + value.remaining() + TypeSizes.NATIVE.sizeof(timestamp);
+    }
+
+    /*
+     * This returns the size of the column when serialized.
+     * @see com.facebook.infrastructure.db.IColumn#serializedSize()
+    */
+    public int serializedSize(TypeSizes sizes)
     {
         /*
          * Size of a column is =
@@ -136,16 +145,7 @@ public class Column implements IColumn
         */
         int nameSize = name.remaining();
         int valueSize = value.remaining();
-        return typeSizes.sizeof((short) nameSize) + nameSize + 1 + typeSizes.sizeof(timestamp)
+ typeSizes.sizeof(valueSize) + valueSize;
-    }
-
-    /*
-     * This returns the size of the column when serialized.
-     * @see com.facebook.infrastructure.db.IColumn#serializedSize()
-    */
-    public int serializedSize(TypeSizes typeSizes)
-    {
-        return dataSize(typeSizes);
+        return sizes.sizeof((short) nameSize) + nameSize + 1 + sizes.sizeof(timestamp) +
sizes.sizeof(valueSize) + valueSize;
     }
 
     public int serializationFlags()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad72c578/src/java/org/apache/cassandra/db/ColumnFamily.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamily.java b/src/java/org/apache/cassandra/db/ColumnFamily.java
index d5c4c76..a9a8b0e 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamily.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamily.java
@@ -250,12 +250,12 @@ public class ColumnFamily extends AbstractColumnContainer implements
IRowCacheEn
     }
 
     /** the size of user-provided data, not including internal overhead */
-    int dataSize(TypeSizes typeSizes)
+    int dataSize()
     {
-        int size = TypeSizes.NATIVE.sizeof(1L) + TypeSizes.NATIVE.sizeof(1); // tombstone
tracking
+        int size = TypeSizes.NATIVE.sizeof(getMarkedForDeleteAt());
         for (IColumn column : columns)
         {
-            size += column.dataSize(typeSizes);
+            size += column.dataSize();
         }
         return size;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad72c578/src/java/org/apache/cassandra/db/CounterColumn.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/CounterColumn.java b/src/java/org/apache/cassandra/db/CounterColumn.java
index d081959..acc2af0 100644
--- a/src/java/org/apache/cassandra/db/CounterColumn.java
+++ b/src/java/org/apache/cassandra/db/CounterColumn.java
@@ -93,13 +93,19 @@ public class CounterColumn extends Column
     }
 
     @Override
-    public int dataSize(TypeSizes typeSizes)
+    public int dataSize()
     {
         /*
          * A counter column adds to a Column :
          *  + 8 bytes for timestampOfLastDelete
          */
-        return super.dataSize(typeSizes) + typeSizes.sizeof(timestampOfLastDelete);
+        return super.dataSize() + TypeSizes.NATIVE.sizeof(timestampOfLastDelete);
+    }
+
+    @Override
+    public int serializedSize(TypeSizes sizes)
+    {
+        return super.serializedSize(sizes) + sizes.sizeof(timestampOfLastDelete);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad72c578/src/java/org/apache/cassandra/db/ExpiringColumn.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ExpiringColumn.java b/src/java/org/apache/cassandra/db/ExpiringColumn.java
index f2f41b2..07a0064 100644
--- a/src/java/org/apache/cassandra/db/ExpiringColumn.java
+++ b/src/java/org/apache/cassandra/db/ExpiringColumn.java
@@ -74,14 +74,18 @@ public class ExpiringColumn extends Column
     }
 
     @Override
-    public int dataSize(TypeSizes typeSizes)
-    {
-        /*
-         * An expired column adds to a Column :
-         *    4 bytes for the localExpirationTime
-         *  + 4 bytes for the timeToLive
-        */
-        return super.dataSize(typeSizes) + typeSizes.sizeof(localExpirationTime) + typeSizes.sizeof(timeToLive);
+    public int dataSize()
+    {
+        return super.dataSize() + TypeSizes.NATIVE.sizeof(localExpirationTime) + TypeSizes.NATIVE.sizeof(timeToLive);
+    }
+
+    @Override
+    public int serializedSize(TypeSizes sizes)
+    {
+        // An expired column adds to a Column :
+        //    4 bytes for the localExpirationTime
+        //  + 4 bytes for the timeToLive
+        return super.serializedSize(sizes) + sizes.sizeof(localExpirationTime) + sizes.sizeof(timeToLive);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad72c578/src/java/org/apache/cassandra/db/IColumn.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/IColumn.java b/src/java/org/apache/cassandra/db/IColumn.java
index 9d7279c..d195e68 100644
--- a/src/java/org/apache/cassandra/db/IColumn.java
+++ b/src/java/org/apache/cassandra/db/IColumn.java
@@ -42,7 +42,8 @@ public interface IColumn
     public long mostRecentLiveChangeAt();
     public long mostRecentNonGCableChangeAt(int gcbefore);
     public ByteBuffer name();
-    public int dataSize(TypeSizes typeSizes);
+    /** the size of user-provided data, not including internal overhead */
+    public int dataSize();
     public int serializedSize(TypeSizes typeSizes);
     public int serializationFlags();
     public long timestamp();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad72c578/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 0d38160..884698b 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -119,9 +119,7 @@ public class Memtable
 
     public long getLiveSize()
     {
-        // 25% fudge factor on the base throughput * liveRatio calculation.  (Based on observed
-        // pre-slabbing behavior -- not sure what accounts for this. May have changed with
introduction of slabbing.)
-        return (long) (currentThroughput.get() * cfs.liveRatio * 1.25);
+        return (long) (currentThroughput.get() * cfs.liveRatio);
     }
 
     public long getSerializedSize()
@@ -225,7 +223,7 @@ public class Memtable
 
     private void resolve(DecoratedKey key, ColumnFamily cf)
     {
-        currentThroughput.addAndGet(cf.dataSize(TypeSizes.NATIVE));
+        currentThroughput.addAndGet(cf.dataSize());
         currentOperations.addAndGet((cf.getColumnCount() == 0)
                                     ? cf.isMarkedForDelete() ? 1 : 0
                                     : cf.getColumnCount());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad72c578/src/java/org/apache/cassandra/db/SuperColumn.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SuperColumn.java b/src/java/org/apache/cassandra/db/SuperColumn.java
index 9098446..06b2ed0 100644
--- a/src/java/org/apache/cassandra/db/SuperColumn.java
+++ b/src/java/org/apache/cassandra/db/SuperColumn.java
@@ -102,13 +102,11 @@ public class SuperColumn extends AbstractColumnContainer implements
IColumn
     /**
      * This calculates the exact size of the sub columns on the fly
      */
-    public int dataSize(TypeSizes typeSizes)
+    public int dataSize()
     {
-        int size = 0;
+        int size = TypeSizes.NATIVE.sizeof(getMarkedForDeleteAt());
         for (IColumn subColumn : getSubColumns())
-        {
-            size += subColumn.serializedSize(typeSizes);
-        }
+            size += subColumn.dataSize();
         return size;
     }
 
@@ -116,7 +114,7 @@ public class SuperColumn extends AbstractColumnContainer implements IColumn
      * This returns the size of the super-column when serialized.
      * @see org.apache.cassandra.db.IColumn#serializedSize()
     */
-    public int serializedSize(TypeSizes typeSizes)
+    public int serializedSize(TypeSizes sizes)
     {
         /*
          * We need to keep the way we are calculating the column size in sync with the
@@ -130,11 +128,13 @@ public class SuperColumn extends AbstractColumnContainer implements
IColumn
          * size(constantSize) of subcolumns.
          */
         int nameSize = name.remaining();
-        int subColumnsSize = dataSize(typeSizes);
-        return typeSizes.sizeof((short) nameSize) + nameSize
-                + typeSizes.sizeof(getLocalDeletionTime())
-                + typeSizes.sizeof(getMarkedForDeleteAt())
-                + typeSizes.sizeof(subColumnsSize) + subColumnsSize;
+        int subColumnsSize = 0;
+        for (IColumn subColumn : getSubColumns())
+            subColumnsSize += subColumn.serializedSize(sizes);
+        return sizes.sizeof((short) nameSize) + nameSize
+                + sizes.sizeof(getLocalDeletionTime())
+                + sizes.sizeof(getMarkedForDeleteAt())
+                + sizes.sizeof(subColumnsSize) + subColumnsSize;
     }
 
     public long timestamp()


Mime
View raw message