Databases Reference
In-Depth Information
You may recall I reentered data for the post2 title, so you could query for both versions like so:
hbase(main):027:0> get 'blogposts', 'post2', { COLUMN=>'post:title', VERSIONS=>2 }
COLUMN CELL
post:title timestamp=1302059851203,
value=yet another blog post
post:title timestamp=1302059819904,
value=yet an interesting blog post
2 row(s) in 0.0440 seconds
Available for
download on
Wrox.com
blogposts.txt
By default, HBase returns only the latest version but you can always ask for multiple versions or get
an explicit older version if you like.
With these simple queries working, let's move on to the last example data store, Apache Cassandra.
Storing Data In and Accessing Data from Apache Cassandra
In this section, I reuse the blogposts example from the previous section to show some of the
fundamental features of Apache Cassandra. In the preceding chapter, you had a fi rst feel of Apache
Cassandra; now you will build on that and get familiar with more of its features.
To get started, go to the Apache Cassandra installation folder and start the server in the foreground
by running the following command:
bin/cassandra -f
When the server starts up, run the cassandra-cli or command-line client like so:
bin/cassandra-cli -host localhost -port 9160
Now query for available keyspaces like so:
show keyspaces;
You will see the system and any additional keyspaces that you may have created. In the previous
chapter, you created a sample keyspace called CarDataStore . For this example, create a new
keyspace called BlogPosts with the help of the following script:
/*schema-blogposts.txt*/
Available for
download on
Wrox.com
create keyspace BlogPosts
with replication_factor = 1
and placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy';
use BlogPosts;
create column family post
with comparator = UTF8Type
Search WWH ::




Custom Search