Database Reference
In-Depth Information
NetworkTopologyStrategy . This allows for the use of multiple
datacenters while the SimpleStrategy used in this example is confined
to a single datacenter. Even if a single physical datacenter is used, it is
common practice to define “datacenters” of clusters that maintain different
workloads. For example, one “datacenter” can be dedicated to accepting
real-time random access reads and writes, whereas another “datacenter” is
dedicated to scan-heavy map-reduce style processing. This is often done
with Hadoop because Cassandra can act as a replacement for Hadoop's
native HDFS storage layer.
Tocreateatable,switchtothe metrics keyspaceviathe USE commandand
then execute CREATE TABLE to store some time-series metrics:
cqlsh> USE metrics;
cqlsh:metrics> CREATE TABLE counts (
customer_id INT,
metric TEXT,
ts TIMESTAMP,
value COUNTER,
PRIMARY KEY (customer_id,metric,ts)
);
It is not necessary to select the keyspace; dot-notation can be used to access
the table directory. The table from the last example would be accessed as
metrics.counts .
This table contains a customer identifier, a metric name and a timestamp.
All three of them form the primary key because there can only be a single
count for the combination of customer, metric, and time. In Cassandra,
columns are serialized and deserialized to and from byte arrays
corresponding to their types. These types, which are similar to those found
in a relational database, are summarized in Table 6.2 .
 
Search WWH ::




Custom Search