Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2532EC3BA for ; Wed, 6 Jun 2012 08:58:21 +0000 (UTC) Received: (qmail 55764 invoked by uid 500); 6 Jun 2012 08:58:18 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 55745 invoked by uid 500); 6 Jun 2012 08:58:18 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 55728 invoked by uid 99); 6 Jun 2012 08:58:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2012 08:58:18 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of filippo@ntoklo.com designates 74.125.83.44 as permitted sender) Received: from [74.125.83.44] (HELO mail-ee0-f44.google.com) (74.125.83.44) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2012 08:58:08 +0000 Received: by eekd4 with SMTP id d4so2383283eek.31 for ; Wed, 06 Jun 2012 01:57:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:message-id:in-reply-to:references:subject:x-mailer :mime-version:content-type:x-gm-message-state; bh=KAoezH1g+vllBJDBIWfLHKtNgyNnW7WJ2ATRUSuaYP8=; b=G7/wdJRL/t2ik7GBbXrj86AmQA0KcgDretHP9+JyFXdLq1SwYYXuPqafMlOOJKnbVn EFN3vfcIaY7HuTgsg3VlxTGc4Fyz9ZBok2V257wWYhVZlPqTAUElx0awuQmkva4+YMb9 e33s2n0Ru3J0mL7D8T2LsaqN2CFY8reOGwnr3Ppb5PoBVT6F4GKE85s7fKYx2lACUJsR VOjb1LH7S3UbXLO7AeMt7LiZrmOoUq92aHAwiNKjF6Uu1Iw2CAtPspyx/t8+R3/kJ34n 3mF66EhX2i8p7Bt09ik5GNOtgoR+dgtumD77W5lbKG/GIL18fD+zKLY64rGQ0Lpd6myq frFw== Received: by 10.14.101.73 with SMTP id a49mr8304707eeg.34.1338973068357; Wed, 06 Jun 2012 01:57:48 -0700 (PDT) Received: from Filippos-MacBook.local ([80.71.29.65]) by mx.google.com with ESMTPS id z5sm3952620eem.3.2012.06.06.01.57.46 (version=SSLv3 cipher=OTHER); Wed, 06 Jun 2012 01:57:47 -0700 (PDT) Date: Wed, 6 Jun 2012 09:57:45 +0100 From: Filippo Diotalevi To: user@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: Re: Query X-Mailer: sparrow 1.5 (build 1043.1) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="4fcf1b89_ded7263_1af" X-Gm-Message-State: ALoCoQlZSvHwh8pSAZ1N26UviQS5UiSlCQYMnvgigCHBecRMFwCaX76MxeVJh50fBVmWkDMEoElx --4fcf1b89_ded7263_1af Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 columns = new ArrayList(); 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 --4fcf1b89_ded7263_1af Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hi, 
the Javadoc (or source code) of the me.pr= ettyprint.hector.api.factory.H=46actory class contains all the examples t= o create keyspaces and column families.

To creat= e a keyspace:

String testKeyspace =3D =22te= stKeyspace=22; 
KeyspaceDefinition newKeyspace =3D H=46= actory.createKeyspaceDefinition(testKeyspace);
cluster.addKeysp= ace(newKeyspace);


To create= a column family and a keyspace:

String key= space =3D =22testKeyspace=22; 
String column1 =3D =22testc= olumn=22;
Column=46amilyDefinition column=46amily1 =3D H=46= actory.createColumn=46amilyDefinition(keyspace, column1);
List&= lt;Column=46amilyDefinition> columns =3D new ArrayList<Column=46= amilyDefinition>(); 
columns.add(column=46amily1);

KeyspaceDefinition testKeyspace =3D
H=46ac= tory.createKeyspaceDefinition(keyspace, org.apache.cassandra.locator= .SimpleStrategy.class.getName(), 1, columns);
cluster.addKeyspa= ce(testKeyspace);

-- 
=46ilippo Dio= talevi


=20

On Wednesday, 6 June 2= 012 at 07:05, MOHD ARSHAD SALEEM wrote:

Hi All,

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

Regards
Arshad
=20 =20 =20 =20
=20

--4fcf1b89_ded7263_1af--