Skip to content

Commit

Permalink
Fix encoding of cell names for super columns (CASSANDRA-12235 follow-up)
Browse files Browse the repository at this point in the history
patch by Sylvain Lebresne; reviewed by Aleksey Yeschenko for
CASSANDRA-12335
  • Loading branch information
Sylvain Lebresne authored and iamaleksey committed Aug 8, 2016
1 parent 55aea2d commit ae816cb
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/java/org/apache/cassandra/db/LegacyLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ public static ByteBuffer encodeCellName(CFMetaData metadata, ClusteringPrefix cl
// We use comparator.size() rather than clustering.size() because of static clusterings
int clusteringSize = metadata.comparator.size();
int size = clusteringSize + (metadata.isDense() ? 0 : 1) + (collectionElement == null ? 0 : 1);
if (metadata.isSuper())
size = clusteringSize + 1;
ByteBuffer[] values = new ByteBuffer[size];
for (int i = 0; i < clusteringSize; i++)
{
Expand All @@ -282,10 +284,23 @@ public static ByteBuffer encodeCellName(CFMetaData metadata, ClusteringPrefix cl
values[i] = v;
}

if (!metadata.isDense())
values[clusteringSize] = columnName;
if (collectionElement != null)
values[clusteringSize + 1] = collectionElement;
if (metadata.isSuper())
{
// We need to set the "column" (in thrift terms) name, i.e. the value corresponding to the subcomparator.
// What it is depends if this a cell for a declared "static" column or a "dynamic" column part of the
// super-column internal map.
assert columnName != null; // This should never be null for supercolumns, see decodeForSuperColumn() above
values[clusteringSize] = columnName.equals(CompactTables.SUPER_COLUMN_MAP_COLUMN)
? collectionElement
: columnName;
}
else
{
if (!metadata.isDense())
values[clusteringSize] = columnName;
if (collectionElement != null)
values[clusteringSize + 1] = collectionElement;
}

return CompositeType.build(isStatic, values);
}
Expand Down

0 comments on commit ae816cb

Please sign in to comment.