Filter cached results correctly. Patch by marcuse, reviewed aleksey for CASSANDRA-7636
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0947fb8a Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0947fb8a Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0947fb8a Branch: refs/heads/trunk Commit: 0947fb8a91ddbf9785a675bafaac51c02dd1f27e Parents: d4d6246 Author: Brandon Williams <[email protected]> Authored: Thu Jul 31 12:38:03 2014 -0500 Committer: Brandon Williams <[email protected]> Committed: Thu Jul 31 12:38:03 2014 -0500 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/db/ColumnFamilyStore.java | 2 +- .../apache/cassandra/db/RowCacheCQLTest.java | 40 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/0947fb8a/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 5210e0d..378e812 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.0-final + * Filter cached results correctly (CASSANDRA-7636) * Fix tracing on the new SEPExecutor (CASSANDRA-7644) * Remove shuffle and taketoken (CASSANDRA-7601) * Clean up Windows batch scripts (CASSANDRA-7619) http://git-wip-us.apache.org/repos/asf/cassandra/blob/0947fb8a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java index fb66c34..8e7bdeb 100644 --- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java +++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java @@ -1522,7 +1522,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean { metric.rowCacheHit.inc(); Tracing.trace("Row cache hit"); - return cachedCf; + return filterColumnFamily(cachedCf, filter); } metric.rowCacheHitOutOfRange.inc(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/0947fb8a/test/unit/org/apache/cassandra/db/RowCacheCQLTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/RowCacheCQLTest.java b/test/unit/org/apache/cassandra/db/RowCacheCQLTest.java new file mode 100644 index 0000000..3dc5ce3 --- /dev/null +++ b/test/unit/org/apache/cassandra/db/RowCacheCQLTest.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.cassandra.db; + +import org.junit.Test; + +import org.apache.cassandra.cql3.CQLTester; +import org.apache.cassandra.cql3.UntypedResultSet; +import org.apache.cassandra.service.CacheService; +import static org.junit.Assert.assertEquals; + +public class RowCacheCQLTest extends CQLTester +{ + @Test + public void test7636() throws Throwable + { + CacheService.instance.setRowCacheCapacityInMB(1); + createTable("CREATE TABLE %s (p1 bigint, c1 int, PRIMARY KEY (p1, c1)) WITH caching = '{\"keys\":\"NONE\", \"rows_per_partition\":\"ALL\"}'"); + execute("INSERT INTO %s (p1, c1) VALUES (123, 10)"); + assertEmpty(execute("SELECT * FROM %s WHERE p1=123 and c1 > 1000")); + UntypedResultSet res = execute("SELECT * FROM %s WHERE p1=123 and c1 > 0"); + assertEquals(1, res.size()); + assertEmpty(execute("SELECT * FROM %s WHERE p1=123 and c1 > 1000")); + } +}
