cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1034960 - /cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
Date Sun, 14 Nov 2010 09:05:51 GMT
Author: jbellis
Date: Sun Nov 14 09:05:50 2010
New Revision: 1034960

URL: http://svn.apache.org/viewvc?rev=1034960&view=rev
Log:
cli: use key type conversion on list ranges, and reject invalid set of super columns
patch by jbellis

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java?rev=1034960&r1=1034959&r2=1034960&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java Sun
Nov 14 09:05:50 2010
@@ -283,12 +283,12 @@ public class CliClient extends CliUserHe
         }
 
         ColumnPath path = new ColumnPath(columnFamily);
-        if(superColumnName != null)
+        if (superColumnName != null)
             path.setSuper_column(superColumnName);
-        
-        if(columnName != null)
+
+        if (columnName != null)
             path.setColumn(columnName);
-        
+
         thriftClient.remove(ByteBuffer.wrap(key.getBytes(Charsets.UTF_8)), path,
                              FBUtilities.timestampMicros(), ConsistencyLevel.ONE);
         sessionState.out.println(String.format("%s removed.", (columnSpecCnt == 0) ? "row"
: "column"));
@@ -563,10 +563,11 @@ public class CliClient extends CliUserHe
         Tree keyTree = columnFamilySpec.getChild(1); // could be a function or regular text
 
         String columnFamily = CliCompiler.getColumnFamily(columnFamilySpec);
+        CfDef cfDef = getCfDef(columnFamily);
         int columnSpecCnt = CliCompiler.numColumnSpecifiers(columnFamilySpec);
         String value = CliUtils.unescapeSQLString(statement.getChild(1).getText());
         Tree valueTree = statement.getChild(1);
-        
+
         byte[] superColumnName = null;
         ByteBuffer columnName;
 
@@ -580,6 +581,11 @@ public class CliClient extends CliUserHe
         else if (columnSpecCnt == 1)
         {
             // get the column name
+            if (cfDef.column_type.equals("Super"))
+            {
+                sessionState.out.println("Column family " + columnFamily + " may only contain
SuperColumns");
+                return;
+            }
             columnName = getColumnName(columnFamily, columnFamilySpec.getChild(2));
         }
         // table.cf['key']['super_column']['column'] = 'value'
@@ -596,7 +602,7 @@ public class CliClient extends CliUserHe
         switch (valueTree.getType())
         {
         case CliParser.FUNCTION_CALL:
-            columnValueInBytes = convertValueByFunction(valueTree, getCfDef(columnFamily),
columnName, true);
+            columnValueInBytes = convertValueByFunction(valueTree, cfDef, columnName, true);
             break;
         default:
             columnValueInBytes = columnValueAsBytes(columnName, columnFamily, value);
@@ -948,7 +954,9 @@ public class CliClient extends CliUserHe
 
         // set the key range
         KeyRange range = new KeyRange(limitCount);
-        range.setStart_key(startKey.getBytes()).setEnd_key(endKey.getBytes());
+        AbstractType keyComparator = this.cfKeysComparators.get(columnFamily);
+        range.setStart_key(getBytesAccordingToType(startKey, keyComparator))
+             .setEnd_key(getBytesAccordingToType(endKey, keyComparator));
 
         ColumnParent columnParent = new ColumnParent(columnFamily);
         List<KeySlice> keySlices = thriftClient.get_range_slices(columnParent, predicate,
range, ConsistencyLevel.ONE);
@@ -1870,10 +1878,6 @@ public class CliClient extends CliUserHe
         String key = CliUtils.unescapeSQLString(keyTree.getText());
 
         AbstractType keyComparator = this.cfKeysComparators.get(columnFamily);
-        return keyComparator == null
-                ? ByteBuffer.wrap(key.getBytes(Charsets.UTF_8))
-                : getBytesAccordingToType(key, keyComparator);
-
+        return getBytesAccordingToType(key, keyComparator);
     }
-
 }



Mime
View raw message