diff --git a/CHANGES.txt b/CHANGES.txt index 235953ee4c..b0aa52389d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -68,6 +68,7 @@ * (cql3) Add name of parameters in CqlResultSet (CASSANDRA-4242) * (cql3) Correctly validate order by queries (CASSANDRA-4246) * rename stress to cassandra-stress for saner packaging (CASSANDRA-4256) + * Fix exception on colum metadata with non-string comparator (CASSANDRA-4269) Merged from 1.0: * Fix super columns bug where cache is not updated (CASSANDRA-4190) * fix maxTimestamp to include row tombstones (CASSANDRA-4116) diff --git a/src/java/org/apache/cassandra/cql3/CFDefinition.java b/src/java/org/apache/cassandra/cql3/CFDefinition.java index da293c9146..52ffd6f48a 100644 --- a/src/java/org/apache/cassandra/cql3/CFDefinition.java +++ b/src/java/org/apache/cassandra/cql3/CFDefinition.java @@ -85,7 +85,7 @@ public class CFDefinition implements Iterable for (Map.Entry def : cfm.getColumn_metadata().entrySet()) { - ColumnIdentifier id = new ColumnIdentifier(def.getKey()); + ColumnIdentifier id = new ColumnIdentifier(def.getKey(), cfm.getColumnDefinitionComparator(def.getValue())); this.metadata.put(id, new Name(id, Name.Kind.COLUMN_METADATA, def.getValue().getValidator())); } } @@ -111,7 +111,7 @@ public class CFDefinition implements Iterable assert cfm.getColumnAliases() == null || cfm.getColumnAliases().isEmpty(); for (Map.Entry def : cfm.getColumn_metadata().entrySet()) { - ColumnIdentifier id = new ColumnIdentifier(def.getKey()); + ColumnIdentifier id = new ColumnIdentifier(def.getKey(), cfm.getColumnDefinitionComparator(def.getValue())); this.metadata.put(id, new Name(id, Name.Kind.COLUMN_METADATA, def.getValue().getValidator())); } } @@ -123,7 +123,7 @@ public class CFDefinition implements Iterable { return cfm.getKeyAlias() == null ? new ColumnIdentifier(DEFAULT_KEY_ALIAS, false) - : new ColumnIdentifier(cfm.getKeyAlias()); + : new ColumnIdentifier(cfm.getKeyAlias(), definitionType); } private static ColumnIdentifier getColumnId(CFMetaData cfm, int i) @@ -131,14 +131,14 @@ public class CFDefinition implements Iterable List definedNames = cfm.getColumnAliases(); return definedNames == null || i >= definedNames.size() ? new ColumnIdentifier(DEFAULT_COLUMN_ALIAS + (i + 1), false) - : new ColumnIdentifier(cfm.getColumnAliases().get(i)); + : new ColumnIdentifier(cfm.getColumnAliases().get(i), definitionType); } private static ColumnIdentifier getValueId(CFMetaData cfm) { return cfm.getValueAlias() == null ? new ColumnIdentifier(DEFAULT_VALUE_ALIAS, false) - : new ColumnIdentifier(cfm.getValueAlias()); + : new ColumnIdentifier(cfm.getValueAlias(), definitionType); } public Name get(ColumnIdentifier name) diff --git a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java index 2ad2a14ef3..6744a11f85 100644 --- a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java +++ b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java @@ -21,6 +21,7 @@ import java.util.Locale; import java.nio.charset.CharacterCodingException; import java.nio.ByteBuffer; +import org.apache.cassandra.db.marshal.AbstractType; import org.apache.cassandra.utils.ByteBufferUtil; /** @@ -37,17 +38,10 @@ public class ColumnIdentifier implements Comparable this.key = ByteBufferUtil.bytes(this.text); } - public ColumnIdentifier(ByteBuffer key) + public ColumnIdentifier(ByteBuffer key, AbstractType type) { - try - { - this.key = key; - this.text = ByteBufferUtil.string(key); - } - catch (CharacterCodingException e) - { - throw new RuntimeException(e); - } + this.key = key; + this.text = type.getString(key); } @Override