Cassandra storage engine use example
You are viewing an old version of this article. View
the current version here.
cqlsh> CREATE KEYSPACE mariadbtest2 ... WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy' ... AND strategy_options:replication_factor='1'; cqlsh> USE mariadbtest2; cqlsh:mariadbtest2> create columnfamily cf1 ( pk varchar primary key, data1 varchar, data2 bigint); cqlsh:mariadbtest2> select * from cf1; cqlsh:mariadbtest2>
MariaDB [test]> create table t1 ( -> rowkey varchar(36) primary key, -> data1 varchar(60), data2 varchar(60) -> ) engine=cassandra thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1'; ERROR 1928 (HY000): Internal error: 'Failed to map column data2 to datatype org.apache.cassandra.db.marshal.LongType' MariaDB [test]> create table t1 ( -> rowkey varchar(36) primary key, -> data1 varchar(60), data2 bigint -> ) engine=cassandra thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1'; Query OK, 0 rows affected (0.04 sec) MariaDB [test]> insert into t1 values ('rowkey10', 'data1-value', 123456); Query OK, 1 row affected (0.01 sec) MariaDB [test]> insert into t1 values ('rowkey11', 'data1-value2', 34543); Query OK, 1 row affected (0.00 sec) MariaDB [test]> insert into t1 values ('rowkey12', 'data1-value3', 454); Query OK, 1 row affected (0.00 sec) MariaDB [test]> select * from t1 where rowkey='rowkey11'; +----------+--------------+-------+ | rowkey | data1 | data2 | +----------+--------------+-------+ | rowkey11 | data1-value2 | 34543 | +----------+--------------+-------+ 1 row in set (0.00 sec)
Now let's check from Cassandra:
cqlsh:mariadbtest2> select * from cf1; pk | data1 | data2 ----------+--------------+-------- rowkey12 | data1-value3 | 454 rowkey10 | data1-value | 123456 rowkey11 | data1-value2 | 34543
Or, in cassandra-cli:
[default@mariadbtest2] list cf1; Using default limit of 100 Using default column limit of 100 ------------------- RowKey: rowkey12 => (column=data1, value=data1-value3, timestamp=1345452471835) => (column=data2, value=454, timestamp=1345452471835) ------------------- RowKey: rowkey10 => (column=data1, value=data1-value, timestamp=1345452467728) => (column=data2, value=123456, timestamp=1345452467728) ------------------- RowKey: rowkey11 => (column=data1, value=data1-value2, timestamp=1345452471831) => (column=data2, value=34543, timestamp=1345452471831) 3 Rows Returned. Elapsed time: 5 msec(s).
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.