Skip to content

Instantly share code, notes, and snippets.

@amorton
Created April 25, 2011 23:01
Show Gist options
  • Save amorton/941445 to your computer and use it in GitHub Desktop.
Save amorton/941445 to your computer and use it in GitHub Desktop.
force sub columns to be ordered when the super column is deserialised (cassandra 0.7.4)
Index: src/java/org/apache/cassandra/db/SuperColumn.java
===================================================================
--- src/java/org/apache/cassandra/db/SuperColumn.java (date 1300200460000)
+++ src/java/org/apache/cassandra/db/SuperColumn.java (revision )
@@ -359,8 +359,11 @@
/* read the number of columns */
int size = dis.readInt();
ColumnSerializer serializer = Column.serializer();
- ColumnSortedMap preSortedMap = new ColumnSortedMap(comparator, serializer, dis, size);
- SuperColumn superColumn = new SuperColumn(name, new ConcurrentSkipListMap<ByteBuffer,IColumn>(preSortedMap));
+ final ColumnSortedMap preSortedMap = new ColumnSortedMap(comparator, serializer, dis, size);
+ ConcurrentSkipListMap<ByteBuffer, IColumn> columns = new ConcurrentSkipListMap<ByteBuffer, IColumn>(preSortedMap.comparator()){{
+ putAll(preSortedMap);
+ }};
+ SuperColumn superColumn = new SuperColumn(name, columns);
if (localDeleteTime != Integer.MIN_VALUE && localDeleteTime <= 0)
{
throw new IOException("Invalid localDeleteTime read: " + localDeleteTime);
@amorton
Copy link
Author

amorton commented Apr 25, 2011

This is for a specific case where the on disk order of the sub columns needed to change. Running nodetool scrub should re-write the sub columns in the new order. Do not use in production other than to fix this. Only works if all rows smaller than in memory compaction limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment