incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MOHD ARSHAD SALEEM <marshadsal...@tataelxsi.co.in>
Subject RE: Query
Date Wed, 06 Jun 2012 10:08:52 GMT
Hi,
After creating the keyspace successfully now i want to know how to read write data using API,s

Regards
Arshad
________________________________
From: Filippo Diotalevi [filippo@ntoklo.com]
Sent: Wednesday, June 06, 2012 2:27 PM
To: user@cassandra.apache.org
Subject: Re: Query

Hi,
the Javadoc (or source code) of the me.prettyprint.hector.api.factory.HFactory class contains
all the examples to create keyspaces and column families.

To create a keyspace:

String testKeyspace = "testKeyspace";
KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition(testKeyspace);
cluster.addKeyspace(newKeyspace);


To create a column family and a keyspace:

String keyspace = "testKeyspace";
String column1 = "testcolumn";
ColumnFamilyDefinition columnFamily1 = HFactory.createColumnFamilyDefinition(keyspace, column1);
List<ColumnFamilyDefinition> columns = new ArrayList<ColumnFamilyDefinition>();
columns.add(columnFamily1);

KeyspaceDefinition testKeyspace =
HFactory.createKeyspaceDefinition(keyspace, org.apache.cassandra.locator.SimpleStrategy.class.getName(),
1, columns);
cluster.addKeyspace(testKeyspace);

--
Filippo Diotalevi



On Wednesday, 6 June 2012 at 07:05, MOHD ARSHAD SALEEM wrote:

Hi All,

I am using Hector client for cassandra . I wanted to know how to create keyspace and column
family using API's to read and write data.
or  i have to create keyspace and column family manually using command line interface.

Regards
Arshad


Mime
View raw message