cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [2/6] cassandra git commit: Interned ColumnIdentifiers should use minimal ByteBuffers. MemoryMeter shouldn't take ColumnDefinition into account when measuring object sizes.
Date Fri, 26 May 2017 19:20:56 GMT
Interned ColumnIdentifiers should use minimal ByteBuffers. MemoryMeter shouldn't take ColumnDefinition
into account when measuring object sizes.

Patch by Eduard Tudenhoefner; reviewed by Joel Knighton for CASSANDRA-13533


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

Branch: refs/heads/cassandra-3.11
Commit: 8ffdd26cbee33c5dc1205c0f7292628e1a2c69e3
Parents: 62092e4
Author: Eduard Tudenhoefner <eduard.tudenhoefner@datastax.com>
Authored: Wed May 10 18:04:33 2017 -0700
Committer: Joel Knighton <jkni@apache.org>
Committed: Fri May 26 13:48:54 2017 -0500

----------------------------------------------------------------------
 CHANGES.txt                                            |  1 +
 .../org/apache/cassandra/config/ColumnDefinition.java  |  2 ++
 .../org/apache/cassandra/cql3/ColumnIdentifier.java    |  2 ++
 .../apache/cassandra/cql3/ColumnIdentifierTest.java    | 13 +++++++++++++
 4 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8ffdd26c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index fe6ab09..18dca09 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.14
+ * Interned ColumnIdentifiers should use minimal ByteBuffers (CASSANDRA-13533)
  * ReverseIndexedReader may drop rows during 2.1 to 3.0 upgrade (CASSANDRA-13525)
  * Fix repair process violating start/end token limits for small ranges (CASSANDRA-13052)
  * Add storage port options to sstableloader (CASSANDRA-13518)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8ffdd26c/src/java/org/apache/cassandra/config/ColumnDefinition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/ColumnDefinition.java b/src/java/org/apache/cassandra/config/ColumnDefinition.java
index 6bcc2e0..34840e3 100644
--- a/src/java/org/apache/cassandra/config/ColumnDefinition.java
+++ b/src/java/org/apache/cassandra/config/ColumnDefinition.java
@@ -29,7 +29,9 @@ import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.db.rows.*;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.serializers.MarshalException;
+import org.github.jamm.Unmetered;
 
+@Unmetered
 public class ColumnDefinition extends ColumnSpecification implements Comparable<ColumnDefinition>
 {
     public static final Comparator<Object> asymmetricColumnDataComparator =

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8ffdd26c/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
index ceb81be..9b9ec4a 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
@@ -146,6 +146,8 @@ public class ColumnIdentifier extends Selectable implements IMeasurableMemory,
C
 
     public static ColumnIdentifier getInterned(AbstractType<?> type, ByteBuffer bytes,
String text)
     {
+        bytes = ByteBufferUtil.minimalBufferFor(bytes);
+
         InternedKey key = new InternedKey(type, bytes);
         ColumnIdentifier id = internedInstances.get(key);
         if (id != null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8ffdd26c/test/unit/org/apache/cassandra/cql3/ColumnIdentifierTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/ColumnIdentifierTest.java b/test/unit/org/apache/cassandra/cql3/ColumnIdentifierTest.java
index c4b43b8..3a34ad5 100644
--- a/test/unit/org/apache/cassandra/cql3/ColumnIdentifierTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ColumnIdentifierTest.java
@@ -82,4 +82,17 @@ public class ColumnIdentifierTest
         Assert.assertEquals(text, c3.toString());
     }
 
+    @Test
+    public void testInterningUsesMinimalByteBuffer()
+    {
+        byte[] bytes = new byte[2];
+        bytes[0] = 0x63;
+        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
+        byteBuffer.limit(1);
+
+        ColumnIdentifier c1 = ColumnIdentifier.getInterned(byteBuffer, UTF8Type.instance);
+
+        Assert.assertEquals(2, byteBuffer.capacity());
+        Assert.assertEquals(1, c1.bytes.capacity());
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message