cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [4/4] git commit: Merge branch 'cassandra-1.2' into trunk
Date Wed, 24 Jul 2013 16:13:54 GMT
Merge branch 'cassandra-1.2' into trunk

Conflicts:
	test/unit/org/apache/cassandra/db/KeyCacheTest.java


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

Branch: refs/heads/trunk
Commit: 813577e32b7e9a40ff1e71875d019eda44c84586
Parents: 371e7bf 422d223
Author: Yuki Morishita <yukim@apache.org>
Authored: Wed Jul 24 11:07:31 2013 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Wed Jul 24 11:07:31 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/cql3/AbstractMarker.java   |  5 ++
 src/java/org/apache/cassandra/cql3/Lists.java   | 76 ++++++++++++++----
 src/java/org/apache/cassandra/cql3/Maps.java    | 84 +++++++++++++++-----
 src/java/org/apache/cassandra/cql3/Sets.java    | 73 +++++++++++++----
 src/java/org/apache/cassandra/cql3/Term.java    | 28 ++++++-
 .../cassandra/cql3/functions/FunctionCall.java  | 10 +++
 .../org/apache/cassandra/db/KeyCacheTest.java   | 70 ++++++++++------
 8 files changed, 266 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/813577e3/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/813577e3/src/java/org/apache/cassandra/cql3/Lists.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/813577e3/src/java/org/apache/cassandra/cql3/Maps.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/813577e3/src/java/org/apache/cassandra/cql3/Sets.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/813577e3/test/unit/org/apache/cassandra/db/KeyCacheTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/KeyCacheTest.java
index e8e524d,3458961..10bcedd
--- a/test/unit/org/apache/cassandra/db/KeyCacheTest.java
+++ b/test/unit/org/apache/cassandra/db/KeyCacheTest.java
@@@ -35,8 -27,14 +27,12 @@@ import org.junit.Test
  
  import org.apache.cassandra.SchemaLoader;
  import org.apache.cassandra.Util;
+ import org.apache.cassandra.cache.KeyCacheKey;
  import org.apache.cassandra.db.compaction.CompactionManager;
+ import org.apache.cassandra.db.filter.QueryFilter;
 -import org.apache.cassandra.db.filter.QueryPath;
+ import org.apache.cassandra.service.CacheService;
 -import org.apache.cassandra.thrift.ColumnParent;
  import org.apache.cassandra.utils.ByteBufferUtil;
+ 
  import static junit.framework.Assert.assertEquals;
  
  public class KeyCacheTest extends SchemaLoader
@@@ -60,28 -58,45 +56,45 @@@
  
          // empty the cache
          CacheService.instance.invalidateKeyCache();
-         assert CacheService.instance.keyCache.size() == 0;
 -        assertKeyCacheSize(0, TABLE1, COLUMN_FAMILY2);
++        assertKeyCacheSize(0, KEYSPACE1, COLUMN_FAMILY2);
  
          // insert data and force to disk
 -        insertData(TABLE1, COLUMN_FAMILY2, 0, 100);
 +        insertData(KEYSPACE1, COLUMN_FAMILY2, 0, 100);
          store.forceBlockingFlush();
  
          // populate the cache
 -        readData(TABLE1, COLUMN_FAMILY2, 0, 100);
 -        assertKeyCacheSize(100, TABLE1, COLUMN_FAMILY2);
 +        readData(KEYSPACE1, COLUMN_FAMILY2, 0, 100);
-         assertEquals(100, CacheService.instance.keyCache.size());
++        assertKeyCacheSize(100, KEYSPACE1, COLUMN_FAMILY2);
  
          // really? our caches don't implement the map interface? (hence no .addAll)
          Map<KeyCacheKey, RowIndexEntry> savedMap = new HashMap<KeyCacheKey, RowIndexEntry>();
          for (KeyCacheKey k : CacheService.instance.keyCache.getKeySet())
          {
-             savedMap.put(k, CacheService.instance.keyCache.get(k));
 -            if (k.desc.ksname.equals(TABLE1) && k.desc.cfname.equals(COLUMN_FAMILY2))
++            if (k.desc.ksname.equals(KEYSPACE1) && k.desc.cfname.equals(COLUMN_FAMILY2))
+                 savedMap.put(k, CacheService.instance.keyCache.get(k));
          }
  
          // force the cache to disk
          CacheService.instance.keyCache.submitWrite(Integer.MAX_VALUE).get();
  
          CacheService.instance.invalidateKeyCache();
-         assert CacheService.instance.keyCache.size() == 0;
 -        assertKeyCacheSize(0, TABLE1, COLUMN_FAMILY2);
++        assertKeyCacheSize(0, KEYSPACE1, COLUMN_FAMILY2);
+ 
+         CacheService.instance.keyCache.loadSaved(store);
 -        assertKeyCacheSize(savedMap.size(), TABLE1, COLUMN_FAMILY2);
++        assertKeyCacheSize(savedMap.size(), KEYSPACE1, COLUMN_FAMILY2);
+ 
+         // probably it's better to add equals/hashCode to RowIndexEntry...
+         for (Map.Entry<KeyCacheKey, RowIndexEntry> entry : savedMap.entrySet())
+         {
+             RowIndexEntry expected = entry.getValue();
+             RowIndexEntry actual = CacheService.instance.keyCache.get(entry.getKey());
+             assertEquals(expected.position, actual.position);
+             assertEquals(expected.columnsIndex(), actual.columnsIndex());
+             if (expected.isIndexed())
+             {
+                 assertEquals(expected.deletionTime(), actual.deletionTime());
+             }
+         }
      }
  
      @Test
@@@ -96,7 -111,7 +109,7 @@@
          CacheService.instance.invalidateKeyCache();
  
          // KeyCache should start at size 0 if we're caching X% of zero data.
-         assertEquals(0, CacheService.instance.keyCache.size());
 -        assertKeyCacheSize(0, TABLE1, COLUMN_FAMILY1);
++        assertKeyCacheSize(0, KEYSPACE1, COLUMN_FAMILY1);
  
          DecoratedKey key1 = Util.dk("key1");
          DecoratedKey key2 = Util.dk("key2");
@@@ -127,15 -141,14 +140,15 @@@
                                                         ByteBufferUtil.EMPTY_BYTE_BUFFER,
                                                         ByteBufferUtil.EMPTY_BYTE_BUFFER,
                                                         false,
 -                                                       10));
 +                                                       10,
 +                                                       System.currentTimeMillis()));
  
-         assertEquals(2, CacheService.instance.keyCache.size());
 -        assertKeyCacheSize(2, TABLE1, COLUMN_FAMILY1);
++        assertKeyCacheSize(2, KEYSPACE1, COLUMN_FAMILY1);
  
          Util.compactAll(cfs).get();
          // after compaction cache should have entries for
          // new SSTables, if we had 2 keys in cache previously it should become 4
-         assertEquals(4, CacheService.instance.keyCache.size());
 -        assertKeyCacheSize(4, TABLE1, COLUMN_FAMILY1);
++        assertKeyCacheSize(4, KEYSPACE1, COLUMN_FAMILY1);
  
          // re-read same keys to verify that key cache didn't grow further
          cfs.getColumnFamily(QueryFilter.getSliceFilter(key1,
@@@ -151,9 -163,19 +164,20 @@@
                                                         ByteBufferUtil.EMPTY_BYTE_BUFFER,
                                                         ByteBufferUtil.EMPTY_BYTE_BUFFER,
                                                         false,
 -                                                       10));
 +                                                       10,
 +                                                       System.currentTimeMillis()));
  
-         assert CacheService.instance.keyCache.size() == 4;
 -        assertKeyCacheSize(4, TABLE1, COLUMN_FAMILY1);
++        assertKeyCacheSize(4, KEYSPACE1, COLUMN_FAMILY1);
+     }
+ 
+     private void assertKeyCacheSize(int expected, String keyspace, String columnFamily)
+     {
+         int size = 0;
+         for (KeyCacheKey k : CacheService.instance.keyCache.getKeySet())
+         {
+             if (k.desc.ksname.equals(keyspace) && k.desc.cfname.equals(columnFamily))
+                 size++;
+         }
+         assertEquals(expected, size);
      }
  }


Mime
View raw message