Author: jbellis
Date: Mon Nov 15 19:23:04 2010
New Revision: 1035418

URL: http://svn.apache.org/viewvc?rev=1035418&view=rev
Log:
fix cli list + "assume CF keys as uuid."
patch by jbellis

Modified:
    cassandra/branches/cassandra-0.7/conf/cassandra.yaml
    
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
    
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/cli/CliTest.java

Modified: cassandra/branches/cassandra-0.7/conf/cassandra.yaml
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/conf/cassandra.yaml?rev=1035418&r1=1035417&r2=1035418&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/conf/cassandra.yaml (original)
+++ cassandra/branches/cassandra-0.7/conf/cassandra.yaml Mon Nov 15 19:23:04 
2010
@@ -272,7 +272,7 @@ index_interval: 128
 # unusual circumstances you will have one Keyspace per application.
 #
 # Keyspace required parameters:
-# - name: name of the keyspace; "system" is
+# - name: name of the keyspace; "system" and "definitions" are 
 #   reserved for Cassandra Internals.
 # - replica_placement_strategy: the class that determines how replicas
 #   are distributed among nodes. Contains both the class as well as
@@ -363,55 +363,101 @@ index_interval: 128
 #        before the memtable is flushed. If undefined, throughput / 64 * 0.3
 #        will be used.
 #
-# NOTE: this keyspace definition is for demonstration purposes only.
-#       Cassandra will not load these definitions during startup. See
-#       http://wiki.apache.org/cassandra/FAQ#no_keyspaces for an explanation.
 keyspaces:
-    - name: Keyspace1
-      replica_placement_strategy: org.apache.cassandra.locator.SimpleStrategy
-      replication_factor: 1
-      column_families:
-        - name: Standard1
-          compare_with: BytesType
-          keys_cached: 10000
-          rows_cached: 1000
-          row_cache_save_period_in_seconds: 0
-          key_cache_save_period_in_seconds: 3600
-          memtable_flush_after_mins: 59
-          memtable_throughput_in_mb: 255
-          memtable_operations_in_millions: 0.29
-
-        - name: Standard2
-          compare_with: UTF8Type
-          read_repair_chance: 0.1
-          keys_cached: 100
-          gc_grace_seconds: 0
-          min_compaction_threshold: 5
-          max_compaction_threshold: 31
-
-        - name: StandardByUUID1
-          compare_with: TimeUUIDType
-
-        - name: Super1
-          column_type: Super
-          compare_with: BytesType
-          compare_subcolumns_with: BytesType
-
-        - name: Super2
-          column_type: Super
-          compare_subcolumns_with: UTF8Type
-          rows_cached: 10000
-          keys_cached: 50
-          comment: 'A column family with supercolumns, whose column and 
subcolumn names are UTF8 strings'
-
-        - name: Super3
-          column_type: Super
-          compare_with: LongType
-          comment: 'A column family with supercolumns, whose column names are 
Longs (8 bytes)'
-
-        - name: Indexed1
-          default_validation_class: LongType
-          column_metadata:
-            - name: birthdate
-              validator_class: LongType
-              index_type: KEYS
+- column_families:
+  - column_metadata:
+    - !!org.apache.cassandra.config.RawColumnDefinition
+      name: password
+      validator_class: org.apache.cassandra.db.marshal.UTF8Type
+    column_type: Standard
+    comment: ''
+    compare_with: org.apache.cassandra.db.marshal.UTF8Type
+    gc_grace_seconds: 864000
+    key_cache_save_period_in_seconds: 3600
+    keys_cached: 200000.0
+    max_compaction_threshold: 32
+    memtable_flush_after_mins: 60
+    min_compaction_threshold: 4
+    name: User
+    read_repair_chance: 1.0
+    row_cache_save_period_in_seconds: 0
+    rows_cached: 0.0
+  - column_type: Standard
+    comment: ''
+    compare_with: org.apache.cassandra.db.marshal.LongType
+    default_validation_class: org.apache.cassandra.db.marshal.LexicalUUIDType
+    gc_grace_seconds: 864000
+    key_cache_save_period_in_seconds: 3600
+    keys_cached: 200000.0
+    max_compaction_threshold: 32
+    memtable_flush_after_mins: 60
+    min_compaction_threshold: 4
+    name: Userline
+    read_repair_chance: 1.0
+    row_cache_save_period_in_seconds: 0
+    rows_cached: 0.0
+  - column_type: Standard
+    comment: ''
+    compare_with: org.apache.cassandra.db.marshal.UTF8Type
+    default_validation_class: org.apache.cassandra.db.marshal.UTF8Type
+    gc_grace_seconds: 864000
+    key_cache_save_period_in_seconds: 3600
+    keys_cached: 200000.0
+    max_compaction_threshold: 32
+    memtable_flush_after_mins: 60
+    min_compaction_threshold: 4
+    name: Followers
+    read_repair_chance: 1.0
+    row_cache_save_period_in_seconds: 0
+    rows_cached: 0.0
+  - column_metadata:
+    - !!org.apache.cassandra.config.RawColumnDefinition
+      name: body
+      validator_class: org.apache.cassandra.db.marshal.UTF8Type
+    - !!org.apache.cassandra.config.RawColumnDefinition
+      name: username
+      validator_class: org.apache.cassandra.db.marshal.UTF8Type
+    column_type: Standard
+    comment: ''
+    compare_with: org.apache.cassandra.db.marshal.UTF8Type
+    gc_grace_seconds: 864000
+    key_cache_save_period_in_seconds: 3600
+    keys_cached: 200000.0
+    max_compaction_threshold: 32
+    memtable_flush_after_mins: 60
+    min_compaction_threshold: 4
+    name: Tweet
+    read_repair_chance: 1.0
+    row_cache_save_period_in_seconds: 0
+    rows_cached: 0.0
+  - column_type: Standard
+    comment: ''
+    compare_with: org.apache.cassandra.db.marshal.UTF8Type
+    default_validation_class: org.apache.cassandra.db.marshal.UTF8Type
+    gc_grace_seconds: 864000
+    key_cache_save_period_in_seconds: 3600
+    keys_cached: 200000.0
+    max_compaction_threshold: 32
+    memtable_flush_after_mins: 60
+    min_compaction_threshold: 4
+    name: Friends
+    read_repair_chance: 1.0
+    row_cache_save_period_in_seconds: 0
+    rows_cached: 0.0
+  - column_type: Standard
+    comment: ''
+    compare_with: org.apache.cassandra.db.marshal.LongType
+    default_validation_class: org.apache.cassandra.db.marshal.LexicalUUIDType
+    gc_grace_seconds: 864000
+    key_cache_save_period_in_seconds: 3600
+    keys_cached: 200000.0
+    max_compaction_threshold: 32
+    memtable_flush_after_mins: 60
+    min_compaction_threshold: 4
+    name: Timeline
+    read_repair_chance: 1.0
+    row_cache_save_period_in_seconds: 0
+    rows_cached: 0.0
+  name: Twissjava
+  replica_placement_strategy: org.apache.cassandra.locator.SimpleStrategy
+  replication_factor: 1

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=1035418&r1=1035417&r2=1035418&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
 Mon Nov 15 19:23:04 2010
@@ -904,8 +904,8 @@ public class CliClient extends CliUserHe
         // extract column family
         String columnFamily = statement.getChild(0).getText();
 
-        String startKey = "";
-        String endKey = "";
+        String rawStartKey = "";
+        String rawEndKey = "";
         int limitCount = Integer.MAX_VALUE; // will reset to default later if 
it's not specified
 
         // optional arguments: key range and limit
@@ -916,9 +916,9 @@ public class CliClient extends CliUserHe
             {
                 if (child.getChildCount() > 0)
                 {
-                    startKey = 
CliUtils.unescapeSQLString(child.getChild(0).getText());
+                    rawStartKey = 
CliUtils.unescapeSQLString(child.getChild(0).getText());
                     if (child.getChildCount() > 1)
-                        endKey = 
CliUtils.unescapeSQLString(child.getChild(1).getText());
+                        rawEndKey = 
CliUtils.unescapeSQLString(child.getChild(1).getText());
                 }
             }
             else
@@ -955,8 +955,9 @@ public class CliClient extends CliUserHe
         // set the key range
         KeyRange range = new KeyRange(limitCount);
         AbstractType keyComparator = this.cfKeysComparators.get(columnFamily);
-        range.setStart_key(getBytesAccordingToType(startKey, keyComparator))
-             .setEnd_key(getBytesAccordingToType(endKey, keyComparator));
+        ByteBuffer startKey = rawStartKey.isEmpty() ? 
FBUtilities.EMPTY_BYTE_BUFFER : getBytesAccordingToType(rawStartKey, 
keyComparator);
+        ByteBuffer endKey = rawEndKey.isEmpty() ? 
FBUtilities.EMPTY_BYTE_BUFFER : getBytesAccordingToType(rawEndKey, 
keyComparator);
+        range.setStart_key(startKey).setEnd_key(endKey);
 
         ColumnParent columnParent = new ColumnParent(columnFamily);
         List<KeySlice> keySlices = thriftClient.get_range_slices(columnParent, 
predicate, range, ConsistencyLevel.ONE);
@@ -1424,6 +1425,12 @@ public class CliClient extends CliUserHe
      */
     private ByteBuffer getBytesAccordingToType(String object, AbstractType 
comparator)
     {
+        // TODO there is tension here between using this function to generate 
default values,
+        // and using it to parse input.  For instance, normally we want to 
convert empty string
+        // to empty byte array for any type -- all types special case empty 
byte[] to mean
+        // "minimum value" -- but we also want timeuuid() to create a valid 
uuid for us.
+        // For now, this function takes the create-valid-values approach, and 
we leave
+        // other use cases to special case "" -> byte[0] before calling this.
         if (comparator instanceof LongType)
         {
             long longType;

Modified: 
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/cli/CliTest.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/cli/CliTest.java?rev=1035418&r1=1035417&r2=1035418&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/cli/CliTest.java
 (original)
+++ 
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/cli/CliTest.java
 Mon Nov 15 19:23:04 2010
@@ -125,7 +125,7 @@ public class CliTest extends CleanupHelp
             CliMain.processStatement(statement);
             String result = outStream.toString();
             // System.out.println("Result:\n" + result);
-            assertEquals("", errStream.toString());
+            assertEquals(errStream.toString() + " processing " + statement, 
"", errStream.toString());
             if (statement.startsWith("drop ") || statement.startsWith("create 
") || statement.startsWith("update "))
             {
                 
assertTrue(result.matches("(.{8})-(.{4})-(.{4})-(.{4})-(.{12})\n"));


Reply via email to