You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ee...@apache.org on 2011/02/25 22:38:54 UTC

svn commit: r1074709 - in /cassandra/trunk: doc/cql/CQL.html doc/cql/CQL.textile src/java/org/apache/cassandra/cql/Cql.g test/system/test_cql.py

Author: eevans
Date: Fri Feb 25 21:38:53 2011
New Revision: 1074709

URL: http://svn.apache.org/viewvc?rev=1074709&view=rev
Log:
CASSANDRA-2025 updated consistency level spec (removed '.')

Patch by eevans for CASSANDRA-2025

Modified:
    cassandra/trunk/doc/cql/CQL.html
    cassandra/trunk/doc/cql/CQL.textile
    cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g
    cassandra/trunk/test/system/test_cql.py

Modified: cassandra/trunk/doc/cql/CQL.html
URL: http://svn.apache.org/viewvc/cassandra/trunk/doc/cql/CQL.html?rev=1074709&r1=1074708&r2=1074709&view=diff
==============================================================================
--- cassandra/trunk/doc/cql/CQL.html (original)
+++ cassandra/trunk/doc/cql/CQL.html Fri Feb 25 21:38:53 2011
@@ -8,7 +8,7 @@ SELECT [FIRST N] [REVERSED] name1..nameN
 </code></pre><p>Following the column family clause is an optional <a href="#consistency">consistency level specification</a>.</p><h3 id="Filteringrows">Filtering rows</h3><pre><code>SELECT ... WHERE KEY = keyname AND name1 = value1
 SELECT ... WHERE KEY &gt;= startkey and KEY =&lt; endkey AND name1 = value1
 </code></pre><p>The WHERE clause provides for filtering the rows that appear in results.  The clause can filter on a key name, or range of keys, and in the case of indexed columns, on column values.  Key filters are specified using the <code>KEY</code> keyword, a relational operator, (one of <code>=</code>, <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;</code>, and <code>&lt;=</code>), and a term value.  When terms appear on both sides of a relational operator it is assumed the filter applies to an indexed column. With column index filters, the term on the left of the operator is the name, the term on the right is the value to filter <i>on</i>.</p><p><i>Note: The greater-than and less-than operators (<code>&gt;</code> and <code>&lt;</code>) result in key ranges that are inclusive of the terms. There is no supported notion of &#8220;strictly&#8221; greater-than or less-than; these operators are merely supported as aliases to <code>&gt;=</code> and <code>&lt;=</code>.</i>  
 </p><h3 id="Limits">Limits</h3><pre><code>SELECT ... WHERE &lt;CLAUSE&gt; [LIMIT N] ...
-</code></pre><p>Limiting the number of rows returned can be achieved by adding the <code>LIMIT</code> option to a <code>SELECT</code> expression. <code>LIMIT</code> defaults to 10,000 when left unset.</p><h2 id="UPDATE">UPDATE</h2><p><em>Synopsis:</em></p><pre><code>UPDATE &lt;COLUMN FAMILY&gt; [USING CONSISTENCY.&lt;CL&gt;]
+</code></pre><p>Limiting the number of rows returned can be achieved by adding the <code>LIMIT</code> option to a <code>SELECT</code> expression. <code>LIMIT</code> defaults to 10,000 when left unset.</p><h2 id="UPDATE">UPDATE</h2><p><em>Synopsis:</em></p><pre><code>UPDATE &lt;COLUMN FAMILY&gt; [USING CONSISTENCY &lt;CL&gt;]
         SET name1 = value1, name2 = value2 WHERE KEY = keyname;
 </code></pre><p>An <code>UPDATE</code> is used to write one or more columns to a record in a Cassandra column family. No results are returned.</p><h3 id="ColumnFamily2">Column Family</h3><pre><code>UPDATE &lt;COLUMN FAMILY&gt; ...
 </code></pre><p>Statements begin with the <code>UPDATE</code> keyword followed by a Cassandra column family name.</p><h3 id="ConsistencyLevel2">Consistency Level</h3><pre><code>UPDATE ... [USING &lt;CONSISTENCY&gt;] ...
@@ -34,4 +34,4 @@ UPDATE ... WHERE KEY IN (keyname1, keyna
 </code></pre><p>It is possible to assign columns a type during column family creation.  Columns configured with a type are validated accordingly when a write occurs. Column types are specified as a parenthesized, comma-separated list of column term and type pairs.  The list of recognized types are:</p><table><tr><th>type</th><th>description</th></tr><tr><td>bytes</td><td>Arbitrary bytes (no validation)</td></tr><tr><td>ascii</td><td>ASCII character string</td></tr><tr><td>utf8</td><td>UTF8 encoded string</td></tr><tr><td>timeuuid</td><td>Type 1 UUID</td></tr><tr><td>uuid</td><td>Type 4 UUID</td></tr><tr><td>int</td><td>4-byte integer</td></tr><tr><td>long</td><td>8-byte long</td></tr></table><p><em>Note: In addition to the recognized types listed above, it is also possible to supply a string containing the name of a class (a sub-class of <code>AbstractType</code>), either fully qualified, or relative to the <code>org.apache.cassandra.db.marshal</code> package.</em></p><h3 id
 ="ColumnFamilyOptionsoptional">Column Family Options (optional)</h3><pre><code>CREATE COLUMNFAMILY ... WITH keyword1 = arg1 AND keyword2 = arg2;
 </code></pre><p>A number of optional keyword arguments can be supplied to control the configuration of a new column family.</p><table><tr><th>keyword</th><th>default</th><th>description</th></tr><tr><td>comparator</td><td>bytes</td><td>Determines sorting and validation of column names. Valid values are identical to the types listed in <a href="#columntypes">Specifying Column Type</a> above.</td></tr><tr><td>comment</td><td>none</td><td>A free-form, human-readable comment.</td></tr><tr><td>row_cache_size</td><td>0</td><td>Number of rows whose entire contents to cache in memory.</td></tr><tr><td>key_cache_size</td><td>200000</td><td>Number of keys per SSTable whose locations are kept in memory in &#8220;mostly LRU&#8221; order.</td></tr><tr><td>read_repair_chance</td><td>1.0</td><td>The probability with which read repairs should be invoked on non-quorum reads.</td></tr><tr><td>gc_grace_seconds</td><td>864000</td><td>Time to wait before garbage collecting tombstones (deletion m
 arkers).</td></tr><tr><td>default_validation</td><td>bytes</td><td>Determines validation of column values. Valid values are identical to the types listed in <a href="#columntypes">Specifying Column Type</a> above.</td></tr><tr><td>min_compaction_threshold</td><td>4</td><td>Minimum number of SSTables needed to start a minor compaction.</td></tr><tr><td>max_compaction_threshold</td><td>32</td><td>Maximum number of SSTables allowed before a minor compaction is forced.</td></tr><tr><td>row_cache_save_period_in_seconds</td><td>0</td><td>Number of seconds between saving row caches.</td></tr><tr><td>key_cache_save_period_in_seconds</td><td>14400</td><td>Number of seconds between saving key caches.</td></tr><tr><td>memtable_flush_after_mins</td><td>60</td><td>Maximum time to leave a dirty table unflushed.</td></tr><tr><td>memtable_throughput_in_mb</td><td>dynamic</td><td>Maximum size of the memtable before it is flushed.</td></tr><tr><td>memtable_operations_in_millions</td><td>dynam
 ic</td><td>Number of operations in millions before the memtable is flushed.</td></tr><tr><td>replicate_on_write</td><td>false</td><td></td></tr></table><h2 id="CREATEINDEX">CREATE INDEX</h2><p><em>Synopsis:</em></p><pre><code>CREATE INDEX [index_name] ON &lt;column_family&gt; (column_name);
 </code></pre><p>A <code>CREATE INDEX</code> statement is used to create a new, automatic secondary index for the named column.</p><h2 id="CommonIdioms">Common Idioms</h2><h3 id="consistency">Specifying Consistency</h3><pre><code>... USING &lt;CONSISTENCY&gt; ...
-</code></pre><p>Consistency level specifications are made up the keyword <code>USING</code>, followed by a consistency level identifier. Valid consistency levels are as follows:</p><ul><li><code>CONSISTENCY.ZERO</code></li><li><code>CONSISTENCY.ONE</code> (default)</li><li><code>CONSISTENCY.QUORUM</code></li><li><code>CONSISTENCY.ALL</code></li><li><code>CONSISTENCY.DCQUORUM</code></li><li><code>CONSISTENCY.DCQUORUMSYNC</code></li></ul><h3 id="terms">Term specification</h3><p>Where possible, the type of terms are inferred; the following term types are supported:</p><h4 id="string_literals">String Literals</h4><p>String literals are any value enclosed in double-quotes, (`"`).  String literals are treated as raw bytes; no interpolation is performed.</p><h4 id="Unicode">Unicode</h4><p>Unicode terms are any double-quoted string prefixed with a lower-case <code>u</code>, for example <code>u"© 2011 The Apache Software Foundation"</code>.  Unicode terms are identical to standard
  <a href="#string_literals">string literals</a>, with the exception that they are encoded to bytes using the UTF-8 charset.</p><h4 id="Integerslongs">Integers / longs</h4><p>Integers are any term consisting soley of unquoted numericals, longs are any otherwise valid integer term followed by an upper case &#8220;L&#8221;, (e.g. 100L).  It is an error to specify an integer term that will not fit in 4 bytes unsigned, or a long that will not fit in 8 bytes unsigned.</p><h4 id="UUIDs">UUIDs</h4><p>There are two types of UUIDs supported by the CQL specification, time-based (version 1) and randomly generated (version 4). These are specified in statements using the <code>timeuuid(&lt;UUID STRING&gt;)</code> and <code>uuid(&lt;UUID STRING&gt;)</code> notations respectively.</p><p>In addition to the hex-based string representation, <code>timeuuid()</code> terms also accept arguments to specify the data-time component. The full list of <code>timeuuid()</code> arguments are:</p><table><
 tr><th>argument</th><th>example</th><th>behavior</th></tr><tr><td>none</td><td>timeuuid()</td><td>Results in the creation of a new UUID based on system time of the node parsing the query.</td></tr><tr><td>now</td><td>timeuuid(&#8220;now&#8221;)</td><td>Results in the creation of a new UUID based on system time of the node parsing the query.</td></tr><tr><td>milliseconds since epoch</td><td>timeuuid(1296755320376)</td><td>Creates a UUID with a time component that is based on the supplied time-stamp.</td></tr><tr><td><a href="http://en.wikipedia.org/wiki/8601">iso8601 timestamp</a></td><td>timeuuid(&#8220;2011-02-01T14:00-0600&#8221;)</td><td>Creates a UUID with a time component that is based on the supplied time-stamp.</td></tr><tr><td><a href="http://tools.ietf.org/html/rfc4122">string representation (hex)</a></td><td>timeuuid(&#8220;e9229b24-2fbe-11e0-a4de-0026c650d722&#8221;)</td><td>Reproduces the specified version 1 UUID node-side.</td></tr></table></body></html>
\ No newline at end of file
+</code></pre><p>Consistency level specifications are made up the keyword <code>USING</code>, followed by a consistency level identifier. Valid consistency levels are as follows:</p><ul><li><code>CONSISTENCY ZERO</code></li><li><code>CONSISTENCY ONE</code> (default)</li><li><code>CONSISTENCY QUORUM</code></li><li><code>CONSISTENCY ALL</code></li><li><code>CONSISTENCY DCQUORUM</code></li><li><code>CONSISTENCY DCQUORUMSYNC</code></li></ul><h3 id="terms">Term specification</h3><p>Where possible, the type of terms are inferred; the following term types are supported:</p><h4 id="string_literals">String Literals</h4><p>String literals are any value enclosed in double-quotes, (`"`).  String literals are treated as raw bytes; no interpolation is performed.</p><h4 id="Unicode">Unicode</h4><p>Unicode terms are any double-quoted string prefixed with a lower-case <code>u</code>, for example <code>u"© 2011 The Apache Software Foundation"</code>.  Unicode terms are identical to standard
  <a href="#string_literals">string literals</a>, with the exception that they are encoded to bytes using the UTF-8 charset.</p><h4 id="Integerslongs">Integers / longs</h4><p>Integers are any term consisting soley of unquoted numericals, longs are any otherwise valid integer term followed by an upper case &#8220;L&#8221;, (e.g. 100L).  It is an error to specify an integer term that will not fit in 4 bytes unsigned, or a long that will not fit in 8 bytes unsigned.</p><h4 id="UUIDs">UUIDs</h4><p>There are two types of UUIDs supported by the CQL specification, time-based (version 1) and randomly generated (version 4). These are specified in statements using the <code>timeuuid(&lt;UUID STRING&gt;)</code> and <code>uuid(&lt;UUID STRING&gt;)</code> notations respectively.</p><p>In addition to the hex-based string representation, <code>timeuuid()</code> terms also accept arguments to specify the data-time component. The full list of <code>timeuuid()</code> arguments are:</p><table><
 tr><th>argument</th><th>example</th><th>behavior</th></tr><tr><td>none</td><td>timeuuid()</td><td>Results in the creation of a new UUID based on system time of the node parsing the query.</td></tr><tr><td>now</td><td>timeuuid(&#8220;now&#8221;)</td><td>Results in the creation of a new UUID based on system time of the node parsing the query.</td></tr><tr><td>milliseconds since epoch</td><td>timeuuid(1296755320376)</td><td>Creates a UUID with a time component that is based on the supplied time-stamp.</td></tr><tr><td><a href="http://en.wikipedia.org/wiki/8601">iso8601 timestamp</a></td><td>timeuuid(&#8220;2011-02-01T14:00-0600&#8221;)</td><td>Creates a UUID with a time component that is based on the supplied time-stamp.</td></tr><tr><td><a href="http://tools.ietf.org/html/rfc4122">string representation (hex)</a></td><td>timeuuid(&#8220;e9229b24-2fbe-11e0-a4de-0026c650d722&#8221;)</td><td>Reproduces the specified version 1 UUID node-side.</td></tr></table></body></html>
\ No newline at end of file

Modified: cassandra/trunk/doc/cql/CQL.textile
URL: http://svn.apache.org/viewvc/cassandra/trunk/doc/cql/CQL.textile?rev=1074709&r1=1074708&r2=1074709&view=diff
==============================================================================
--- cassandra/trunk/doc/cql/CQL.textile (original)
+++ cassandra/trunk/doc/cql/CQL.textile Fri Feb 25 21:38:53 2011
@@ -73,7 +73,7 @@ h2. UPDATE
 _Synopsis:_
 
 bc. 
-UPDATE <COLUMN FAMILY> [USING CONSISTENCY.<CL>]
+UPDATE <COLUMN FAMILY> [USING CONSISTENCY <CL>]
         SET name1 = value1, name2 = value2 WHERE KEY = keyname;
         
 An @UPDATE@ is used to write one or more columns to a record in a Cassandra column family. No results are returned.
@@ -244,12 +244,12 @@ bc. 
 
 Consistency level specifications are made up the keyword @USING@, followed by a consistency level identifier. Valid consistency levels are as follows:
 
-* @CONSISTENCY.ZERO@
-* @CONSISTENCY.ONE@ (default)
-* @CONSISTENCY.QUORUM@
-* @CONSISTENCY.ALL@
-* @CONSISTENCY.DCQUORUM@
-* @CONSISTENCY.DCQUORUMSYNC@
+* @CONSISTENCY ZERO@
+* @CONSISTENCY ONE@ (default)
+* @CONSISTENCY QUORUM@
+* @CONSISTENCY ALL@
+* @CONSISTENCY DCQUORUM@
+* @CONSISTENCY DCQUORUMSYNC@
 
 h3(#terms). Term specification
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g?rev=1074709&r1=1074708&r2=1074709&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g Fri Feb 25 21:38:53 2011
@@ -94,7 +94,7 @@ selectStatement returns [SelectStatement
           | K_COUNT '(' s2=selectExpression ')' { expression = s2; isCountOp = true; }
           )
           K_FROM columnFamily=IDENT
-          ( K_USING K_CONSISTENCY '.' K_LEVEL { cLevel = ConsistencyLevel.valueOf($K_LEVEL.text); } )?
+          ( K_USING K_CONSISTENCY K_LEVEL { cLevel = ConsistencyLevel.valueOf($K_LEVEL.text); } )?
           ( K_WHERE whereClause )?
           ( K_LIMIT rows=INTEGER { numRecords = Integer.parseInt($rows.text); } )?
           endStmnt
@@ -141,7 +141,7 @@ batchUpdateStatement returns [BatchUpdat
           ConsistencyLevel cLevel = ConsistencyLevel.ONE;
           List<UpdateStatement> updates = new ArrayList<UpdateStatement>();
       }
-      K_BEGIN K_BATCH ( K_USING K_CONSISTENCY '.' K_LEVEL { cLevel = ConsistencyLevel.valueOf($K_LEVEL.text); } )?
+      K_BEGIN K_BATCH ( K_USING K_CONSISTENCY K_LEVEL { cLevel = ConsistencyLevel.valueOf($K_LEVEL.text); } )?
           u1=updateStatement { updates.add(u1); } ( uN=updateStatement { updates.add(uN); } )*
       K_APPLY K_BATCH EOF
       {
@@ -166,7 +166,7 @@ updateStatement returns [UpdateStatement
           Map<Term, Term> columns = new HashMap<Term, Term>();
       }
       K_UPDATE columnFamily=IDENT
-          (K_USING K_CONSISTENCY '.' K_LEVEL { cLevel = ConsistencyLevel.valueOf($K_LEVEL.text); })?
+          (K_USING K_CONSISTENCY K_LEVEL { cLevel = ConsistencyLevel.valueOf($K_LEVEL.text); })?
           K_SET termPair[columns] (',' termPair[columns])*
           K_WHERE K_KEY '=' key=term endStmnt
       {
@@ -192,7 +192,7 @@ deleteStatement returns [DeleteStatement
       }
       K_DELETE
           ( cols=termList { columnsList = $cols.items; })?
-          K_FROM columnFamily=IDENT ( K_USING K_CONSISTENCY '.' K_LEVEL )?
+          K_FROM columnFamily=IDENT ( K_USING K_CONSISTENCY K_LEVEL )?
           K_WHERE ( K_KEY '=' key=term           { keyList = Collections.singletonList(key); }
                   | K_KEY K_IN '(' keys=termList { keyList = $keys.items; } ')'
                   )?

Modified: cassandra/trunk/test/system/test_cql.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_cql.py?rev=1074709&r1=1074708&r2=1074709&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_cql.py (original)
+++ cassandra/trunk/test/system/test_cql.py Fri Feb 25 21:38:53 2011
@@ -34,7 +34,7 @@ def load_sample(dbconn):
     """)
 
     dbconn.execute("""
-    BEGIN BATCH USING CONSISTENCY.ONE
+    BEGIN BATCH USING CONSISTENCY ONE
      UPDATE StandardLong1 SET 1L="1", 2L="2", 3L="3", 4L="4" WHERE KEY="aa";
      UPDATE StandardLong1 SET 5L="5", 6L="6", 7L="8", 9L="9" WHERE KEY="ab";
      UPDATE StandardLong1 SET 9L="9", 8L="8", 7L="7", 6L="6" WHERE KEY="ac";
@@ -46,7 +46,7 @@ def load_sample(dbconn):
     """)
     
     dbconn.execute("""
-    BEGIN BATCH USING CONSISTENCY.ONE
+    BEGIN BATCH USING CONSISTENCY ONE
       UPDATE StandardInteger1 SET 10="a", 20="b", 30="c", 40="d" WHERE KEY="k1";
       UPDATE StandardInteger1 SET 10="e", 20="f", 30="g", 40="h" WHERE KEY="k2";
       UPDATE StandardInteger1 SET 10="i", 20="j", 30="k", 40="l" WHERE KEY="k3";