From 84eabc7bbf302c58792167350de4f28561273c5d Mon Sep 17 00:00:00 2001 From: Eric Evans Date: Thu, 17 Feb 2011 01:23:44 +0000 Subject: [PATCH] documentation update for CREATE INDEX Patch by eevans for CASSANDRA-1709 git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1071470 13f79535-47bb-0310-9956-ffa450edef68 --- doc/cql/CQL.html | 5 +++-- doc/cql/CQL.textile | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/cql/CQL.html b/doc/cql/CQL.html index 67ef858659..31a3652599 100644 --- a/doc/cql/CQL.html +++ b/doc/cql/CQL.html @@ -1,4 +1,4 @@ -

Cassandra Query Language (CQL) v0.99.1

Table of Contents

  1. Cassandra Query Language (CQL) v0.99.1
    1. Table of Contents
    2. USE
    3. SELECT
      1. Specifying Columns
      2. Column Family
      3. Consistency Level
      4. Filtering rows
      5. Limits
    4. UPDATE
      1. Column Family
      2. Consistency Level
      3. Specifying Columns and Row
    5. DELETE
      1. Specifying Columns
      2. Column Family
      3. Consistency Level
      4. Specifying Rows
    6. TRUNCATE
    7. CREATE KEYSPACE
    8. CREATE COLUMNFAMILY
      1. Specifying Column Type (optional)
      2. Column Family Options (optional)
    9. Common Idioms
      1. Specifying Consistency
      2. Term specification
        1. String Literals
        2. Unicode
        3. Integers / longs
        4. UUIDs

USE

Synopsis:

USE <KEYSPACE>;
+

Cassandra Query Language (CQL) v0.99.1

Table of Contents

  1. Cassandra Query Language (CQL) v0.99.1
    1. Table of Contents
    2. USE
    3. SELECT
      1. Specifying Columns
      2. Column Family
      3. Consistency Level
      4. Filtering rows
      5. Limits
    4. UPDATE
      1. Column Family
      2. Consistency Level
      3. Specifying Columns and Row
    5. DELETE
      1. Specifying Columns
      2. Column Family
      3. Consistency Level
      4. Specifying Rows
    6. TRUNCATE
    7. CREATE KEYSPACE
    8. CREATE COLUMNFAMILY
      1. Specifying Column Type (optional)
      2. Column Family Options (optional)
    9. CREATE INDEX
    10. Common Idioms
      1. Specifying Consistency
      2. Term specification
        1. String Literals
        2. Unicode
        3. Integers / longs
        4. UUIDs

USE

Synopsis:

USE <KEYSPACE>;
 

A USE statement consists of the USE 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.

SELECT

Synopsis:

SELECT [FIRST N] [REVERSED] <SELECT EXPR> FROM <COLUMN FAMILY> [USING <CONSISTENCY>]
         [WHERE <CLAUSE>] [LIMIT N];
 

A SELECT 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.

Specifying Columns

SELECT [FIRST N] [REVERSED] name1, name2, name3 FROM ...
@@ -32,5 +32,6 @@ UPDATE ... WHERE KEY IN (keyname1, keyname2)
     [AND keyword2 = arg2 [AND ...]]];
 

CREATE COLUMNFAMILY statements create new column family namespaces under the current keyspace. Valid column family names are strings of alphanumeric characters and underscores, which begin with a letter.

Specifying Column Type (optional)

CREATE COLUMNFAMILY <COLUMN FAMILY> (name1 type, name2 type) ...;
 

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:

typedescription
bytesArbitrary bytes (no validation)
asciiASCII character string
utf8UTF8 encoded string
timeuuidType 1 UUID
uuidType 4 UUID
int4-byte integer
long8-byte long

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 AbstractType), either fully qualified, or relative to the org.apache.cassandra.db.marshal package.

Column Family Options (optional)

CREATE COLUMNFAMILY ... WITH keyword1 = arg1 AND keyword2 = arg2;
-

A number of optional keyword arguments can be supplied to control the configuration of a new column family.

keyworddefaultdescription
comparatorbytesDetermines sorting and validation of column names. Valid values are identical to the types listed in Specifying Column Type above.
commentnoneA free-form, human-readable comment.
row_cache_size0Number of rows whose entire contents to cache in memory.
key_cache_size200000Number of keys per SSTable whose locations are kept in memory in “mostly LRU” order.
read_repair_chance1.0The probability with which read repairs should be invoked on non-quorum reads.
gc_grace_seconds864000Time to wait before garbage collecting tombstones (deletion markers).
default_validationbytesDetermines validation of column values. Valid values are identical to the types listed in Specifying Column Type above.
min_compaction_threshold4Minimum number of SSTables needed to start a minor compaction.
max_compaction_threshold32Maximum number of SSTables allowed before a minor compaction is forced.
row_cache_save_period_in_seconds0Number of seconds between saving row caches.
key_cache_save_period_in_seconds14400Number of seconds between saving key caches.
memtable_flush_after_mins60Maximum time to leave a dirty table unflushed.
memtable_throughput_in_mbdynamicMaximum size of the memtable before it is flushed.
memtable_operations_in_millionsdynamicNumber of operations in millions before the memtable is flushed.
replicate_on_writefalse

Common Idioms

Specifying Consistency

... USING <CONSISTENCY> ...
+

A number of optional keyword arguments can be supplied to control the configuration of a new column family.

keyworddefaultdescription
comparatorbytesDetermines sorting and validation of column names. Valid values are identical to the types listed in Specifying Column Type above.
commentnoneA free-form, human-readable comment.
row_cache_size0Number of rows whose entire contents to cache in memory.
key_cache_size200000Number of keys per SSTable whose locations are kept in memory in “mostly LRU” order.
read_repair_chance1.0The probability with which read repairs should be invoked on non-quorum reads.
gc_grace_seconds864000Time to wait before garbage collecting tombstones (deletion markers).
default_validationbytesDetermines validation of column values. Valid values are identical to the types listed in Specifying Column Type above.
min_compaction_threshold4Minimum number of SSTables needed to start a minor compaction.
max_compaction_threshold32Maximum number of SSTables allowed before a minor compaction is forced.
row_cache_save_period_in_seconds0Number of seconds between saving row caches.
key_cache_save_period_in_seconds14400Number of seconds between saving key caches.
memtable_flush_after_mins60Maximum time to leave a dirty table unflushed.
memtable_throughput_in_mbdynamicMaximum size of the memtable before it is flushed.
memtable_operations_in_millionsdynamicNumber of operations in millions before the memtable is flushed.
replicate_on_writefalse

CREATE INDEX

Synopsis:

CREATE INDEX [index_name] ON <column_family> (column_name);
+

A CREATE INDEX statement is used to create a new, automatic secondary index for the named column.

Common Idioms

Specifying Consistency

... USING <CONSISTENCY> ...
 

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

Term specification

Where possible, the type of terms are inferred; the following term types are supported:

String Literals

String literals are any value enclosed in double-quotes, (`"`). String literals are treated as raw bytes; no interpolation is performed.

Unicode

Unicode terms are any double-quoted string prefixed with a lower-case u, for example u"© 2011 The Apache Software Foundation". Unicode terms are identical to standard string literals, with the exception that they are encoded to bytes using the UTF-8 charset.

Integers / longs

Integers are any term consisting soley of unquoted numericals, longs are any otherwise valid integer term followed by an upper case “L”, (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.

UUIDs

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 timeuuid(<UUID STRING>) and uuid(<UUID STRING>) notations respectively.

In addition to the hex-based string representation, timeuuid() terms also accept arguments to specify the data-time component. The full list of timeuuid() arguments are:

argumentexamplebehavior
nonetimeuuid()Results in the creation of a new UUID based on system time of the node parsing the query.
nowtimeuuid(“now”)Results in the creation of a new UUID based on system time of the node parsing the query.
milliseconds since epochtimeuuid(1296755320376)Creates a UUID with a time component that is based on the supplied time-stamp.
iso8601 timestamptimeuuid(“2011-02-01T14:00-0600”)Creates a UUID with a time component that is based on the supplied time-stamp.
string representation (hex)timeuuid(“e9229b24-2fbe-11e0-a4de-0026c650d722”)Reproduces the specified version 1 UUID node-side.
\ No newline at end of file diff --git a/doc/cql/CQL.textile b/doc/cql/CQL.textile index 574893737f..27bc0ceac6 100644 --- a/doc/cql/CQL.textile +++ b/doc/cql/CQL.textile @@ -227,6 +227,14 @@ A number of optional keyword arguments can be supplied to control the configurat |memtable_operations_in_millions|dynamic|Number of operations in millions before the memtable is flushed.| |replicate_on_write|false| | +h2. CREATE INDEX + +_Synopsis:_ + +bc. CREATE INDEX [index_name] ON (column_name); + +A @CREATE INDEX@ statement is used to create a new, automatic secondary index for the named column. + h2. Common Idioms h3(#consistency). Specifying Consistency