Author: eevans
Date: Wed Nov 17 16:57:21 2010
New Revision: 1036110

URL: http://svn.apache.org/viewvc?rev=1036110&view=rev
Log:
CASSANDRA-1705. doc update for proposed UPDATE

Patch by eevans

Modified:
    cassandra/trunk/doc/cql/CQL.html
    cassandra/trunk/doc/cql/CQL.textile

Modified: cassandra/trunk/doc/cql/CQL.html
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/doc/cql/CQL.html?rev=1036110&r1=1036109&r2=1036110&view=diff
==============================================================================
--- cassandra/trunk/doc/cql/CQL.html (original)
+++ cassandra/trunk/doc/cql/CQL.html Wed Nov 17 16:57:21 2010
@@ -1,16 +1,22 @@
-<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD 
XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";><html 
xmlns="http://www.w3.org/1999/xhtml";><head><meta http-equiv="Content-Type" 
content="text/html; charset=utf-8"/></head><body><h1 
id="CassandraQueryLanguageCQLv0.99.0">Cassandra Query Language (CQL) 
v0.99.0</h1><h2 id="TableofContents">Table of Contents</h2><ol 
style="list-style: none;"><li><a 
href="#CassandraQueryLanguageCQLv0.99.0">Cassandra Query Language (CQL) 
v0.99.0</a><ol style="list-style: none;"><li><a href="#TableofContents">Table 
of Contents</a></li><li><a href="#USE">USE</a></li><li><a 
href="#SELECT">SELECT</a><ol style="list-style: none;"><li><a 
href="#ColumnFamily">Column Family</a></li><li><a 
href="#ConsistencyLevel">Consistency Level</a></li><li><a 
href="#Expressions">Expressions</a></li><li><a 
href="#Limits">Limits</a></li><li><a 
href="#Ordering">Ordering</a></li></ol></li><li><a href="#UPDATE">UP
 DATE</a><ol style="list-style: none;"><li><a href="#ColumnFamily2">Column 
Family</a></li><li><a href="#ConsistencyLevel2">Consistency 
Level</a></li><li><a href="#RowsandColumns">Rows and 
Columns</a></li></ol></li><li><a href="#CommonIdioms">Common Idioms</a><ol 
style="list-style: none;"><li><a href="#consistency">Specifying 
Consistency</a></li><li><a href="#terms">Term specification</a><ol 
style="list-style: none;"><li><a href="#StringLiterals">String 
Literals</a></li><li><a href="#Integerslongs">Integers / 
longs</a></li></ol></li></ol></li></ol></li></ol><h2 
id="USE">USE</h2><p><i>Synopsis:</i></p><pre><code>USE &lt;KEYSPACE&gt;;
-</code></pre><p>A <code>USE</code> statement consists of the <code>USE</code> 
keyword, followed by a valid keyspace name.  Its purpose is to assign the 
per-connection, current working keyspace.  All subsequent keyspace-specific 
actions will be performed in the context of the supplied value.</p><h2 
id="SELECT">SELECT</h2><p><i>Synopsis:</i></p><pre><code>SELECT [FROM] 
&lt;COLUMN FAMILY&gt; [USING &lt;CONSISTENCY&gt;]
-        WHERE &lt;EXRESSION&gt; [ROWLIMIT N] [COLLIMIT N] [ASC | DESC];
-</code></pre><p>A <code>SELECT</code> is used to read one or more records from 
a Cassandra column family. It returns a result-set of rows, where each row 
consists of a key and a collection of columns corresponding to the 
query.</p><h3 id="ColumnFamily">Column Family</h3><pre><code>SELECT [FROM] 
&lt;COLUMN FAMILY&gt; ...
-</code></pre><p>Statements begin with the <code>SELECT</code> keyword followed 
by a Cassandra column family name. The keyword <code>FROM</code> can be used as 
a delimiter to improve readability, but is not required.</p><h3 
id="ConsistencyLevel">Consistency Level</h3><pre><code>SELECT ... [USING 
&lt;CONSISTENCY&gt;] ...
-</code></pre><p>Following the column family identifier is an optional <a 
href="#consistency">consistency level specification</a>.</p><h3 
id="Expressions">Expressions</h3><pre><code>SELECT ... &lt;EXPRESSION&gt;
-SELECT ... [[KEY | COL] [&gt; | &gt;= | = | &lt; | &lt;=] TERM] [[AND ...] ...]
-</code></pre><p>The expression portion of a CQL <code>SELECT</code> statement 
consists of one or more relations delimited by the <code>AND</code> keyword.  
Relations are defined as one of either the <code>KEY</code> or 
<code>COLUMN</code> keywords, a relational operator (<code>&gt;</code>, 
<code>&gt;=</code>, <code>=</code>, <code>&lt;</code>, <code>&lt;=</code>), and 
a <a href="#terms">term</a>.</p><p><em>NOTE: The keyword <code>COLUMN</code> 
can be abbreviated as <code>COL</code>.</em></p><p><em>NOTE: Key and column 
ranges are always inclusive so the semantics of <code>&gt;=</code> and 
<code>&gt;</code>, and <code>&lt;=</code> and <code>&lt;</code> are identical.  
This is subject to change.</em></p><h3 id="Limits">Limits</h3><pre><code>SELECT 
... &lt;EXPRESSION&gt; [ROWLIMIT N | COLLIMIT N] ...
-</code></pre><p>Limiting the number of row and/or column results can be 
achieved by including one or both of the optional <code>ROWLIMIT</code> and 
<code>COLLIMIT</code> clauses after a <code>SELECT</code> expression.</p><h3 
id="Ordering">Ordering</h3><pre><code>SELECT ... [[ASC | ASCENDING] | [DESC | 
DESCENDING]]
-</code></pre><p>By default, results are returned in the order determined by 
the column family comparator, <em>this is always considered ascending 
order</em>.  Reversing this sort order is possible by supplying the 
<code>DESCENDING</code> clause in <code>SELECT</code> statements.</p><p>The 
<code>ASCENDING</code> keyword is also included, both for completeness sake, 
and to improve statement readability if desired.  It has no effect 
otherwise.</p><p><em>NOTE: The keywords <code>ASC</code> and <code>DESC</code> 
are valid abbreviations for <code>ASCENDING</code> and <code>DESCENDING</code> 
respectively.</em></p><h2 
id="UPDATE">UPDATE</h2><p><em>Synopsis:</em></p><pre><code>UPDATE &lt;COLUMN 
FAMILY&gt; [USING CONSISTENCY.&lt;CL&gt;] WITH
-        ROW(&lt;KEY&gt;, COL(&lt;NAME&gt;, &lt;VALUE&gt;), ...);
-</code></pre><p>An <code>UPDATE</code> is used to write one or more records to 
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>SELECT ... [USING &lt;CONSISTENCY&gt;] ...
-</code></pre><p>Following the column family identifier is an optional <a 
href="#consistency">consistency level specification</a>.</p><h3 
id="RowsandColumns">Rows and Columns</h3><pre><code>... WITH ROW(&lt;KEY&gt;, 
COL(&lt;NAME&gt;, &lt;VALUE&gt;), ...)[, ROW(&lt;KEY&gt;, ...)];
-</code></pre><p>Rows are constructed by creating a parenthesized expression 
using the <code>ROW</code> keyword.  Within the parenthesis, row specifications 
contain a key <a href="#terms">term</a>, followed by a comma, and one or more 
comma delimited column specifications. Columns are in turn a parenthesized 
expression using the <code>COLUMN</code> keyword, with two comma delimited <a 
href="#terms">term</a> arguments, the column name and value respectively.  More 
than one row can be specified by separating them with commas.</p><p><em>NOTE: 
While there are no isolation guarantees,  <code>UPDATE</code> queries are 
atomic.</em></p><h2 id="CommonIdioms">Common Idioms</h2><h3 
id="consistency">Specifying Consistency</h3><pre><code>... USING 
&lt;CONSISTENCY&gt; ...
+<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD 
XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";><html 
xmlns="http://www.w3.org/1999/xhtml";><head><meta http-equiv="Content-Type" 
content="text/html; charset=utf-8"/></head><body><h1 
id="CassandraQueryLanguageCQLv0.99.1">Cassandra Query Language (CQL) 
v0.99.1</h1><h2 id="TableofContents">Table of Contents</h2><ol 
style="list-style: none;"><li><a 
href="#CassandraQueryLanguageCQLv0.99.1">Cassandra Query Language (CQL) 
v0.99.1</a><ol style="list-style: none;"><li><a href="#TableofContents">Table 
of Contents</a></li><li><a href="#USE">USE</a></li><li><a 
href="#SELECT">SELECT</a><ol style="list-style: none;"><li><a 
href="#SpecifyingColumns">Specifying Columns</a></li><li><a 
href="#ColumnFamily">Column Family</a></li><li><a 
href="#ConsistencyLevel">Consistency Level</a></li><li><a 
href="#Filteringrows">Filtering rows</a></li><li><a 
href="#Limits">Limits</a></li></ol></li>
 <li><a href="#UPDATE">UPDATE</a><ol style="list-style: none;"><li><a 
href="#ColumnFamily2">Column Family</a></li><li><a 
href="#ConsistencyLevel2">Consistency Level</a></li><li><a 
href="#SpecifyingColumnsandRow">Specifying Columns and 
Row</a></li></ol></li><li><a href="#CommonIdioms">Common Idioms</a><ol 
style="list-style: none;"><li><a href="#consistency">Specifying 
Consistency</a></li><li><a href="#terms">Term specification</a><ol 
style="list-style: none;"><li><a href="#StringLiterals">String 
Literals</a></li><li><a href="#Integerslongs">Integers / 
longs</a></li></ol></li></ol></li></ol></li></ol><h2 
id="USE">USE</h2><p><i>Synopsis:</i></p><pre><code>USE &lt;KEYSPACE&gt;;
+</code></pre><p>A <code>USE</code> statement consists of the <code>USE</code> 
keyword, followed by a valid keyspace name.  Its purpose is to assign the 
per-connection, current working keyspace.  All subsequent keyspace-specific 
actions will be performed in the context of the supplied value.</p><h2 
id="SELECT">SELECT</h2><p><i>Synopsis:</i></p><pre><code>SELECT [FIRST N] 
[REVERSED] &lt;SELECT EXPR&gt; FROM &lt;COLUMN FAMILY&gt; [USING 
&lt;CONSISTENCY&gt;]
+        [WHERE &lt;CLAUSE&gt;] [LIMIT N];
+</code></pre><p>A <code>SELECT</code> is used to read one or more records from 
a Cassandra column family. It returns a result-set of rows, where each row 
consists of a key and a collection of columns corresponding to the 
query.</p><h3 id="SpecifyingColumns">Specifying Columns</h3><pre><code>SELECT 
[FIRST N] [REVERSED] name1, name2, name3 FROM ...
+SELECT [FIRST N] [REVERSED] name1..nameN FROM ...
+</code></pre><p>The SELECT expression determines which columns will appear in 
the results and takes the form of either a comma separated list of names, or a 
range. The range notation consists of a start and end column name separated by 
two periods (<code>..</code>). The set of columns returned for a range is start 
and end inclusive.</p><p>The <code>FIRST</code> option accepts an integer 
argument and can be used to apply a limit to the number of columns returned per 
row.  When this limit is left unset it defaults to 10,000 columns.</p><p>The 
<code>REVERSED</code> option causes the sort order of the results to be 
reversed.</p><p>It is worth noting that unlike the projection in a SQL SELECT, 
there is no guarantee that the results will contain all of the columns 
specified. This is because Cassandra is schema-less and there are no guarantees 
that a given column exists.</p><h3 id="ColumnFamily">Column 
Family</h3><pre><code>SELECT ... FROM &lt;COLUMN FAMILY&gt; ...
+</code></pre><p>The <code>FROM</code> clause is used to specify the Cassandra 
column family applicable to a <code>SELECT</code> query.</p><h3 
id="ConsistencyLevel">Consistency Level</h3><pre><code>SELECT ... [USING 
&lt;CONSISTENCY&gt;] ...
+</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;]
+        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;] ...
+</code></pre><p>Following the column family identifier is an optional <a 
href="#consistency">consistency level specification</a>.</p><h3 
id="SpecifyingColumnsandRow">Specifying Columns and Row</h3><pre><code>UPDATE 
... SET name1 = value1, name2 = value2 WHERE KEY = keyname;
+</code></pre><p>Rows are created or updated by supplying column names and 
values in term assignment format. Multiple columns can be set by separating the 
name/value pairs using commas.  Each update statement requires exactly one key 
to be specified using a WHERE clause and the <code>KEY</code> 
keyword.</p><p>Additionally, it is also possible to send multiple UPDATES to a 
node at once using a batch syntax:</p><pre><code>BEGIN BATCH [USING 
&lt;CONSISTENCY&gt;]
+UPDATE CF1 SET name1 = value1, name2 = value2 WHERE KEY = keyname1;
+UPDATE CF1 SET name3 = value3 WHERE KEY = keyname2;
+UPDATE CF2 SET name4 = value4, name5 = value5 WHERE KEY = keyname3;
+APPLY BATCH
+</code></pre><p>When batching UPDATEs, a single consistency level is used for 
the entire batch, it appears after the <code>BEGIN BATCH</code> statement, and 
uses the standard <a href="#consistency">consistency level specification</a>. 
Batch UPDATEs default to <code>CONSISTENCY.ONE</code> when left 
unspecified.</p><p><em>NOTE: While there are no isolation guarantees,  
<code>UPDATE</code> queries are atomic within a give record.</em></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="StringLiterals">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="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 s
 pecify an integer term that will not fit in 4 bytes unsigned, or a long that 
will not fit in 8 bytes unsigned.</p></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=1036110&r1=1036109&r2=1036110&view=diff
==============================================================================
--- cassandra/trunk/doc/cql/CQL.textile (original)
+++ cassandra/trunk/doc/cql/CQL.textile Wed Nov 17 16:57:21 2010
@@ -73,10 +73,10 @@ h2. UPDATE
 _Synopsis:_
 
 bc. 
-UPDATE <COLUMN FAMILY> [USING CONSISTENCY.<CL>] WITH
-        ROW(<KEY>, COL(<NAME>, <VALUE>), ...);
+UPDATE <COLUMN FAMILY> [USING CONSISTENCY.<CL>]
+        SET name1 = value1, name2 = value2 WHERE KEY = keyname;
         
-An @UPDATE@ is used to write one or more records to a Cassandra column family. 
No results are returned.
+An @UPDATE@ is used to write one or more columns to a record in a Cassandra 
column family. No results are returned.
 
 h3. Column Family
 
@@ -88,18 +88,29 @@ Statements begin with the @UPDATE@ keywo
 h3. Consistency Level
 
 bc. 
-SELECT ... [USING <CONSISTENCY>] ...
+UPDATE ... [USING <CONSISTENCY>] ...
 
 Following the column family identifier is an optional "consistency level 
specification":#consistency.
 
-h3. Rows and Columns
+h3. Specifying Columns and Row
 
 bc. 
-... WITH ROW(<KEY>, COL(<NAME>, <VALUE>), ...)[, ROW(<KEY>, ...)];
+UPDATE ... SET name1 = value1, name2 = value2 WHERE KEY = keyname;
 
-Rows are constructed by creating a parenthesized expression using the @ROW@ 
keyword.  Within the parenthesis, row specifications contain a key 
"term":#terms, followed by a comma, and one or more comma delimited column 
specifications. Columns are in turn a parenthesized expression using the 
@COLUMN@ keyword, with two comma delimited "term":#terms arguments, the column 
name and value respectively.  More than one row can be specified by separating 
them with commas.
+Rows are created or updated by supplying column names and values in term 
assignment format. Multiple columns can be set by separating the name/value 
pairs using commas.  Each update statement requires exactly one key to be 
specified using a WHERE clause and the @KEY@ keyword.
 
-_NOTE: While there are no isolation guarantees,  @UPDATE@ queries are atomic._
+Additionally, it is also possible to send multiple UPDATES to a node at once 
using a batch syntax:
+
+bc. 
+BEGIN BATCH [USING <CONSISTENCY>]
+UPDATE CF1 SET name1 = value1, name2 = value2 WHERE KEY = keyname1;
+UPDATE CF1 SET name3 = value3 WHERE KEY = keyname2;
+UPDATE CF2 SET name4 = value4, name5 = value5 WHERE KEY = keyname3;
+APPLY BATCH
+
+When batching UPDATEs, a single consistency level is used for the entire 
batch, it appears after the @BEGIN BATCH@ statement, and uses the standard 
"consistency level specification":#consistency. Batch UPDATEs default to 
@CONSISTENCY.ONE@ when left unspecified.
+
+_NOTE: While there are no isolation guarantees,  @UPDATE@ queries are atomic 
within a give record._
 
 h2. Common Idioms
 


Reply via email to