issue with querying SuperColumn

2011-06-21 Thread Vivek Mishra


I am facing one issue with querying superColumn using clien.get() API. Although 
it is working when I try it for a ColumnFamily(rather than SuperColumnFamily).

It is working for:
ColumnFamily: users
  Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type
  Default column value validator: org.apache.cassandra.db.marshal.BytesType
  Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
  Row cache size / save period in seconds: 0.0/0
  Key cache size / save period in seconds: 20.0/14400
  Memtable thresholds: 0.2953125/63/1440 (millions of ops/MB/minutes)
 GC grace seconds: 864000
  Compaction min/max thresholds: 4/32
  Read repair chance: 1.0
  Replicate on write: false
  Built indexes: []

Issuing list of users(using Cassandra-cli):

[default@key1] list users;
Using default limit of 100
---
RowKey: 1
= (column=name, value=74657374, timestamp=1308637325517000)


Java code:
String key=1;
ColumnPath columnPath = new ColumnPath(users);
columnPath.setColumn(name.getBytes());
ColumnOrSuperColumn colName = 
cassndraClient.get(java.nio.ByteBuffer.wrap(key.getBytes()), columnPath , 
ConsistencyLevel.ONE);
Column col = colName.getColumn();
System.out.println(new String(col.getValue(), UTF-8));


RESULT: I am getting test printed.

BUT when I tried it for Super column family SuperCli :

ColumnFamily: SuperCli (Super)
  Key Validation Class: org.apache.cassandra.db.marshal.BytesType
  Default column value validator: org.apache.cassandra.db.marshal.BytesType
  Columns sorted by: 
org.apache.cassandra.db.marshal.UTF8Type/org.apache.cassandra.db.marshal.UTF8Type
  Row cache size / save period in seconds: 0.0/0
  Key cache size / save period in seconds: 20.0/14400
  Memtable thresholds: 0.2953125/63/1440 (millions of ops/MB/minutes)
  GC grace seconds: 864000
  Compaction min/max thresholds: 4/32
  Read repair chance: 1.0
  Replicate on write: false
  Built indexes: []

[default@key1] list SuperCli;
Using default limit of 100
---
RowKey: 31
= (super_column=address,
 (column=city, value=6e6f696461, timestamp=1308296234977000))
= (super_column=address1,
 (column=city, value=476e6f696461, timestamp=1308296283221000))
= (super_column=address2,
 (column=city, value=476e6f696461, timestamp=1308296401951000))

1 Row Returned.


Java Code:

ColumnPath columnPath = new ColumnPath(SuperCli);
columnPath.setSuper_column(address.getBytes());
String key=31;
cassndraClient.get(java.nio.ByteBuffer.wrap(key.getBytes()), 
columnPath , ConsistencyLevel.ONE);


I am getting exception:

NotFoundException()
 at 
org.apache.cassandra.thrift.Cassandra$get_result.read(Cassandra.java:6418)
 at 
org.apache.cassandra.thrift.Cassandra$Client.recv_get(Cassandra.java:519)
 at org.apache.cassandra.thrift.Cassandra$Client.get(Cassandra.java:492)
 at CasQuery.main(CasQuery.java:112)




Any idea about this issue?


--Vivek



Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend a 
live session by Head of Impetus Labs on 'Secrets of Building a Cloud Vendor 
Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud '.

Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus 
webinar on May 27 by registering at http://www.impetus.com/webinar?eventid=42 .


NOTE: This message may contain information that is confidential, proprietary, 
privileged or otherwise protected by law. The message is intended solely for 
the named addressee. If received in error, please destroy and notify the 
sender. Any use of this email is prohibited when received in error. Impetus 
does not represent, warrant and/or guarantee, that the integrity of this 
communication has been maintained nor that the communication is free of errors, 
virus, interception or interference.


Re: issue with querying SuperColumn

2011-06-21 Thread Richard Low
You have key validation class UTF8Type for the standard CF, but
BytesType for the super.  This is why the key is 1 for standard, but
printed as 31 for super, which is the hex ascii code for 1.  In your
java code, use 1.getBytes() as your key and it should work.

Richard.

-- 
Richard Low
Acunu | http://www.acunu.com | @acunu

On Tue, Jun 21, 2011 at 7:36 AM, Vivek Mishra
vivek.mis...@impetus.co.in wrote:




 I am facing one issue with querying superColumn using clien.get() API.
 Although it is working when I try it for a ColumnFamily(rather than
 SuperColumnFamily).



 It is working for:

     ColumnFamily: users

   Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type

   Default column value validator:
 org.apache.cassandra.db.marshal.BytesType

   Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type

   Row cache size / save period in seconds: 0.0/0

   Key cache size / save period in seconds: 20.0/14400

   Memtable thresholds: 0.2953125/63/1440 (millions of ops/MB/minutes)

  GC grace seconds: 864000

   Compaction min/max thresholds: 4/32

   Read repair chance: 1.0

   Replicate on write: false

   Built indexes: []



 Issuing list of users(using Cassandra-cli):



 [default@key1] list users;

 Using default limit of 100

 ---

 RowKey: 1

 = (column=name, value=74657374, timestamp=1308637325517000)





 Java code:

 String key=1;

     ColumnPath columnPath = new ColumnPath(users);

     columnPath.setColumn(name.getBytes());

     ColumnOrSuperColumn colName =
 cassndraClient.get(java.nio.ByteBuffer.wrap(key.getBytes()), columnPath ,
 ConsistencyLevel.ONE);

     Column col = colName.getColumn();

     System.out.println(new String(col.getValue(), UTF-8));





 RESULT: I am getting “test” printed.



 BUT when I tried it for Super column family “SuperCli” :



     ColumnFamily: SuperCli (Super)

   Key Validation Class: org.apache.cassandra.db.marshal.BytesType

   Default column value validator:
 org.apache.cassandra.db.marshal.BytesType

   Columns sorted by:
 org.apache.cassandra.db.marshal.UTF8Type/org.apache.cassandra.db.marshal.UTF8Type

   Row cache size / save period in seconds: 0.0/0

   Key cache size / save period in seconds: 20.0/14400

   Memtable thresholds: 0.2953125/63/1440 (millions of ops/MB/minutes)

   GC grace seconds: 864000

   Compaction min/max thresholds: 4/32

   Read repair chance: 1.0

   Replicate on write: false

   Built indexes: []



 [default@key1] list SuperCli;

 Using default limit of 100

 ---

 RowKey: 31

 = (super_column=address,

  (column=city, value=6e6f696461, timestamp=1308296234977000))

 = (super_column=address1,

  (column=city, value=476e6f696461, timestamp=1308296283221000))

 = (super_column=address2,

  (column=city, value=476e6f696461, timestamp=1308296401951000))



 1 Row Returned.





 Java Code:



 ColumnPath columnPath = new ColumnPath(SuperCli);

     columnPath.setSuper_column(address.getBytes());

     String key=31;

     cassndraClient.get(java.nio.ByteBuffer.wrap(key.getBytes()),
 columnPath , ConsistencyLevel.ONE);





 I am getting exception:



 NotFoundException()

  at
 org.apache.cassandra.thrift.Cassandra$get_result.read(Cassandra.java:6418)

  at
 org.apache.cassandra.thrift.Cassandra$Client.recv_get(Cassandra.java:519)

  at org.apache.cassandra.thrift.Cassandra$Client.get(Cassandra.java:492)

  at CasQuery.main(CasQuery.java:112)









 Any idea about this issue?





 --Vivek

 
 Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend
 a live session by Head of Impetus Labs on ‘Secrets of Building a Cloud
 Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud
 ‘.

 Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus
 webinar on May 27 by registering at
 http://www.impetus.com/webinar?eventid=42 .


 NOTE: This message may contain information that is confidential,
 proprietary, privileged or otherwise protected by law. The message is
 intended solely for the named addressee. If received in error, please
 destroy and notify the sender. Any use of this email is prohibited when
 received in error. Impetus does not represent, warrant and/or guarantee,
 that the integrity of this communication has been maintained nor that the
 communication is free of errors, virus, interception or interference.



RE: issue with querying SuperColumn

2011-06-21 Thread Vivek Mishra
Thanks Richard.
You are right. I missed that in key validation class.

-Original Message-
From: Richard Low [mailto:r...@acunu.com]
Sent: Tuesday, June 21, 2011 12:44 PM
To: user@cassandra.apache.org
Subject: Re: issue with querying SuperColumn

You have key validation class UTF8Type for the standard CF, but BytesType for 
the super.  This is why the key is 1 for standard, but printed as 31 for 
super, which is the hex ascii code for 1.  In your java code, use 
1.getBytes() as your key and it should work.

Richard.

--
Richard Low
Acunu | http://www.acunu.com | @acunu

On Tue, Jun 21, 2011 at 7:36 AM, Vivek Mishra vivek.mis...@impetus.co.in 
wrote:




 I am facing one issue with querying superColumn using clien.get() API.
 Although it is working when I try it for a ColumnFamily(rather than
 SuperColumnFamily).



 It is working for:

 ColumnFamily: users

   Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type

   Default column value validator:
 org.apache.cassandra.db.marshal.BytesType

   Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type

   Row cache size / save period in seconds: 0.0/0

   Key cache size / save period in seconds: 20.0/14400

   Memtable thresholds: 0.2953125/63/1440 (millions of
 ops/MB/minutes)

  GC grace seconds: 864000

   Compaction min/max thresholds: 4/32

   Read repair chance: 1.0

   Replicate on write: false

   Built indexes: []



 Issuing list of users(using Cassandra-cli):



 [default@key1] list users;

 Using default limit of 100

 ---

 RowKey: 1

 = (column=name, value=74657374, timestamp=1308637325517000)





 Java code:

 String key=1;

 ColumnPath columnPath = new ColumnPath(users);

 columnPath.setColumn(name.getBytes());

 ColumnOrSuperColumn colName =
 cassndraClient.get(java.nio.ByteBuffer.wrap(key.getBytes()),
 columnPath , ConsistencyLevel.ONE);

 Column col = colName.getColumn();

 System.out.println(new String(col.getValue(), UTF-8));





 RESULT: I am getting “test” printed.



 BUT when I tried it for Super column family “SuperCli” :



 ColumnFamily: SuperCli (Super)

   Key Validation Class: org.apache.cassandra.db.marshal.BytesType

   Default column value validator:
 org.apache.cassandra.db.marshal.BytesType

   Columns sorted by:
 org.apache.cassandra.db.marshal.UTF8Type/org.apache.cassandra.db.marsh
 al.UTF8Type

   Row cache size / save period in seconds: 0.0/0

   Key cache size / save period in seconds: 20.0/14400

   Memtable thresholds: 0.2953125/63/1440 (millions of
 ops/MB/minutes)

   GC grace seconds: 864000

   Compaction min/max thresholds: 4/32

   Read repair chance: 1.0

   Replicate on write: false

   Built indexes: []



 [default@key1] list SuperCli;

 Using default limit of 100

 ---

 RowKey: 31

 = (super_column=address,

  (column=city, value=6e6f696461, timestamp=1308296234977000))

 = (super_column=address1,

  (column=city, value=476e6f696461, timestamp=1308296283221000))

 = (super_column=address2,

  (column=city, value=476e6f696461, timestamp=1308296401951000))



 1 Row Returned.





 Java Code:



 ColumnPath columnPath = new ColumnPath(SuperCli);

 columnPath.setSuper_column(address.getBytes());

 String key=31;


 cassndraClient.get(java.nio.ByteBuffer.wrap(key.getBytes()),
 columnPath , ConsistencyLevel.ONE);





 I am getting exception:



 NotFoundException()

  at
 org.apache.cassandra.thrift.Cassandra$get_result.read(Cassandra.java:6
 418)

  at
 org.apache.cassandra.thrift.Cassandra$Client.recv_get(Cassandra.java:5
 19)

  at
 org.apache.cassandra.thrift.Cassandra$Client.get(Cassandra.java:492)

  at CasQuery.main(CasQuery.java:112)









 Any idea about this issue?





 --Vivek

 
 Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to
 attend a live session by Head of Impetus Labs on ‘Secrets of Building
 a Cloud Vendor Agnostic PetaByte Scale Real-time Secure Web
 Application on the Cloud ‘.

 Looking to leverage the Cloud for your Big Data Strategy ? Attend
 Impetus webinar on May 27 by registering at
 http://www.impetus.com/webinar?eventid=42 .


 NOTE: This message may contain information that is confidential,
 proprietary, privileged or otherwise protected by law. The message is
 intended solely for the named addressee. If received in error, please
 destroy and notify the sender. Any use of this email is prohibited
 when received in error. Impetus does not represent, warrant and/or
 guarantee, that the integrity of this communication has been
 maintained nor that the communication is free of errors, virus, interception 
 or interference.




Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend a 
live session by Head

RE: Querying superColumn

2011-06-17 Thread Vivek Mishra
Correct. But that will not solve issue of data colocation(data locality) ?

From: Sasha Dolgy [mailto:sdo...@gmail.com]
Sent: Thursday, June 16, 2011 8:47 PM
To: user@cassandra.apache.org
Subject: Re: Querying superColumn


Have 1 row with employee info for country/office/division, each column an 
employee id and json info about the employee or a reference.to.another row id 
for that employee data

No more supercolumn.
On Jun 16, 2011 1:56 PM, Vivek Mishra 
vivek.mis...@impetus.co.inmailto:vivek.mis...@impetus.co.in wrote:
 I have a question about querying super column

 For example:

 I have a supercolumnFamily DEPARTMENT with dynamic superColumn 'EMPLOYEE'( 
 name, country).

 Now for rowKey 'DEPT1' I have inserted multiple super column like:

 Employee1{
 Name: Vivek
 country: India
 }

 Employee2{
 Name: Vivs
 country: USA
 }



 Now if I want to retrieve a super column whose rowkey is 'DEPT1' and employee 
 name is 'Vivek'. Can I get only 'EMPLOYEE1' ?



 -Vivek

 

 Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend a 
 live session by Head of Impetus Labs on 'Secrets of Building a Cloud Vendor 
 Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud '.

 Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus 
 webinar on May 27 by registering at http://www.impetus.com/webinar?eventid=42 
 .


 NOTE: This message may contain information that is confidential, proprietary, 
 privileged or otherwise protected by law. The message is intended solely for 
 the named addressee. If received in error, please destroy and notify the 
 sender. Any use of this email is prohibited when received in error. Impetus 
 does not represent, warrant and/or guarantee, that the integrity of this 
 communication has been maintained nor that the communication is free of 
 errors, virus, interception or interference.



Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend a 
live session by Head of Impetus Labs on 'Secrets of Building a Cloud Vendor 
Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud '.

Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus 
webinar on May 27 by registering at http://www.impetus.com/webinar?eventid=42 .


NOTE: This message may contain information that is confidential, proprietary, 
privileged or otherwise protected by law. The message is intended solely for 
the named addressee. If received in error, please destroy and notify the 
sender. Any use of this email is prohibited when received in error. Impetus 
does not represent, warrant and/or guarantee, that the integrity of this 
communication has been maintained nor that the communication is free of errors, 
virus, interception or interference.


Re: Querying superColumn

2011-06-17 Thread Sasha Dolgy
Write two records ...

1.  [department1] = { Vivek : India }
2.  [India] = { Vivek : department1 }

1.  [department1] = { Vivs : USA }
2.  [USA] = { Vivs : department1 }

Now you can query a single row to display all employees in USA or all
employees in department1 ... employee moves to a new department in a
new country, simply remove the column from that department row and
country row and re-insert into the new rows...

My understanding with Cassandra and similar technologies is that you
are designing to be smart and avoid data duplication.  You are
designing to address the searches and queries based on your business
requirements ... when you know what those are, you cheat and
pre-populate the data you will be searching on ...

On Fri, Jun 17, 2011 at 1:16 PM, Vivek Mishra
vivek.mis...@impetus.co.in wrote:
 Correct. But that will not solve issue of data colocation(data locality) ?



 From: Sasha Dolgy [mailto:sdo...@gmail.com]
 Sent: Thursday, June 16, 2011 8:47 PM
 To: user@cassandra.apache.org
 Subject: Re: Querying superColumn



 Have 1 row with employee info for country/office/division, each column an
 employee id and json info about the employee or a reference.to.another row
 id for that employee data

 No more supercolumn.

 On Jun 16, 2011 1:56 PM, Vivek Mishra vivek.mis...@impetus.co.in wrote:
 I have a question about querying super column

 For example:

 I have a supercolumnFamily DEPARTMENT with dynamic superColumn 'EMPLOYEE'(
 name, country).

 Now for rowKey 'DEPT1' I have inserted multiple super column like:

 Employee1{
 Name: Vivek
 country: India
 }

 Employee2{
 Name: Vivs
 country: USA
 }



 Now if I want to retrieve a super column whose rowkey is 'DEPT1' and
 employee name is 'Vivek'. Can I get only 'EMPLOYEE1' ?



 -Vivek

 

 Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to
 attend a live session by Head of Impetus Labs on 'Secrets of Building a
 Cloud Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the
 Cloud '.

 Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus
 webinar on May 27 by registering at
 http://www.impetus.com/webinar?eventid=42 .


 NOTE: This message may contain information that is confidential,
 proprietary, privileged or otherwise protected by law. The message is
 intended solely for the named addressee. If received in error, please
 destroy and notify the sender. Any use of this email is prohibited when
 received in error. Impetus does not represent, warrant and/or guarantee,
 that the integrity of this communication has been maintained nor that the
 communication is free of errors, virus, interception or interference.

 
 Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend
 a live session by Head of Impetus Labs on ‘Secrets of Building a Cloud
 Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud
 ‘.

 Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus
 webinar on May 27 by registering at
 http://www.impetus.com/webinar?eventid=42 .


 NOTE: This message may contain information that is confidential,
 proprietary, privileged or otherwise protected by law. The message is
 intended solely for the named addressee. If received in error, please
 destroy and notify the sender. Any use of this email is prohibited when
 received in error. Impetus does not represent, warrant and/or guarantee,
 that the integrity of this communication has been maintained nor that the
 communication is free of errors, virus, interception or interference.




-- 
Sasha Dolgy
sasha.do...@gmail.com


Querying superColumn

2011-06-16 Thread Vivek Mishra
I have a question about querying super column

For example:

I have a supercolumnFamily  DEPARTMENT with dynamic superColumn 'EMPLOYEE'( 
name, country).

Now for rowKey 'DEPT1' I have inserted multiple super column like:

Employee1{
Name: Vivek
country:  India
}

Employee2{
Name: Vivs
country:  USA
}



Now if I want to retrieve a super column whose rowkey is 'DEPT1' and  employee 
name is 'Vivek'. Can I get only 'EMPLOYEE1' ?



-Vivek



Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend a 
live session by Head of Impetus Labs on 'Secrets of Building a Cloud Vendor 
Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud '.

Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus 
webinar on May 27 by registering at http://www.impetus.com/webinar?eventid=42 .


NOTE: This message may contain information that is confidential, proprietary, 
privileged or otherwise protected by law. The message is intended solely for 
the named addressee. If received in error, please destroy and notify the 
sender. Any use of this email is prohibited when received in error. Impetus 
does not represent, warrant and/or guarantee, that the integrity of this 
communication has been maintained nor that the communication is free of errors, 
virus, interception or interference.


Re: Querying superColumn

2011-06-16 Thread Donal Zang

Well, you are looking for the secondary index.
But for now,AFAIK, the supercolumn can not use secondary index .
On 16/06/2011 13:55, Vivek Mishra wrote:


Now for rowKey 'DEPT1' I have inserted multiple super column like:

*Employee1{*

*Name: Vivek*

*country:  India*

*}*

**

*Employee2{*

*Name: Vivs*

*country:  USA*

*}*

Now if I want to retrieve a super column whose rowkey is 'DEPT1' and  
employee name is 'Vivek'. Can I get only 'EMPLOYEE1' ?





--
Donal Zang
Computing Center, IHEP
19B YuquanLu, Shijingshan District,Beijing, 100049
zan...@ihep.ac.cn
86 010 8823 6018



Re: Querying superColumn

2011-06-16 Thread Sasha Dolgy
Have 1 row with employee info for country/office/division, each column an
employee id and json info about the employee or a reference.to.another row
id for that employee data

No more supercolumn.
On Jun 16, 2011 1:56 PM, Vivek Mishra vivek.mis...@impetus.co.in wrote:
 I have a question about querying super column

 For example:

 I have a supercolumnFamily DEPARTMENT with dynamic superColumn 'EMPLOYEE'(
name, country).

 Now for rowKey 'DEPT1' I have inserted multiple super column like:

 Employee1{
 Name: Vivek
 country: India
 }

 Employee2{
 Name: Vivs
 country: USA
 }



 Now if I want to retrieve a super column whose rowkey is 'DEPT1' and
employee name is 'Vivek'. Can I get only 'EMPLOYEE1' ?



 -Vivek

 

 Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to
attend a live session by Head of Impetus Labs on 'Secrets of Building a
Cloud Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the
Cloud '.

 Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus
webinar on May 27 by registering at
http://www.impetus.com/webinar?eventid=42 .


 NOTE: This message may contain information that is confidential,
proprietary, privileged or otherwise protected by law. The message is
intended solely for the named addressee. If received in error, please
destroy and notify the sender. Any use of this email is prohibited when
received in error. Impetus does not represent, warrant and/or guarantee,
that the integrity of this communication has been maintained nor that the
communication is free of errors, virus, interception or interference.