You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/05/22 17:15:27 UTC
[2/2] git commit: Fix setting column metadata for CF with non-string
comparator
Fix setting column metadata for CF with non-string comparator
patch by slebresne; reviewed by jbellis for CASSANDRA-4269
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a7ed01cc
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a7ed01cc
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a7ed01cc
Branch: refs/heads/trunk
Commit: a7ed01cc2b5b785148d245d175ce07ab5fe23c6b
Parents: 2236b15
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Tue May 22 12:33:03 2012 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Tue May 22 17:11:02 2012 +0200
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../org/apache/cassandra/cql3/CFDefinition.java | 10 +++++-----
.../apache/cassandra/cql3/ColumnIdentifier.java | 14 ++++----------
3 files changed, 10 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a7ed01cc/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1df85f6..21570c7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -56,6 +56,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)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a7ed01cc/src/java/org/apache/cassandra/cql3/CFDefinition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/CFDefinition.java b/src/java/org/apache/cassandra/cql3/CFDefinition.java
index a99f6ee..8d7101b 100644
--- a/src/java/org/apache/cassandra/cql3/CFDefinition.java
+++ b/src/java/org/apache/cassandra/cql3/CFDefinition.java
@@ -86,7 +86,7 @@ public class CFDefinition implements Iterable<CFDefinition.Name>
for (Map.Entry<ByteBuffer, ColumnDefinition> 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()));
}
}
@@ -112,7 +112,7 @@ public class CFDefinition implements Iterable<CFDefinition.Name>
assert cfm.getColumnAliases() == null || cfm.getColumnAliases().isEmpty();
for (Map.Entry<ByteBuffer, ColumnDefinition> 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()));
}
}
@@ -124,7 +124,7 @@ public class CFDefinition implements Iterable<CFDefinition.Name>
{
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)
@@ -132,14 +132,14 @@ public class CFDefinition implements Iterable<CFDefinition.Name>
List<ByteBuffer> 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)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a7ed01cc/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
index 60f3ecb..337e619 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
@@ -22,6 +22,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;
/**
@@ -38,17 +39,10 @@ public class ColumnIdentifier implements Comparable<ColumnIdentifier>
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