table -> keyspace

patch by jbellis; reviewed by Michael Greene for CASSANDRA-271

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@799140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-07-30 00:29:28 +00:00
parent 56a846ba1c
commit 572b5f852d
34 changed files with 871 additions and 876 deletions

View File

@ -25,19 +25,20 @@
one logical cluster from joining any other cluster. -->
<ClusterName>Test Cluster</ClusterName>
<!-- Tables and ColumnFamilies
Think of a table as a namespace, not a relational table.
(ColumnFamilies are closer in meaning to those.)
<!-- Keyspaces and ColumnFamilies
A ColumnFamily is the Cassandra concept closest to a relational table.
Keyspaces are separate groups of ColumnFamilies. Except in very
unusual circumstances you will have one Keyspace per application.
There is an implicit table named 'system' for Cassandra internals.
There is an implicit keyspace named 'system' for Cassandra internals.
The default ColumnSort is Time for standard column families.
For super column families, specifying ColumnSort is not supported;
the supercolumns themselves are always name-sorted and their subcolumns
are always time-sorted.
-->
<Tables>
<Table Name="Table1">
<Keyspaces>
<Keyspace Name="Keyspace1">
<!-- The fraction of keys per sstable whose locations we
keep in memory in "mostly LRU" order. (JUST the key
locations, NOT any column values.)
@ -72,8 +73,8 @@
<ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
<ColumnFamily CompareWith="UUIDType" Name="StandardByUUID1"/>
<ColumnFamily ColumnType="Super" CompareWith="UTF8Type" CompareSubcolumnsWith="UTF8Type" Name="Super1"/>
</Table>
</Tables>
</Keyspace>
</Keyspaces>
<!-- Partitioner: any IPartitioner may be used, including your own
as long as it is on the classpath. Out of the box,

View File

@ -72,7 +72,7 @@ struct CqlResult {
exception NotFoundException {
}
# invalid request (table / CF does not exist, etc.)
# invalid request (keyspace / CF does not exist, etc.)
exception InvalidRequestException {
1: string why
}
@ -119,41 +119,41 @@ struct ColumnPathOrParent {
service Cassandra {
list<Column> get_slice_by_names(1:string table, 2:string key, 3:ColumnParent column_parent, 4:list<binary> column_names, 5:ConsistencyLevel consistency_level=1)
list<Column> get_slice_by_names(1:string keyspace, 2:string key, 3:ColumnParent column_parent, 4:list<binary> column_names, 5:ConsistencyLevel consistency_level=1)
throws (1: InvalidRequestException ire, 2: NotFoundException nfe),
list<Column> get_slice(1:string table, 2:string key, 3:ColumnParent column_parent, 4:binary start, 5:binary finish, 6:bool is_ascending, 7:i32 count=100, 8:ConsistencyLevel consistency_level=1)
list<Column> get_slice(1:string keyspace, 2:string key, 3:ColumnParent column_parent, 4:binary start, 5:binary finish, 6:bool is_ascending, 7:i32 count=100, 8:ConsistencyLevel consistency_level=1)
throws (1: InvalidRequestException ire, 2: NotFoundException nfe),
Column get_column(1:string table, 2:string key, 3:ColumnPath column_path, 4:ConsistencyLevel consistency_level=1)
Column get_column(1:string keyspace, 2:string key, 3:ColumnPath column_path, 4:ConsistencyLevel consistency_level=1)
throws (1: InvalidRequestException ire, 2: NotFoundException nfe),
i32 get_column_count(1:string table, 2:string key, 3:ColumnParent column_parent, 5:ConsistencyLevel consistency_level=1)
i32 get_column_count(1:string keyspace, 2:string key, 3:ColumnParent column_parent, 5:ConsistencyLevel consistency_level=1)
throws (1: InvalidRequestException ire),
void insert(1:string table, 2:string key, 3:ColumnPath column_path, 4:binary value, 5:i64 timestamp, 6:ConsistencyLevel consistency_level=0)
void insert(1:string keyspace, 2:string key, 3:ColumnPath column_path, 4:binary value, 5:i64 timestamp, 6:ConsistencyLevel consistency_level=0)
throws (1: InvalidRequestException ire, 2: UnavailableException ue),
void batch_insert(1:string table, 2:BatchMutation batch_mutation, 3:ConsistencyLevel consistency_level=0)
void batch_insert(1:string keyspace, 2:BatchMutation batch_mutation, 3:ConsistencyLevel consistency_level=0)
throws (1: InvalidRequestException ire, 2: UnavailableException ue),
void remove(1:string table, 2:string key, 3:ColumnPathOrParent column_path_or_parent, 4:i64 timestamp, 5:ConsistencyLevel consistency_level=0)
void remove(1:string keyspace, 2:string key, 3:ColumnPathOrParent column_path_or_parent, 4:i64 timestamp, 5:ConsistencyLevel consistency_level=0)
throws (1: InvalidRequestException ire, 2: UnavailableException ue),
list<SuperColumn> get_slice_super(1:string table, 2:string key, 3:string column_family, 4:binary start, 5:binary finish, 6:bool is_ascending, 7:i32 count=100, 8:ConsistencyLevel consistency_level=1)
list<SuperColumn> get_slice_super(1:string keyspace, 2:string key, 3:string column_family, 4:binary start, 5:binary finish, 6:bool is_ascending, 7:i32 count=100, 8:ConsistencyLevel consistency_level=1)
throws (1: InvalidRequestException ire),
list<SuperColumn> get_slice_super_by_names(1:string table, 2:string key, 3:string column_family, 4:list<binary> super_column_names, 5:ConsistencyLevel consistency_level=1)
list<SuperColumn> get_slice_super_by_names(1:string keyspace, 2:string key, 3:string column_family, 4:list<binary> super_column_names, 5:ConsistencyLevel consistency_level=1)
throws (1: InvalidRequestException ire),
SuperColumn get_super_column(1:string table, 2:string key, 3:SuperColumnPath super_column_path, 4:ConsistencyLevel consistency_level=1)
SuperColumn get_super_column(1:string keyspace, 2:string key, 3:SuperColumnPath super_column_path, 4:ConsistencyLevel consistency_level=1)
throws (1: InvalidRequestException ire, 2: NotFoundException nfe),
void batch_insert_super_column(1:string table, 2:BatchMutationSuper batch_mutation_super, 3:ConsistencyLevel consistency_level=0)
void batch_insert_super_column(1:string keyspace, 2:BatchMutationSuper batch_mutation_super, 3:ConsistencyLevel consistency_level=0)
throws (1: InvalidRequestException ire, 2: UnavailableException ue),
# range query: returns matching keys
list<string> get_key_range(1:string table, 2:string column_family, 3:string start="", 4:string finish="", 5:i32 count=100)
list<string> get_key_range(1:string keyspace, 2:string column_family, 3:string start="", 4:string finish="", 5:i32 count=100)
throws (1: InvalidRequestException ire),
/////////////////////////////////////////////////////////////////////////////////////
@ -167,8 +167,8 @@ service Cassandra {
// get property whose value is list of "strings"
list<string> get_string_list_property(1:string property),
// describe specified table
map<string, map<string, string>> describe_table(1:string table)
// describe specified keyspace
map<string, map<string, string>> describe_keyspace(1:string keyspace)
throws (1: NotFoundException nfe),
// execute a CQL query

File diff suppressed because it is too large Load Diff

View File

@ -19,12 +19,7 @@ public class ConsistencyLevel {
public static final int QUORUM = 2;
public static final int ALL = 3;
public static final IntRangeSet VALID_VALUES = new IntRangeSet(
ZERO,
ONE,
QUORUM,
ALL );
public static final IntRangeSet VALID_VALUES = new IntRangeSet(ZERO, ONE, QUORUM, ALL);
public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>() {{
put(ZERO, "ZERO");
put(ONE, "ONE");

View File

@ -178,8 +178,8 @@ K_NAME: 'NAME';
K_QUIT: 'QUIT';
K_SET: 'SET';
K_SHOW: 'SHOW';
K_TABLE: 'TABLE';
K_TABLES: 'TABLES';
K_TABLE: 'KEYSPACE';
K_TABLES: 'KEYSPACES';
K_THRIFT: 'THRIFT';
K_VERSION: 'VERSION';

View File

@ -93,14 +93,14 @@ public class CliClient
css_.out.println("List of all CLI commands:");
css_.out.println("? Same as help.");
css_.out.println("connect <hostname>/<port> Connect to Cassandra's thrift service.");
css_.out.println("describe table <tbl> Describe table.");
css_.out.println("describe keyspace <keyspacename> Describe keyspace.");
css_.out.println("exit Exit CLI.");
css_.out.println("explain plan [<set stmt>|<get stmt>|<select stmt>] Explains the PLAN for specified stmt.");
css_.out.println("help Display this help.");
css_.out.println("quit Exit CLI.");
css_.out.println("show config file Display contents of config file");
css_.out.println("show cluster name Display cassandra server version");
css_.out.println("show tables Show list of tables.");
css_.out.println("show keyspaces Show list of keyspaces.");
css_.out.println("show version Show server version.");
css_.out.println("select ... CQL select statement (TBD).");
css_.out.println("get ... CQL data retrieval statement.");
@ -229,7 +229,7 @@ public class CliClient
if (!CliMain.isConnected())
return;
List<String> tables = thriftClient_.get_string_list_property("tables");
List<String> tables = thriftClient_.get_string_list_property("keyspaces");
for (String table : tables)
{
css_.out.println(table);
@ -250,7 +250,7 @@ public class CliClient
// Describe and display
Map<String, Map<String, String>> columnFamiliesMap;
try {
columnFamiliesMap = thriftClient_.describe_table(tableName);
columnFamiliesMap = thriftClient_.describe_keyspace(tableName);
for (String columnFamilyName: columnFamiliesMap.keySet()) {
Map<String, String> columnMap = columnFamiliesMap.get(columnFamilyName);
String desc = columnMap.get("Desc");
@ -264,7 +264,7 @@ public class CliClient
css_.out.println("------");
}
} catch (NotFoundException e) {
css_.out.println("Table " + tableName + " could not be found.");
css_.out.println("Keyspace " + tableName + " could not be found.");
}
return;

View File

@ -327,7 +327,7 @@ public class DatabaseDescriptor
}
/* Read the table related stuff from config */
NodeList tables = xmlUtils.getRequestedNodeList("/Storage/Tables/Table");
NodeList tables = xmlUtils.getRequestedNodeList("/Storage/Keyspaces/Keyspace");
int size = tables.getLength();
for ( int i = 0; i < size; ++i )
{
@ -346,7 +346,7 @@ public class DatabaseDescriptor
tables_.add(tName);
tableToCFMetaDataMap_.put(tName, new HashMap<String, CFMetaData>());
String xqlCacheSize = "/Storage/Tables/Table[@Name='" + tName + "']/KeysCachedFraction";
String xqlCacheSize = "/Storage/Keyspaces/Keyspace[@Name='" + tName + "']/KeysCachedFraction";
value = xmlUtils.getNodeValue(xqlCacheSize);
if (value == null)
{
@ -357,7 +357,7 @@ public class DatabaseDescriptor
tableKeysCachedFractions_.put(tName, Double.valueOf(value));
}
String xqlTable = "/Storage/Tables/Table[@Name='" + tName + "']/";
String xqlTable = "/Storage/Keyspaces/Keyspace[@Name='" + tName + "']/";
NodeList columnFamilies = xmlUtils.getRequestedNodeList(xqlTable + "ColumnFamily");
// get name of the rowKey for this table

View File

@ -20,9 +20,9 @@ package org.apache.cassandra.db;
import org.apache.cassandra.service.InvalidRequestException;
public class TableNotDefinedException extends InvalidRequestException
public class KeyspaceNotDefinedException extends InvalidRequestException
{
public TableNotDefinedException(String why)
public KeyspaceNotDefinedException(String why)
{
super(why);
}

View File

@ -85,7 +85,7 @@ public class CassandraDaemon
for (String table : tables)
{
if (logger.isDebugEnabled())
logger.debug("opening table " + table);
logger.debug("opening keyspace " + table);
Table tbl = Table.open(table);
tbl.onStart();
}

View File

@ -463,7 +463,7 @@ public class CassandraServer implements Cassandra.Iface
public List<String> get_string_list_property(String propertyName)
{
if (propertyName.equals("tables"))
if (propertyName.equals("keyspaces"))
{
return DatabaseDescriptor.getTables();
}
@ -473,11 +473,11 @@ public class CassandraServer implements Cassandra.Iface
}
}
public Map<String,Map<String,String>> describe_table(String tableName) throws NotFoundException
public Map<String, Map<String, String>> describe_keyspace(String table) throws NotFoundException
{
Map <String, Map<String, String>> columnFamiliesMap = new HashMap<String, Map<String, String>> ();
Map<String, CFMetaData> tableMetaData = DatabaseDescriptor.getTableMetaData(tableName);
Map<String, CFMetaData> tableMetaData = DatabaseDescriptor.getTableMetaData(table);
// table doesn't exist
if (tableMetaData == null) {
throw new NotFoundException();

View File

@ -1,8 +1,7 @@
package org.apache.cassandra.service;
import org.apache.cassandra.db.TableNotDefinedException;
import org.apache.cassandra.db.KeyspaceNotDefinedException;
import org.apache.cassandra.db.ColumnFamilyNotDefinedException;
import org.apache.cassandra.db.RowMutation;
import org.apache.cassandra.config.DatabaseDescriptor;
public class ThriftValidation
@ -21,7 +20,7 @@ public class ThriftValidation
}
}
static void validateCommand(String tablename, String... columnFamilyNames) throws TableNotDefinedException, ColumnFamilyNotDefinedException
static void validateCommand(String tablename, String... columnFamilyNames) throws KeyspaceNotDefinedException, ColumnFamilyNotDefinedException
{
validateTable(tablename);
for (String cfName : columnFamilyNames)
@ -33,11 +32,11 @@ public class ThriftValidation
}
}
private static void validateTable(String tablename) throws TableNotDefinedException
private static void validateTable(String tablename) throws KeyspaceNotDefinedException
{
if (!DatabaseDescriptor.getTables().contains(tablename))
{
throw new TableNotDefinedException("Table " + tablename + " does not exist in this schema.");
throw new KeyspaceNotDefinedException("Keyspace " + tablename + " does not exist in this schema.");
}
}

View File

@ -328,7 +328,7 @@ public class NodeProbe
double tableTotalReadTime = 0.0f;
double tableTotalWriteTime = 0.0f;
outs.println("Table: " + tableName);
outs.println("Keyspace: " + tableName);
for (ColumnFamilyStoreMBean cfstore: columnFamilies) {
int writeCount = cfstore.getWriteCount();
int readCount = cfstore.getReadCount();

View File

@ -40,21 +40,21 @@
<StagingFileDirectory>build/test/cassandra/staging</StagingFileDirectory>
<MemtableSizeInMB>1</MemtableSizeInMB>
<MemtableObjectCountInMillions>0.00002</MemtableObjectCountInMillions> <!-- 20 -->
<Tables>
<Table Name = "Table1">
<Keyspaces>
<Keyspace Name = "Keyspace1">
<ColumnFamily Name="Standard1"/>
<ColumnFamily Name="Standard2"/>
<ColumnFamily CompareWith="LongType" Name="StandardLong1"/>
<ColumnFamily CompareWith="LongType" Name="StandardLong2"/>
<ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super1"/>
<ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super2"/>
</Table>
<Table Name = "Table2">
</Keyspace>
<Keyspace Name = "Keyspace2">
<ColumnFamily Name="Standard1"/>
<ColumnFamily Name="Standard3"/>
<ColumnFamily ColumnType="Super" Name="Super3"/>
</Table>
</Tables>
</Keyspace>
</Keyspaces>
<Seeds>
<!-- Add names of hosts that are deemed contact points -->
<Seed>127.0.0.1</Seed>

View File

@ -39,8 +39,8 @@ def _insert_simple(block=True):
consistencyLevel = ConsistencyLevel.ONE
else:
consistencyLevel = ConsistencyLevel.ZERO
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 0, consistencyLevel)
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c2'), 'value2', 0, consistencyLevel)
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 0, consistencyLevel)
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c2'), 'value2', 0, consistencyLevel)
def _insert_batch(block):
cfmap = {'Standard1': _SIMPLE_COLUMNS,
@ -50,68 +50,68 @@ def _insert_batch(block):
else:
consistencyLevel = ConsistencyLevel.ZERO
client.batch_insert('Table1', BatchMutation(key='key1', cfmap=cfmap), consistencyLevel)
client.batch_insert('Keyspace1', BatchMutation(key='key1', cfmap=cfmap), consistencyLevel)
def _verify_batch():
_verify_simple()
L = client.get_slice('Table1', 'key1', ColumnParent('Standard2'), '', '', True, 1000, ConsistencyLevel.ONE)
L = client.get_slice('Keyspace1', 'key1', ColumnParent('Standard2'), '', '', True, 1000, ConsistencyLevel.ONE)
assert L == _SIMPLE_COLUMNS, L
def _verify_simple():
assert client.get_column('Table1', 'key1', ColumnPath('Standard1', column='c1'), ConsistencyLevel.ONE) == Column('c1', 'value1', 0)
L = client.get_slice('Table1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE)
assert client.get_column('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), ConsistencyLevel.ONE) == Column('c1', 'value1', 0)
L = client.get_slice('Keyspace1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE)
assert L == _SIMPLE_COLUMNS, L
def _insert_super():
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc1', _i64(4)), 'value4', 0, ConsistencyLevel.ZERO)
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 0, ConsistencyLevel.ZERO)
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(6)), 'value6', 0, ConsistencyLevel.ZERO)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc1', _i64(4)), 'value4', 0, ConsistencyLevel.ZERO)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 0, ConsistencyLevel.ZERO)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(6)), 'value6', 0, ConsistencyLevel.ZERO)
time.sleep(0.1)
def _insert_range():
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 0, ConsistencyLevel.ONE)
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c2'), 'value2', 0, ConsistencyLevel.ONE)
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c3'), 'value3', 0, ConsistencyLevel.ONE)
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 0, ConsistencyLevel.ONE)
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c2'), 'value2', 0, ConsistencyLevel.ONE)
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c3'), 'value3', 0, ConsistencyLevel.ONE)
time.sleep(0.1)
def _verify_range():
result = client.get_slice('Table1','key1', ColumnParent('Standard1'), 'c1', 'c2', True, 1000, ConsistencyLevel.ONE)
result = client.get_slice('Keyspace1','key1', ColumnParent('Standard1'), 'c1', 'c2', True, 1000, ConsistencyLevel.ONE)
assert len(result) == 2
assert result[0].name == 'c1'
assert result[1].name == 'c2'
result = client.get_slice('Table1','key1', ColumnParent('Standard1'), 'c3', 'c2', False, 1000, ConsistencyLevel.ONE)
result = client.get_slice('Keyspace1','key1', ColumnParent('Standard1'), 'c3', 'c2', False, 1000, ConsistencyLevel.ONE)
assert len(result) == 2
assert result[0].name == 'c3'
assert result[1].name == 'c2'
result = client.get_slice('Table1','key1', ColumnParent('Standard1'), 'a', 'z' , True, 1000, ConsistencyLevel.ONE)
result = client.get_slice('Keyspace1','key1', ColumnParent('Standard1'), 'a', 'z' , True, 1000, ConsistencyLevel.ONE)
assert len(result) == 3, result
result = client.get_slice('Table1','key1', ColumnParent('Standard1'), 'a', 'z' , True, 2, ConsistencyLevel.ONE)
result = client.get_slice('Keyspace1','key1', ColumnParent('Standard1'), 'a', 'z' , True, 2, ConsistencyLevel.ONE)
assert len(result) == 2, result
def _insert_super_range():
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc1', _i64(4)), 'value4', 0, False)
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 0, False)
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(6)), 'value6', 0, False)
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc3', _i64(7)), 'value7', 0, False)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc1', _i64(4)), 'value4', 0, False)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 0, False)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(6)), 'value6', 0, False)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc3', _i64(7)), 'value7', 0, False)
time.sleep(0.1)
def _verify_super_range():
result = client.get_slice_super('Table1','key1', 'Super1', 'sc2', 'sc3', True, 2, ConsistencyLevel.ONE)
result = client.get_slice_super('Keyspace1','key1', 'Super1', 'sc2', 'sc3', True, 2, ConsistencyLevel.ONE)
assert len(result) == 2
assert result[0].name == 'sc2'
assert result[1].name == 'sc3'
result = client.get_slice_super('Table1','key1', 'Super1', 'sc3', 'sc2', False, 2, ConsistencyLevel.ONE)
result = client.get_slice_super('Keyspace1','key1', 'Super1', 'sc3', 'sc2', False, 2, ConsistencyLevel.ONE)
assert len(result) == 2
assert result[0].name == 'sc3'
assert result[1].name == 'sc2'
def _verify_super(supercf='Super1'):
assert client.get_column('Table1', 'key1', ColumnPath(supercf, 'sc1', _i64(4)), ConsistencyLevel.ONE) == Column(_i64(4), 'value4', 0)
slice = client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert client.get_column('Keyspace1', 'key1', ColumnPath(supercf, 'sc1', _i64(4)), ConsistencyLevel.ONE) == Column(_i64(4), 'value4', 0)
slice = client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert slice == _SUPER_COLUMNS, slice
def _expect_exception(fn, type_):
@ -132,21 +132,21 @@ class TestMutations(CassandraTester):
_verify_simple()
def test_empty_slice(self):
assert client.get_slice('Table1', 'key1', ColumnParent('Standard2'), '', '', True, 1000, ConsistencyLevel.ONE) == []
assert client.get_slice('Keyspace1', 'key1', ColumnParent('Standard2'), '', '', True, 1000, ConsistencyLevel.ONE) == []
def test_empty_slice_super(self):
assert client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE) == []
assert client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE) == []
def test_missing_super(self):
_expect_missing(lambda: client.get_column('Table1', 'key1', ColumnPath('Super1', 'sc1', 'c1'), ConsistencyLevel.ONE))
_expect_missing(lambda: client.get_column('Keyspace1', 'key1', ColumnPath('Super1', 'sc1', 'c1'), ConsistencyLevel.ONE))
def test_count(self):
_insert_simple()
_insert_super()
assert client.get_column_count('Table1', 'key1', ColumnParent('Standard2'), ConsistencyLevel.ONE) == 0
assert client.get_column_count('Table1', 'key1', ColumnParent('Standard1'), ConsistencyLevel.ONE) == 2
assert client.get_column_count('Table1', 'key1', ColumnParent('Super1', 'sc2'), ConsistencyLevel.ONE) == 2
assert client.get_column_count('Table1', 'key1', ColumnParent('Super1'), ConsistencyLevel.ONE) == 2
assert client.get_column_count('Keyspace1', 'key1', ColumnParent('Standard2'), ConsistencyLevel.ONE) == 0
assert client.get_column_count('Keyspace1', 'key1', ColumnParent('Standard1'), ConsistencyLevel.ONE) == 2
assert client.get_column_count('Keyspace1', 'key1', ColumnParent('Super1', 'sc2'), ConsistencyLevel.ONE) == 2
assert client.get_column_count('Keyspace1', 'key1', ColumnParent('Super1'), ConsistencyLevel.ONE) == 2
def test_insert_blocking(self):
_insert_simple()
@ -166,18 +166,18 @@ class TestMutations(CassandraTester):
_verify_batch()
def test_bad_calls(self):
_expect_exception(lambda: client.insert('Table1', 'key1', ColumnPath('Standard1', 'x', 'y'), 'value', 0, ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.insert('Keyspace1', 'key1', ColumnPath('Standard1', 'x', 'y'), 'value', 0, ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_column('Table1', 'key1', ColumnPath('Standard1'), ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_column('Table1', 'key1', ColumnPath('Standard1', 'x', 'y'), ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_column('Table1', 'key1', ColumnPath('Super1'), ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_column('Table1', 'key1', ColumnPath('Super1', 'x'), ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_key_range('Table1', 'S', '', '', 1000), InvalidRequestException)
_expect_exception(lambda: client.get_column('Keyspace1', 'key1', ColumnPath('Standard1'), ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_column('Keyspace1', 'key1', ColumnPath('Standard1', 'x', 'y'), ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_column('Keyspace1', 'key1', ColumnPath('Super1'), ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_column('Keyspace1', 'key1', ColumnPath('Super1', 'x'), ConsistencyLevel.ONE), InvalidRequestException)
_expect_exception(lambda: client.get_key_range('Keyspace1', 'S', '', '', 1000), InvalidRequestException)
def test_batch_insert_super(self):
cfmap = {'Super1': _SUPER_COLUMNS,
'Super2': _SUPER_COLUMNS}
client.batch_insert_super_column('Table1', BatchMutation(key='key1', cfmap=cfmap), ConsistencyLevel.ZERO)
client.batch_insert_super_column('Keyspace1', BatchMutation(key='key1', cfmap=cfmap), ConsistencyLevel.ZERO)
time.sleep(0.1)
_verify_super('Super1')
_verify_super('Super2')
@ -185,32 +185,32 @@ class TestMutations(CassandraTester):
def test_batch_insert_super_blocking(self):
cfmap = {'Super1': _SUPER_COLUMNS,
'Super2': _SUPER_COLUMNS}
client.batch_insert_super_column('Table1', BatchMutation(key='key1', cfmap=cfmap), ConsistencyLevel.ONE)
client.batch_insert_super_column('Keyspace1', BatchMutation(key='key1', cfmap=cfmap), ConsistencyLevel.ONE)
_verify_super('Super1')
_verify_super('Super2')
def test_cf_remove_column(self):
_insert_simple()
client.remove('Table1', 'key1', ColumnPathOrParent('Standard1', column='c1'), 1, ConsistencyLevel.ONE)
_expect_missing(lambda: client.get_column('Table1', 'key1', ColumnPath('Standard1', column='c1'), ConsistencyLevel.ONE))
assert client.get_column('Table1', 'key1', ColumnPath('Standard1', column='c2'), ConsistencyLevel.ONE) \
client.remove('Keyspace1', 'key1', ColumnPathOrParent('Standard1', column='c1'), 1, ConsistencyLevel.ONE)
_expect_missing(lambda: client.get_column('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), ConsistencyLevel.ONE))
assert client.get_column('Keyspace1', 'key1', ColumnPath('Standard1', column='c2'), ConsistencyLevel.ONE) \
== Column('c2', 'value2', 0)
assert client.get_slice('Table1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) \
assert client.get_slice('Keyspace1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) \
== [Column('c2', 'value2', 0)]
# New insert, make sure it shows up post-remove:
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c3'), 'value3', 0, ConsistencyLevel.ONE)
assert client.get_slice('Table1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == \
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c3'), 'value3', 0, ConsistencyLevel.ONE)
assert client.get_slice('Keyspace1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == \
[Column('c2', 'value2', 0), Column('c3', 'value3', 0)]
# Test resurrection. First, re-insert the value w/ older timestamp,
# and make sure it stays removed
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 0, ConsistencyLevel.ONE)
assert client.get_slice('Table1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == \
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 0, ConsistencyLevel.ONE)
assert client.get_slice('Keyspace1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == \
[Column('c2', 'value2', 0), Column('c3', 'value3', 0)]
# Next, w/ a newer timestamp; it should come back:
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 2, ConsistencyLevel.ONE)
assert client.get_slice('Table1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == \
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 2, ConsistencyLevel.ONE)
assert client.get_slice('Keyspace1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == \
[Column('c1', 'value1', 2), Column('c2', 'value2', 0), Column('c3', 'value3', 0)]
@ -219,17 +219,17 @@ class TestMutations(CassandraTester):
_insert_super()
# Remove the key1:Standard1 cf:
client.remove('Table1', 'key1', ColumnPathOrParent('Standard1'), 3, ConsistencyLevel.ONE)
assert client.get_slice('Table1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == []
client.remove('Keyspace1', 'key1', ColumnPathOrParent('Standard1'), 3, ConsistencyLevel.ONE)
assert client.get_slice('Keyspace1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == []
_verify_super()
# Test resurrection. First, re-insert a value w/ older timestamp,
# and make sure it stays removed:
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 0, ConsistencyLevel.ONE)
assert client.get_slice('Table1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == []
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 0, ConsistencyLevel.ONE)
assert client.get_slice('Keyspace1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == []
# Next, w/ a newer timestamp; it should come back:
client.insert('Table1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 4, ConsistencyLevel.ONE)
assert client.get_slice('Table1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == \
client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), 'value1', 4, ConsistencyLevel.ONE)
assert client.get_slice('Keyspace1', 'key1', ColumnParent('Standard1'), '', '', True, 1000, ConsistencyLevel.ONE) == \
[Column('c1', 'value1', 4)]
@ -238,33 +238,33 @@ class TestMutations(CassandraTester):
_insert_super()
# Make sure remove clears out what it's supposed to, and _only_ that:
client.remove('Table1', 'key1', ColumnPathOrParent('Super1', 'sc2', _i64(5)), 5, ConsistencyLevel.ONE)
_expect_missing(lambda: client.get_column('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), ConsistencyLevel.ONE))
assert client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE) == \
client.remove('Keyspace1', 'key1', ColumnPathOrParent('Super1', 'sc2', _i64(5)), 5, ConsistencyLevel.ONE)
_expect_missing(lambda: client.get_column('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), ConsistencyLevel.ONE))
assert client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE) == \
[SuperColumn(name='sc1', columns=[Column(_i64(4), 'value4', 0)]),
SuperColumn(name='sc2', columns=[Column(_i64(6), 'value6', 0)])]
_verify_simple()
# New insert, make sure it shows up post-remove:
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(7)), 'value7', 0, ConsistencyLevel.ONE)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(7)), 'value7', 0, ConsistencyLevel.ONE)
scs = [SuperColumn(name='sc1',
columns=[Column(_i64(4), 'value4', 0)]),
SuperColumn(name='sc2',
columns=[Column(_i64(6), 'value6', 0), Column(_i64(7), 'value7', 0)])]
actual = client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE) == scs, actual
actual = client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE) == scs, actual
# Test resurrection. First, re-insert the value w/ older timestamp,
# and make sure it stays removed:
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 0, ConsistencyLevel.ONE)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 0, ConsistencyLevel.ONE)
actual = client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
actual = client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert actual == scs, actual
# Next, w/ a newer timestamp; it should come back
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 6, ConsistencyLevel.ONE)
actual = client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 6, ConsistencyLevel.ONE)
actual = client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert actual == \
[SuperColumn(name='sc1', columns=[Column(_i64(4), 'value4', 0)]),
SuperColumn(name='sc2', columns=[Column(_i64(5), 'value5', 6),
@ -276,72 +276,72 @@ class TestMutations(CassandraTester):
_insert_super()
# Make sure remove clears out what it's supposed to, and _only_ that:
client.remove('Table1', 'key1', ColumnPathOrParent('Super1', 'sc2'), 5, ConsistencyLevel.ONE)
_expect_missing(lambda: client.get_column('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), ConsistencyLevel.ONE))
actual = client.get_slice('Table1', 'key1', ColumnParent('Super1', 'sc2'), '', '', True, 1000, ConsistencyLevel.ONE)
client.remove('Keyspace1', 'key1', ColumnPathOrParent('Super1', 'sc2'), 5, ConsistencyLevel.ONE)
_expect_missing(lambda: client.get_column('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), ConsistencyLevel.ONE))
actual = client.get_slice('Keyspace1', 'key1', ColumnParent('Super1', 'sc2'), '', '', True, 1000, ConsistencyLevel.ONE)
assert actual == [], actual
scs = [SuperColumn(name='sc1', columns=[Column(_i64(4), 'value4', 0)])]
actual = client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
actual = client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert actual == scs, actual
_verify_simple()
# Test resurrection. First, re-insert the value w/ older timestamp,
# and make sure it stays removed:
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 0, ConsistencyLevel.ONE)
actual = client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 0, ConsistencyLevel.ONE)
actual = client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert actual == scs, actual
# Next, w/ a newer timestamp; it should come back
client.insert('Table1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 6, ConsistencyLevel.ONE)
actual = client.get_slice_super('Table1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5', 6, ConsistencyLevel.ONE)
actual = client.get_slice_super('Keyspace1', 'key1', 'Super1', '', '', True, 1000, ConsistencyLevel.ONE)
assert actual == \
[SuperColumn(name='sc1', columns=[Column(_i64(4), 'value4', 0)]),
SuperColumn(name='sc2', columns=[Column(_i64(5), 'value5', 6)])], actual
def test_empty_range(self):
assert client.get_key_range('Table1', 'Standard1', '', '', 1000) == []
assert client.get_key_range('Keyspace1', 'Standard1', '', '', 1000) == []
_insert_simple()
assert client.get_key_range('Table1', 'Super1', '', '', 1000) == []
assert client.get_key_range('Keyspace1', 'Super1', '', '', 1000) == []
def test_range_with_remove(self):
_insert_simple()
assert client.get_key_range('Table1', 'Standard1', 'key1', '', 1000) == ['key1']
assert client.get_key_range('Keyspace1', 'Standard1', 'key1', '', 1000) == ['key1']
client.remove('Table1', 'key1', ColumnPathOrParent('Standard1', column='c1'), 1, ConsistencyLevel.ONE)
client.remove('Table1', 'key1', ColumnPathOrParent('Standard1', column='c2'), 1, ConsistencyLevel.ONE)
actual = client.get_key_range('Table1', 'Standard1', '', '', 1000)
client.remove('Keyspace1', 'key1', ColumnPathOrParent('Standard1', column='c1'), 1, ConsistencyLevel.ONE)
client.remove('Keyspace1', 'key1', ColumnPathOrParent('Standard1', column='c2'), 1, ConsistencyLevel.ONE)
actual = client.get_key_range('Keyspace1', 'Standard1', '', '', 1000)
assert actual == [], actual
def test_range_with_remove_cf(self):
_insert_simple()
assert client.get_key_range('Table1', 'Standard1', 'key1', '', 1000) == ['key1']
assert client.get_key_range('Keyspace1', 'Standard1', 'key1', '', 1000) == ['key1']
client.remove('Table1', 'key1', ColumnPathOrParent('Standard1'), 1, ConsistencyLevel.ONE)
actual = client.get_key_range('Table1', 'Standard1', '', '', 1000)
client.remove('Keyspace1', 'key1', ColumnPathOrParent('Standard1'), 1, ConsistencyLevel.ONE)
actual = client.get_key_range('Keyspace1', 'Standard1', '', '', 1000)
assert actual == [], actual
def test_range_collation(self):
for key in ['-a', '-b', 'a', 'b'] + [str(i) for i in xrange(100)]:
client.insert('Table1', key, ColumnPath('Standard1', column=key), 'v', 0, ConsistencyLevel.ONE)
L = client.get_key_range('Table1', 'Standard1', '', '', 1000)
client.insert('Keyspace1', key, ColumnPath('Standard1', column=key), 'v', 0, ConsistencyLevel.ONE)
L = client.get_key_range('Keyspace1', 'Standard1', '', '', 1000)
# note the collated ordering rather than ascii
assert L == ['0', '1', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '2', '20', '21', '22', '23', '24', '25', '26', '27','28', '29', '3', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '4', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '5', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '6', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '7', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '8', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '9', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', 'a', '-a', 'b', '-b'], L
def test_range_partial(self):
for key in ['-a', '-b', 'a', 'b'] + [str(i) for i in xrange(100)]:
client.insert('Table1', key, ColumnPath('Standard1', column=key), 'v', 0, ConsistencyLevel.ONE)
client.insert('Keyspace1', key, ColumnPath('Standard1', column=key), 'v', 0, ConsistencyLevel.ONE)
L = client.get_key_range('Table1', 'Standard1', 'a', '', 1000)
L = client.get_key_range('Keyspace1', 'Standard1', 'a', '', 1000)
assert L == ['a', '-a', 'b', '-b'], L
L = client.get_key_range('Table1', 'Standard1', '', '15', 1000)
L = client.get_key_range('Keyspace1', 'Standard1', '', '15', 1000)
assert L == ['0', '1', '10', '11', '12', '13', '14', '15'], L
L = client.get_key_range('Table1', 'Standard1', '50', '51', 1000)
L = client.get_key_range('Keyspace1', 'Standard1', '50', '51', 1000)
assert L == ['50', '51'], L
L = client.get_key_range('Table1', 'Standard1', '1', '', 10)
L = client.get_key_range('Keyspace1', 'Standard1', '1', '', 10)
assert L == ['1', '10', '11', '12', '13', '14', '15', '16', '17', '18'], L
def test_get_slice_range(self):
@ -354,12 +354,12 @@ class TestMutations(CassandraTester):
def test_get_slice_by_names(self):
_insert_range()
result = client.get_slice_by_names('Table1','key1', ColumnParent('Standard1'), ['c1', 'c2'], ConsistencyLevel.ONE)
result = client.get_slice_by_names('Keyspace1', 'key1', ColumnParent('Standard1'), ['c1', 'c2'], ConsistencyLevel.ONE)
assert len(result) == 2
assert result[0].name == 'c1'
assert result[1].name == 'c2'
_insert_super()
result = client.get_slice_by_names('Table1','key1', ColumnParent('Super1', 'sc1'), [_i64(4)], ConsistencyLevel.ONE)
result = client.get_slice_by_names('Keyspace1', 'key1', ColumnParent('Super1', 'sc1'), [_i64(4)], ConsistencyLevel.ONE)
assert len(result) == 1
assert result[0].name == _i64(4)

View File

@ -103,12 +103,12 @@ public class ColumnFamilyStoreTest extends CleanupHelper
@Test
public void testGetColumnWithWrongBF() throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(), 0);
rm.add(new QueryPath("Standard1", null, "Column2".getBytes()), "asdf".getBytes(), 0);
rm.apply();

View File

@ -40,7 +40,7 @@ public class ColumnFamilyTest
{
ColumnFamily cf;
cf = ColumnFamily.create("Table1", "Standard1");
cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("C", "v", 1));
DataOutputBuffer bufOut = new DataOutputBuffer();
ColumnFamily.serializer().serialize(cf, bufOut);
@ -65,7 +65,7 @@ public class ColumnFamilyTest
}
// write
cf = ColumnFamily.create("Table1", "Standard1");
cf = ColumnFamily.create("Keyspace1", "Standard1");
DataOutputBuffer bufOut = new DataOutputBuffer();
for (String cName : map.navigableKeySet())
{
@ -87,7 +87,7 @@ public class ColumnFamilyTest
@Test
public void testGetColumnCount()
{
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1", "", 1));
cf.addColumn(column("col2", "", 2));
@ -100,7 +100,7 @@ public class ColumnFamilyTest
@Test
public void testTimestamp()
{
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1", "val1", 2));
cf.addColumn(column("col1", "val2", 2)); // same timestamp, new value
@ -112,9 +112,9 @@ public class ColumnFamilyTest
@Test
public void testMergeAndAdd()
{
ColumnFamily cf_new = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf_old = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf_result = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf_new = ColumnFamily.create("Keyspace1", "Standard1");
ColumnFamily cf_old = ColumnFamily.create("Keyspace1", "Standard1");
ColumnFamily cf_result = ColumnFamily.create("Keyspace1", "Standard1");
byte val[] = "sample value".getBytes();
byte val2[] = "x value ".getBytes();
@ -136,7 +136,7 @@ public class ColumnFamilyTest
@Test
public void testEmptyDigest()
{
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
assert cf.digest().length == 0;
}
}

View File

@ -34,7 +34,7 @@ public class CommitLogTest extends CleanupHelper
assert CommitLog.getSegmentCount() == 0;
CommitLog.setSegmentSize(1000);
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store1 = table.getColumnFamilyStore("Standard1");
ColumnFamilyStore store2 = table.getColumnFamilyStore("Standard2");
RowMutation rm;
@ -43,7 +43,7 @@ public class CommitLogTest extends CleanupHelper
// add data. use relatively large values to force quick segment creation since we have a low flush threshold in the test config.
for (int i = 0; i < 10; i++)
{
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), value, 0);
rm.add(new QueryPath("Standard2", null, "Column1".getBytes()), value, 0);
rm.apply();

View File

@ -38,7 +38,7 @@ public class CompactionsTest extends CleanupHelper
public void testCompactions() throws IOException, ExecutionException, InterruptedException
{
// this test does enough rows to force multiple block indexes to be used
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
final int ROWS_PER_SSTABLE = 10;
@ -46,7 +46,7 @@ public class CompactionsTest extends CleanupHelper
for (int j = 0; j < (SSTableReader.indexInterval() * 3) / ROWS_PER_SSTABLE; j++) {
for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
String key = String.valueOf(i % 2);
RowMutation rm = new RowMutation("Table1", key);
RowMutation rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath("Standard1", null, String.valueOf(i / 2).getBytes()), new byte[0], j * ROWS_PER_SSTABLE + i);
rm.apply();
inserted.add(key);

View File

@ -14,20 +14,20 @@ public class MultitableTest extends CleanupHelper
@Test
public void testSameCFs() throws IOException, ExecutionException, InterruptedException
{
Table table1 = Table.open("Table1");
Table table2 = Table.open("Table2");
Table table1 = Table.open("Keyspace1");
Table table2 = Table.open("Keyspace2");
RowMutation rm;
ColumnFamily cf;
rm = new RowMutation("Table1", "keymulti");
cf = ColumnFamily.create("Table1", "Standard1");
rm = new RowMutation("Keyspace1", "keymulti");
cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1", "val1", 1L));
rm.add(cf);
rm.apply();
rm = new RowMutation("Table2", "keymulti");
cf = ColumnFamily.create("Table2", "Standard1");
rm = new RowMutation("Keyspace2", "keymulti");
cf = ColumnFamily.create("Keyspace2", "Standard1");
cf.addColumn(column("col2", "val2", 1L));
rm.add(cf);
rm.apply();

View File

@ -58,7 +58,7 @@ public class NameSortTest extends CleanupHelper
private void testNameSort(int N) throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
for (int i = 0; i < N; ++i)
{
@ -69,7 +69,7 @@ public class NameSortTest extends CleanupHelper
for (int j = 0; j < 8; ++j)
{
byte[] bytes = j % 2 == 0 ? "a".getBytes() : "b".getBytes();
rm = new RowMutation("Table1", key);
rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath("Standard1", null, ("Column-" + j).getBytes()), bytes, j);
rm.apply();
}
@ -77,7 +77,7 @@ public class NameSortTest extends CleanupHelper
// super
for (int j = 0; j < 8; ++j)
{
rm = new RowMutation("Table1", key);
rm = new RowMutation("Keyspace1", key);
for (int k = 0; k < 4; ++k)
{
String value = (j + k) % 2 == 0 ? "a" : "b";

View File

@ -34,13 +34,13 @@ public class OneCompactionTest
{
private void testCompaction(String columnFamilyName, int insertsPerTable) throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore(columnFamilyName);
Set<String> inserted = new HashSet<String>();
for (int j = 0; j < insertsPerTable; j++) {
String key = "0";
RowMutation rm = new RowMutation("Table1", key);
RowMutation rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath(columnFamilyName, null, "0".getBytes()), new byte[0], j);
rm.apply();
inserted.add(key);

View File

@ -44,15 +44,15 @@ public class ReadMessageTest
ReadCommand rm, rm2;
rm = new SliceByNamesReadCommand("Table1", "row1", new QueryPath("Standard1"), colList);
rm = new SliceByNamesReadCommand("Keyspace1", "row1", new QueryPath("Standard1"), colList);
rm2 = serializeAndDeserializeReadMessage(rm);
assert rm2.toString().equals(rm.toString());
rm = new SliceFromReadCommand("Table1", "row1", new QueryPath("Standard1"), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
rm = new SliceFromReadCommand("Keyspace1", "row1", new QueryPath("Standard1"), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
rm2 = serializeAndDeserializeReadMessage(rm);
assert rm2.toString().equals(rm.toString());
rm = new SliceFromReadCommand("Table1", "row1", new QueryPath("Standard1"), "a".getBytes(), "z".getBytes(), true, 5);
rm = new SliceFromReadCommand("Keyspace1", "row1", new QueryPath("Standard1"), "a".getBytes(), "z".getBytes(), true, 5);
rm2 = serializeAndDeserializeReadMessage(rm);
assertEquals(rm2.toString(), rm.toString());
}
@ -71,15 +71,15 @@ public class ReadMessageTest
@Test
public void testGetColumn() throws IOException, ColumnFamilyNotDefinedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "abcd".getBytes(), 0);
rm.apply();
ReadCommand command = new SliceByNamesReadCommand("Table1", "key1", new QueryPath("Standard1"), Arrays.asList("Column1".getBytes()));
ReadCommand command = new SliceByNamesReadCommand("Keyspace1", "key1", new QueryPath("Standard1"), Arrays.asList("Column1".getBytes()));
Row row = command.getRow(table);
ColumnFamily cf = row.getColumnFamily("Standard1");
IColumn col = cf.getColumn("Column1".getBytes());

View File

@ -16,14 +16,14 @@ public class RecoveryManager2Test extends CleanupHelper
@Test
public void testWithFlush() throws IOException, ExecutionException, InterruptedException
{
Table table1 = Table.open("Table1");
Table table1 = Table.open("Keyspace1");
Set<String> keys = new HashSet<String>();
for (int i = 0; i < 100; i++)
{
String key = "key" + i;
RowMutation rm = new RowMutation("Table1", key);
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
RowMutation rm = new RowMutation("Keyspace1", key);
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1", "val1", 1L));
rm.add(cf);
rm.apply();

View File

@ -42,20 +42,20 @@ public class RecoveryManagerTest extends CleanupHelper
@Test
public void testOne() throws IOException, ExecutionException, InterruptedException
{
Table table1 = Table.open("Table1");
Table table2 = Table.open("Table2");
Table table1 = Table.open("Keyspace1");
Table table2 = Table.open("Keyspace2");
RowMutation rm;
ColumnFamily cf;
rm = new RowMutation("Table1", "keymulti");
cf = ColumnFamily.create("Table1", "Standard1");
rm = new RowMutation("Keyspace1", "keymulti");
cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1", "val1", 1L));
rm.add(cf);
rm.apply();
rm = new RowMutation("Table2", "keymulti");
cf = ColumnFamily.create("Table2", "Standard3");
rm = new RowMutation("Keyspace2", "keymulti");
cf = ColumnFamily.create("Keyspace2", "Standard3");
cf.addColumn(column("col2", "val2", 1L));
rm.add(cf);
rm.apply();

View File

@ -32,17 +32,17 @@ public class RemoveColumnFamilyTest
@Test
public void testRemoveColumnFamily() throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(), 0);
rm.apply();
// remove
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.delete(new QueryPath("Standard1"), 1);
rm.apply();

View File

@ -32,19 +32,19 @@ public class RemoveColumnFamilyWithFlush1Test
@Test
public void testRemoveColumnFamilyWithFlush1() throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(), 0);
rm.add(new QueryPath("Standard1", null, "Column2".getBytes()), "asdf".getBytes(), 0);
rm.apply();
store.forceBlockingFlush();
// remove
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.delete(new QueryPath("Standard1"), 1);
rm.apply();

View File

@ -32,16 +32,16 @@ public class RemoveColumnFamilyWithFlush2Test
@Test
public void testRemoveColumnFamilyWithFlush2() throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(), 0);
rm.apply();
// remove
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.delete(new QueryPath("Standard1"), 1);
rm.apply();
store.forceBlockingFlush();

View File

@ -33,18 +33,18 @@ public class RemoveColumnTest
@Test
public void testRemoveColumn() throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(), 0);
rm.apply();
store.forceBlockingFlush();
// remove
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.delete(new QueryPath("Standard1", null, "Column1".getBytes()), 1);
rm.apply();

View File

@ -34,18 +34,18 @@ public class RemoveSubColumnTest
@Test
public void testRemoveSubColumn() throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Super1");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
addMutation(rm, "Super1", "SC1", 1, "asdf", 0);
rm.apply();
store.forceBlockingFlush();
// remove
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.delete(new QueryPath("Super1", "SC1".getBytes(), getBytes(1)), 1);
rm.apply();

View File

@ -38,17 +38,17 @@ public class RemoveSuperColumnTest
@Test
public void testRemoveSuperColumn() throws IOException, ExecutionException, InterruptedException
{
ColumnFamilyStore store = Table.open("Table1").getColumnFamilyStore("Super1");
ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super1");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
addMutation(rm, "Super1", "SC1", 1, "val1", 0);
rm.apply();
store.forceBlockingFlush();
// remove
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.delete(new QueryPath("Super1", "SC1".getBytes()), 1);
rm.apply();
@ -65,7 +65,7 @@ public class RemoveSuperColumnTest
private void validateRemoveTwoSources() throws IOException
{
ColumnFamilyStore store = Table.open("Table1").getColumnFamilyStore("Super1");
ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super1");
ColumnFamily resolved = store.getColumnFamily(new NamesQueryFilter("key1", new QueryPath("Super1"), "SC1".getBytes()));
assert resolved.getSortedColumns().iterator().next().getMarkedForDeleteAt() == 1;
assert resolved.getSortedColumns().iterator().next().getSubColumns().size() == 0;
@ -75,7 +75,7 @@ public class RemoveSuperColumnTest
private void validateRemoveCompacted() throws IOException
{
ColumnFamilyStore store = Table.open("Table1").getColumnFamilyStore("Super1");
ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super1");
ColumnFamily resolved = store.getColumnFamily(new NamesQueryFilter("key1", new QueryPath("Super1"), "SC1".getBytes()));
assert resolved.getSortedColumns().iterator().next().getMarkedForDeleteAt() == 1;
Collection<IColumn> subColumns = resolved.getSortedColumns().iterator().next().getSubColumns();
@ -85,22 +85,22 @@ public class RemoveSuperColumnTest
@Test
public void testRemoveSuperColumnWithNewData() throws IOException, ExecutionException, InterruptedException
{
ColumnFamilyStore store = Table.open("Table1").getColumnFamilyStore("Super2");
ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super2");
RowMutation rm;
// add data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
addMutation(rm, "Super2", "SC1", 1, "val1", 0);
rm.apply();
store.forceBlockingFlush();
// remove
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
rm.delete(new QueryPath("Super2", "SC1".getBytes()), 1);
rm.apply();
// new data
rm = new RowMutation("Table1", "key1");
rm = new RowMutation("Keyspace1", "key1");
addMutation(rm, "Super2", "SC1", 2, "val2", 2);
rm.apply();
@ -117,7 +117,7 @@ public class RemoveSuperColumnTest
private void validateRemoveWithNewData() throws IOException
{
ColumnFamilyStore store = Table.open("Table1").getColumnFamilyStore("Super2");
ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super2");
ColumnFamily resolved = store.getColumnFamily(new NamesQueryFilter("key1", new QueryPath("Super2", "SC1".getBytes()), getBytes(2)));
Collection<IColumn> subColumns = resolved.getSortedColumns().iterator().next().getSubColumns();
assert subColumns.size() == 1;

View File

@ -32,10 +32,10 @@ public class RowTest
@Test
public void testDiffColumnFamily()
{
ColumnFamily cf1 = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf1 = ColumnFamily.create("Keyspace1", "Standard1");
cf1.addColumn(column("one", "onev", 0));
ColumnFamily cf2 = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf2 = ColumnFamily.create("Keyspace1", "Standard1");
cf2.delete(0, 0);
ColumnFamily cfDiff = cf1.diff(cf2);
@ -61,15 +61,15 @@ public class RowTest
public void testRepair()
{
Row row1 = new Row();
ColumnFamily cf1 = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf1 = ColumnFamily.create("Keyspace1", "Standard1");
cf1.addColumn(column("one", "A", 0));
row1.addColumnFamily(cf1);
Row row2 = new Row();
ColumnFamily cf2 = ColumnFamily.create("Table1", "Standard1");
ColumnFamily cf2 = ColumnFamily.create("Keyspace1", "Standard1");
cf2.addColumn(column("one", "B", 1));
cf2.addColumn(column("two", "C", 1));
ColumnFamily cf3 = ColumnFamily.create("Table2", "Standard3");
ColumnFamily cf3 = ColumnFamily.create("Keyspace2", "Standard3");
cf3.addColumn(column("three", "D", 1));
row2.addColumnFamily(cf2);
row2.addColumnFamily(cf3);

View File

@ -62,7 +62,7 @@ public class TableTest extends CleanupHelper
@Test
public void testGetRowSingleColumn() throws Throwable
{
final Table table = Table.open("Table1");
final Table table = Table.open("Keyspace1");
final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
Runner setup = new Runner()
@ -93,10 +93,10 @@ public class TableTest extends CleanupHelper
public void testGetRowSliceByRange() throws Throwable
{
String key = TEST_KEY+"slicerow";
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
RowMutation rm = new RowMutation("Table1", key);
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
RowMutation rm = new RowMutation("Keyspace1", key);
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
// First write "a", "b", "c"
cf.addColumn(column("a", "val1", 1L));
cf.addColumn(column("b", "val2", 1L));
@ -119,8 +119,8 @@ public class TableTest extends CleanupHelper
private RowMutation makeSimpleRowMutation()
{
RowMutation rm = new RowMutation("Table1",TEST_KEY);
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
RowMutation rm = new RowMutation("Keyspace1",TEST_KEY);
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1","val1", 1L));
cf.addColumn(column("col2","val2", 1L));
cf.addColumn(column("col3","val3", 1L));
@ -131,9 +131,9 @@ public class TableTest extends CleanupHelper
@Test
public void testGetSliceNoMatch() throws Throwable
{
Table table = Table.open("Table1");
RowMutation rm = new RowMutation("Table1", "row1000");
ColumnFamily cf = ColumnFamily.create("Table1", "Standard2");
Table table = Table.open("Keyspace1");
RowMutation rm = new RowMutation("Keyspace1", "row1000");
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard2");
cf.addColumn(column("col1", "val1", 1));
rm.add(cf);
rm.apply();
@ -166,15 +166,15 @@ public class TableTest extends CleanupHelper
public void testGetSliceFromBasic() throws Throwable
{
// tests slicing against data from one row in a memtable and then flushed to an sstable
final Table table = Table.open("Table1");
final Table table = Table.open("Keyspace1");
final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
final String ROW = "row1";
Runner setup = new Runner()
{
public void run() throws Exception
{
RowMutation rm = new RowMutation("Table1", ROW);
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
RowMutation rm = new RowMutation("Keyspace1", ROW);
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1", "val1", 1L));
cf.addColumn(column("col3", "val3", 1L));
cf.addColumn(column("col4", "val4", 1L));
@ -184,7 +184,7 @@ public class TableTest extends CleanupHelper
rm.add(cf);
rm.apply();
rm = new RowMutation("Table1", ROW);
rm = new RowMutation("Keyspace1", ROW);
rm.delete(new QueryPath("Standard1", null, "col4".getBytes()), 2L);
rm.apply();
}
@ -225,15 +225,15 @@ public class TableTest extends CleanupHelper
public void testGetSliceFromAdvanced() throws Throwable
{
// tests slicing against data from one row spread across two sstables
final Table table = Table.open("Table1");
final Table table = Table.open("Keyspace1");
final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
final String ROW = "row2";
Runner setup = new Runner()
{
public void run() throws Exception
{
RowMutation rm = new RowMutation("Table1", ROW);
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
RowMutation rm = new RowMutation("Keyspace1", ROW);
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1", "val1", 1L));
cf.addColumn(column("col2", "val2", 1L));
cf.addColumn(column("col3", "val3", 1L));
@ -244,8 +244,8 @@ public class TableTest extends CleanupHelper
rm.apply();
cfStore.forceBlockingFlush();
rm = new RowMutation("Table1", ROW);
cf = ColumnFamily.create("Table1", "Standard1");
rm = new RowMutation("Keyspace1", ROW);
cf = ColumnFamily.create("Keyspace1", "Standard1");
cf.addColumn(column("col1", "valx", 2L));
cf.addColumn(column("col2", "valx", 2L));
cf.addColumn(column("col3", "valx", 2L));
@ -275,11 +275,11 @@ public class TableTest extends CleanupHelper
public void testGetSliceFromLarge() throws Throwable
{
// tests slicing against 1000 columns in an sstable
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
String ROW = "row3";
RowMutation rm = new RowMutation("Table1", ROW);
ColumnFamily cf = ColumnFamily.create("Table1", "Standard1");
RowMutation rm = new RowMutation("Keyspace1", ROW);
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
for (int i = 1000; i < 2000; i++)
cf.addColumn(column("col" + i, ("vvvvvvvvvvvvvvvv" + i), 1L));
rm.add(cf);
@ -315,15 +315,15 @@ public class TableTest extends CleanupHelper
public void testGetSliceFromSuperBasic() throws Throwable
{
// tests slicing against data from one row spread across two sstables
final Table table = Table.open("Table1");
final Table table = Table.open("Keyspace1");
final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Super1");
final String ROW = "row2";
Runner setup = new Runner()
{
public void run() throws Exception
{
RowMutation rm = new RowMutation("Table1", ROW);
ColumnFamily cf = ColumnFamily.create("Table1", "Super1");
RowMutation rm = new RowMutation("Keyspace1", ROW);
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Super1");
SuperColumn sc = new SuperColumn("sc1".getBytes(), new LongType());
sc.addColumn(new Column(getBytes(1), "val1".getBytes(), 1L));
cf.addColumn(sc);

View File

@ -37,16 +37,16 @@ public class TimeSortTest extends CleanupHelper
@Test
public void testMixedSources() throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfStore = table.getColumnFamilyStore("StandardLong1");
RowMutation rm;
rm = new RowMutation("Table1", "key0");
rm = new RowMutation("Keyspace1", "key0");
rm.add(new QueryPath("StandardLong1", null, getBytes(100)), "a".getBytes(), 100);
rm.apply();
cfStore.forceBlockingFlush();
rm = new RowMutation("Table1", "key0");
rm = new RowMutation("Keyspace1", "key0");
rm.add(new QueryPath("StandardLong1", null, getBytes(0)), "b".getBytes(), 0);
rm.apply();
@ -58,12 +58,12 @@ public class TimeSortTest extends CleanupHelper
@Test
public void testTimeSort() throws IOException, ExecutionException, InterruptedException
{
Table table = Table.open("Table1");
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfStore = table.getColumnFamilyStore("StandardLong1");
for (int i = 900; i < 1000; ++i)
{
RowMutation rm = new RowMutation("Table1", Integer.toString(i));
RowMutation rm = new RowMutation("Keyspace1", Integer.toString(i));
for (int j = 0; j < 8; ++j)
{
rm.add(new QueryPath("StandardLong1", null, getBytes(j * 2)), "a".getBytes(), j * 2);
@ -78,14 +78,14 @@ public class TimeSortTest extends CleanupHelper
// interleave some new data to test memtable + sstable
String key = "900";
RowMutation rm = new RowMutation("Table1", key);
RowMutation rm = new RowMutation("Keyspace1", key);
for (int j = 0; j < 4; ++j)
{
rm.add(new QueryPath("StandardLong1", null, getBytes(j * 2 + 1)), "b".getBytes(), j * 2 + 1);
}
rm.apply();
// and some overwrites
rm = new RowMutation("Table1", key);
rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath("StandardLong1", null, getBytes(0)), "c".getBytes(), 100);
rm.add(new QueryPath("StandardLong1", null, getBytes(10)), "c".getBytes(), 100);
rm.apply();

View File

@ -40,17 +40,17 @@ public class CassandraServerTest extends CleanupHelper
cfmap.put("Standard1", columns);
cfmap.put("Standard2", columns);
BatchMutation m = new BatchMutation("Table1", "key1", cfmap);
BatchMutation m = new BatchMutation("Keyspace1", "key1", cfmap);
server.batch_insert(m, 1);
Column column;
column = server.get_column("Table1", "key1", "Standard1:c2");
column = server.get_column("Keyspace1", "key1", "Standard1:c2");
assert column.value.equals("0");
column = server.get_column("Table1", "key1", "Standard2:c2");
column = server.get_column("Keyspace1", "key1", "Standard2:c2");
assert column.value.equals("0");
ArrayList<Column> Columns = server.get_slice_strong("Table1", "key1", "Standard1", -1, -1);
ArrayList<Column> Columns = server.get_slice_strong("Keyspace1", "key1", "Standard1", -1, -1);
assert Columns.size() == 2;
} finally {
server.shutdown();