cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r1092687 [1/2] - in /cassandra/trunk: ./ contrib/ drivers/py/ drivers/py/cql/ drivers/py/test/ interface/thrift/gen-java/org/apache/cassandra/thrift/ lib/licenses/ src/java/org/apache/cassandra/cache/ src/java/org/apache/cassandra/cli/ src/...
Date Fri, 15 Apr 2011 12:48:16 GMT
Author: gdusbabek
Date: Fri Apr 15 12:48:15 2011
New Revision: 1092687

URL: http://svn.apache.org/viewvc?rev=1092687&view=rev
Log:
merge from 0.8

Added:
    cassandra/trunk/drivers/py/cql/cursor.py
      - copied unchanged from r1091883, cassandra/branches/cassandra-0.8/drivers/py/cql/cursor.py
    cassandra/trunk/lib/licenses/guava-r08.txt
      - copied unchanged from r1091883, cassandra/branches/cassandra-0.8/lib/licenses/guava-r08.txt
    cassandra/trunk/src/java/org/apache/cassandra/cli/CliCommandHelp.java
      - copied unchanged from r1092685, cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/CliCommandHelp.java
    cassandra/trunk/src/java/org/apache/cassandra/io/CompactionType.java
      - copied unchanged from r1092685, cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/io/CompactionType.java
    cassandra/trunk/src/resources/
      - copied from r1092685, cassandra/branches/cassandra-0.8/src/resources/
    cassandra/trunk/src/resources/org/
      - copied from r1092685, cassandra/branches/cassandra-0.8/src/resources/org/
    cassandra/trunk/src/resources/org/apache/
      - copied from r1092685, cassandra/branches/cassandra-0.8/src/resources/org/apache/
    cassandra/trunk/src/resources/org/apache/cassandra/
      - copied from r1092685, cassandra/branches/cassandra-0.8/src/resources/org/apache/cassandra/
    cassandra/trunk/src/resources/org/apache/cassandra/cli/
      - copied from r1092685, cassandra/branches/cassandra-0.8/src/resources/org/apache/cassandra/cli/
    cassandra/trunk/src/resources/org/apache/cassandra/cli/CliHelp.yaml
      - copied unchanged from r1092685, cassandra/branches/cassandra-0.8/src/resources/org/apache/cassandra/cli/CliHelp.yaml
Removed:
    cassandra/trunk/lib/licenses/guava-r05.txt
Modified:
    cassandra/trunk/   (props changed)
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/build.xml
    cassandra/trunk/contrib/   (props changed)
    cassandra/trunk/drivers/py/README
    cassandra/trunk/drivers/py/cql/__init__.py
    cassandra/trunk/drivers/py/cql/connection.py
    cassandra/trunk/drivers/py/cql/decoders.py
    cassandra/trunk/drivers/py/cql/errors.py
    cassandra/trunk/drivers/py/cql/marshal.py
    cassandra/trunk/drivers/py/cql/results.py
    cassandra/trunk/drivers/py/cqlsh
    cassandra/trunk/drivers/py/test/test_query_compression.py
    cassandra/trunk/drivers/py/test/test_query_preparation.py
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java   (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java   (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java   (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java   (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java   (props changed)
    cassandra/trunk/src/java/org/apache/cassandra/cache/AutoSavingCache.java
    cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g
    cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java
    cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java
    cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
    cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    cassandra/trunk/src/java/org/apache/cassandra/io/CompactionInfo.java
    cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java
    cassandra/trunk/test/long/org/apache/cassandra/db/LongCompactionSpeedTest.java
    cassandra/trunk/test/system/test_cql.py
    cassandra/trunk/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
    cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java

Propchange: cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 15 12:48:15 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
 /cassandra/branches/cassandra-0.7:1026516-1091087,1091503,1091542,1091654
 /cassandra/branches/cassandra-0.7.0:1053690-1055654
-/cassandra/branches/cassandra-0.8:1090935-1091782,1091884
+/cassandra/branches/cassandra-0.8:1090935-1092685
 /cassandra/tags/cassandra-0.7.0-rc3:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3:774578-796573
 /incubator/cassandra/branches/cassandra-0.4:810145-834239,834349-834350

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Fri Apr 15 12:48:15 2011
@@ -1,7 +1,8 @@
 0.8-dev
  * remove Avro RPC support (CASSANDRA-926)
  * adds support for columns that act as incr/decr counters 
-   (CASSANDRA-1072, 1937, 1944, 1936, 2101, 2093, 2288, 2105, 2384, 2236, 2342)
+   (CASSANDRA-1072, 1937, 1944, 1936, 2101, 2093, 2288, 2105, 2384, 2236, 2342,
+   2454)
  * CQL (CASSANDRA-1703, 1704, 1705, 1706, 1707, 1708, 1710, 1711, 1940, 
    2124, 2302, 2277)
  * avoid double RowMutation serialization on write path (CASSANDRA-1800)
@@ -23,6 +24,7 @@
  * compaction throttling (CASSANDRA-2156)
  * add key type information and alias (CASSANDRA-2311, 2396)
  * cli no longer divides read_repair_chance by 100 (CASSANDRA-2458)
+ * made CompactionInfo.getTaskType return an enum (CASSANDRA-2482)
 
 
 0.7.5

Modified: cassandra/trunk/build.xml
URL: http://svn.apache.org/viewvc/cassandra/trunk/build.xml?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/build.xml (original)
+++ cassandra/trunk/build.xml Fri Apr 15 12:48:15 2011
@@ -27,6 +27,7 @@
     <property name="basedir" value="."/>
     <property name="build.src" value="${basedir}/src"/>
     <property name="build.src.java" value="${basedir}/src/java"/>
+    <property name="build.src.resources" value="${basedir}/src/resources"/>
     <property name="build.src.driver" value="${basedir}/drivers/java/src" />
     <property name="avro.src" value="${basedir}/src/avro"/>
     <property name="build.src.gen-java" value="${basedir}/src/gen-java"/>
@@ -383,7 +384,9 @@
             <src path="${build.src.driver}" />
             <classpath refid="cassandra.classpath"/>
         </javac>
-
+        <copy todir="${build.classes.main}">
+            <fileset dir="${build.src.resources}" />
+        </copy>
         <taskdef name="paranamer" classname="com.thoughtworks.paranamer.ant.ParanamerGeneratorTask">
           <classpath refid="cassandra.classpath" />
         </taskdef>

Propchange: cassandra/trunk/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 15 12:48:15 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/contrib:922689-1052356,1052358-1053452,1053454,1053456-1068009
 /cassandra/branches/cassandra-0.7/contrib:1026516-1091087,1091503,1091542,1091654
 /cassandra/branches/cassandra-0.7.0/contrib:1053690-1055654
-/cassandra/branches/cassandra-0.8/contrib:1090935-1091782,1091884
+/cassandra/branches/cassandra-0.8/contrib:1090935-1092685
 /cassandra/tags/cassandra-0.7.0-rc3/contrib:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/contrib:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/contrib:810145-810987,810994-834239,834349-834350

Modified: cassandra/trunk/drivers/py/README
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/README?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/README (original)
+++ cassandra/trunk/drivers/py/README Fri Apr 15 12:48:15 2011
@@ -1,2 +1,28 @@
-Python language driver for CQL, a SQL-alike query language for Apache
-Cassandra.
+A Python driver for CQL that adheres to py-dbapi v2
+ (PEP249, Python Database API Specification v2.0:  http://www.python.org/dev/peps/pep-0249/).
+
+Standard use:
+ >> import cql
+ >> con = cql.connect(host, port, keyspace)
+ >> cursor = con.cursor()
+ >> cursor.execute("CQL QUERY", {kw=Foo, kw2=Bar, etc...})
+
+    - cursor.description  # None initially, list of N tuples that represent
+                              the N columns in a row after an execute. Only 
+                              contains type and name info, not values.
+    - cursor.rowcount     # -1 initially, N after an execute
+    - cursor.arraysize    # variable size of a fetchmany call
+    - cursor.fetchone()   # returns  a single row
+    - cursor.fetchmany()  # returns  self.arraysize # of rows
+    - cursor.fetchall()   # returns  all rows, don't do this.
+
+ >> cursor.execute("ANOTHER QUERY", **more_kwargs)
+ >> for row in cursor:  # Iteration is equivalent to lots of fetchone() calls
+ >>     doRowMagic(row)
+
+ >> cursor.close()
+ >> con.close()
+
+Query substitution:
+ - Use named parameters and a dictionary of names and values. 
+    e.g. execute("SELECT * FROM CF WHERE name=:name", name="Foo")

Modified: cassandra/trunk/drivers/py/cql/__init__.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cql/__init__.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cql/__init__.py (original)
+++ cassandra/trunk/drivers/py/cql/__init__.py Fri Apr 15 12:48:15 2011
@@ -15,9 +15,82 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""
-Cassandra Query Language driver
-"""
+import exceptions
+import datetime
+
+import connection
+import marshal
+
+
+# dbapi Error hierarchy
+
+class Warning(exceptions.StandardError): pass
+class Error  (exceptions.StandardError): pass
+
+class InterfaceError(Error): pass
+class DatabaseError (Error): pass
+
+class DataError        (DatabaseError): pass
+class OperationalError (DatabaseError): pass
+class IntegrityError   (DatabaseError): pass
+class InternalError    (DatabaseError): pass
+class ProgrammingError (DatabaseError): pass
+class NotSupportedError(DatabaseError): pass
+
+
+# Module constants
+
+apilevel = 1.0
+threadsafety = 1 # Threads may share the module, but not connections/cursors.
+paramstyle = 'named'
+
+ROW_KEY = "Row Key"
+
+# TODO: Pull connections out of a pool instead.
+def connect(host, port=9160, keyspace='system', user=None, password=None):
+    return connection.Connection(host, port, keyspace, user, password)
+
+# Module Type Objects and Constructors
+
+Date = datetime.date
+
+Time = datetime.time
+
+Timestamp = datetime.datetime
+
+Binary = buffer
+
+def DateFromTicks(ticks):
+    return Date(*time.localtime(ticks)[:3])
+
+def TimeFromTicks(ticks):
+    return Time(*time.localtime(ticks)[3:6])
+
+def TimestampFromTicks(ticks):
+    return Timestamp(*time.localtime(ticks)[:6])
+
+class DBAPITypeObject:
+
+    def __init__(self, *values):
+        self.values = values
+
+    def __cmp__(self,other):
+        if other in self.values:
+            return 0
+        if other < self.values:
+            return 1
+        else:
+            return -1
+
+STRING = DBAPITypeObject(marshal.BYTES_TYPE, marshal.ASCII_TYPE, marshal.UTF8_TYPE)
+
+BINARY = DBAPITypeObject(marshal.BYTES_TYPE, marshal.UUID_TYPE, marshal.LEXICAL_UUID_TYPE)
+
+NUMBER = DBAPITypeObject(marshal.LONG_TYPE, marshal.INTEGER_TYPE)
+
+DATETIME = DBAPITypeObject(marshal.TIME_UUID_TYPE)
+
+ROWID = DBAPITypeObject(marshal.BYTES_TYPE, marshal.ASCII_TYPE, marshal.UTF8_TYPE,
+                        marshal.INTEGER_TYPE, marshal.LONG_TYPE, marshal.UUID_TYPE,
+                        marshal.LEXICAL_UUID_TYPE, marshal.TIME_UUID_TYPE)
 
-from connection import Connection
-from connection_pool import ConnectionPool

Modified: cassandra/trunk/drivers/py/cql/connection.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cql/connection.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cql/connection.py (original)
+++ cassandra/trunk/drivers/py/cql/connection.py Fri Apr 15 12:48:15 2011
@@ -15,183 +15,69 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from os.path import exists, abspath, dirname, join
+from cursor import Cursor
+from cassandra import Cassandra
 from thrift.transport import TTransport, TSocket
 from thrift.protocol import TBinaryProtocol
-from thrift.Thrift import TApplicationException
-from errors import CQLException, InvalidCompressionScheme
-from marshal import prepare
-from decoders import SchemaDecoder
-from results import RowsProxy
-import zlib, re
-
-from cassandra import Cassandra
-from cassandra.ttypes import Compression, InvalidRequestException, \
-                             CqlResultType, AuthenticationRequest, \
-                             SchemaDisagreementException
-    
-COMPRESSION_SCHEMES = ['GZIP', 'NONE']
-DEFAULT_COMPRESSION = 'GZIP'
 
-__all__ = ['COMPRESSION_SCHEMES', 'DEFAULT_COMPRESSION', 'Connection']
 
 class Connection(object):
-    """
-    CQL connection object.
-    
-    Example usage:
-    >>> conn = Connection("localhost", keyspace="Keyspace1")
-    >>> r = conn.execute('SELECT "age" FROM Users')
-    >>> for row in r.rows:
-    ...     for column in row.columns:
-    ...         print "%s is %s years of age" % (r.key, column.age)
-    """
-    _keyspace_re = re.compile("USE (\w+);?", re.I | re.M)
-    _cfamily_re = re.compile("\s*SELECT\s+.+\s+FROM\s+[\']?(\w+)", re.I | re.M)
-    _ddl_re = re.compile("\s*(CREATE|ALTER|DROP)\s+", re.I | re.M)
-    
-    def __init__(self, host, port=9160, keyspace=None, username=None,
-                 password=None, decoder=None):
+
+    def __init__(self, host, port, keyspace, user=None, password=None):
         """
         Params:
         * host .........: hostname of Cassandra node.
-        * port .........: port number to connect to (optional).
-        * keyspace .....: keyspace name (optional).
-        * username .....: username used in authentication (optional).
+        * port .........: port number to connect to.
+        * keyspace .....: keyspace to connect to.
+        * user .........: username used in authentication (optional).
         * password .....: password used in authentication (optional).
-        * decoder ......: result decoder instance (optional, defaults to none).
         """
+        self.host = host
+        self.port = port
+        self.keyspace = keyspace
+
         socket = TSocket.TSocket(host, port)
         self.transport = TTransport.TFramedTransport(socket)
         protocol = TBinaryProtocol.TBinaryProtocolAccelerated(self.transport)
         self.client = Cassandra.Client(protocol)
+
         socket.open()
-        
-        # XXX: "current" is probably a misnomer.
-        self._cur_keyspace = None
-        self._cur_column_family = None
-        
-        if username and password:
-            credentials = {"username": username, "password": password}
-            self.client.login(AuthenticationRequest(credentials=credentials))
-        
-        if keyspace:
-            self.execute('USE %s;' % keyspace)
-            self._cur_keyspace = keyspace
-        
-        if not decoder:
-            self.decoder = SchemaDecoder(self.__get_schema())
-        else:
-            self.decoder = decoder
-
-    def __get_schema(self):
-        def columns(metadata):
-            results = {}
-            for col in metadata:
-                results[col.name] = col.validation_class
-            return results
-        
-        def column_families(cf_defs):
-            cfresults = {}
-            for cf in cf_defs:
-                cfresults[cf.name] = {"comparator": cf.comparator_type}
-                cfresults[cf.name]["default_validation_class"] = \
-                         cf.default_validation_class
-                cfresults[cf.name]["key_validation_class"] = \
-                         cf.key_validation_class
-                cfresults[cf.name]["columns"] = columns(cf.column_metadata)
-            return cfresults
-        
-        schema = {}
-        for ksdef in self.client.describe_keyspaces():
-            schema[ksdef.name] = column_families(ksdef.cf_defs)
-        return schema        
-            
-    def prepare(self, query, *args):
-        prepared_query = prepare(query, *args)
-        
-        # Snag the keyspace or column family and stash it for later use in
-        # decoding columns.  These regexes don't match every query, but the
-        # current column family only needs to be current for SELECTs.
-        match = Connection._cfamily_re.match(prepared_query)
-        if match:
-            self._cur_column_family = match.group(1)
-            return prepared_query
-        match = Connection._keyspace_re.match(prepared_query)
-        if match:
-            self._cur_keyspace = match.group(1)
-            return prepared_query
-        
-        # If this is a CREATE, then refresh the schema for decoding purposes.
-        match = Connection._ddl_re.match(prepared_query)
-        if match:
-            if isinstance(self.decoder, SchemaDecoder):
-                self.decoder.schema = self.__get_schema()
-                
-        return prepared_query
+        self.open_socket = True
 
-    def execute(self, query, *args, **kwargs):
-        """
-        Execute a CQL query on a remote node.
-        
-        Params:
-        * query .........: CQL query string.
-        * args ..........: Query parameters.
-        * compression ...: Query compression type (optional).
-        """
-        if kwargs.has_key("compression"):
-            compress = kwargs.get("compression").upper()
-        else:
-            compress = DEFAULT_COMPRESSION
-        
-        compressed_query = Connection.compress_query(self.prepare(query, *args),
-                                                     compress)
-        request_compression = getattr(Compression, compress)
-
-        try:
-            response = self.client.execute_cql_query(compressed_query,
-                                                     request_compression)
-        except InvalidRequestException, ire:
-            raise CQLException("Bad Request: %s" % ire.why)
-        except SchemaDisagreementException, sde:
-            raise CQLException("schema versions disagree, (try again later).")
-        except TApplicationException, tapp:
-            raise CQLException("Internal application error")
-        except Exception, exc:
-            raise CQLException(exc)
-
-        if response.type == CqlResultType.ROWS:
-            return RowsProxy(response.rows,
-                             self._cur_keyspace,
-                             self._cur_column_family,
-                             self.decoder)
-        
-        if response.type == CqlResultType.INT:
-            return response.num
+        if user and password:
+            credentials = {"username": user, "password": password}
+            self.client.login(AuthenticationRequest(credentials=credentials))
 
-        return None
+        if keyspace:
+            c = self.cursor()
+            c.execute('USE %s;' % keyspace)
+            c.close()
+
+    def __str__(self):
+        return "{host: '%s:%s', keyspace: '%s'}"%(self.host,self.port,self.keyspace)
+
+    ###
+    # Connection API
+    ###
 
     def close(self):
+        if not self.open_socket:
+            raise InternalError("Connection has been closed.")
+
         self.transport.close()
-        
-    def is_open(self):
-        return self.transport.isOpen()
+        self.open_socket = False
 
-    @classmethod
-    def compress_query(cls, query, compression):
+    def commit(self):
         """
-        Returns a query string compressed with the specified compression type.
-        
-        Params:
-        * query .........: The query string to compress.
-        * compression ...: Type of compression to use.
+        'Database modules that do not support transactions should
+          implement this method with void functionality.'
         """
-        if not compression in COMPRESSION_SCHEMES:
-            raise InvalidCompressionScheme(compression)
+        return
+
+    def rollback(self):
+        raise NotSupportedError("Rollback functionality not present in Cassandra.")
 
-        if compression == 'GZIP':
-            return zlib.compress(query)
-            
-        return query
-    
-# vi: ai ts=4 tw=0 sw=4 et
+    def cursor(self):
+        if not self.open_socket:
+            raise InternalError("Connection has been closed.")
+        return Cursor(self)

Modified: cassandra/trunk/drivers/py/cql/decoders.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cql/decoders.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cql/decoders.py (original)
+++ cassandra/trunk/drivers/py/cql/decoders.py Fri Apr 15 12:48:15 2011
@@ -15,62 +15,53 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from os.path import abspath, dirname, join
-from marshal import unmarshal
+import cql
+from marshal import (unmarshallers, unmarshal_noop)
 
-class BaseDecoder(object):
-    def decode_column(self, keyspace, column_family, name, value):
-        raise NotImplementedError()
-        
-    def decode_key(self, keyspace, column_family, key):
-        raise NotImplementedError()
-    
-class NoopDecoder(BaseDecoder):
-    def decode_column(self, keyspace, column_family, name, value):
-        return (name, value)
-        
-    def decode_key(self, keyspace, column_family, key):
-        return key
-
-class SchemaDecoder(BaseDecoder):
+class SchemaDecoder(object):
     """
     Decode binary column names/values according to schema.
     """
     def __init__(self, schema={}):
         self.schema = schema
-        
+
     def __get_column_family_def(self, keyspace, column_family):
         if self.schema.has_key(keyspace):
             if self.schema[keyspace].has_key(column_family):
                 return self.schema[keyspace][column_family]
         return None
-    
+
     def __comparator_for(self, keyspace, column_family):
         cfam = self.__get_column_family_def(keyspace, column_family)
-        if cfam and cfam.has_key("comparator"):
+        if cfam and "comparator" in cfam:
             return cfam["comparator"]
         return None
-    
+
     def __validator_for(self, keyspace, column_family, name):
         cfam = self.__get_column_family_def(keyspace, column_family)
         if cfam:
-            if cfam["columns"].has_key(name):
+            if name in cfam["columns"]:
                 return cfam["columns"][name]
-            else:
-                return cfam["default_validation_class"]
+            return cfam["default_validation_class"]
         return None
-        
-    def __keytype_for(self, keyspace, column_family, key):
+
+    def __keytype_for(self, keyspace, column_family):
         cfam = self.__get_column_family_def(keyspace, column_family)
-        if cfam and cfam.has_key("key_validation_class"):
+        if cfam and "key_validation_class" in cfam:
             return cfam["key_validation_class"]
         return None
 
-    def decode_column(self, keyspace, column_family, name, value):
+    def decode_row(self, keyspace, column_family, row):
+        key_type = self.__keytype_for(keyspace, column_family)
+        key = unmarshallers.get(key_type, unmarshal_noop)(row.key)
+        description = [(cql.ROW_KEY, key_type, None, None, None, None, None, False)]
+
         comparator = self.__comparator_for(keyspace, column_family)
-        validator = self.__validator_for(keyspace, column_family, name)
-        return (unmarshal(name, comparator), unmarshal(value, validator))
-        
-    def decode_key(self, keyspace, column_family, key):
-        return unmarshal(key, self.__keytype_for(keyspace, column_family, key))
-    
+        unmarshal = unmarshallers.get(comparator, unmarshal_noop)
+        values = [key]
+        for column in row.columns:
+            description.append((unmarshal(column.name), comparator, None, None, None, None, True))
+            validator = self.__validator_for(keyspace, column_family, column.name)
+            values.append(unmarshallers.get(validator, unmarshal_noop)(column.value))
+
+        return description, values

Modified: cassandra/trunk/drivers/py/cql/errors.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cql/errors.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cql/errors.py (original)
+++ cassandra/trunk/drivers/py/cql/errors.py Fri Apr 15 12:48:15 2011
@@ -15,8 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-__all__ = ['InvalidCompressionScheme', 'CQLException', 'InvalidQueryFormat']
+__all__ = ['InvalidCompressionScheme', 'InvalidQueryFormat']
 
 class InvalidCompressionScheme(Exception): pass
 class InvalidQueryFormat(Exception): pass
-class CQLException(Exception): pass

Modified: cassandra/trunk/drivers/py/cql/marshal.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cql/marshal.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cql/marshal.py (original)
+++ cassandra/trunk/drivers/py/cql/marshal.py Fri Apr 15 12:48:15 2011
@@ -15,68 +15,75 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import re
+import struct
 from uuid import UUID
-from StringIO import StringIO
-from errors import InvalidQueryFormat
-from struct import unpack
-
-__all__ = ['prepare', 'marshal', 'unmarshal']
-
-def prepare(query, *args):
-    result = StringIO()
-    index = query.find('?')
-    oldindex = 0
-    count = 0
-    
-    while (index >= 0):
-        result.write(query[oldindex:index])
-        try:
-            result.write(marshal(args[count]))
-        except IndexError:
-            raise InvalidQueryFormat("not enough arguments in substitution")
-        
-        oldindex = index + 1
-        index = query.find('?', index + 1)
-        count += 1
-    result.write(query[oldindex:])
-    
-    if count < len(args):
-        raise InvalidQueryFormat("too many arguments in substitution")
-    
-    return result.getvalue()
+
+import cql
+
+__all__ = ['prepare', 'marshal', 'unmarshal_noop', 'unmarshallers']
+
+if hasattr(struct, 'Struct'): # new in Python 2.5
+   _have_struct = True
+   _long_packer = struct.Struct('>q')
+else:
+    _have_struct = False
+
+_param_re = re.compile(r"(?<!strategy_options)(:[a-zA-Z_][a-zA-Z0-9_]*)", re.M)
+
+BYTES_TYPE = "org.apache.cassandra.db.marshal.BytesType"
+ASCII_TYPE = "org.apache.cassandra.db.marshal.AsciiType"
+UTF8_TYPE = "org.apache.cassandra.db.marshal.UTF8Type"
+INTEGER_TYPE = "org.apache.cassandra.db.marshal.IntegerType"
+LONG_TYPE = "org.apache.cassandra.db.marshal.LongType"
+UUID_TYPE = "org.apache.cassandra.db.marshal.UUIDType"
+LEXICAL_UUID_TYPE = "org.apache.cassandra.db.marshal.LexicalType"
+TIME_UUID_TYPE = "org.apache.cassandra.db.marshal.TimeUUIDType"
+
+def prepare(query, params):
+    # For every match of the form ":param_name", call marshal
+    # on kwargs['param_name'] and replace that section of the query
+    # with the result
+    new, count = re.subn(_param_re, lambda m: marshal(params[m.group(1)[1:]]), query)
+    if len(params) > count:
+        raise cql.ProgrammingError("More keywords were provided than parameters")
+    return new
 
 def marshal(term):
-    if isinstance(term, (long,int)):
-        return "%d" % term
-    elif isinstance(term, unicode):
+    if isinstance(term, unicode):
         return "'%s'" % __escape_quotes(term.encode('utf8'))
     elif isinstance(term, str):
         return "'%s'" % __escape_quotes(term)
-    elif isinstance(term, UUID):
+    else:
         return str(term)
+
+def unmarshal_noop(bytestr):
+    return bytestr
+
+def unmarshal_utf8(bytestr):
+    return bytestr.decode("utf8")
+
+def unmarshal_int(bytestr):
+    return decode_bigint(bytestr)
+
+def unmarshal_long(bytestr):
+    if _have_struct:
+        return _long_packer.unpack(bytestr)[0]
     else:
-        return str(term)    
-    
-def unmarshal(bytestr, typestr):
-    if typestr == "org.apache.cassandra.db.marshal.BytesType":
-        return bytestr
-    elif typestr == "org.apache.cassandra.db.marshal.AsciiType":
-        return bytestr
-    elif typestr == "org.apache.cassandra.db.marshal.UTF8Type":
-        return bytestr.decode("utf8")
-    elif typestr == "org.apache.cassandra.db.marshal.IntegerType":
-        return decode_bigint(bytestr)
-    elif typestr == "org.apache.cassandra.db.marshal.LongType":
         return unpack(">q", bytestr)[0]
-    elif typestr == "org.apache.cassandra.db.marshal.UUIDType":
-        return UUID(bytes=bytestr)
-    elif typestr == "org.apache.cassandra.db.marshal.LexicalUUIDType":
-        return UUID(bytes=bytestr)
-    elif typestr == "org.apache.cassandra.db.marshal.TimeUUIDType":
-        return UUID(bytes=bytestr)
-    else:
-        return bytestr
-    
+
+def unmarshal_uuid(bytestr):
+    return UUID(bytes=bytestr)
+
+unmarshallers = {BYTES_TYPE:        unmarshal_noop,
+                 ASCII_TYPE:        unmarshal_noop,
+                 UTF8_TYPE:         unmarshal_utf8,
+                 INTEGER_TYPE:      unmarshal_int,
+                 LONG_TYPE:         unmarshal_long,
+                 UUID_TYPE:         unmarshal_uuid,
+                 LEXICAL_UUID_TYPE: unmarshal_uuid,
+                 TIME_UUID_TYPE:    unmarshal_uuid}
+
 def decode_bigint(term):
     val = int(term.encode('hex'), 16)
     if (ord(term[0]) & 128) != 0:

Modified: cassandra/trunk/drivers/py/cql/results.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cql/results.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cql/results.py (original)
+++ cassandra/trunk/drivers/py/cql/results.py Fri Apr 15 12:48:15 2011
@@ -15,84 +15,48 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-class RowsProxy(object):
-    def __init__(self, rows, keyspace, cfam, decoder):
+class ResultSet(object):
+
+    def __init__(self, rows, keyspace, column_family, decoder):
         self.rows = rows
-        self.keyspace = keyspace
-        self.cfam = cfam
+        self.ks = keyspace
+        self.cf = column_family
         self.decoder = decoder
 
-    def __len__(self):
-        return len(self.rows)
-        
-    def __getitem__(self, idx):
-        return Row(self.rows[idx].key,
-                   self.rows[idx].columns,
-                   self.keyspace,
-                   self.cfam,
-                   self.decoder)
-    
-    def __iter__(self):
-        for r in self.rows:
-            yield Row(r.key, r.columns, self.keyspace, self.cfam, self.decoder)
+        # We need to try to parse the first row to set the description
+        if len(self.rows) > 0:
+            self.description, self._first_vals = self.decoder.decode_row(self.ks, self.cf, self.rows[0])
+        else:
+            self.description, self._first_vals = (None, None)
 
-class Row(object):
-    def __init__(self, key, columns, keyspace, cfam, decoder):
-        self._key = key
-        self.keyspace = keyspace
-        self.cfam = cfam
-        self.decoder = decoder
-        self.columns = ColumnsProxy(columns, keyspace, cfam, decoder)
-    
-    def __get_key(self):
-        return self.decoder.decode_key(self.keyspace, self.cfam, self._key)
-    key = property(__get_key)
-    
-    def __iter__(self):
-        return iter(self.columns)
-    
-    def __getitem__(self, idx):
-        return self.columns[idx]
-    
     def __len__(self):
-        return len(self.columns)
+        return len(self.rows)
 
-class ColumnsProxy(object):
-    def __init__(self, columns, keyspace, cfam, decoder):
-        self.columns = columns
-        self.keyspace = keyspace
-        self.cfam = cfam
-        self.decoder = decoder
-        
-    def __len__(self):
-        return len(self.columns)
-    
     def __getitem__(self, idx):
-        return Column(self.decoder.decode_column(self.keyspace,
-                                                 self.cfam,
-                                                 self.columns[idx].name,
-                                                 self.columns[idx].value))
+        if isinstance(idx, int):
+            if idx == 0 and self._first_vals:
+                return self._first_vals
+            self.description, vals = self.decoder.decode_row(self.ks, self.cf, self.rows[idx])
+            return vals
+        elif isinstance(idx, slice):
+            num_rows = len(self.rows)
+            results = []
+            for i in xrange(idx.start, min(len(self.rows), idx.stop)):
+                if i == 0 and self._first_vals:
+                    vals = self._first_vals
+                else:
+                    self.description, vals = self.decoder.decode_row(self.ks, self.cf, self.rows[i])
+                results.append(vals)
+            return results
+        else:
+            raise TypeError
 
     def __iter__(self):
-        for c in self.columns:
-            yield Column(self.decoder.decode_column(self.keyspace,
-                                                    self.cfam,
-                                                    c.name,
-                                                    c.value))
-    
-    def __str__(self):
-        return "ColumnsProxy(columns=%s)" % self.columns
-    
-    def __repr__(self):
-        return str(self)
-
-class Column(object):
-    def __init__(self, (name, value)):
-        self.name = name
-        self.value = value
-    
-    def __str__(self):
-        return "Column(%s, %s)" % (self.name, self.value)
-    
-    def __repr__(self):
-        return str(self)
+        idx = 0
+        for r in self.rows:
+            if idx == 0 and self._first_vals:
+                yield self._first_vals
+            else:
+                self.description, vals = self.decoder.decode_row(self.ks, self.cf, r)
+                yield vals
+            idx += 1

Modified: cassandra/trunk/drivers/py/cqlsh
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cqlsh?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cqlsh (original)
+++ cassandra/trunk/drivers/py/cqlsh Fri Apr 15 12:48:15 2011
@@ -26,14 +26,11 @@ import os
 import re
 
 try:
-    from cql import Connection
-    from cql.errors import CQLException
-    from cql.results import RowsProxy
+    import cql
 except ImportError:
     sys.path.append(os.path.abspath(os.path.dirname(__file__)))
-    from cql import Connection
-    from cql.errors import CQLException
-    from cql.results import RowsProxy
+    import cql
+from cql.results import ResultSet
 
 HISTORY = os.path.join(os.path.expanduser('~'), '.cqlsh')
 CQLTYPES = ("bytes", "ascii", "utf8", "timeuuid", "uuid", "long", "int")
@@ -55,10 +52,7 @@ class Shell(cmd.Cmd):
     def __init__(self, hostname, port, color=False, username=None,
             password=None):
         cmd.Cmd.__init__(self)
-        self.conn = Connection(hostname,
-                               port=port,
-                               username=username,
-                               password=password)
+        self.conn = cql.connect(hostname, port, user=username, password=password)
                                
         if os.path.exists(HISTORY):
             readline.read_history_file(HISTORY)
@@ -92,10 +86,11 @@ class Shell(cmd.Cmd):
         statement = self.get_statement(arg)
         if not statement: return
         
-        result = self.conn.execute(statement)
+        cursor = self.conn.cursor()
+        cursor.execute(statement)
         
-        if isinstance(result, RowsProxy):
-            for row in result:
+        if isinstance(cursor.result, ResultSet):
+            for row in cursor.result.rows:
                 self.printout(row.key, BLUE, False)
                 for column in row.columns:
                     self.printout(" | ", newline=False)
@@ -105,7 +100,7 @@ class Shell(cmd.Cmd):
                     self.printout(repr(column.value), YELLOW, False)
                 self.printout("")
         else:
-            if result: print result
+            if cursor.result: print cursor.result[0]
 
     def emptyline(self):
         pass
@@ -221,7 +216,7 @@ if __name__ == '__main__':
         except SystemExit:
             readline.write_history_file(HISTORY)
             break
-        except CQLException, cqlerr:
+        except cql.Error, cqlerr:
             shell.printerr(str(cqlerr), color=RED)
         except KeyboardInterrupt:
             shell.reset_statement()

Modified: cassandra/trunk/drivers/py/test/test_query_compression.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/test/test_query_compression.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/test/test_query_compression.py (original)
+++ cassandra/trunk/drivers/py/test/test_query_compression.py Fri Apr 15 12:48:15 2011
@@ -15,18 +15,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from os.path import abspath, exists, join, dirname
-
-if exists(join(abspath(dirname(__file__)), '..', 'cql')):
-    import sys; sys.path.append(join(abspath(dirname(__file__)), '..'))
-
 import unittest, zlib
-from cql import Connection
 
 class TestCompression(unittest.TestCase):
     def test_gzip(self):
         "compressing a string w/ gzip"
         query = "SELECT \"foo\" FROM Standard1 WHERE KEY = \"bar\";"
-        compressed = Connection.compress_query(query, 'GZIP')
+        compressed = zlib.compress(query)
         decompressed = zlib.decompress(compressed)
         assert query == decompressed, "Decompressed query did not match"

Modified: cassandra/trunk/drivers/py/test/test_query_preparation.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/test/test_query_preparation.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/test/test_query_preparation.py (original)
+++ cassandra/trunk/drivers/py/test/test_query_preparation.py Fri Apr 15 12:48:15 2011
@@ -16,26 +16,26 @@
 # limitations under the License.
 
 import unittest
+import cql
 from cql.marshal import prepare
-from cql.errors import InvalidQueryFormat
 
 # TESTS[i] ARGUMENTS[i] -> STANDARDS[i]
 TESTS = (
 """
-SELECT ?,?,?,? FROM ColumnFamily WHERE KEY = ? AND 'col' = ?;
+SELECT :a,:b,:c,:d FROM ColumnFamily WHERE KEY = :e AND 'col' = :f;
 """,
 """
 USE Keyspace;
 """,
 """
-SELECT ?..? FROM ColumnFamily;
+SELECT :a..:b FROM ColumnFamily;
 """,
 )
 
 ARGUMENTS = (
-    (1, 3, long(1000), long(3000), "key", unicode("val")),
-    tuple(),
-    ("a'b", "c'd'e"),
+    {'a': 1, 'b': 3, 'c': long(1000), 'd': long(3000), 'e': "key", 'f': unicode("val")},
+    {},
+    {'a': "a'b", 'b': "c'd'e"},
 )
 
 STANDARDS = (
@@ -54,13 +54,12 @@ class TestPrepare(unittest.TestCase):
     def test_prepares(self):
         "test prepared queries against known standards"
         for (i, test) in enumerate(TESTS):
-            a = prepare(test, *ARGUMENTS[i])
+            a = prepare(test, **ARGUMENTS[i])
             b = STANDARDS[i]
             assert a == b, "\n%s !=\n%s" % (a, b)
-    
+
     def test_bad(self):
         "ensure bad calls raise exceptions"
-        self.assertRaises(InvalidQueryFormat, prepare, "? ?", 1)
-        self.assertRaises(InvalidQueryFormat, prepare, "? ?", 1, 2, 3)
-        self.assertRaises(InvalidQueryFormat, prepare, "none", 1)
-
+        self.assertRaises(KeyError, prepare, ":a :b", a=1)
+        self.assertRaises(cql.ProgrammingError, prepare, ":a :b", a=1, b=2, c=3)
+        self.assertRaises(cql.ProgrammingError, prepare, "none", a=1)

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 15 12:48:15 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
 /cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1026516-1091087,1091503,1091542,1091654
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090935-1091782,1091884
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090935-1092685
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/Cassandra.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/Cassandra.java:810145-834239,834349-834350

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 15 12:48:15 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
 /cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1026516-1091087,1091503,1091542,1091654
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090935-1091782,1091884
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090935-1092685
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/column_t.java:774578-792198
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/Column.java:810145-834239,834349-834350

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 15 12:48:15 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
 /cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1026516-1091087,1091503,1091542,1091654
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090935-1091782,1091884
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090935-1092685
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:810145-834239,834349-834350

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 15 12:48:15 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
 /cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1026516-1091087,1091503,1091542,1091654
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090935-1091782,1091884
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090935-1092685
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:810145-834239,834349-834350

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 15 12:48:15 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
 /cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1026516-1091087,1091503,1091542,1091654
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090935-1091782,1091884
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090935-1092685
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/superColumn_t.java:774578-792198
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/SuperColumn.java:810145-834239,834349-834350

Modified: cassandra/trunk/src/java/org/apache/cassandra/cache/AutoSavingCache.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cache/AutoSavingCache.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cache/AutoSavingCache.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cache/AutoSavingCache.java Fri Apr 15 12:48:15 2011
@@ -36,6 +36,7 @@ import org.apache.cassandra.db.ColumnFam
 import org.apache.cassandra.db.CompactionManager;
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.io.CompactionInfo;
+import org.apache.cassandra.io.CompactionType;
 import org.apache.cassandra.io.util.BufferedRandomAccessFile;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.service.StorageService;
@@ -203,9 +204,18 @@ public abstract class AutoSavingCache<K,
                 bytes += translateKey(key).remaining();
             // an approximation -- the keyset can change while saving
             estimatedTotalBytes = bytes;
+            CompactionType type;
+
+            if (cacheType.equals(ColumnFamilyStore.CacheType.KEY_CACHE_TYPE)) 
+                type = CompactionType.KEY_CACHE_SAVE;
+            else if (cacheType.equals(ColumnFamilyStore.CacheType.ROW_CACHE_TYPE))
+                type = CompactionType.ROW_CACHE_SAVE;
+            else
+                type = CompactionType.UNKNOWN;
+
             info = new CompactionInfo(ksname,
                                       cfname,
-                                      "Save " + getCachePath().getName(),
+                                      type,
                                       0,
                                       estimatedTotalBytes);
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g Fri Apr 15 12:48:15 2011
@@ -119,7 +119,7 @@ package org.apache.cassandra.cli;
 
         if (e instanceof NoViableAltException)
         {
-            errorMessage = "Command not found: `" + this.input + "`. Type 'help' or '?' for help.";
+            errorMessage = "Command not found: `" + this.input + "`. Type 'help;' or '?' for help.";
         }
         else
         {

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java Fri Apr 15 12:48:15 2011
@@ -17,7 +17,9 @@
  */
 package org.apache.cassandra.cli;
 
+import java.io.IOError;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
@@ -34,6 +36,7 @@ import org.apache.cassandra.db.ColumnFam
 import org.apache.cassandra.db.CompactionManagerMBean;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.io.CompactionInfo;
+import org.apache.cassandra.io.CompactionType;
 import org.apache.cassandra.locator.SimpleSnitch;
 import org.apache.cassandra.service.StorageProxy;
 import org.apache.cassandra.thrift.*;
@@ -43,9 +46,13 @@ import org.apache.cassandra.utils.FBUtil
 import org.apache.cassandra.utils.UUIDGen;
 import org.apache.thrift.TBaseHelper;
 import org.apache.thrift.TException;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.Loader;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Yaml;
 
 // Cli Client Side Library
-public class CliClient extends CliUserHelp
+public class CliClient
 {
 
     /**
@@ -98,6 +105,34 @@ public class CliClient extends CliUserHe
         STRATEGY_OPTIONS
     }
 
+    /*
+        * the <i>add column family</i> command requires a list of arguments,
+        *  this enum defines which arguments are valid.
+        */
+    protected enum ColumnFamilyArgument
+    {
+        COLUMN_TYPE,
+        COMPARATOR,
+        SUBCOMPARATOR,
+        COMMENT,
+        ROWS_CACHED,
+        ROW_CACHE_SAVE_PERIOD,
+        KEYS_CACHED,
+        KEY_CACHE_SAVE_PERIOD,
+        READ_REPAIR_CHANCE,
+        GC_GRACE,
+        COLUMN_METADATA,
+        MEMTABLE_OPERATIONS,
+        MEMTABLE_THROUGHPUT,
+        MEMTABLE_FLUSH_AFTER,
+        DEFAULT_VALIDATION_CLASS,
+        MIN_COMPACTION_THRESHOLD,
+        MAX_COMPACTION_THRESHOLD,
+        REPLICATE_ON_WRITE,
+        ROW_CACHE_PROVIDER,
+        KEY_VALIDATION_CLASS
+    }
+
     private static final String DEFAULT_PLACEMENT_STRATEGY = "org.apache.cassandra.locator.NetworkTopologyStrategy";
 
     private Cassandra.Client thriftClient = null;
@@ -106,13 +141,45 @@ public class CliClient extends CliUserHe
     private String username = null;
     private Map<String, KsDef> keyspacesMap = new HashMap<String, KsDef>();
     private Map<String, AbstractType> cfKeysComparators;
-    private ConsistencyLevel consistencyLevel = ConsistencyLevel.ONE;   
- 
+    private ConsistencyLevel consistencyLevel = ConsistencyLevel.ONE;
+    private CliUserHelp help;
     public CliClient(CliSessionState cliSessionState, Cassandra.Client thriftClient)
     {
         this.sessionState = cliSessionState;
         this.thriftClient = thriftClient;
         this.cfKeysComparators = new HashMap<String, AbstractType>();
+        help = getHelp();
+    }
+
+        private CliUserHelp getHelp()
+    {
+        final InputStream is =  CliClient.class.getClassLoader().getResourceAsStream("org/apache/cassandra/cli/CliHelp.yaml");
+        assert is != null;
+
+        try
+        {
+            final Constructor constructor = new Constructor(CliUserHelp.class);
+            TypeDescription desc = new TypeDescription(CliUserHelp.class);
+            desc.putListPropertyType("commands", CliCommandHelp.class);
+            final Yaml yaml = new Yaml(new Loader(constructor));
+            return (CliUserHelp)yaml.load(is);
+        }
+        finally
+        {
+            try
+            {
+                is.close();
+            }
+            catch (IOException e)
+            {
+                throw new IOError(e);
+            }
+        }
+    }
+
+    public void printBanner()
+    {
+        sessionState.out.println(help.banner);
     }
 
     // Execute a CLI Statement 
@@ -134,7 +201,7 @@ public class CliClient extends CliUserHe
                     executeGetWithConditions(tree);
                     break;
                 case CliParser.NODE_HELP:
-                    printCmdHelp(tree, sessionState);
+                    executeHelp(tree);
                     break;
                 case CliParser.NODE_THRIFT_SET:
                     executeSet(tree);
@@ -240,7 +307,27 @@ public class CliClient extends CliUserHe
         
         return keyspacesMap.get(keyspace);
     }
-    
+
+    private void executeHelp(Tree tree)
+    {
+        if (tree.getChildCount() > 0)
+        {
+            String token = tree.getChild(0).getText();
+            for (CliCommandHelp ch : help.commands)
+            {
+                if (token.equals(ch.name))
+                {
+                    sessionState.out.println(ch.help);
+                    break;
+                }
+            }
+        }
+        else
+        {
+            sessionState.out.println(help.help);
+        }
+    }
+
     private void executeCount(Tree statement)
             throws TException, InvalidRequestException, UnavailableException, TimedOutException
     {
@@ -677,7 +764,7 @@ public class CliClient extends CliUserHe
         // table.cf['key']
         if (columnSpecCnt == 0)
         {
-            sessionState.err.println("No column name specified, (type 'help' or '?' for help on syntax).");
+            sessionState.err.println("No column name specified, (type 'help;' or '?' for help on syntax).");
             return;
         }
         // table.cf['key']['column'] = 'value'
@@ -1552,7 +1639,7 @@ public class CliClient extends CliUserHe
                 for (CompactionInfo info : compactionManagerMBean.getCompactions())
                 {
                     // if ongoing compaction type is index build
-                    if (!info.getTaskType().contains("index build"))
+                    if (info.getTaskType() != CompactionType.INDEX_BUILD)
                         continue;
                     sessionState.out.printf("%nCurrently building index %s, completed %d of %d bytes.%n",
                                             info.getColumnFamily(),

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java Fri Apr 15 12:48:15 2011
@@ -181,12 +181,6 @@ public class CliMain
         }
     }
 
-    private static void printBanner()
-    {
-        sessionState.out.println("Welcome to cassandra CLI.\n");
-        sessionState.out.println("Type 'help;' or '?' for help. Type 'quit;' or 'exit;' to quit.");
-    }
-
     /**
      * Checks whether the thrift client is connected.
      * @return boolean - true when connected, false otherwise
@@ -315,7 +309,7 @@ public class CliMain
             sessionState.out.close();
         }
 
-        printBanner();
+        cliClient.printBanner();
 
         String prompt;
         String line = "";

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java Fri Apr 15 12:48:15 2011
@@ -17,401 +17,16 @@
  */
 package org.apache.cassandra.cli;
 
-import java.util.EnumMap;
-
-import org.antlr.runtime.tree.Tree;
+import java.util.List;
 
 /**
  * @author Pavel A. Yaskevich
  */
-public class CliUserHelp {
-
-    /*
-     * the <i>add column family</i> command requires a list of arguments,
-     *  this enum defines which arguments are valid.
-     */
-    protected enum ColumnFamilyArgument
-    {
-        COLUMN_TYPE,
-        COMPARATOR,
-        SUBCOMPARATOR,
-        COMMENT,
-        ROWS_CACHED,
-        ROW_CACHE_SAVE_PERIOD,
-        KEYS_CACHED,
-        KEY_CACHE_SAVE_PERIOD,
-        READ_REPAIR_CHANCE,
-        GC_GRACE,
-        COLUMN_METADATA,
-        MEMTABLE_OPERATIONS,
-        MEMTABLE_THROUGHPUT,
-        MEMTABLE_FLUSH_AFTER,
-        DEFAULT_VALIDATION_CLASS,
-        MIN_COMPACTION_THRESHOLD,
-        MAX_COMPACTION_THRESHOLD,
-        REPLICATE_ON_WRITE,
-        ROW_CACHE_PROVIDER,
-        KEY_VALIDATION_CLASS
-    }
-
-    protected EnumMap<ColumnFamilyArgument, String> argumentExplanations = new EnumMap<ColumnFamilyArgument, String>(ColumnFamilyArgument.class)
-    {{
-        put(ColumnFamilyArgument.COLUMN_TYPE, "Super or Standard");
-        put(ColumnFamilyArgument.COMMENT, "Human-readable column family description. Any string is acceptable");
-        put(ColumnFamilyArgument.COMPARATOR, "The class used as a comparator when sorting column names.\n                  Valid options include: AsciiType, BytesType, LexicalUUIDType,\n                  LongType, IntegerType, TimeUUIDType, and UTF8Type");
-        put(ColumnFamilyArgument.SUBCOMPARATOR, "Comparator for sorting subcolumn names, for Super columns only");
-        put(ColumnFamilyArgument.MEMTABLE_OPERATIONS, "Flush memtables after this many operations (in millions)");
-        put(ColumnFamilyArgument.MEMTABLE_THROUGHPUT, "... or after this many MB have been written");
-        put(ColumnFamilyArgument.MEMTABLE_FLUSH_AFTER, "... or after this many minutes");
-        put(ColumnFamilyArgument.ROWS_CACHED, "Number or percentage of rows to cache");
-        put(ColumnFamilyArgument.ROW_CACHE_SAVE_PERIOD, "Period with which to persist the row cache, in seconds");
-        put(ColumnFamilyArgument.KEYS_CACHED, "Number or percentage of keys to cache");
-        put(ColumnFamilyArgument.KEY_CACHE_SAVE_PERIOD, "Period with which to persist the key cache, in seconds");
-        put(ColumnFamilyArgument.READ_REPAIR_CHANCE, "Probability (0.0-1.0) with which to perform read repairs on CL.ONE reads");
-        put(ColumnFamilyArgument.GC_GRACE, "Discard tombstones after this many seconds");
-        put(ColumnFamilyArgument.MIN_COMPACTION_THRESHOLD, "Avoid minor compactions of less than this number of sstable files");
-        put(ColumnFamilyArgument.MAX_COMPACTION_THRESHOLD, "Compact no more than this number of sstable files at once");
-        put(ColumnFamilyArgument.REPLICATE_ON_WRITE, "Replicate every counter update from the leader to the follower replicas");
-        put(ColumnFamilyArgument.ROW_CACHE_PROVIDER, "Row cache provider, opions are SerializingProvider/ConcurrentLinkedHashCacheProvider");
-    }};
-    
-    protected void printCmdHelp(Tree statement, CliSessionState state)
-    {
-        if (statement.getChildCount() > 0)
-        {
-            int helpType = statement.getChild(0).getType();
-
-            switch(helpType)
-            {
-            case CliParser.NODE_HELP:
-                state.out.println("help <command>;\n");
-                state.out.println("Display the general help page with a list of available commands.");
-                break;
-            case CliParser.NODE_CONNECT:
-                state.out.println("connect <hostname>/<port> (<username> '<password>')?;\n");
-                state.out.println("Connect to the specified host on the specified port (using specified username and password).\n");
-                state.out.println("example:");
-                state.out.println("connect localhost/9160;");
-                state.out.println("connect localhost/9160 user 'badpasswd';");
-                state.out.println("connect 127.0.0.1/9160 user 'badpasswd';");
-                break;
-
-            case CliParser.NODE_USE_TABLE:
-                state.out.println("use <keyspace>;");
-                state.out.println("use <keyspace> <username> '<password>';\n");
-                state.out.println("Switch to the specified keyspace. The optional username and password fields");
-                state.out.println("are needed when performing authentication.\n");
-                break;
-
-            case CliParser.NODE_DESCRIBE_TABLE:
-                state.out.println("describe keyspace (<keyspace>)?;\n");
-                state.out.println("Show additional information about the specified keyspace.");
-                state.out.println("Command could be used without <keyspace> argument if you are already authenticated to keyspace.\n");
-                state.out.println("example:");
-                state.out.println("describe keyspace system;");
-                break;
-
-            case CliParser.NODE_DESCRIBE_CLUSTER:
-                state.out.println("describe cluster;\n");
-                state.out.println("Display information about cluster: snitch, partitioner, schema versions.");
-                break;
-
-            case CliParser.NODE_EXIT:
-                state.out.println("exit;");
-                state.out.println("quit;\n");
-                state.out.println("Exit this utility.");
-                break;
-
-            case CliParser.NODE_SHOW_CLUSTER_NAME:
-                state.out.println("show cluster name;\n");
-                state.out.println("Displays the name of the currently connected cluster.");
-                break;
-
-            case CliParser.NODE_SHOW_VERSION:
-                state.out.println("show api version;\n");
-                state.out.println("Displays the API version number.");
-                break;
-
-            case CliParser.NODE_SHOW_KEYSPACES:
-                state.out.println("show keyspaces;\n");
-                state.out.println("Displays a list of the keyspaces available on the currently connected cluster.");
-                break;
-
-            case CliParser.NODE_ADD_KEYSPACE:
-                state.out.println("create keyspace <keyspace>;");
-                state.out.println("create keyspace <keyspace> with <att1>=<value1>;");
-                state.out.println("create keyspace <keyspace> with <att1>=<value1> and <att2>=<value2> ...;\n");
-                state.out.println("Create a new keyspace with the specified values for the given set of attributes.\n");
-                state.out.println("valid attributes are:");
-                state.out.println("    placement_strategy: the fully qualified class used to place replicas in");
-                state.out.println("                        this keyspace. Valid values are");
-                state.out.println("                        org.apache.cassandra.locator.SimpleStrategy,");
-                state.out.println("                        org.apache.cassandra.locator.NetworkTopologyStrategy,");
-                state.out.println("                        and org.apache.cassandra.locator.OldNetworkTopologyStrategy");
-                state.out.println("      strategy_options: additional options for placement_strategy.");
-                state.out.println("                        Simple and OldNetworkTopology strategies require");
-                state.out.println("                        'replication_factor':N, and NetworkTopologyStrategy");
-                state.out.println("                        requires a map of 'DCName':N per-DC.");
-                state.out.println("\nexamples:");
-                state.out.println("create keyspace foo with");
-                state.out.println("        placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'");
-                state.out.println("        and strategy_options=[{replication_factor:3}];");
-                state.out.println("create keyspace foo with");
-                state.out.println("        placement_strategy = 'org.apache.cassandra.locator.NetworkTopologyStrategy';");
-                state.out.println("        and strategy_options=[{DC1:2, DC2:2}];");
-                break;
-
-            case CliParser.NODE_UPDATE_KEYSPACE:
-                state.out.println("update keyspace <keyspace>;");
-                state.out.println("update keyspace <keyspace> with <att1>=<value1>;");
-                state.out.println("update keyspace <keyspace> with <att1>=<value1> and <att2>=<value2> ...;\n");
-                state.out.println("Update a keyspace with the specified values for the given set of attributes.\n");
-                state.out.println("valid attributes are:");
-                state.out.println("    placement_strategy: the fully qualified class used to place replicas in");
-                state.out.println("                        this keyspace. Valid values are");
-                state.out.println("                        org.apache.cassandra.locator.SimpleStrategy,");
-                state.out.println("                        org.apache.cassandra.locator.NetworkTopologyStrategy,");
-                state.out.println("                        and org.apache.cassandra.locator.OldNetworkTopologyStrategy");
-                state.out.println("      strategy_options: additional options for placement_strategy.");
-                state.out.println("                        Simple and OldNetworkTopology strategies require");
-                state.out.println("                        'replication_factor':N, and NetworkTopologyStrategy");
-                state.out.println("                        requires a map of 'DCName':N per-DC.");
-                state.out.println("\nexamples:");
-                state.out.println("update keyspace foo with");
-                state.out.println("        placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'");
-                state.out.println("        and strategy_options=[{replication_factor:4}];");
-                state.out.println("update keyspace foo with");
-                state.out.println("        placement_strategy = 'org.apache.cassandra.locator.NetworkTopologyStrategy';");
-                state.out.println("        and strategy_options=[{DC1:3, DC2:2}];");
-                break;
-
-            case CliParser.NODE_ADD_COLUMN_FAMILY:
-                state.out.println("create column family Bar;");
-                state.out.println("create column family Bar with <att1>=<value1>;");
-                state.out.println("create column family Bar with <att1>=<value1> and <att2>=<value2>...;\n");
-                state.out.println("Create a new column family with the specified values for the given set of");
-                state.out.println("attributes. Note that you must be using a keyspace.\n");
-                state.out.println("valid attributes are:");
-                for (ColumnFamilyArgument argument : ColumnFamilyArgument.values())
-                    state.out.printf("    - %s: %s%n", argument.toString().toLowerCase(), argumentExplanations.get(argument));
-                state.out.println("    - column_metadata: Metadata which describes columns of column family.");
-                state.out.println("        Supported format is [{ k:v, k:v, ... }, { ... }, ...]");
-                state.out.println("        Valid attributes: column_name, validation_class (see comparator),");
-                state.out.println("                          index_type (integer), index_name.");
-                state.out.println("example:\n");
-                state.out.println("create column family Bar with column_type = 'Super' and comparator = 'AsciiType'");
-                state.out.println("      and rows_cached = 10000;");
-                state.out.println("create column family Baz with comparator = 'LongType' and rows_cached = 10000;");
-                state.out.print("create column family Foo with comparator=LongType and column_metadata=");
-                state.out.print("[{ column_name:Test, validation_class:IntegerType, index_type:0, index_name:IdxName");
-                state.out.println("}, { column_name:'other name', validation_class:LongType }];");
-                break;
-
-            case CliParser.NODE_UPDATE_COLUMN_FAMILY:
-                state.out.println("update column family Bar;");
-                state.out.println("update column family Bar with <att1>=<value1>;");
-                state.out.println("update column family Bar with <att1>=<value1> and <att2>=<value2>...;\n");
-                state.out.println("Update a column family with the specified values for the given set of");
-                state.out.println("attributes. Note that you must be using a keyspace.\n");
-                state.out.println("valid attributes are:");
-                for (ColumnFamilyArgument argument : ColumnFamilyArgument.values())
-                {
-                    if (argument == ColumnFamilyArgument.COMPARATOR || argument == ColumnFamilyArgument.SUBCOMPARATOR)
-                        continue;
-                    state.out.printf("    - %s: %s%n", argument.toString().toLowerCase(), argumentExplanations.get(argument));
-                }
-                state.out.println("    - column_metadata: Metadata which describes columns of column family.");
-                state.out.println("        Supported format is [{ k:v, k:v, ... }, { ... }, ...]");
-                state.out.println("        Valid attributes: column_name, validation_class (see comparator),");
-                state.out.println("                          index_type (integer), index_name.");
-                state.out.println("example:\n");
-                state.out.print("update column family Foo with column_metadata=");
-                state.out.print("[{ column_name:Test, validation_class:IntegerType, index_type:0, index_name:IdxName");
-                state.out.println("}] and rows_cached=100 and comment='this is helpful comment.';");
-                break;
-
-            case CliParser.NODE_DEL_KEYSPACE:
-                state.out.println("drop keyspace <keyspace>;\n");
-                state.out.println("Drops the specified keyspace.\n");
-                state.out.println("example:");
-                state.out.println("drop keyspace foo;");
-                break;
-
-            case CliParser.NODE_DEL_COLUMN_FAMILY:
-                state.out.println("drop column family <name>;\n");
-                state.out.println("Drops the specified column family.\n");
-                state.out.println("example:");
-                state.out.println("drop column family foo;");
-                break;
-
-            case CliParser.NODE_THRIFT_GET :
-                state.out.println("get <cf>['<key>'];");
-                state.out.println("get <cf>['<key>']['<col>'] (as <type>)*;");
-                state.out.println("get <cf>['<key>']['<super>'];");
-                state.out.println("get <cf>['<key>'][<function>];");
-                state.out.println("get <cf>['<key>'][<function>(<super>)][<function>(<col>)];");
-                state.out.println("get <cf> where <column> = <value> [and <column> > <value> and ...] [limit <integer>];");
-                state.out.println("Default LIMIT is 100. Available operations: =, >, >=, <, <=\n");
-                state.out.println("get <cf>['<key>']['<super>']['<col>'] (as <type>)*;");
-                state.out.print("Note: `as <type>` is optional, it dynamically converts column value to the specified type");
-                state.out.println(", column value validator will be set to <type>.");
-                state.out.println("Available functions: " + CliClient.Function.getFunctionNames());
-                state.out.println("Available types: IntegerType, LongType, UTF8Type, ASCIIType, TimeUUIDType, LexicalUUIDType.\n");
-                state.out.println("examples:");
-                state.out.println("get bar[testkey];");
-                state.out.println("get bar[testkey][test_column] as IntegerType;");
-                state.out.println("get bar[testkey][utf8(hello)];");
-                break;
-
-            case CliParser.NODE_THRIFT_SET:
-                state.out.println("set <cf>['<key>']['<col>'] = <value>;");
-                state.out.println("set <cf>['<key>']['<super>']['<col>'] = <value>;");
-                state.out.println("set <cf>['<key>']['<col>'] = <function>(<argument>);");
-                state.out.println("set <cf>['<key>']['<super>']['<col>'] = <function>(<argument>);");
-                state.out.println("set <cf>[<key>][<function>(<col>)] = <value> || <function>;");
-                state.out.println("set <cf>[<key>][<function>(<col>) || <col>] = <value> || <function> with ttl = <secs>;");
-                state.out.println("Available functions: " + CliClient.Function.getFunctionNames() + "\n");
-                state.out.println("examples:");
-                state.out.println("set bar['testkey']['my super']['test col']='this is a test';");
-                state.out.println("set baz['testkey']['test col']='this is also a test';");
-                state.out.println("set diz[testkey][testcol] = utf8('this is utf8 string.');");
-                state.out.println("set bar[testkey][timeuuid()] = utf('hello world');");
-                state.out.println("set bar[testkey][timeuuid()] = utf('hello world') with ttl = 30;");
-                state.out.println("set diz[testkey][testcol] = 'this is utf8 string.' with ttl = 150;");
-                break;
-
-            case CliParser.NODE_THRIFT_INCR:
-                state.out.println("incr <cf>['<key>']['<col>'] [by <value>];");
-                state.out.println("incr <cf>['<key>']['<super>']['<col>'] [by <value>];");
-                state.out.println("examples:");
-                state.out.println("incr bar['testkey']['my super']['test col'];");
-                state.out.println("incr bar['testkey']['my super']['test col'] by 42;");
-                state.out.println("incr baz['testkey']['test col'] by -4;");
-                break;
-
-            case CliParser.NODE_THRIFT_DECR:
-                state.out.println("decr <cf>['<key>']['<col>'] [by <value>];");
-                state.out.println("decr <cf>['<key>']['<super>']['<col>'] [by <value>];");
-                state.out.println("examples:");
-                state.out.println("decr bar['testkey']['my super']['test col'];");
-                state.out.println("decr bar['testkey']['my super']['test col'] by 42;");
-                state.out.println("decr baz['testkey']['test col'] by 10;");
-                break;
-
-            case CliParser.NODE_THRIFT_DEL:
-                state.out.println("del <cf>['<key>'];");
-                state.out.println("del <cf>['<key>']['<col>'];");
-                state.out.println("del <cf>['<key>']['<super>']['<col>'];\n");
-                state.out.println("Deletes a record, a column, or a subcolumn.\n");
-                state.out.println("example:");
-                state.out.println("del bar['testkey']['my super']['test col'];");
-                state.out.println("del baz['testkey']['test col'];");
-                state.out.println("del baz['testkey'];");
-                break;
-
-            case CliParser.NODE_THRIFT_COUNT:
-                state.out.println("count <cf>['<key>'];");
-                state.out.println("count <cf>['<key>']['<super>'];\n");
-                state.out.println("Count the number of columns in the specified key or subcolumns in the specified");
-                state.out.println("super column.\n");
-                state.out.println("example:");
-                state.out.println("count bar['testkey']['my super'];");
-                state.out.println("count baz['testkey'];");
-                break;
-
-            case CliParser.NODE_LIST:
-                state.out.println("list <cf>;");
-                state.out.println("list <cf>[<startKey>:];");
-                state.out.println("list <cf>[<startKey>:<endKey>];");
-                state.out.println("list ... limit N;");
-                state.out.println("List a range of rows in the column or supercolumn family.\n");
-                state.out.println("example:");
-                state.out.println("list Users[j:] limit 40;");
-                break;
-
-            case CliParser.NODE_TRUNCATE:
-                state.out.println("truncate <column_family>;");
-                state.out.println("Truncate specified column family.\n");
-                state.out.println("example:");
-                state.out.println("truncate Category;");
-                break;
+public class CliUserHelp
+{
+    public String banner;
 
-            case CliParser.NODE_ASSUME:
-                state.out.println("assume <column_family> comparator as <type>;");
-                state.out.println("assume <column_family> sub_comparator as <type>;");
-                state.out.println("assume <column_family> validator as <type>;");
-                state.out.println("assume <column_family> keys as <type>;\n");
-                state.out.println("Assume one of the attributes (comparator, sub_comparator, validator or keys)");
-                state.out.println("of the given column family to match specified type. Available types: " + CliClient.Function.getFunctionNames());
-                state.out.println("example:");
-                state.out.println("assume Users comparator as lexicaluuid;");
-                break;
-            case CliParser.NODE_CONSISTENCY_LEVEL:
-                state.out.println("consistencylevel as <level>");
-                state.out.println("example:");
-                state.out.println("consistencylevel as QUORUM");
-                break;
-            default:
-                state.out.println("?");
-                break;
-            }
-        }
-        else
-        {
-            state.out.println("List of all CLI commands:");
-            state.out.println("?                                                          Display this message.");
-            state.out.println("help;                                                         Display this help.");
-            state.out.println("help <command>;                         Display detailed, command-specific help.");
-            state.out.println("connect <hostname>/<port> (<username> '<password>')?; Connect to thrift service.");
-            state.out.println("use <keyspace> [<username> 'password'];                    Switch to a keyspace.");
-            state.out.println("describe keyspace (<keyspacename>)?;                          Describe keyspace.");
-            state.out.println("exit;                                                                  Exit CLI.");
-            state.out.println("quit;                                                                  Exit CLI.");
-            state.out.println("describe cluster;                             Display information about cluster.");
-            state.out.println("show cluster name;                                         Display cluster name.");
-            state.out.println("show keyspaces;                                          Show list of keyspaces.");
-            state.out.println("show api version;                                       Show server API version.");
-            state.out.println("create keyspace <keyspace> [with <att1>=<value1> [and <att2>=<value2> ...]];");
-            state.out.println("                Add a new keyspace with the specified attribute(s) and value(s).");
-            state.out.println("update keyspace <keyspace> [with <att1>=<value1> [and <att2>=<value2> ...]];");
-            state.out.println("                 Update a keyspace with the specified attribute(s) and value(s).");
-            state.out.println("create column family <cf> [with <att1>=<value1> [and <att2>=<value2> ...]];");
-            state.out.println("        Create a new column family with the specified attribute(s) and value(s).");
-            state.out.println("update column family <cf> [with <att1>=<value1> [and <att2>=<value2> ...]];");
-            state.out.println("            Update a column family with the specified attribute(s) and value(s).");
-            state.out.println("drop keyspace <keyspace>;                                     Delete a keyspace.");
-            state.out.println("drop column family <cf>;                                 Delete a column family.");
-            state.out.println("get <cf>['<key>'];                                       Get a slice of columns.");
-            state.out.println("get <cf>['<key>']['<super>'];                        Get a slice of sub columns.");
-            state.out.println("get <cf> where <column> = <value> [and <column> > <value> and ...] [limit int]; ");
-            state.out.println("get <cf>['<key>']['<col>'] (as <type>)*;                     Get a column value.");
-            state.out.println("get <cf>['<key>']['<super>']['<col>'] (as <type>)*;      Get a sub column value.");
-            state.out.println("set <cf>['<key>']['<col>'] = <value> (with ttl = <secs>)*;         Set a column.");
-            state.out.println("set <cf>['<key>']['<super>']['<col>'] = <value> (with ttl = <secs>)*;");
-            state.out.println("                                                               Set a sub column.");
-            state.out.println("del <cf>['<key>'];                                                Delete record.");
-            state.out.println("del <cf>['<key>']['<col>'];                                       Delete column.");
-            state.out.println("del <cf>['<key>']['<super>']['<col>'];                        Delete sub column.");
-            state.out.println("count <cf>['<key>'];                                    Count columns in record.");
-            state.out.println("count <cf>['<key>']['<super>'];                 Count columns in a super column.");
-            state.out.println("incr <cf>['<key>']['<col>'] [by <value>];            Increment a counter column.");
-            state.out.println("incr <cf>['<key>']['<super>']['<col>'] [by <value>];");
-            state.out.println("                                                 Increment a counter sub-column.");
-            state.out.println("decr <cf>['<key>']['<col>'] [by <value>];            Decrement a counter column.");
-            state.out.println("decr <cf>['<key>']['<super>']['<col>'] [by <value>];");
-            state.out.println("                                                 Decrement a counter sub-column.");
-            state.out.println("truncate <column_family>;                      Truncate specified column family.");
-            state.out.println("assume <column_family> <attribute> as <type>;");
-            state.out.println("              Assume a given column family attributes to match a specified type.");
-            state.out.println("consistencylevel as <level>;");
-            state.out.println("                  Change the consistency level for set,get, and list operations.");
-            state.out.println("list <cf>;                                   List all rows in the column family.");
-            state.out.println("list <cf>[<startKey>:];");
-            state.out.println("                       List rows in the column family beginning with <startKey>.");
-            state.out.println("list <cf>[<startKey>:<endKey>];");
-            state.out.println("        List rows in the column family in the range from <startKey> to <endKey>.");
-            state.out.println("list ... limit N;                                   Limit the list results to N.");
-        }
-    }
+    public String help;
 
+    public List<CliCommandHelp> commands;
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java Fri Apr 15 12:48:15 2011
@@ -657,6 +657,7 @@ public final class CFMetaData
         if (cf_def.isSetMerge_shards_chance()) { newCFMD.mergeShardsChance(cf_def.merge_shards_chance); }
         if (cf_def.isSetRow_cache_provider()) { newCFMD.rowCacheProvider(FBUtilities.newCacheProvider(cf_def.row_cache_provider)); }
         if (cf_def.isSetKey_alias()) { newCFMD.keyAlias(cf_def.key_alias); }
+        if (cf_def.isSetKey_validation_class()) { newCFMD.keyValidator(DatabaseDescriptor.getComparator(cf_def.key_validation_class)); }
 
         return newCFMD.comment(cf_def.comment)
                       .rowCacheSize(cf_def.row_cache_size)



Mime
View raw message