cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject cassandra git commit: entry-weighers in QueryProcessor should respect partitionKeyBindIndexes field
Date Thu, 26 May 2016 13:50:22 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 301bcae67 -> 0b825778a


entry-weighers in QueryProcessor should respect partitionKeyBindIndexes field

patch by Robert Stupp; reviewed by Benjamin Lerer for CASSANDRA-11718


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

Branch: refs/heads/trunk
Commit: 0b825778a141da196e60ebe5996ac1c43e0e8eaf
Parents: 301bcae
Author: Robert Stupp <snazy@snazy.de>
Authored: Thu May 26 15:49:16 2016 +0200
Committer: Robert Stupp <snazy@snazy.de>
Committed: Thu May 26 15:49:16 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/cql3/QueryProcessor.java   | 30 ++++----------------
 2 files changed, 6 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b825778/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 627f905..1426507 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.8
+ * entry-weighers in QueryProcessor should respect partitionKeyBindIndexes field (CASSANDRA-11718)
  * Support older ant versions (CASSANDRA-11807)
  * Estimate compressed on disk size when deciding if sstable size limit reached (CASSANDRA-11623)
  * cassandra-stress profiles should support case sensitive schemas (CASSANDRA-11546)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b825778/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index feedfc4..d812af4 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -55,7 +55,6 @@ import org.apache.cassandra.tracing.Tracing;
 import org.apache.cassandra.transport.Server;
 import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.utils.*;
-import org.github.jamm.MemoryMeter;
 
 public class QueryProcessor implements QueryHandler
 {
@@ -64,25 +63,6 @@ public class QueryProcessor implements QueryHandler
     public static final QueryProcessor instance = new QueryProcessor();
 
     private static final Logger logger = LoggerFactory.getLogger(QueryProcessor.class);
-    private static final MemoryMeter meter = new MemoryMeter().withGuessing(MemoryMeter.Guess.FALLBACK_BEST).ignoreKnownSingletons();
-
-    private static final EntryWeigher<MD5Digest, ParsedStatement.Prepared> cqlMemoryUsageWeigher
= new EntryWeigher<MD5Digest, ParsedStatement.Prepared>()
-    {
-        @Override
-        public int weightOf(MD5Digest key, ParsedStatement.Prepared value)
-        {
-            return Ints.checkedCast(measure(key) + measure(value.rawCQLStatement) + measure(value.statement)
+ measure(value.boundNames));
-        }
-    };
-
-    private static final EntryWeigher<Integer, ParsedStatement.Prepared> thriftMemoryUsageWeigher
= new EntryWeigher<Integer, ParsedStatement.Prepared>()
-    {
-        @Override
-        public int weightOf(Integer key, ParsedStatement.Prepared value)
-        {
-            return Ints.checkedCast(measure(key) + measure(value.rawCQLStatement) + measure(value.statement)
+ measure(value.boundNames));
-        }
-    };
 
     private static final ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared>
preparedStatements;
     private static final ConcurrentLinkedHashMap<Integer, ParsedStatement.Prepared>
thriftPreparedStatements;
@@ -102,7 +82,7 @@ public class QueryProcessor implements QueryHandler
     {
         preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, ParsedStatement.Prepared>()
                              .maximumWeightedCapacity(capacityToBytes(DatabaseDescriptor.getPreparedStatementsCacheSizeMB()))
-                             .weigher(cqlMemoryUsageWeigher)
+                             .weigher(QueryProcessor::measure)
                              .listener((md5Digest, prepared) -> {
                                  metrics.preparedStatementsEvicted.inc();
                                  lastMinuteEvictionsCount.incrementAndGet();
@@ -110,7 +90,7 @@ public class QueryProcessor implements QueryHandler
 
         thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, ParsedStatement.Prepared>()
                                    .maximumWeightedCapacity(capacityToBytes(DatabaseDescriptor.getThriftPreparedStatementsCacheSizeMB()))
-                                   .weigher(thriftMemoryUsageWeigher)
+                                   .weigher(QueryProcessor::measure)
                                    .listener((integer, prepared) -> {
                                        metrics.preparedStatementsEvicted.inc();
                                        thriftLastMinuteEvictionsCount.incrementAndGet();
@@ -429,7 +409,7 @@ public class QueryProcessor implements QueryHandler
     {
         // Concatenate the current keyspace so we don't mix prepared statements between keyspace
(#5352).
         // (if the keyspace is null, queryString has to have a fully-qualified keyspace so
it's fine.
-        long statementSize = measure(prepared.statement);
+        long statementSize = ObjectSizes.measureDeep(prepared.statement);
         // don't execute the statement if it's bigger than the allowed threshold
         if (forThrift)
         {
@@ -544,9 +524,9 @@ public class QueryProcessor implements QueryHandler
         }
     }
 
-    private static long measure(Object key)
+    private static int measure(Object key, ParsedStatement.Prepared value)
     {
-        return meter.measureDeep(key);
+        return Ints.checkedCast(ObjectSizes.measureDeep(key) + ObjectSizes.measureDeep(value));
     }
 
     /**


Mime
View raw message