Return-Path: Delivered-To: apmail-incubator-cassandra-user-archive@minotaur.apache.org Received: (qmail 91156 invoked from network); 18 Jun 2009 17:15:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jun 2009 17:15:23 -0000 Received: (qmail 95989 invoked by uid 500); 18 Jun 2009 17:15:35 -0000 Delivered-To: apmail-incubator-cassandra-user-archive@incubator.apache.org Received: (qmail 95971 invoked by uid 500); 18 Jun 2009 17:15:35 -0000 Mailing-List: contact cassandra-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cassandra-user@incubator.apache.org Delivered-To: mailing list cassandra-user@incubator.apache.org Received: (qmail 95948 invoked by uid 99); 18 Jun 2009 17:15:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jun 2009 17:15:28 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jbellis@gmail.com designates 72.14.220.155 as permitted sender) Received: from [72.14.220.155] (HELO fg-out-1718.google.com) (72.14.220.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jun 2009 17:15:19 +0000 Received: by fg-out-1718.google.com with SMTP id l27so1577910fgb.3 for ; Thu, 18 Jun 2009 10:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=lXWYQelfEac+O2PJdehr317N7k0T3OWcaEjkoUeNqzs=; b=naWi6ELDJxSxo1UxWkLgHWJYf1CkaiZuwOK7cUPLYt0i2kZk/90J+Yotf5iXnQgBPQ KckVobDxDAkPKl+fOdc43ICc7BWwC+6CmlqM6yUWjT+PPBGQJ4tY1Zp/Zsf8K00lucja ULG++gPjn/i+BwsIo/zAhLoptf+AYAs97YyHI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=A1KbmOX9iXoysH6pT1jaezr8luyWGM5uITNUhQUOCvDiysVzdhG0I8gE7AfdGw8xX1 TqDUeUSl2UlaFZ0Gl7f0gPV+it/3u66FF0n6sXS6p2Twks5PGm+UsdJDGAQVlAOqTHXm kyqxDbI6iL+y6YRgMxArIOpSZ+rNf3z2xykMs= MIME-Version: 1.0 Received: by 10.216.36.84 with SMTP id v62mr498645wea.128.1245345298695; Thu, 18 Jun 2009 10:14:58 -0700 (PDT) In-Reply-To: <70cd74010906181012t3fb17138r1db8b097db546aa1@mail.gmail.com> References: <70cd74010906171354x237d1444j6e94d03bc50b2d3c@mail.gmail.com> <70cd74010906181012t3fb17138r1db8b097db546aa1@mail.gmail.com> Date: Thu, 18 Jun 2009 12:14:58 -0500 Message-ID: Subject: Re: Data persistency From: Jonathan Ellis To: cassandra-user@incubator.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org You don't. Supercolumns are not arbitrarily nestable. A columnfamily is either super or normal; a super columnfamily contains supercolumns, which in turn contain Columns. A normal columnfamily contains Columns directly. You can't mix-and-match supercolumns and normal columns (at the same level of nesting) in a single columnfamily. -Jonathan On Thu, Jun 18, 2009 at 12:12 PM, Ivan Chang wrote: > Using Cassandra.Client works.=A0 However more questions arise, specifical= ly > regarding Super Columns, while the following code persist the super colum= n > "sc1"with 3 simple columns.=A0 How do I create nested super columns?=A0 A= super > column with multiple super columns and standard columns?=A0 Thanks, Ivan > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // Super Column > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 batch_mutation_super_t bt =3D new batch= _mutation_super_t(); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 bt.key =3D "testkey"; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 bt.table =3D tablename_; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 bt.cfmap =3D new HashMap>(); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 List superColumn_arr =3D= new > ArrayList(); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 List column_arr2 =3D new Arra= yList(); > =A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0 column_arr2.add(new column_t("c1", "v1".g= etBytes(), now)); > =A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0 column_arr2.add(new column_t("c2", "v2".g= etBytes(), now)); > =A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0 column_arr2.add(new column_t("c3", "v3".g= etBytes(), now)); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 superColumn_arr.add(new superColumn_t("= sc1", column_arr2)); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 bt.cfmap.put("Super1", superColumn_arr)= ; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 peerstorageClient.batch_insert_superCol= umn(bt, false); > > On Wed, Jun 17, 2009 at 5:01 PM, Jonathan Ellis wrote= : >> >> You're using internal APIs. =A0Don't do that unless you know what you're >> doing. :) >> >> The client API is in Cassandra.Client. >> >> We have some sample code here: >> http://wiki.apache.org/cassandra/ClientExamples >> >> (although none in Java yet, it should still be pretty clear.) >> >> -Jonathan >> >> On Wed, Jun 17, 2009 at 3:54 PM, Ivan Chang wrote= : >> > I tried to insert and retrieve data from a standalone Java program. >> > While I >> > am able to insert and retrieve the correct data from within the Java >> > session.=A0 After I terminate the session, and rerun only the data >> > retrieval >> > part, the previous inserted data does not exist anymore, throwing a nu= ll >> > exception.=A0 Here's the code: >> > >> > =A0=A0=A0=A0=A0=A0=A0 // Get storage-config file location >> > >> > >> > System.out.println("storage-config=3D"+DatabaseDescriptor.getConfigFil= eName()); >> > >> > =A0=A0=A0=A0=A0=A0=A0 // Insert some data with key "partner1" >> > =A0=A0=A0=A0=A0=A0=A0 RowMutation rm =3D new RowMutation("Table1", "pa= rtner1"); >> > =A0=A0=A0 =A0=A0=A0 ColumnFamily cf =3D new ColumnFamily("Standard1", = "Standard"); >> > =A0=A0=A0 =A0=A0=A0 long now =3D Calendar.getInstance().getTimeInMilli= s(); >> > =A0=A0=A0 =A0=A0=A0 System.out.println(now); >> > =A0=A0=A0 =A0=A0=A0 cf.addColumn("firstname", "John1".getBytes(), now)= ; >> > =A0=A0=A0 =A0=A0=A0 cf.addColumn("lastname", "Doe1".getBytes(), now); >> > =A0=A0=A0 =A0=A0=A0 rm.add(cf); >> > =A0=A0=A0 =A0=A0=A0 try { >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 rm.apply(); >> > =A0=A0=A0 =A0=A0=A0 } catch (Exception e) { >> > =A0=A0=A0 =A0=A0=A0 } >> > >> > =A0=A0=A0=A0=A0=A0=A0 // Retrieve data for key "partner1" >> > =A0=A0=A0 =A0=A0=A0 Table table =3D Table.open("Table1"); >> > >> > =A0=A0=A0 =A0=A0=A0 try { >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 Row result =3D table.getRow("partner1", = "Standard1"); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 System.out.println(result.toString()); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 ColumnFamily cres =3D result.getColumnFa= mily("Standard1"); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 Map cols =3D cres.getColumns(); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 System.out.println(cols.size()); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 Set c =3D cols.keySet(); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 Iterator it =3D c.iterator(); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 while (it.hasNext()) { >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 String cn =3D (String) it.next= (); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 System.out.println(cn); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 System.out.println(new >> > String(cres.getColumn(cn).value())); >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 } >> > =A0=A0=A0 =A0=A0=A0 } catch (Exception e) { >> > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 System.out.println("Ex: " + e.getMessage= ()); >> > =A0=A0=A0 =A0=A0=A0 } >> > >> > the print out from above is >> > >> > storage-config=3D~/Cassandra/trunk/conf/storage-conf.xml >> > 1245270260114 >> > Row(partner1 [ColumnFamily(Standard1 [firstname:false:5@1245270260114, >> > lastname:false:4@1245270260114]))] >> > 2 >> > lastname >> > Doe1 >> > firstname >> > John1 >> > >> > However, when I commented out the insert part of the above code and tr= y >> > retrieve data again by rerunning the main code, I got an exception: >> > >> > Row(partner1 [)] >> > Ex: null >> > >> > So the data doesn't seem to persist across sessions. >> > >> > Could someone explain what's wrong with the code? >> > >> > Thanks, >> > Ivan >> > > >