[infinispan-commits] Infinispan SVN: r2420 - trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Sep 20 10:54:39 EDT 2010
Author: NadirX
Date: 2010-09-20 10:54:39 -0400 (Mon, 20 Sep 2010)
New Revision: 2420
Modified:
trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java
Log:
Unhash keys when read from Cassandra
Modified: trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java
===================================================================
--- trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java 2010-09-20 14:53:46 UTC (rev 2419)
+++ trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java 2010-09-20 14:54:39 UTC (rev 2420)
@@ -147,7 +147,7 @@
}
for (KeySlice keySlice : keySlices) {
- String key = keySlice.getKey();
+ String key = unhashKey(keySlice.getKey());
List<ColumnOrSuperColumn> columns = keySlice.getColumns();
if(columns.size()>0) {
byte[] value = columns.get(0).getColumn().getValue();
@@ -185,7 +185,7 @@
}
for (KeySlice keySlice : keySlices) {
- String key = keySlice.getKey();
+ String key = unhashKey(keySlice.getKey());
if (keysToExclude == null || !keysToExclude.contains(key))
s.add(key);
}
@@ -320,15 +320,13 @@
*/
public void toStream(ObjectOutput out) throws CacheLoaderException {
try {
- Set<InternalCacheEntry> loadAll = loadAll();
- log.debug("toStream() entries");
+ Set<InternalCacheEntry> loadAll = loadAll();
int count = 0;
for (InternalCacheEntry entry : loadAll) {
getMarshaller().objectToObjectStream(entry, out);
count++;
}
getMarshaller().objectToObjectStream(null, out);
- log.debug("wrote " + count + " entries");
} catch (IOException e) {
throw new CacheLoaderException(e);
}
@@ -340,7 +338,6 @@
*/
public void fromStream(ObjectInput in) throws CacheLoaderException {
try {
- log.debug("fromStream()");
int count = 0;
while (true) {
count++;
@@ -349,7 +346,6 @@
break;
store(entry);
}
- log.debug("read " + count + " entries");
} catch (IOException e) {
throw new CacheLoaderException(e);
} catch (ClassNotFoundException e) {
@@ -410,6 +406,10 @@
return ENTRY_KEY_PREFIX+key.toString();
}
+ public static String unhashKey(String key) {
+ return key.substring(ENTRY_KEY_PREFIX.length());
+ }
+
public static String expirationColumn(long timestamp) {
return String.format("expiration%013d", timestamp);
}
@@ -428,14 +428,12 @@
}
if (value == null) { // Delete
- log.debug("Delete '{0}'", key);
Deletion deletion = new Deletion(System.currentTimeMillis());
if (column != null) { // Single column delete
deletion.setPredicate(new SlicePredicate().setColumn_names(Arrays.asList(new byte[][] { column })));
} // else Delete entire column family
columnFamilyMutations.add(new Mutation().setDeletion(deletion));
- } else { // Insert/update
- log.debug("Insert/update '{0}', size={1}", key, value.length);
+ } else { // Insert/update
ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
cosc.setColumn(new Column(column, value, System.currentTimeMillis()));
columnFamilyMutations.add(new Mutation().setColumn_or_supercolumn(cosc));
More information about the infinispan-commits
mailing list