http://git-wip-us.apache.org/repos/asf/cassandra/blob/38027382/src/resources/org/apache/cassandra/cli/CliHelp.yaml ---------------------------------------------------------------------- diff --git a/src/resources/org/apache/cassandra/cli/CliHelp.yaml b/src/resources/org/apache/cassandra/cli/CliHelp.yaml deleted file mode 100644 index cc838f8..0000000 --- a/src/resources/org/apache/cassandra/cli/CliHelp.yaml +++ /dev/null @@ -1,1262 +0,0 @@ - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Help file for online commands in Yaml. - -banner: | - Type 'help;' or '?' for help. - Type 'quit;' or 'exit;' to quit. - -help: | - Getting around: - ? Display this help. - help; Display this help. - help <command>; Display command-specific help. - exit; Exit this utility. - quit; Exit this utility. - - Commands: - assume Apply client side validation. - connect Connect to a Cassandra node. - consistencylevel Sets consisteny level for the client to use. - count Count columns or super columns. - create column family Add a column family to an existing keyspace. - create keyspace Add a keyspace to the cluster. - del Delete a column, super column or row. - decr Decrements a counter column. - describe cluster Describe the cluster configuration. - describe Describe a keyspace and its column families or column family in current keyspace. - drop column family Remove a column family and its data. - drop keyspace Remove a keyspace and its data. - drop index Remove an existing index from specific column. - get Get rows and columns. - incr Increments a counter column. - list List rows in a column family. - set Set columns. - show api version Show the server API version. - show cluster name Show the cluster name. - show keyspaces Show all keyspaces and their column families. - show schema Show a cli script to create keyspaces and column families. - truncate Drop the data in a column family. - update column family Update the settings for a column family. - update keyspace Update the settings for a keyspace. - use Switch to a keyspace. - -commands: - - name: NODE_HELP - help: | - help <command>; - - Display the general help page with a list of available commands.; - - name: NODE_CONNECT - help: | - connect <hostname>/<port> (<username> '<password>')?; - - Connect to the a Cassandra node on the specified port. - - If a username and password are supplied the login will occur when the - 'use' statement is executed. If the server does not support authentication - it will silently ignore credentials. - - For information on configuring authentication and authorisation see the - conf/cassandra.yaml file or the project documentation. - - Required Parameters: - - hostname: Machine name or IP address of the node to connect to. - - - port: rpc_port to connect to the node on, as defined in - conf/Cassandra.yaml for the node. The default port is 9160. - - Optional Parameters: - - password: Password for the supplied username. - - - username: Username to authenticate to the node as. - - Examples: - connect localhost/9160; - connect localhost/9160 user 'badpasswd'; - connect 127.0.0.1/9160 user 'badpasswd'; - - name: NODE_USE_TABLE - help: | - use <keyspace>; - use <keyspace> <username> '<password>'; - - Use the specified keyspace. - - If a username and password are supplied they will be used to authorize - against the keyspace. Otherwise the credentials supplied to the 'connect' - statement will be used to authorize the user . If the server does not - support authentication it will silently ignore credentials. - - Required Parameters: - - keyspace: Name of the keyspace to use. The keyspace must exist. - - Optional Parameters: - - password: Password for the supplied username. - - - username: Username to login to the node as. - - Examples: - use Keyspace1; - use Keyspace1 user 'badpasswd'; - - name: NODE_DESCRIBE - help: | - describe; - describe <keyspace>; - describe <column_family>; - - Describes the settings for the current or named keyspace, or the settings - of the column family in the current authenticated keyspace. - - Optional Parameters: - - keyspace: Name of the keyspace to describe. - - column_family: Name of the column family to describe. - - Examples: - describe; - Describes current authenticated keyspace - describe <keyspace>; - Describe this keyspace - describe <column_family>; - Describe the colum family in the current authenticated keyspace - - name: NODE_DESCRIBE_CLUSTER - help: | - describe cluster; - - Describes the snitch, partitioner and schema versions for the currently - connected cluster. - - NOTE: The cluster should only report one schema version. Multiple versions - may indicate a failed schema modification, consult the project documentation. - - Examples: - describe cluster; - - name: NODE_EXIT - help: | - exit; - quit; - - Exit this utility. - - Examples: - exit; - quit; - - name: NODE_SHOW_CLUSTER_NAME - help: | - show cluster name; - - Displays the name of the currently connected cluster. - - Examples: - show cluster name; - - name: NODE_SHOW_VERSION - help: | - show api version; - - Displays the API version number. - - This version number is used by high level clients and is not the same as - the server release version. - - Examples: - show api version; - - name: NODE_SHOW_KEYSPACES - help: | - show keyspaces; - - Describes the settings and the column families for all keyspaces on the - currently connected cluster. - - Examples: - show keyspaces; - - name: NODE_SHOW_SCHEMA - help: | - show schema; - show schema <keyspace>; - - Creates a CLI script to create the current, specified or all keyspaces - and their column families. - - Optional Parameters: - - keyspace: Name of the keyspace to create the script for. If omitted - the current keyspace is used, if there is no current keyspace all - keyspaces are considered. - - Examples: - show schema; - show schema Keyspace1; - - name: NODE_ADD_KEYSPACE - help: | - create keyspace <keyspace>; - create keyspace <keyspace> with <att1>=<value1>; - create keyspace <keyspace> with <att1>=<value1> and <att2>=<value2> ...; - - Create a keyspace with the specified attributes. - - Required Parameters: - - keyspace: Name of the new keyspace, "system" is reserved for - Cassandra internals. Names may only contain letters, numbers and - underscores. - - Keyspace Attributes (all are optional): - - placement_strategy: Class used to determine how replicas - are distributed among nodes. Defaults to NetworkTopologyStrategy with - one datacenter defined with a replication factor of 1 ("[datacenter1:1]"). - - Supported values are: - - org.apache.cassandra.locator.SimpleStrategy - - org.apache.cassandra.locator.NetworkTopologyStrategy - - org.apache.cassandra.locator.OldNetworkTopologyStrategy - - SimpleStrategy merely places the first replica at the node whose - token is closest to the key (as determined by the Partitioner), and - additional replicas on subsequent nodes along the ring in increasing - Token order. - - Supports a single strategy option 'replication_factor' that - specifies the replication factor for the cluster. - - With NetworkTopologyStrategy, for each datacenter, you can specify - how many replicas you want on a per-keyspace basis. Replicas are - placed on different racks within each DC, if possible. - - Supports strategy options which specify the replication factor for - each datacenter. The replication factor for the entire cluster is the - sum of all per datacenter values. Note that the datacenter names - must match those used in conf/cassandra-topology.properties. - - OldNetworkToplogyStrategy [formerly RackAwareStrategy] - places one replica in each of two datacenters, and the third on a - different rack in in the first. Additional datacenters are not - guaranteed to get a replica. Additional replicas after three are - placed in ring order after the third without regard to rack or - datacenter. - - Supports a single strategy option 'replication_factor' that - specifies the replication factor for the cluster. - - - strategy_options: Optional additional options for placement_strategy. - Options have the form {key:value}, see the information on each - strategy and the examples. - - - durable_writes: When set to false all Mutations on keyspace will by-pass CommitLog. - Set to true by default. - - Examples: - create keyspace Keyspace2 - with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' - and strategy_options = {replication_factor:4}; - create keyspace Keyspace3 - with placement_strategy = 'org.apache.cassandra.locator.NetworkTopologyStrategy' - and strategy_options={DC1:2, DC2:2}; - create keyspace Keyspace4 - with placement_strategy = 'org.apache.cassandra.locator.OldNetworkTopologyStrategy' - and strategy_options = {replication_factor:1}; - - name: NODE_UPDATE_KEYSPACE - help: | - update keyspace <keyspace>; - update keyspace <keyspace> with <att1>=<value1>; - update keyspace <keyspace> with <att1>=<value1> and <att2>=<value2> ...; - - Update a keyspace with the specified attributes. - - Note: updating some keyspace properties may require additional maintenance - actions. Consult project documentation for more details. - - Required Parameters: - - keyspace: Name of the keyspace to update. - - Keyspace Attributes (all are optional): - - placement_strategy: Class used to determine how replicas - are distributed among nodes. Defaults to NetworkTopologyStrategy with - one datacenter defined with a replication factor of 1 ("[datacenter1:1]"). - - Supported values are: - - org.apache.cassandra.locator.SimpleStrategy - - org.apache.cassandra.locator.NetworkTopologyStrategy - - org.apache.cassandra.locator.OldNetworkTopologyStrategy - - SimpleStrategy merely places the first replica at the node whose - token is closest to the key (as determined by the Partitioner), and - additional replicas on subsequent nodes along the ring in increasing - Token order. - - Supports a single strategy option 'replication_factor' that - specifies the replication factor for the cluster. - - With NetworkTopologyStrategy, for each datacenter, you can specify - how many replicas you want on a per-keyspace basis. Replicas are - placed on different racks within each DC, if possible. - - Supports strategy options which specify the replication factor for - each datacenter. The replication factor for the entire cluster is the - sum of all per datacenter values. Note that the datacenter names - must match those used in conf/cassandra-topology.properties. - - OldNetworkToplogyStrategy [formerly RackAwareStrategy] - places one replica in each of two datacenters, and the third on a - different rack in in the first. Additional datacenters are not - guaranteed to get a replica. Additional replicas after three are - placed in ring order after the third without regard to rack or - datacenter. - - Supports a single strategy option 'replication_factor' that - specifies the replication factor for the cluster. - - - strategy_options: Optional additional options for placement_strategy. - Options have the form {key:value}, see the information on each - strategy and the examples. - - - durable_writes: When set to false all Mutations on keyspace will by-pass CommitLog. - Set to true by default. - - Examples: - update keyspace Keyspace2 - with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' - and strategy_options = {replication_factor:4}; - update keyspace Keyspace3 - with placement_strategy = 'org.apache.cassandra.locator.NetworkTopologyStrategy' - and strategy_options={DC1:2, DC2:2}; - update keyspace Keyspace4 - with placement_strategy = 'org.apache.cassandra.locator.OldNetworkTopologyStrategy' - and strategy_options = {replication_factor:1}; - - name: NODE_ADD_COLUMN_FAMILY - help: | - create column family <name>; - create column family <name> with <att1>=<value1>; - create column family <name> with <att1>=<value1> and <att2>=<value2>...; - - Create a column family in the current keyspace with the specified - attributes. - - Required Parameters: - - name: Name of the new column family. Names may only contain letters, - numbers and underscores. - - column family Attributes (all are optional): - - column_metadata: Defines the validation and indexes for known columns in - this column family. - - Columns not listed in the column_metadata section will use the - default_validator to validate their values. - - Column Required parameters: - - name: Binds a validator (and optionally an indexer) to columns - with this name in any row of the enclosing column family. - - - validator: Validator to use for values for this column. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - CompositeType (should be used with sub-types specified e.g. 'CompositeType(UTF8Type, Int32Type)' - quotes are important (!) in this case) - - It is also valid to specify the fully-qualified class name to a class - that extends org.apache.cassandra.db.marshal.AbstractType. - - Column Optional parameters: - - index_name: Name for the index. Both an index name and - type must be specified. - - - index_type: The type of index to be created. - - Suported values are: - - KEYS: a ColumnFamily backed index - - CUSTOM: a user supplied index implementaion. You must supply a - 'class_name' field in the index_options with the full classname - of the implementation. - - - index_options: Optional additional options for index_type. - Options have the form {key:value}. - - - bloom_filter_fp_chance: Desired false positive probability for - sstable row bloom filters. Default is 0.000744. - - - index_interval: controls the sampling of entries from the primrary - row index in terms of space versus time. The larger the interval, - the smaller and less effective the sampling will be. All the sampled - entries must fit in memory. Default value is 128. - - - column_type: Type of columns this column family holds, valid values are - Standard and Super. Default is Standard. - - - comment: Human readable column family description. - - - comparator: Validator to use to validate and compare column names in - this column family. For Standard column families it applies to columns, for - Super column families applied to super columns. Also see the subcomparator - attribute. Default is BytesType, which is a straight forward lexical - comparison of the bytes in each column. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - CompositeType (should be used with sub-types specified e.g. 'CompositeType(UTF8Type, Int32Type)' - quotes are important (!) in this case) - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - - default_validation_class: Validator to use for values in columns which are - not listed in the column_metadata. Default is BytesType which applies - no validation. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - CompositeType (should be used with sub-types specified e.g. 'CompositeType(UTF8Type, Int32Type)' - quotes are important (!) in this case) - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - - key_validation_class: Validator to use for keys. - Default is BytesType which applies no validation. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - - gc_grace: Time to wait in seconds before garbage collecting tombstone - deletion markers. Default value is 864000 or 10 days. - - Set this to a large enough value that you are confident that the deletion - markers will be propagated to all replicas by the time this many seconds - has elapsed, even in the face of hardware failures. - - See http://wiki.apache.org/Cassandra/DistributedDeletes - - - read_repair_chance: Probability (0.0-1.0) with which to perform read - repairs for any read operation. Default is 0.1. - - Note that disabling read repair entirely means that the dynamic snitch - will not have any latency information from all the replicas to recognize - when one is performing worse than usual. - - - dclocal_read_repair_chance: Probability (0.0-1.0) with which to - perform read repairs against the node from the local data-center. If - this is lower than read_repair_chance, this will be ignored. - - Example: - update column family Standard2 - with read_repair_chance=0.1 - and dclocal_read_repair_chance=0.5; - - For 10 read queries, 1 will do read repair on all replicas (and - thus in particular on all replica of the local DC), 4 will only do - read repair on replica of the local DC and 5 will not do any read - repair. - - - subcomparator: Validator to use to validate and compare sub column names - in this column family. Only applied to Super column families. Default is - BytesType, which is a straight forward lexical comparison of the bytes in - each column. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - - max_compaction_threshold: The maximum number of SSTables allowed before a - minor compaction is forced. Default is 32, setting to 0 disables minor - compactions. - - Decreasing this will cause minor compactions to start more frequently and - be less intensive. The min_compaction_threshold and max_compaction_threshold - boundaries are the number of tables Cassandra attempts to merge together at - once. - - - min_compaction_threshold: The minimum number of SSTables needed - to start a minor compaction. Default is 4, setting to 0 disables minor - compactions. - - Increasing this will cause minor compactions to start less frequently and - be more intensive. The min_compaction_threshold and max_compaction_threshold - boundaries are the number of tables Cassandra attempts to merge together at - once. - - - compression_options: Options related to compression. - Options have the form {key:value}. - The main recognized options are: - - sstable_compression: the algorithm to use to compress sstables for - this column family. If none is provided, compression will not be - enabled. Supported values are SnappyCompressor, DeflateCompressor or - any custom compressor. It is also valid to specify the fully-qualified - class name to a class that implements org.apache.cassandra.io.ICompressor. - - - chunk_length_kb: specify the size of the chunk used by sstable - compression (default to 64, must be a power of 2). - - To disable compression just set compression_options to null like this - `compression_options = null`. - - Examples: - create column family Super4 - with column_type = 'Super' - and comparator = 'AsciiType' - and caching='ALL'; - create column family Standard3 - with comparator = 'LongType' - and caching='ALL'; - create column family Standard4 - with comparator = AsciiType - and column_metadata = - [{ - column_name : Test, - validation_class : IntegerType, - index_type : 0, - index_name : IdxName}, - { - column_name : 'other name', - validation_class : LongType - }]; - create column family UseComposites - with comparator = 'CompositeType(UTF8Type, Int32Type)' - and caching='ALL'; - - name: NODE_UPDATE_COLUMN_FAMILY - help: | - update column family <name>; - update column family <name> with <att1>=<value1>; - update column family <name> with <att1>=<value1> and <att2>=<value2>...; - - Updates the settings for a column family in the current keyspace. - - Required Parameters: - - name: Name of the column family to update. - - column family Attributes (all are optional): - - column_metadata: Defines the validation and indexes for known columns in - this column family. - - Columns not listed in the column_metadata section will use the - default_validator to validate their values. - - Column Required parameters: - - name: Binds a validator (and optionally an indexer) to columns - with this name in any row of the enclosing column family. - - - validator: Validator to use for values for this column. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - CompositeType (should be used with sub-types specified e.g. 'CompositeType(UTF8Type, Int32Type)' - quotes are important (!) in this case) - - It is also valid to specify the fully-qualified class name to a class - that extends org.apache.cassandra.db.marshal.AbstractType. - - Column Optional parameters: - - index_name: Name for the index. Both an index name and - type must be specified. - - NOTE: After the update has completed the column family will only - contain the secondary indexes listed in the update statement. Existing - indexes will be dropped if they are not present in the update. - - - index_type: The type of index to be created. - - Suported values are: - - KEYS: a ColumnFamily backed index - - CUSTOM: a user supplied index implementaion. You must supply a - 'class_name' field in the index_options with the full classname - of the implementation. - - - index_options: Optional additional options for index_type. - Options have the form {key:value}. - - - bloom_filter_fp_chance: Desired false positive probability for - sstable row bloom filters. Default is 0.000744. - - - column_type: Type of columns this column family holds, valid values are - Standard and Super. Default is Standard. - - - comment: Column family description. - - - comparator: Validator to use to validate and compare column names in - this column family. For Standard column families it applies to columns, for - Super column families applied to super columns. Also see the subcomparator - attribute. Default is BytesType, which is a straight forward lexical - comparison of the bytes in each column. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - CompositeType (should be used with sub-types specified e.g. 'CompositeType(UTF8Type, Int32Type)' - quotes are important (!) in this case) - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - - default_validation_class: Validator to use for values in columns which are - not listed in the column_metadata. Default is BytesType which applies - no validation. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - CompositeType (should be used with sub-types specified e.g. 'CompositeType(UTF8Type, Int32Type)' - quotes are important (!) in this case) - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - - key_validation_class: Validator to use for keys. - Default is BytesType which applies no validation. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - - gc_grace: Time to wait in seconds before garbage collecting tombstone - deletion markers. Default value is 864000 or 10 days. - - Set this to a large enough value that you are confident that the deletion - markers will be propagated to all replicas by the time this many seconds - has elapsed, even in the face of hardware failures. - - See http://wiki.apache.org/Cassandra/DistributedDeletes - - - read_repair_chance: Probability (0.0-1.0) with which to perform read - repairs for any read operation. Default is 0.1. - - Note that disabling read repair entirely means that the dynamic snitch - will not have any latency information from all the replicas to recognize - when one is performing worse than usual. - - - dclocal_read_repair_chance: Probability (0.0-1.0) with which to - perform read repairs against the node from the local data-center. If - this is lower than read_repair_chance, this will be ignored. - - Example: - update column family Standard2 - with read_repair_chance=0.1 - and dclocal_read_repair_chance=0.5; - - For 10 read queries, 1 will do read repair on all replicas (and - thus in particular on all replica of the local DC), 4 will only do - read repair on replica of the local DC and 5 will not do any read - repair. - - - subcomparator: Validator to use to validate and compare sub column names - in this column family. Only applied to Super column families. Default is - BytesType, which is a straight forward lexical comparison of the bytes in - each column. - - Supported values are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - - caching: Enable/Disable caching for the column family. - - There is 2 kind of caches: key cache and row cache. A column family - can be set to use no cache, only one of them or both. - - A key cache hit saves 1 seek while a row cache hit avoids disk - completely (saving at least 2 seeks). However the row cache holds - entire rows and is thus much more space-intensive. Also, since full - rows are stored, row cache should be used only for column families - whose rows are small. - - Note: the global memory size of both cache can be set in the - configuration file (yaml) or through JMX (though it isn't persisted - across restarts in that latter case). - - Supported values are: - - ALL (Enable row cache and key Cache) - - KEYS_ONLY - - ROWS_ONLY - - NONE; - - cells_per_row_to_cache: State the number of cells per row to cache. - - Defaults to 100. Set to "ALL" if you want the old cache behaviour. - - Will not be used if row caching is not enabled. - - speculative_retry: Speculative retry is used to speculate a read failure. - - Speculative retry will execute additional read on a different nodes when - the read request doesn't complete within the x milliseconds. - - Xpercentile will execute additional read requests to a different replicas - when read request was not completed within X percentile of the - normal/earlier recorded latencies. - - Xms will execute additional read request to a diffrent replica when read - request was not completed in X milliseconds. - - ALWAYS will execute data read request to 2 (If available) of the replicas - expecting a node to fail read. - - Supported values are: - - ALWAYS - - Xpercentile - - Xms - - NONE; - - - max_compaction_threshold: The maximum number of SSTables allowed before a - minor compaction is forced. Default is 32, setting to 0 disables minor - compactions. - - Decreasing this will cause minor compactions to start more frequently and - be less intensive. The min_compaction_threshold and max_compaction_threshold - boundaries are the number of tables Cassandra attempts to merge together at - once. - - - min_compaction_threshold: The minimum number of SSTables needed - to start a minor compaction. Default is 4, setting to 0 disables minor - compactions. - - Increasing this will cause minor compactions to start less frequently and - be more intensive. The min_compaction_threshold and max_compaction_threshold - boundaries are the number of tables Cassandra attempts to merge together at - once. - - - compression_options: Options related to compression. - Options have the form {key:value}. - The main recognized options are: - - sstable_compression: the algorithm to use to compress sstables for - this column family. If none is provided, compression will not be - enabled. Supported values are SnappyCompressor, DeflateCompressor or - any custom compressor. It is also valid to specify the fully-qualified - class name to a class that implements org.apache.cassandra.io.ICompressor. - - - chunk_length_kb: specify the size of the chunk used by sstable - compression (default to 64, must be a power of 2). - - To disable compression just set compression_options to null like this - `compression_options = null`. - - Examples: - update column family Super4 - with column_type = 'Super' - and caching='ALL'; - update column family Standard3 - and caching='ALL'; - update column family Standard4 - with column_metadata = - [{ - column_name : Test, - validation_class : IntegerType, - index_type : 0, - index_name : IdxName}, - { - column_name : 'other name', - validation_class : LongType - }]; - - name: NODE_DEL_KEYSPACE - help: | - drop keyspace <keyspace>; - - Drops the specified keyspace. - - A snapshot of the data is created in a sub directory of the Keyspace data directory. The files - must be manually deleted using either "nodetool clearsnapshot" or the command line. - - Required Parameters: - - keyspace: Name of the keyspace to delete. - - Example: - drop keyspace Keyspace1; - - name: NODE_DEL_COLUMN_FAMILY - help: | - drop column family <cf>; - - Drops the specified column family. - - A snapshot of the data is created in a sub directory of the Keyspace data directory. The files - must be manually deleted using either "nodetool clearsnapshot" or the command line. - - Required Parameters: - - cf: Name of the column family to delete. - - Example: - drop column family Standard2; - - name: NODE_DROP_INDEX - help: | - drop index on <cf>.<column>; - - Drops index on specified column of the column family. - - Required Parameters: - - cf: Name of the column family. - - column: Name of the column to delete index on. - - Example: - drop index on Users.name; - - name: NODE_THRIFT_GET - help: | - get <cf>['<key>']; - get <cf>['<key>']['<col>'] (as <type>)*; - get <cf>['<key>']['<super>']['<col>'] (as <type>)*; - get <cf>['<key>']['<super>']; - get <cf>['<key>'][<function>]; - get <cf>[function(<key>)][<function>(<super>)][<function>(<col>)]; - get <cf> where <col> <operator> <value> [ - and <col> <operator> <value> and ...] [limit <limit>]; - get <cf> where <col> <operator> <function>(<value>) [ - and <col> <operator> <function> and ...] [limit <limit>]; - - Gets columns or super columns for the specified column family and key. Or - returns all columns from rows which meet the specified criteria when using - the 'where' form. - - Note: The implementation of secondary indexes in Cassandra 0.7 has some - restrictions, see - http://www.datastax.com/dev/blog/whats-new-Cassandra-07-secondary-indexes - - Required Parameters: - - cf: Name of the column family to read from. - - Optional Parameters: - - col: Name of the column to read. Or in the 'where' form name of the column - to test the value of. - - - function: Name of a function to call to parse the supplied argument to the - specified type. Some functions will generate values without needing an - argument. - - Valid options are: - - ascii - - bytes: if used without arguments generates a zero length byte array - - int - - integer - - lexicaluuid: if used without arguments generates a new random uuid - - long - - timeuuid: if used without arguments generates a new time uuid - - utf8 - - - key: Key for the row to read columns from. This parameter is - required in all cases except when the 'where' clause is used. - - - limit: Number of rows to return. Default is 100. - - - operator: Operator to test the column value with. Supported operators are - =, >, >=, <, <= . - - In Cassandra 0.7 at least one = operator must be present. - - - super: Name of the super column to read from. If super is supplied without - col then all columns from the super column are returned. - - - type: Data type to interpret the the columns value as for display. - - Valid options are: - - AsciiType - - BooleanType - - BytesType - - CounterColumnType (distributed counter column) - - DateType - - DoubleType - - FloatType - - Int32Type - - IntegerType (a generic variable-length integer type) - - LexicalUUIDType - - LongType - - UTF8Type - - - value: The value to test the column for, if a function is provided the - value is parsed by the function. Otherwise the meta data for the target - column is used to determine the correct type. - - Examples: - get Standard1[ascii('testkey')]; - #tell cli to convert keys from ascii to bytes - assume Standard1 keys as ascii; - get Standard1[testkey][test_column] as IntegerType; - get Standard1[testkey][utf8(hello)]; - get Indexed1 where birthdate=19750403; - - name: NODE_THRIFT_SET - help: | - set <cf>['<key>']['<col>'] = <value>; - set <cf>['<key>']['<super>']['<col>'] = <value>; - set <cf>['<key>']['<col>'] = <function>(<argument>); - set <cf>['<key>']['<super>']['<col>'] = <function>(<argument>); - set <cf>[<key>][<function>(<col>)] = <value> || <function>; - set <cf>[<function>(<key>)][<function>(<col>) || <col>] = - <value> || <function> with ttl = <secs>; - - Sets the column value for the specified column family and key. - - Required Parameters: - - cf: Name of the column family to set columns in. - - - col: Name of the column to set. - - - key: Key for the row to set columns in. - - Optional Parameters: - - function: Name of a function to call to parse the supplied argument to the - specified type. Some functions will generate values without needing an - argument. - - Valid options are: - - ascii - - bytes: if used without arguments generates a zero length byte array - - int - - integer - - lexicaluuid: if used without arguments generates a new random uuid - - long - - timeuuid: if used without arguments generates a new time uuid - - utf8 - - - secs: Time To Live for the column in seconds. Defaults to no ttl. - - - super: Name of the super column to contain the column. - - - value: The value to set the column to. - - Examples: - set Super1[ascii('testkey')][ascii('my super')][ascii('test col')]='this is a test'; - set Standard1['testkey']['test col']='this is also a test'; - set Standard1[testkey][testcol] = utf8('this is utf8 string.'); - set Standard1[testkey][timeuuid()] = utf8('hello world'); - set Standard1[testkey][timeuuid()] = utf8('hello world') with ttl = 30; - set UseComposites[utf8('testkey')]['CompositeType(utf8(first),int(4))'] = utf8('inserts this string into a column with name first:4'); - - name: NODE_THRIFT_DEL - help: | - del <cf>['<key>']; - del <cf>['<key>']['<col>']; - del <cf>['<key>']['<super>']; - del <cf>['<key>']['<super>']['<col>']; - del <cf>[<function>(<key>)][<function>(<super>)][<function>(<col>)]; - - Deletes a row, a column, or a subcolumn. - - Required Parameters: - - cf: Name of the column family to delete from. - - - key: Key for the row delete from. - - Optional Parameters: - - col: Name of the column to delete. - - - function: Name of a function to call to parse the supplied argument to the - specified type. Some functions will generate values without needing an - argument. - - Supported values are: - - ascii - - bytes: if used without arguments generates a zero length byte array - - int - - integer - - lexicaluuid: if used without arguments generates a new random uuid - - long - - double - - timeuuid: if used without arguments generates a new time uuid - - utf8 - - - super: Name of the super column to delete from. If col is not specified - the super column and all sub columns will be deleted. - - Examples: - del Super1[ascii('testkey')][ascii('my_super')][ascii('test_col')]; - del Standard1['testkey'][ascii('test col')]; - del Standard1['testkey']; - del Standard1[utf8('testkey')]; - - name: NODE_THRIFT_COUNT - help: | - count <cf>['<key>']; - count <cf>['<key>']['<super>']; - - Count the number of columns in the row with the specified key, or - subcolumns in the specified super column. - - Required Parameters: - - cf: Name of the column family to read from.. - - - key: Key for the row to count. - - Optional Parameters: - - super: Name of the super column to count subcolumns in. - - Examples: - count Super1['testkey']['my super']; - count Standard1['testkey']; - - name: NODE_LIST - help: | - list <cf>; - list <cf>[<startKey>:]; - list <cf>[<startKey>:<endKey>]; - list <cf>[<startKey>:<endKey>] limit <limit>; - list <cf>[<startKey>:<endKey>] ?(limit <limit>) ?(columns <col_limit> ?(reversed)); - - List a range of rows, and all of their columns, in the specified column - family. - - The order of rows returned is dependant on the Partitioner in use. - - Required Parameters: - - cf: Name of the column family to list rows from. - - Optional Parameters: - - endKey: Key to end the range at. The end key will be included - in the result. Defaults to an empty byte array. - - - limit: Number of rows to return. Default is 100. - - - columns: Number of columns to return per row, Default to MAX_INTEGER. reversed - - columns in reverse order. - - - startKey: Key start the range from. The start key will be - included in the result. Defaults to an empty byte array. - - Examples: - list Standard1; - list Super1[j:]; - list Standard1[j:k] limit 40; - list Standard1 columns 2; - list Standard1 limit 40 columns 0; - list Standard1 columns 3 reversed; - - name: NODE_TRUNCATE - help: | - truncate <cf>; - - Truncate specified column family. - - Note: All nodes in the cluster must be up to truncate command to execute. - - A snapshot of the data is created, which is deleted asyncronously during a - 'graveyard' compaction. - - Required Parameters: - - cf: Name of the column family to truncate. - - Examples: - truncate Standard1; - - name: NODE_ASSUME - help: | - assume <cf> comparator as <type>; - assume <cf> sub_comparator as <type>; - assume <cf> validator as <type>; - assume <cf> keys as <type>; - - Assume one of the attributes (comparator, sub_comparator, validator or keys) - of the given column family match specified type. The specified type will - be used when displaying data returned from the column family. - - This statement does not change the column family definition stored in - Cassandra. It only affects the cli and how it will transform values - to be sent to and interprets results from Cassandra. - - If results from Cassandra do not validate according to the assumptions an - error is displayed in the cli. - - Required Parameters: - - cf: Name of the column family to make the assumption about. - - - type: Validator type to use when processing values. - - Supported values are: - - ascii - - bytes - - counterColumn (distributed counter column) - - int - - integer (a generic variable-length integer type) - - lexicalUUID - - long - - utf8 - - It is also valid to specify the fully-qualified class name to a class that - extends org.apache.cassandra.db.marshal.AbstractType. - - Examples: - assume Standard1 comparator as lexicaluuid; - assume Standard1 keys as ascii; - - name: NODE_THRIFT_INCR - help: | - incr <cf>['<key>']['<col>'] [by <value>]; - incr <cf>['<key>']['<super>']['<col>'] [by <value>]; - - Increment the specified counter column by the supplied value. - - Note: Counter columns must be defined using a 'create column family' or - 'update column family' statement in the column_metadata as using the - ColumnCounterType validator. - - Required Parameters: - - cf: Name of the column family to increment the column in. - - - col: Name of the counter column to increment. - - - key: Key for the row to increment the counter in. - - Optional Parameters: - - super: Name of the super column that contains the counter column. - - - value: Signed integer value to increment the column by. If not supplied - 1 is used. - - Examples: - incr Counter1[ascii('testkey')][ascii('test col')]; - incr SuperCounter1[ascii('testkey')][ascii('my super')][ascii('test col')] by 42; - incr Counter1[ascii('testkey')][ascii('test col')] by -4; - - name: NODE_THRIFT_DECR - help: | - decr <cf>['<key>']['<col>'] [by <value>]; - decr <cf>['<key>']['<super>']['<col>'] [by <value>]; - - Decrement the specified column by the supplied value. - - Note: Counter columns must be defined using a 'create column family' or - 'update column family' statement in the column_metadata as using the - ColumnCounterType validator. - - Required Parameters: - - cf: Name of the column family to decrement the column in. - - - col: Name of the counter column to increment. - - - key: Key for the row to decrement the counter in. - - Optional Parameters: - - super: Name of the super column that contains the counter column. - - - value: Signed integer value to decrement the column by. If not supplied - 1 is used. - - Examples: - decr Counter1[ascii('testkey')][ascii('test col')]; - decr SuperCounter1[ascii('testkey')][ascii('my super')][ascii('test col')] by 42; - decr Counter1[ascii('testkey')][ascii('test col')] by 10; - - name: NODE_CONSISTENCY_LEVEL - help: | - consistencylevel as <level> - - Sets the consistency level for the client to use. Defaults to One. - - Required Parameters: - - level: Consistency level the client should use. Value is case - insensitive. - - Supported values are: - - ONE - - TWO - - THREE - - QUORUM - - ALL - - LOCAL_QUORUM - - EACH_QUORUM - - ANY - - Note: Consistency level ANY can only be used for write operations.
http://git-wip-us.apache.org/repos/asf/cassandra/blob/38027382/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java ---------------------------------------------------------------------- diff --git a/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java b/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java index 877d30b..a51950b 100644 --- a/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java +++ b/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java @@ -18,32 +18,20 @@ package org.apache.cassandra.pig; import java.io.IOException; -import java.nio.charset.CharacterCodingException; import java.util.Iterator; import org.junit.Assert; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; -import org.apache.cassandra.db.marshal.TimeUUIDType; -import org.apache.cassandra.db.marshal.UUIDType; import org.apache.cassandra.exceptions.ConfigurationException; -import org.apache.cassandra.thrift.AuthenticationException; -import org.apache.cassandra.thrift.AuthorizationException; -import org.apache.cassandra.thrift.InvalidRequestException; -import org.apache.cassandra.thrift.NotFoundException; -import org.apache.cassandra.thrift.TimedOutException; -import org.apache.cassandra.thrift.UnavailableException; -import org.apache.cassandra.utils.Hex; -import org.apache.pig.data.DataByteArray; import org.apache.pig.data.Tuple; import org.apache.thrift.TException; -import org.apache.thrift.transport.TTransportException; public class CqlRecordReaderTest extends PigTestBase { private static String[] statements = { + "DROP KEYSPACE IF EXISTS cql3ks", "CREATE KEYSPACE cql3ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1};", "USE cql3ks;", @@ -69,11 +57,11 @@ public class CqlRecordReaderTest extends PigTestBase }; @BeforeClass - public static void setup() throws TTransportException, IOException, InterruptedException, ConfigurationException, - AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, CharacterCodingException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException + public static void setup() throws IOException, InterruptedException, ConfigurationException, + TException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException { startCassandra(); - setupDataByCql(statements); + executeCQLStatements(statements); startHadoopCluster(); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/38027382/test/pig/org/apache/cassandra/pig/CqlTableDataTypeTest.java ---------------------------------------------------------------------- diff --git a/test/pig/org/apache/cassandra/pig/CqlTableDataTypeTest.java b/test/pig/org/apache/cassandra/pig/CqlTableDataTypeTest.java index bbd5a87..98e170b 100644 --- a/test/pig/org/apache/cassandra/pig/CqlTableDataTypeTest.java +++ b/test/pig/org/apache/cassandra/pig/CqlTableDataTypeTest.java @@ -19,24 +19,16 @@ package org.apache.cassandra.pig; import java.io.IOException; -import java.nio.charset.CharacterCodingException; import java.util.Iterator; import org.apache.cassandra.db.marshal.TimeUUIDType; import org.apache.cassandra.db.marshal.UUIDType; import org.apache.cassandra.exceptions.ConfigurationException; -import org.apache.cassandra.thrift.AuthenticationException; -import org.apache.cassandra.thrift.AuthorizationException; -import org.apache.cassandra.thrift.InvalidRequestException; -import org.apache.cassandra.thrift.NotFoundException; -import org.apache.cassandra.thrift.SchemaDisagreementException; -import org.apache.cassandra.thrift.TimedOutException; -import org.apache.cassandra.thrift.UnavailableException; import org.apache.cassandra.utils.Hex; import org.apache.pig.data.DataByteArray; import org.apache.pig.data.Tuple; import org.apache.thrift.TException; -import org.apache.thrift.transport.TTransportException; + import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -64,6 +56,7 @@ public class CqlTableDataTypeTest extends PigTestBase //MAP //Create table to test the above data types private static String[] statements = { + "DROP KEYSPACE IF EXISTS cql3ks", "CREATE KEYSPACE cql3ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}", "USE cql3ks;", @@ -208,17 +201,16 @@ public class CqlTableDataTypeTest extends PigTestBase }; @BeforeClass - public static void setup() throws TTransportException, IOException, InterruptedException, ConfigurationException, - AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, CharacterCodingException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException + public static void setup() throws IOException, InterruptedException, ConfigurationException, TException, + ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException { startCassandra(); - setupDataByCql(statements); + executeCQLStatements(statements); startHadoopCluster(); } @Test - public void testCqlNativeStorageRegularType() - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + public void testCqlNativeStorageRegularType() throws TException, IOException { //input_cql=select * from cqltable where token(key) > ? and token(key) <= ? cqlTableTest("rows = LOAD 'cql://cql3ks/cqltable?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20cqltable%20where%20token(key)%20%3E%20%3F%20and%20token(key)%20%3C%3D%20%3F' USING CqlNativeStorage();"); @@ -288,8 +280,7 @@ public class CqlTableDataTypeTest extends PigTestBase } @Test - public void testCqlNativeStorageSetType() - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + public void testCqlNativeStorageSetType() throws TException, IOException { //input_cql=select * from settable where token(key) > ? and token(key) <= ? settableTest("set_rows = LOAD 'cql://cql3ks/settable?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20settable%20where%20token(key)%20%3E%20%3F%20and%20token(key)%20%3C%3D%20%3F' USING CqlNativeStorage();"); @@ -355,8 +346,7 @@ public class CqlTableDataTypeTest extends PigTestBase } @Test - public void testCqlNativeStorageListType() - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + public void testCqlNativeStorageListType() throws TException, IOException { //input_cql=select * from listtable where token(key) > ? and token(key) <= ? listtableTest("list_rows = LOAD 'cql://cql3ks/listtable?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20listtable%20where%20token(key)%20%3E%20%3F%20and%20token(key)%20%3C%3D%20%3F' USING CqlNativeStorage();"); @@ -422,8 +412,7 @@ public class CqlTableDataTypeTest extends PigTestBase } @Test - public void testCqlNativeStorageMapType() - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + public void testCqlNativeStorageMapType() throws TException, IOException { //input_cql=select * from maptable where token(key) > ? and token(key) <= ? maptableTest("map_rows = LOAD 'cql://cql3ks/maptable?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20maptable%20where%20token(key)%20%3E%20%3F%20and%20token(key)%20%3C%3D%20%3F' USING CqlNativeStorage();"); http://git-wip-us.apache.org/repos/asf/cassandra/blob/38027382/test/pig/org/apache/cassandra/pig/CqlTableTest.java ---------------------------------------------------------------------- diff --git a/test/pig/org/apache/cassandra/pig/CqlTableTest.java b/test/pig/org/apache/cassandra/pig/CqlTableTest.java index 4ca043d..ecfeb63 100644 --- a/test/pig/org/apache/cassandra/pig/CqlTableTest.java +++ b/test/pig/org/apache/cassandra/pig/CqlTableTest.java @@ -19,21 +19,12 @@ package org.apache.cassandra.pig; import java.io.IOException; -import java.nio.charset.CharacterCodingException; import java.util.Iterator; import org.apache.cassandra.exceptions.ConfigurationException; -import org.apache.cassandra.thrift.AuthenticationException; -import org.apache.cassandra.thrift.AuthorizationException; -import org.apache.cassandra.thrift.InvalidRequestException; -import org.apache.cassandra.thrift.NotFoundException; -import org.apache.cassandra.thrift.SchemaDisagreementException; -import org.apache.cassandra.thrift.TimedOutException; -import org.apache.cassandra.thrift.UnavailableException; import org.apache.pig.data.DataBag; import org.apache.pig.data.Tuple; import org.apache.thrift.TException; -import org.apache.thrift.transport.TTransportException; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -41,6 +32,7 @@ import org.junit.Test; public class CqlTableTest extends PigTestBase { private static String[] statements = { + "DROP KEYSPACE IF EXISTS cql3ks", "CREATE KEYSPACE cql3ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}", "USE cql3ks;", @@ -81,17 +73,16 @@ public class CqlTableTest extends PigTestBase }; @BeforeClass - public static void setup() throws TTransportException, IOException, InterruptedException, ConfigurationException, - AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, CharacterCodingException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException + public static void setup() throws IOException, InterruptedException, ConfigurationException, TException, ClassNotFoundException, + NoSuchFieldException, IllegalAccessException, InstantiationException { startCassandra(); - setupDataByCql(statements); + executeCQLStatements(statements); startHadoopCluster(); } @Test - public void testCqlNativeStorageSchema() - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + public void testCqlNativeStorageSchema() throws TException, IOException { //input_cql=select * from cqltable where token(key1) > ? and token(key1) <= ? cqlTableSchemaTest("rows = LOAD 'cql://cql3ks/cqltable?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20cqltable%20where%20token(key1)%20%3E%20%3F%20and%20token(key1)%20%3C%3D%20%3F' USING CqlNativeStorage();"); @@ -136,15 +127,13 @@ public class CqlTableTest extends PigTestBase } @Test - public void testCqlNativeStorageSingleKeyTable() - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + public void testCqlNativeStorageSingleKeyTable() throws TException, IOException { //input_cql=select * from moredata where token(x) > ? and token(x) <= ? SingleKeyTableTest("moretestvalues= LOAD 'cql://cql3ks/moredata?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20moredata%20where%20token(x)%20%3E%20%3F%20and%20token(x)%20%3C%3D%20%3F' USING CqlNativeStorage();"); } - private void SingleKeyTableTest(String initialQuery) - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + private void SingleKeyTableTest(String initialQuery) throws TException, IOException { pig.setBatchOn(); pig.registerQuery(initialQuery); @@ -167,15 +156,13 @@ public class CqlTableTest extends PigTestBase } @Test - public void testCqlNativeStorageCompositeKeyTable() - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + public void testCqlNativeStorageCompositeKeyTable() throws TException, IOException { //input_cql=select * from compmore where token(id) > ? and token(id) <= ? CompositeKeyTableTest("moredata= LOAD 'cql://cql3ks/compmore?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20compmore%20where%20token(id)%20%3E%20%3F%20and%20token(id)%20%3C%3D%20%3F' USING CqlNativeStorage();"); } - private void CompositeKeyTableTest(String initialQuery) - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + private void CompositeKeyTableTest(String initialQuery) throws TException, IOException { pig.setBatchOn(); pig.registerQuery(initialQuery); @@ -204,15 +191,13 @@ public class CqlTableTest extends PigTestBase } @Test - public void testCqlNativeStorageCollectionColumnTable() - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + public void testCqlNativeStorageCollectionColumnTable() throws TException, IOException { //input_cql=select * from collectiontable where token(m) > ? and token(m) <= ? CollectionColumnTableTest("collectiontable= LOAD 'cql://cql3ks/collectiontable?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20collectiontable%20where%20token(m)%20%3E%20%3F%20and%20token(m)%20%3C%3D%20%3F' USING CqlNativeStorage();"); } - private void CollectionColumnTableTest(String initialQuery) - throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException + private void CollectionColumnTableTest(String initialQuery) throws TException, IOException { pig.setBatchOn(); pig.registerQuery(initialQuery); @@ -245,7 +230,8 @@ public class CqlTableTest extends PigTestBase } @Test - public void testCassandraStorageSchema() throws IOException, ClassNotFoundException, TException, TimedOutException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException + public void testCassandraStorageSchema() throws IOException, ClassNotFoundException, TException, NoSuchFieldException, + IllegalAccessException, InstantiationException { //results: (key1,{((111,),),((111,column1),100),((111,column2),10.1)}) pig.registerQuery("rows = LOAD 'cassandra://cql3ks/cqltable?" + defaultParameters + "' USING CassandraStorage();"); @@ -259,10 +245,10 @@ public class CqlTableTest extends PigTestBase DataBag columns = (DataBag) t.get(1); Iterator<Tuple> iter = columns.iterator(); int i = 0; - while(iter.hasNext()) + while (iter.hasNext()) { i++; - Tuple column = (Tuple) iter.next(); + Tuple column = iter.next(); if (i==1) { Assert.assertEquals(((Tuple) column.get(0)).get(0), 111); http://git-wip-us.apache.org/repos/asf/cassandra/blob/38027382/test/pig/org/apache/cassandra/pig/PigTestBase.java ---------------------------------------------------------------------- diff --git a/test/pig/org/apache/cassandra/pig/PigTestBase.java b/test/pig/org/apache/cassandra/pig/PigTestBase.java index 4b3e422..8c27f6c 100644 --- a/test/pig/org/apache/cassandra/pig/PigTestBase.java +++ b/test/pig/org/apache/cassandra/pig/PigTestBase.java @@ -18,14 +18,9 @@ */ package org.apache.cassandra.pig; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.PrintStream; -import java.nio.charset.CharacterCodingException; import org.apache.cassandra.SchemaLoader; -import org.apache.cassandra.cli.CliMain; -import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.Schema; import org.apache.cassandra.db.marshal.AbstractType; import org.apache.cassandra.db.marshal.TypeParser; @@ -35,11 +30,6 @@ import org.apache.cassandra.service.EmbeddedCassandraService; import org.apache.cassandra.thrift.Cassandra; import org.apache.cassandra.thrift.Compression; import org.apache.cassandra.thrift.ConsistencyLevel; -import org.apache.cassandra.thrift.InvalidRequestException; -import org.apache.cassandra.thrift.NotFoundException; -import org.apache.cassandra.thrift.SchemaDisagreementException; -import org.apache.cassandra.thrift.TimedOutException; -import org.apache.cassandra.thrift.UnavailableException; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.hadoop.conf.Configuration; import org.apache.pig.ExecType; @@ -56,7 +46,6 @@ import org.apache.thrift.transport.TTransport; import org.apache.thrift.transport.TTransportException; import org.junit.After; import org.junit.AfterClass; -import org.junit.Assert; import org.junit.Before; public class PigTestBase extends SchemaLoader @@ -119,75 +108,20 @@ public class PigTestBase extends SchemaLoader { return TypeParser.parse(type); } - catch (ConfigurationException e) - { - throw new IOException(e); - } - catch (SyntaxException e) + catch (ConfigurationException | SyntaxException e) { throw new IOException(e); } } - protected static void setupDataByCli(String[] statements) throws CharacterCodingException, ClassNotFoundException, TException, TimedOutException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException - { - // new error/output streams for CliSessionState - ByteArrayOutputStream errStream = new ByteArrayOutputStream(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - - // checking if we can connect to the running cassandra node on localhost - CliMain.connect("127.0.0.1", 9170); - - // setting new output stream - CliMain.sessionState.setOut(new PrintStream(outStream)); - CliMain.sessionState.setErr(new PrintStream(errStream)); - - // re-creating keyspace for tests - try - { - // dropping in case it exists e.g. could be left from previous run - CliMain.processStatement("drop keyspace thriftKs;"); - } - catch (Exception e) - { - } - - for (String statement : statements) - { - errStream.reset(); - System.out.println("Executing statement: " + statement); - CliMain.processStatement(statement); - String result = outStream.toString(); - System.out.println("result: " + result); - outStream.reset(); // reset stream so we have only output from next statement all the time - errStream.reset(); // no errors to the end user. - } - } - - protected static void setupDataByCql(String[] statements) throws InvalidRequestException, UnavailableException, TimedOutException, TException + protected static void executeCQLStatements(String[] statements) throws TException { Cassandra.Client client = getClient(); - // re-creating keyspace for tests - try - { - // dropping in case it exists e.g. could be left from previous run - client.execute_cql3_query(ByteBufferUtil.bytes("DROP KEYSPACE cql3ks"), Compression.NONE, ConsistencyLevel.ONE); - } - catch (Exception e) - { - } for (String statement : statements) { - try - { - System.out.println("Executing statement: " + statement); - client.execute_cql3_query(ByteBufferUtil.bytes(statement), Compression.NONE, ConsistencyLevel.ONE); - } - catch (SchemaDisagreementException e) - { - Assert.fail(); - } + System.out.println("Executing statement: " + statement); + client.execute_cql3_query(ByteBufferUtil.bytes(statement), Compression.NONE, ConsistencyLevel.ONE); } } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/38027382/test/pig/org/apache/cassandra/pig/ThriftColumnFamilyDataTypeTest.java ---------------------------------------------------------------------- diff --git a/test/pig/org/apache/cassandra/pig/ThriftColumnFamilyDataTypeTest.java b/test/pig/org/apache/cassandra/pig/ThriftColumnFamilyDataTypeTest.java index cc54620..2ffd524 100644 --- a/test/pig/org/apache/cassandra/pig/ThriftColumnFamilyDataTypeTest.java +++ b/test/pig/org/apache/cassandra/pig/ThriftColumnFamilyDataTypeTest.java @@ -19,181 +19,138 @@ package org.apache.cassandra.pig; import java.io.IOException; -import java.nio.charset.CharacterCodingException; -import java.util.Iterator; import org.apache.cassandra.db.marshal.TimeUUIDType; import org.apache.cassandra.db.marshal.UUIDType; import org.apache.cassandra.exceptions.ConfigurationException; -import org.apache.cassandra.thrift.AuthenticationException; -import org.apache.cassandra.thrift.AuthorizationException; -import org.apache.cassandra.thrift.InvalidRequestException; -import org.apache.cassandra.thrift.NotFoundException; -import org.apache.cassandra.thrift.TimedOutException; -import org.apache.cassandra.thrift.UnavailableException; import org.apache.cassandra.utils.Hex; import org.apache.pig.data.DataBag; import org.apache.pig.data.DataByteArray; import org.apache.pig.data.Tuple; import org.apache.thrift.TException; -import org.apache.thrift.transport.TTransportException; -import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import static junit.framework.Assert.assertEquals; + public class ThriftColumnFamilyDataTypeTest extends PigTestBase { - //AsciiType - //LongType - //BytesType - //BooleanType - //CounterColumnType - //DecimalType - //DoubleType - //FloatType - //InetAddressType - //Int32Type - //UTF8Type - //DateType - //UUIDType - //IntegerType - //TimeUUIDType - //IntegerType - //LexicalUUIDType private static String[] statements = { - "create keyspace thriftKs with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and" + - " strategy_options={replication_factor:1};", - "use thriftKs;", - - "create column family SomeApp " + - " with comparator = UTF8Type " + - " and default_validation_class = UTF8Type " + - " and key_validation_class = UTF8Type " + - " and column_metadata = [" + - "{column_name: col_ascii, validation_class: AsciiType}, " + - "{column_name: col_long, validation_class: LongType}, " + - "{column_name: col_bytes, validation_class: BytesType}, " + - "{column_name: col_boolean, validation_class: BooleanType}, " + - "{column_name: col_decimal, validation_class: DecimalType}, " + - "{column_name: col_double, validation_class: DoubleType}, " + - "{column_name: col_float, validation_class: FloatType}," + - "{column_name: col_inetaddress, validation_class: InetAddressType}, " + - "{column_name: col_int32, validation_class: Int32Type}, " + - "{column_name: col_uft8, validation_class: UTF8Type}, " + - "{column_name: col_date, validation_class: DateType}, " + - "{column_name: col_uuid, validation_class: UUIDType}, " + - "{column_name: col_integer, validation_class: IntegerType}, " + - "{column_name: col_timeuuid, validation_class: TimeUUIDType}, " + - "{column_name: col_lexical_uuid, validation_class: LexicalUUIDType}, " + - "]; ", - - "set SomeApp['foo']['col_ascii'] = 'ascii';", - "set SomeApp['foo']['col_boolean'] = false;", - "set SomeApp['foo']['col_bytes'] = 'DEADBEEF';", - "set SomeApp['foo']['col_date'] = '2011-02-03T04:05:00+0000';", - "set SomeApp['foo']['col_decimal'] = '23.345';", - "set SomeApp['foo']['col_double'] = '2.7182818284590451';", - "set SomeApp['foo']['col_float'] = '23.45';", - "set SomeApp['foo']['col_inetaddress'] = '127.0.0.1';", - "set SomeApp['foo']['col_int32'] = 23;", - "set SomeApp['foo']['col_integer'] = 12345;", - "set SomeApp['foo']['col_long'] = 12345678;", - "set SomeApp['foo']['col_lexical_uuid'] = 'e23f450f-53a6-11e2-7f7f-7f7f7f7f7f77';", - "set SomeApp['foo']['col_timeuuid'] = 'e23f450f-53a6-11e2-7f7f-7f7f7f7f7f7f';", - "set SomeApp['foo']['col_uft8'] = 'hello';", - "set SomeApp['foo']['col_uuid'] = '550e8400-e29b-41d4-a716-446655440000';", - - "create column family CC with " + - "key_validation_class = UTF8Type and " + - "default_validation_class=CounterColumnType " + - "and comparator=UTF8Type;", - - "incr CC['chuck']['kick'];", - "incr CC['chuck']['kick'];", - "incr CC['chuck']['kick'];" + "DROP KEYSPACE IF EXISTS thrift_ks", + "CREATE KEYSPACE thrift_ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};", + "USE thrift_ks;", + + "CREATE TABLE some_app (" + + "key text PRIMARY KEY," + + "col_ascii ascii," + + "col_bigint bigint," + + "col_blob blob," + + "col_boolean boolean," + + "col_decimal decimal," + + "col_double double," + + "col_float float," + + "col_inet inet," + + "col_int int," + + "col_text text," + + "col_timestamp timestamp," + + "col_timeuuid timeuuid," + + "col_uuid uuid," + + "col_varint varint)" + + " WITH COMPACT STORAGE;", + + "INSERT INTO some_app (key, col_ascii, col_bigint, col_blob, col_boolean, col_decimal, col_double, col_float," + + "col_inet, col_int, col_text, col_timestamp, col_uuid, col_varint, col_timeuuid) " + + "VALUES ('foo', 'ascii', 12345678, 0xDEADBEEF, false, 23.345, 2.7182818284590451, 23.45, '127.0.0.1', 23, 'hello', " + + "'2011-02-03T04:05:00+0000', 550e8400-e29b-41d4-a716-446655440000, 12345, e23f450f-53a6-11e2-7f7f-7f7f7f7f7f7f);", + + "CREATE TABLE cc (key text, name text, value counter, PRIMARY KEY (key, name)) WITH COMPACT STORAGE", + + "UPDATE cc SET value = value + 3 WHERE key = 'chuck' AND name = 'kick'", }; @BeforeClass - public static void setup() throws TTransportException, IOException, InterruptedException, ConfigurationException, - AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, CharacterCodingException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException + public static void setup() throws IOException, InterruptedException, ConfigurationException, TException, + ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException { startCassandra(); - setupDataByCli(statements); + executeCQLStatements(statements); startHadoopCluster(); } @Test - public void testCassandraStorageDataType() throws IOException, ClassNotFoundException, TException, TimedOutException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException + public void testCassandraStorageDataType() throws IOException, ClassNotFoundException, TException, + NoSuchFieldException, IllegalAccessException, InstantiationException { - pig.registerQuery("rows = LOAD 'cassandra://thriftKs/SomeApp?" + defaultParameters + "' USING CassandraStorage();"); - - //{key: chararray, col_ascii: (name: chararray,value: chararray), - //col_boolean: (name: chararray,value: bytearray), - //col_bytes: (name: chararray,value: bytearray), - //col_date: (name: chararray,value: long), - //col_decimal: (name: chararray,value: chararray), - //col_double: (name: chararray,value: double), - //col_float: (name: chararray,value: float), - //col_inetaddress: (name: chararray,value: chararray), - //col_int32: (name: chararray,value: int), - //col_integer: (name: chararray,value: int), - //col_lexical_uuid: (name: chararray,value: chararray), - //col_long: (name: chararray,value: long), - //col_timeuuid: (name: chararray,value: bytearray), - //col_uft8: (name: chararray,value: chararray), - //col_uuid: (name: chararray,value: chararray), - //columns: {(name: chararray,value: chararray)}} - Iterator<Tuple> it = pig.openIterator("rows"); - if (it.hasNext()) { - Tuple t = it.next(); - Assert.assertEquals(t.get(0), "foo"); - Tuple column = (Tuple) t.get(1); - Assert.assertEquals(column.get(1), "ascii"); - column = (Tuple) t.get(2); - Assert.assertEquals(column.get(1), false); - column = (Tuple) t.get(3); - Assert.assertEquals(column.get(1), new DataByteArray(Hex.hexToBytes("DEADBEEF"))); - column = (Tuple) t.get(4); - Assert.assertEquals(column.get(1), 1296705900000L); - column = (Tuple) t.get(5); - Assert.assertEquals(column.get(1), "23.345"); - column = (Tuple) t.get(6); - Assert.assertEquals(column.get(1), 2.7182818284590451d); - column = (Tuple) t.get(7); - Assert.assertEquals(column.get(1), 23.45f); - column = (Tuple) t.get(8); - Assert.assertEquals(column.get(1), "127.0.0.1"); - column = (Tuple) t.get(9); - Assert.assertEquals(column.get(1), 23); - column = (Tuple) t.get(10); - Assert.assertEquals(column.get(1), 12345); - column = (Tuple) t.get(11); - Assert.assertEquals(column.get(1), new DataByteArray((TimeUUIDType.instance.fromString("e23f450f-53a6-11e2-7f7f-7f7f7f7f7f77").array()))); - column = (Tuple) t.get(12); - Assert.assertEquals(column.get(1), 12345678L); - column = (Tuple) t.get(13); - Assert.assertEquals(column.get(1), new DataByteArray((TimeUUIDType.instance.fromString("e23f450f-53a6-11e2-7f7f-7f7f7f7f7f7f").array()))); - column = (Tuple) t.get(14); - Assert.assertEquals(column.get(1), "hello"); - column = (Tuple) t.get(15); - Assert.assertEquals(column.get(1), new DataByteArray((UUIDType.instance.fromString("550e8400-e29b-41d4-a716-446655440000").array()))); - } - - pig.registerQuery("cc_rows = LOAD 'cassandra://thriftKs/CC?" + defaultParameters + "' USING CassandraStorage();"); - - //(chuck,{(kick,3)}) - it = pig.openIterator("cc_rows"); - if (it.hasNext()) { - Tuple t = it.next(); - Assert.assertEquals(t.get(0), "chuck"); - DataBag columns = (DataBag) t.get(1); - Iterator<Tuple> iter = columns.iterator(); - if(iter.hasNext()) - { - Tuple column = iter.next(); - Assert.assertEquals(column.get(0), "kick"); - Assert.assertEquals(column.get(1), 3L); - } - } + pig.registerQuery("rows = LOAD 'cassandra://thrift_ks/some_app?" + defaultParameters + "' USING CassandraStorage();"); + Tuple t = pig.openIterator("rows").next(); + + // key + assertEquals("foo", t.get(0)); + + // col_ascii + Tuple column = (Tuple) t.get(1); + assertEquals("ascii", column.get(1)); + + // col_bigint + column = (Tuple) t.get(2); + assertEquals(12345678L, column.get(1)); + + // col_blob + column = (Tuple) t.get(3); + assertEquals(new DataByteArray(Hex.hexToBytes("DEADBEEF")), column.get(1)); + + // col_boolean + column = (Tuple) t.get(4); + assertEquals(false, column.get(1)); + + // col_decimal + column = (Tuple) t.get(5); + assertEquals("23.345", column.get(1)); + + // col_double + column = (Tuple) t.get(6); + assertEquals(2.7182818284590451d, column.get(1)); + + // col_float + column = (Tuple) t.get(7); + assertEquals(23.45f, column.get(1)); + + // col_inet + column = (Tuple) t.get(8); + assertEquals("127.0.0.1", column.get(1)); + + // col_int + column = (Tuple) t.get(9); + assertEquals(23, column.get(1)); + + // col_text + column = (Tuple) t.get(10); + assertEquals("hello", column.get(1)); + + // col_timestamp + column = (Tuple) t.get(11); + assertEquals(1296705900000L, column.get(1)); + + // col_timeuuid + column = (Tuple) t.get(12); + assertEquals(new DataByteArray((TimeUUIDType.instance.fromString("e23f450f-53a6-11e2-7f7f-7f7f7f7f7f7f").array())), column.get(1)); + + // col_uuid + column = (Tuple) t.get(13); + assertEquals(new DataByteArray((UUIDType.instance.fromString("550e8400-e29b-41d4-a716-446655440000").array())), column.get(1)); + + // col_varint + column = (Tuple) t.get(14); + assertEquals(12345, column.get(1)); + + pig.registerQuery("cc_rows = LOAD 'cassandra://thrift_ks/cc?" + defaultParameters + "' USING CassandraStorage();"); + t = pig.openIterator("cc_rows").next(); + + assertEquals("chuck", t.get(0)); + + DataBag columns = (DataBag) t.get(1); + column = columns.iterator().next(); + assertEquals("kick", column.get(0)); + assertEquals(3L, column.get(1)); } }