cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject git commit: fix BulkLoader NPE caused by #4732 patch by jbellis; reviewed by yukim for CASSANDRA-4846
Date Tue, 23 Oct 2012 20:26:54 GMT
Updated Branches:
  refs/heads/trunk 5eb9e1c15 -> db3c198ad


fix BulkLoader NPE caused by #4732
patch by jbellis; reviewed by yukim for CASSANDRA-4846


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

Branch: refs/heads/trunk
Commit: db3c198ad0ce46e255202d03ead7ad44df127070
Parents: 5eb9e1c
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Tue Oct 23 15:26:51 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Tue Oct 23 15:26:51 2012 -0500

----------------------------------------------------------------------
 .../apache/cassandra/io/sstable/SSTableReader.java |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/db3c198a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
index 1514a2c..91713a1 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
@@ -84,7 +84,7 @@ public class SSTableReader extends SSTable
     private IndexSummary indexSummary;
     private Filter bf;
 
-    private final InstrumentingCache<KeyCacheKey, RowIndexEntry> keyCache = CacheService.instance.keyCache;
+    private InstrumentingCache<KeyCacheKey, RowIndexEntry> keyCache;
 
     private final BloomFilterTracker bloomFilterTracker = new BloomFilterTracker();
 
@@ -312,6 +312,10 @@ public class SSTableReader extends SSTable
     public void setTrackedBy(DataTracker tracker)
     {
         deletingTask.setTracker(tracker);
+        // under normal operation we can do this at any time, but SSTR is also used outside
C* proper,
+        // e.g. by BulkLoader, which does not initialize the cache.  As a kludge, we set
up the cache
+        // here when we know we're being wired into the rest of the server infrastructure.
+        keyCache = CacheService.instance.keyCache;
     }
 
     void loadBloomFilter() throws IOException
@@ -680,6 +684,7 @@ public class SSTableReader extends SSTable
 
         if (caching == CFMetaData.Caching.NONE
             || caching == CFMetaData.Caching.ROWS_ONLY
+            || keyCache == null
             || keyCache.getCapacity() == 0)
         {
             return;
@@ -697,7 +702,7 @@ public class SSTableReader extends SSTable
 
     private RowIndexEntry getCachedPosition(KeyCacheKey unifiedKey, boolean updateStats)
     {
-        if (keyCache.getCapacity() > 0)
+        if (keyCache != null && keyCache.getCapacity() > 0)
             return updateStats ? keyCache.get(unifiedKey) : keyCache.getInternal(unifiedKey);
         return null;
     }


Mime
View raw message