You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Sunit Randhawa <su...@gmail.com> on 2012/07/05 21:26:55 UTC

Composite Slice Query returning non-sliced data

Hello,

I have 2 Columns for a 'RowKey' as below:

 #1 : set CF['RowKey']['1000']='A=1,B=2';
 #2: set CF['RowKey']['1000:C1']='A=2,B=3'';

#2 has the Composite Column and #1 does not.

Now when I execute the Composite Slice query by 1000 and C1, I do get
both the columns above.

I am hoping get #2 only since I am specifically providing "C1" as
Start and Finish Composite Range with
Composite.ComponentEquality.EQUAL.


I am not sure if this is by design.

Thanks,
Sunit.

RE: help using org.apache.cassandra.cql3

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
Thanks Sylvain, I actually tried the prepared batch, works fine. I did the 1000 rows in one batch, 20 columns each, and it was good. Then I tried 10000, and it still works, I am going to measure which way it is faster overall.

-----Original Message-----
From: Sylvain Lebresne [mailto:sylvain@datastax.com]
Sent: Wednesday, July 11, 2012 9:32 AM
To: user@cassandra.apache.org
Subject: Re: help using org.apache.cassandra.cql3

When I said to use the BATCH statement I mean't using a query that is
a BATCH statement, so something like:
  BEGIN BATCH
    INSERT ...;
    INSERT ...;
    ...
  APPLY BATCH;

If you want to that from java, you will want to look at the jdbc
driver (http://code.google.com/a/apache-extras.org/p/cassandra-jdbc/),
though I don't know what is the status of the support for CQL3.

On Wed, Jul 11, 2012 at 2:18 PM, Leonid Ilyevsky
<li...@mooncapital.com> wrote:
> Is it OK to put 10000 of update statements in one
> batch, with 50000 question marks in it? The set that many variables?

Yes batch statement can be prepared and in theory there isn't much
limit on the number of update statement (nor question marks) you can
put in one batch. However, the way C* work best is if you do
reasonably sized batches. It's even more true for CQL in the sense
that by using a huge batch statement you'll pay the parsing. So you
probably want to prepare one batch statement with a reasonable number
of statement in it (you'll have to test to find number that give the
best performances, but I would typically start with say 50-100 and see
if the performance are good enough) and reuse that to insert the data.

The other reason why breaking the insert into smallish batches is a
good idea is that it allows you to parallelize the insert using
multiple threads. And you need to parallelize if you want to get the
best out of C*.

--
Sylvain

>
> Maybe I can try small example first, just to see if it works at all.
>
>
>
>
>
> From: Derek Williams [mailto:derek@fyrie.net]
> Sent: Tuesday, July 10, 2012 7:19 PM
> To: user@cassandra.apache.org
> Subject: Re: help using org.apache.cassandra.cql3
>
>
>
> On Tue, Jul 10, 2012 at 3:04 PM, Leonid Ilyevsky <li...@mooncapital.com>
> wrote:
>
> I am trying to use the org.apache.cassandra.cql3 package. Having problem
> connecting to the server using ClientState.
>
> I was not sure what to put in the credentials map (I did not set any
> users/passwords on my server), so I tried setting empty strings for
> "username" and "password", setting them to bogus values, passing null to the
> login method - there was no difference.
>
> It does not complain at the login(), but then it complains about
> setKeyspace(<my keyspace>), saying that the specified keyspace does not
> exist (it obviously does exist).
>
> The configuration was loaded from cassandra.yaml used by the server.
>
>
>
> I did not have any problem like this when I used
> org.apache.cassandra.thrift.Cassandra.Client .
>
>
>
> What am I doing wrong?
>
>
>
> I think that package just contains server classes. Everything you need
> should be in org.apache.cassandra.thrift.
>
>
>
> To use cql3 I just use the client methods 'execute_cql_query',
> 'prepare_cql_query' and 'execute_prepared_cql_query', after setting cql
> version to '3.0.0'.
>
>
>
>
>
> --
>
> Derek Williams
>
>
>
>
> ________________________________
> This email, along with any attachments, is confidential and may be legally
> privileged or otherwise protected from disclosure. Any unauthorized
> dissemination, copying or use of the contents of this email is strictly
> prohibited and may be in violation of law. If you are not the intended
> recipient, any disclosure, copying, forwarding or distribution of this email
> is strictly prohibited and this email and any attachments should be deleted
> immediately. This email and any attachments do not constitute an offer to
> sell or a solicitation of an offer to purchase any interest in any
> investment vehicle sponsored by Moon Capital Management LP ("Moon Capital").
> Moon Capital does not provide legal, accounting or tax advice. Any statement
> regarding legal, accounting or tax matters was not intended or written to be
> relied upon by any person as advice. Moon Capital does not waive
> confidentiality or privilege as a result of this email.

This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately.  This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP ("Moon Capital"). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: help using org.apache.cassandra.cql3

Posted by Sylvain Lebresne <sy...@datastax.com>.
When I said to use the BATCH statement I mean't using a query that is
a BATCH statement, so something like:
  BEGIN BATCH
    INSERT ...;
    INSERT ...;
    ...
  APPLY BATCH;

If you want to that from java, you will want to look at the jdbc
driver (http://code.google.com/a/apache-extras.org/p/cassandra-jdbc/),
though I don't know what is the status of the support for CQL3.

On Wed, Jul 11, 2012 at 2:18 PM, Leonid Ilyevsky
<li...@mooncapital.com> wrote:
> Is it OK to put 10000 of update statements in one
> batch, with 50000 question marks in it? The set that many variables?

Yes batch statement can be prepared and in theory there isn't much
limit on the number of update statement (nor question marks) you can
put in one batch. However, the way C* work best is if you do
reasonably sized batches. It's even more true for CQL in the sense
that by using a huge batch statement you'll pay the parsing. So you
probably want to prepare one batch statement with a reasonable number
of statement in it (you'll have to test to find number that give the
best performances, but I would typically start with say 50-100 and see
if the performance are good enough) and reuse that to insert the data.

The other reason why breaking the insert into smallish batches is a
good idea is that it allows you to parallelize the insert using
multiple threads. And you need to parallelize if you want to get the
best out of C*.

--
Sylvain

>
> Maybe I can try small example first, just to see if it works at all.
>
>
>
>
>
> From: Derek Williams [mailto:derek@fyrie.net]
> Sent: Tuesday, July 10, 2012 7:19 PM
> To: user@cassandra.apache.org
> Subject: Re: help using org.apache.cassandra.cql3
>
>
>
> On Tue, Jul 10, 2012 at 3:04 PM, Leonid Ilyevsky <li...@mooncapital.com>
> wrote:
>
> I am trying to use the org.apache.cassandra.cql3 package. Having problem
> connecting to the server using ClientState.
>
> I was not sure what to put in the credentials map (I did not set any
> users/passwords on my server), so I tried setting empty strings for
> “username” and “password”, setting them to bogus values, passing null to the
> login method – there was no difference.
>
> It does not complain at the login(), but then it complains about
> setKeyspace(<my keyspace>), saying that the specified keyspace does not
> exist (it obviously does exist).
>
> The configuration was loaded from cassandra.yaml used by the server.
>
>
>
> I did not have any problem like this when I used
> org.apache.cassandra.thrift.Cassandra.Client .
>
>
>
> What am I doing wrong?
>
>
>
> I think that package just contains server classes. Everything you need
> should be in org.apache.cassandra.thrift.
>
>
>
> To use cql3 I just use the client methods 'execute_cql_query',
> 'prepare_cql_query' and 'execute_prepared_cql_query', after setting cql
> version to '3.0.0'.
>
>
>
>
>
> --
>
> Derek Williams
>
>
>
>
> ________________________________
> This email, along with any attachments, is confidential and may be legally
> privileged or otherwise protected from disclosure. Any unauthorized
> dissemination, copying or use of the contents of this email is strictly
> prohibited and may be in violation of law. If you are not the intended
> recipient, any disclosure, copying, forwarding or distribution of this email
> is strictly prohibited and this email and any attachments should be deleted
> immediately. This email and any attachments do not constitute an offer to
> sell or a solicitation of an offer to purchase any interest in any
> investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”).
> Moon Capital does not provide legal, accounting or tax advice. Any statement
> regarding legal, accounting or tax matters was not intended or written to be
> relied upon by any person as advice. Moon Capital does not waive
> confidentiality or privilege as a result of this email.

RE: help using org.apache.cassandra.cql3

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
I see.
The reason I looked at that package was, I need to use the batch feature, and I could not make it work using thrift with the CF having composite key. It worked fine with the simple key, but not composite, I was getting an error while trying to do the update.
Sylvain suggested (in reply to my other posting) that I use cql3 batch statement, but I am not sure how to do it efficiently from Java. Can batch statement be prepared? Is it OK to put 10000 of update statements in one batch, with 50000 question marks in it? The set that many variables?
Maybe I can try small example first, just to see if it works at all.


From: Derek Williams [mailto:derek@fyrie.net]
Sent: Tuesday, July 10, 2012 7:19 PM
To: user@cassandra.apache.org
Subject: Re: help using org.apache.cassandra.cql3

On Tue, Jul 10, 2012 at 3:04 PM, Leonid Ilyevsky <li...@mooncapital.com>> wrote:
I am trying to use the org.apache.cassandra.cql3 package. Having problem connecting to the server using ClientState.
I was not sure what to put in the credentials map (I did not set any users/passwords on my server), so I tried setting empty strings for “username” and “password”, setting them to bogus values, passing null to the login method – there was no difference.
It does not complain at the login(), but then it complains about setKeyspace(<my keyspace>), saying that the specified keyspace does not exist (it obviously does exist).
The configuration was loaded from cassandra.yaml used by the server.

I did not have any problem like this when I used org.apache.cassandra.thrift.Cassandra.Client .

What am I doing wrong?

I think that package just contains server classes. Everything you need should be in org.apache.cassandra.thrift.

To use cql3 I just use the client methods 'execute_cql_query', 'prepare_cql_query' and 'execute_prepared_cql_query', after setting cql version to '3.0.0'.


--
Derek Williams


________________________________
This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: help using org.apache.cassandra.cql3

Posted by Derek Williams <de...@fyrie.net>.
On Tue, Jul 10, 2012 at 3:04 PM, Leonid Ilyevsky
<li...@mooncapital.com>wrote:

>  I am trying to use the org.apache.cassandra.cql3 package. Having problem
> connecting to the server using ClientState.****
>
> I was not sure what to put in the credentials map (I did not set any
> users/passwords on my server), so I tried setting empty strings for
> “username” and “password”, setting them to bogus values, passing null to
> the login method – there was no difference.****
>
> It does not complain at the login(), but then it complains about
> setKeyspace(<my keyspace>), saying that the specified keyspace does not
> exist (it obviously does exist).****
>
> The configuration was loaded from cassandra.yaml used by the server.****
>
> ** **
>
> I did not have any problem like this when I used
> org.apache.cassandra.thrift.Cassandra.Client .****
>
> ** **
>
> What am I doing wrong?****
>
> **
>

I think that package just contains server classes. Everything you need
should be in org.apache.cassandra.thrift.

To use cql3 I just use the client methods 'execute_cql_query',
'prepare_cql_query' and 'execute_prepared_cql_query', after setting cql
version to '3.0.0'.


-- 
Derek Williams

help using org.apache.cassandra.cql3

Posted by Leonid Ilyevsky <li...@mooncapital.com>.
I am trying to use the org.apache.cassandra.cql3 package. Having problem connecting to the server using ClientState.
I was not sure what to put in the credentials map (I did not set any users/passwords on my server), so I tried setting empty strings for "username" and "password", setting them to bogus values, passing null to the login method - there was no difference.
It does not complain at the login(), but then it complains about setKeyspace(<my keyspace>), saying that the specified keyspace does not exist (it obviously does exist).
The configuration was loaded from cassandra.yaml used by the server.

I did not have any problem like this when I used org.apache.cassandra.thrift.Cassandra.Client .

What am I doing wrong?

Appreciate your help,

Leonid


________________________________
This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP ("Moon Capital"). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.

Re: Composite Slice Query returning non-sliced data

Posted by Tyler Hobbs <ty...@datastax.com>.
On Tue, Jul 10, 2012 at 2:20 PM, Sunit Randhawa <su...@gmail.com>wrote:

> I have tested this extensively and EOC has huge issue in terms of
> usability of CompositeTypes in Cassandra.
>
> As an example: If you have 2 Composite Columns such as A:B:C and A:D:C.
>
> And if you do search on A:B as start and end Composite Components, it
> will return D as well. Because it returns all the remaining columns
> from your start range.
>

That shouldn't be happening, and I can test that it works correctly using
pycassa.  So I suspect a problem with Hector.


>
> Similarly if you do search on A:D as start and end Composite
> Components, it will not return B because the D comes after B.
>

This is expected behavior.


>
> Sadly, the information given here on intro to composite Types:
> http://www.datastax.com/dev/blog/introduction-to-composite-columns-part-1
> also does not work.
>
> On Tue, Jul 10, 2012 at 9:24 AM, Tyler Hobbs <ty...@datastax.com> wrote:
> > I think in this case that's just Hector's way of setting the EOC byte
> for a
> > component.  My guess is that the composite isn't being structured
> correctly
> > through Hector, as well.
> >
> >
> > On Tue, Jul 10, 2012 at 4:40 AM, aaron morton <aa...@thelastpickle.com>
> > wrote:
> >>
> >>
> >> The first thing that stands out is that (in cassandra) comparison
> >> operations are not used in a slice range.
> >
> >
> >
> >
> > --
> > Tyler Hobbs
> > DataStax
> >
>



-- 
Tyler Hobbs
DataStax <http://datastax.com/>

Re: Composite Slice Query returning non-sliced data

Posted by Sunit Randhawa <su...@gmail.com>.
I have tested this extensively and EOC has huge issue in terms of
usability of CompositeTypes in Cassandra.

As an example: If you have 2 Composite Columns such as A:B:C and A:D:C.

And if you do search on A:B as start and end Composite Components, it
will return D as well. Because it returns all the remaining columns
from your start range.

Similarly if you do search on A:D as start and end Composite
Components, it will not return B because the D comes after B.

Sadly, the information given here on intro to composite Types:
http://www.datastax.com/dev/blog/introduction-to-composite-columns-part-1
also does not work.

On Tue, Jul 10, 2012 at 9:24 AM, Tyler Hobbs <ty...@datastax.com> wrote:
> I think in this case that's just Hector's way of setting the EOC byte for a
> component.  My guess is that the composite isn't being structured correctly
> through Hector, as well.
>
>
> On Tue, Jul 10, 2012 at 4:40 AM, aaron morton <aa...@thelastpickle.com>
> wrote:
>>
>>
>> The first thing that stands out is that (in cassandra) comparison
>> operations are not used in a slice range.
>
>
>
>
> --
> Tyler Hobbs
> DataStax
>

Re: Composite Slice Query returning non-sliced data

Posted by Tyler Hobbs <ty...@datastax.com>.
I think in this case that's just Hector's way of setting the EOC byte for a
component.  My guess is that the composite isn't being structured correctly
through Hector, as well.

On Tue, Jul 10, 2012 at 4:40 AM, aaron morton <aa...@thelastpickle.com>wrote:

>
> The first thing that stands out is that (in cassandra) comparison
> operations are not used in a slice range.




-- 
Tyler Hobbs
DataStax <http://datastax.com/>

Re: Composite Slice Query returning non-sliced data

Posted by aaron morton <aa...@thelastpickle.com>.
Ah, it's a Hector query question. 

You may have bette luck on the Hector email list. Or if you can turn on debug logging on the server and grab the query that would be handy. 

The first thing that stands out is that (in cassandra) comparison operations are not used in a slice range. 

Cheers
 
-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 10/07/2012, at 12:36 PM, Sunit Randhawa wrote:

> Aaron,
> 
> Let me start from the beginning.
> 
> 1- I have a ColumnFamily called Rollup15 with below definition:
> 
> create column family Rollup15
>          with comparator =
> 'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
>    and key_validation_class = UTF8Type
>    and default_validation_class = UTF8Type;
> 
> 
> 2- Once created, it is empty. Below is the output of CLI:
> 
> [default@Schema] list Rollup15;
> Using default limit of 100
> 
> 0 Row Returned.
> Elapsed time: 16 msec(s).
> 
> 3- I use the Code below to insert the Composite Data into Cassandra:
> 
> public void insertData(String columnFamilyName, String key,
> 			String value, int rollupInterval, String... columnSlice) {
> 		
> 		Composite colKey = new Composite();
> 		colKey.addComponent(rollupInterval, IntegerSerializer.get());
> 		if (columnSlice != null){
> 			for (String colName : columnSlice){
> 				colKey.addComponent(colName, serializer);
> 			}
> 		}
> 		createMutator(keyspace, serializer).addInsertion(key, columnFamilyName,
> 				createColumn(colKey, value, new CompositeSerializer(),
> serializer)).execute();
> 
> 	}
> 
> 4- After insertion, below is the CLI Output:
> 
> [default@Schema] list Rollup15;
> Using default limit of 100
> -------------------
> RowKey: query1_1337295600
> => (column=15:Composite1:Composite2, value=value123, timesta
> mp=1341879833470000)
> 
> 1 Row Returned.
> Elapsed time: 9 msec(s).
> 
> So, there is record with 3 Composite Keys (15, Composite1 and Composite2)
> 
> 
> 5- Now I am doing fetch based on Code Below. I am doing a fetch for
> column "15:Composite3" which I know it is not there:
> 
> Composite start = new Composite();
> 
>                start.addComponent(0, 15,
>                                Composite.ComponentEquality.EQUAL);
>               start.addComponent(1,
> "Composite3",Composite.ComponentEquality.EQUAL);
> 
> 
>                Composite finish = new Composite();
>                finish.addComponent(0, 15,
>                                Composite.ComponentEquality.EQUAL);
> 
>                finish.addComponent(1,"Composite3"+
> Character.MAX_VALUE, Composite.ComponentEquality.GREATER_THAN_EQUAL);
> 
>                SliceQuery<String, Composite, String> sq
>              =  HFactory.createSliceQuery(keyspace, StringSerializer.get(),
>                                           new CompositeSerializer(),
>                                           StringSerializer.get());
>                sq.setColumnFamily("Rollup15");
> 
>                sq.setKey("query1_1337295600");
>                sq.setRange(start, finish, false, 10000);
> 
>                QueryResult<ColumnSlice<Composite, String>> result = sq
>                                .execute();
>                ColumnSlice<Composite, String> orderedRows = result.get();
> 
> 6- And I get output for RowKey: query1_1337295600 as
> (column=15:Composite1:Composite2, value=value123, timesta
> mp=1341879833470000) which should not be the case since it does not
> belong to the 'Composite3' slice.
> 
> Sunit.
> 
> 
> On Sun, Jul 8, 2012 at 11:45 AM, aaron morton <aa...@thelastpickle.com> wrote:
>> Something like:
>> 
>> This is how I did the write in CLI and this is what it printed.
>> 
>> and then
>> 
>> This is how I did the read in the CLI and this is what it printed.
>> 
>> It's hard to imagine what data is in cassandra based on code.
>> 
>> cheers
>> 
>> -----------------
>> Aaron Morton
>> Freelance Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>> 
>> On 7/07/2012, at 1:28 PM, Sunit Randhawa wrote:
>> 
>> Aaron,
>> 
>> For writing, i am using cli.
>> Below is the piece of code that is reading column names of different types.
>> 
>> 
>> Composite start = new Composite();
>> 
>> start.addComponent(0, beginTime,
>> Composite.ComponentEquality.EQUAL);
>> 
>> if (columns != null){
>> int colCount =1;
>> for (String colName : columns){
>> start.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
>> colCount++;
>> }
>> }
>> 
>> Composite finish = new Composite();
>> finish.addComponent(0, endTime,
>> Composite.ComponentEquality.EQUAL);
>> 
>> if (columns != null){
>> int colCount =1;
>> for (String colName : columns){
>> if (colCount == columns.size())
>> finish.addComponent(colCount,colName+ Character.MAX_VALUE,
>> Composite.ComponentEquality.GREATER_THAN_EQUAL);
>> //Greater_than_equal is meant for any subslices to A:B:C if searched on A:B
>> else
>> finish.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
>> colCount++;
>> }
>> }
>> SliceQuery<String, Composite, String> sq
>>     =  HFactory.createSliceQuery(keyspace, StringSerializer.get(),
>>                                  new CompositeSerializer(),
>>                                  StringSerializer.get());
>> sq.setColumnFamily(columnFamilyName);
>> 
>> sq.setKey(key);
>> logger.debug("Start:"+start+",finish:"+finish);
>> sq.setRange(start, finish, false, 10000);
>> 
>> QueryResult<ColumnSlice<Composite, String>> result = sq
>> .execute();
>> ColumnSlice<Composite, String> orderedRows = result.get();
>> 
>> Please let me know if you additional info.
>> 
>> Thanks,
>> Sunit.
>> 
>> On Fri, Jul 6, 2012 at 10:59 AM, aaron morton <aa...@thelastpickle.com>
>> wrote:
>> 
>> Can you provide an example of writing and reading column names of a
>> 
>> different type.
>> 
>> 
>> Thanks
>> 
>> 
>> -----------------
>> 
>> Aaron Morton
>> 
>> Freelance Developer
>> 
>> @aaronmorton
>> 
>> http://www.thelastpickle.com
>> 
>> 
>> On 6/07/2012, at 11:30 AM, Sunit Randhawa wrote:
>> 
>> 
>> HI Aaron,
>> 
>> 
>> It is
>> 
>> 
>> create column family CF
>> 
>>          with comparator =
>> 
>> 'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
>> 
>>  and key_validation_class = UTF8Type
>> 
>>  and default_validation_class = UTF8Type;
>> 
>> 
>> This is allowing me to insert column names of different type.
>> 
>> 
>> Thanks,
>> 
>> Sunit.
>> 
>> On Thu, Jul 5, 2012 at 4:24 PM, aaron morton <aa...@thelastpickle.com>
>> 
>> wrote:
>> 
>> 
>> #2 has the Composite Column and #1 does not.
>> 
>> 
>> 
>> They are both strings.
>> 
>> 
>> 
>> All column names *must* be of the same type. What was your CF definition ?
>> 
>> 
>> 
>> Cheers
>> 
>> 
>> 
>> -----------------
>> 
>> 
>> Aaron Morton
>> 
>> 
>> Freelance Developer
>> 
>> 
>> @aaronmorton
>> 
>> 
>> http://www.thelastpickle.com
>> 
>> 
>> 
>> On 6/07/2012, at 7:26 AM, Sunit Randhawa wrote:
>> 
>> 
>> 
>> Hello,
>> 
>> 
>> 
>> I have 2 Columns for a 'RowKey' as below:
>> 
>> 
>> 
>> #1 : set CF['RowKey']['1000']='A=1,B=2';
>> 
>> 
>> #2: set CF['RowKey']['1000:C1']='A=2,B=3'';
>> 
>> 
>> 
>> #2 has the Composite Column and #1 does not.
>> 
>> 
>> 
>> Now when I execute the Composite Slice query by 1000 and C1, I do get
>> 
>> 
>> both the columns above.
>> 
>> 
>> 
>> I am hoping get #2 only since I am specifically providing "C1" as
>> 
>> 
>> Start and Finish Composite Range with
>> 
>> 
>> Composite.ComponentEquality.EQUAL.
>> 
>> 
>> 
>> 
>> I am not sure if this is by design.
>> 
>> 
>> 
>> Thanks,
>> 
>> 
>> Sunit.
>> 
>> 
>> 
>> 
>> 
>> 


Re: Composite Slice Query returning non-sliced data

Posted by Sunit Randhawa <su...@gmail.com>.
Aaron,

Let me start from the beginning.

1- I have a ColumnFamily called Rollup15 with below definition:

create column family Rollup15
          with comparator =
'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
    and key_validation_class = UTF8Type
    and default_validation_class = UTF8Type;


2- Once created, it is empty. Below is the output of CLI:

[default@Schema] list Rollup15;
Using default limit of 100

0 Row Returned.
Elapsed time: 16 msec(s).

3- I use the Code below to insert the Composite Data into Cassandra:

public void insertData(String columnFamilyName, String key,
			String value, int rollupInterval, String... columnSlice) {
		
		Composite colKey = new Composite();
		colKey.addComponent(rollupInterval, IntegerSerializer.get());
		if (columnSlice != null){
			for (String colName : columnSlice){
				colKey.addComponent(colName, serializer);
			}
		}
		createMutator(keyspace, serializer).addInsertion(key, columnFamilyName,
				createColumn(colKey, value, new CompositeSerializer(),
serializer)).execute();

	}

4- After insertion, below is the CLI Output:

[default@Schema] list Rollup15;
Using default limit of 100
-------------------
RowKey: query1_1337295600
=> (column=15:Composite1:Composite2, value=value123, timesta
mp=1341879833470000)

1 Row Returned.
Elapsed time: 9 msec(s).

So, there is record with 3 Composite Keys (15, Composite1 and Composite2)


5- Now I am doing fetch based on Code Below. I am doing a fetch for
column "15:Composite3" which I know it is not there:

Composite start = new Composite();

                start.addComponent(0, 15,
                                Composite.ComponentEquality.EQUAL);
               start.addComponent(1,
"Composite3",Composite.ComponentEquality.EQUAL);


                Composite finish = new Composite();
                finish.addComponent(0, 15,
                                Composite.ComponentEquality.EQUAL);

                finish.addComponent(1,"Composite3"+
Character.MAX_VALUE, Composite.ComponentEquality.GREATER_THAN_EQUAL);

                SliceQuery<String, Composite, String> sq
              =  HFactory.createSliceQuery(keyspace, StringSerializer.get(),
                                           new CompositeSerializer(),
                                           StringSerializer.get());
                sq.setColumnFamily("Rollup15");

                sq.setKey("query1_1337295600");
                sq.setRange(start, finish, false, 10000);

                QueryResult<ColumnSlice<Composite, String>> result = sq
                                .execute();
                ColumnSlice<Composite, String> orderedRows = result.get();

6- And I get output for RowKey: query1_1337295600 as
(column=15:Composite1:Composite2, value=value123, timesta
mp=1341879833470000) which should not be the case since it does not
belong to the 'Composite3' slice.

Sunit.


On Sun, Jul 8, 2012 at 11:45 AM, aaron morton <aa...@thelastpickle.com> wrote:
> Something like:
>
> This is how I did the write in CLI and this is what it printed.
>
> and then
>
> This is how I did the read in the CLI and this is what it printed.
>
> It's hard to imagine what data is in cassandra based on code.
>
> cheers
>
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 7/07/2012, at 1:28 PM, Sunit Randhawa wrote:
>
> Aaron,
>
> For writing, i am using cli.
> Below is the piece of code that is reading column names of different types.
>
>
> Composite start = new Composite();
>
> start.addComponent(0, beginTime,
> Composite.ComponentEquality.EQUAL);
>
> if (columns != null){
> int colCount =1;
> for (String colName : columns){
> start.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
> colCount++;
> }
> }
>
> Composite finish = new Composite();
> finish.addComponent(0, endTime,
> Composite.ComponentEquality.EQUAL);
>
> if (columns != null){
> int colCount =1;
> for (String colName : columns){
> if (colCount == columns.size())
> finish.addComponent(colCount,colName+ Character.MAX_VALUE,
> Composite.ComponentEquality.GREATER_THAN_EQUAL);
> //Greater_than_equal is meant for any subslices to A:B:C if searched on A:B
> else
> finish.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
> colCount++;
> }
> }
> SliceQuery<String, Composite, String> sq
>      =  HFactory.createSliceQuery(keyspace, StringSerializer.get(),
>                                   new CompositeSerializer(),
>                                   StringSerializer.get());
> sq.setColumnFamily(columnFamilyName);
>
> sq.setKey(key);
> logger.debug("Start:"+start+",finish:"+finish);
> sq.setRange(start, finish, false, 10000);
>
> QueryResult<ColumnSlice<Composite, String>> result = sq
> .execute();
> ColumnSlice<Composite, String> orderedRows = result.get();
>
> Please let me know if you additional info.
>
> Thanks,
> Sunit.
>
> On Fri, Jul 6, 2012 at 10:59 AM, aaron morton <aa...@thelastpickle.com>
> wrote:
>
> Can you provide an example of writing and reading column names of a
>
> different type.
>
>
> Thanks
>
>
> -----------------
>
> Aaron Morton
>
> Freelance Developer
>
> @aaronmorton
>
> http://www.thelastpickle.com
>
>
> On 6/07/2012, at 11:30 AM, Sunit Randhawa wrote:
>
>
> HI Aaron,
>
>
> It is
>
>
> create column family CF
>
>           with comparator =
>
> 'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
>
>   and key_validation_class = UTF8Type
>
>   and default_validation_class = UTF8Type;
>
>
> This is allowing me to insert column names of different type.
>
>
> Thanks,
>
> Sunit.
>
> On Thu, Jul 5, 2012 at 4:24 PM, aaron morton <aa...@thelastpickle.com>
>
> wrote:
>
>
> #2 has the Composite Column and #1 does not.
>
>
>
> They are both strings.
>
>
>
> All column names *must* be of the same type. What was your CF definition ?
>
>
>
> Cheers
>
>
>
> -----------------
>
>
> Aaron Morton
>
>
> Freelance Developer
>
>
> @aaronmorton
>
>
> http://www.thelastpickle.com
>
>
>
> On 6/07/2012, at 7:26 AM, Sunit Randhawa wrote:
>
>
>
> Hello,
>
>
>
> I have 2 Columns for a 'RowKey' as below:
>
>
>
> #1 : set CF['RowKey']['1000']='A=1,B=2';
>
>
> #2: set CF['RowKey']['1000:C1']='A=2,B=3'';
>
>
>
> #2 has the Composite Column and #1 does not.
>
>
>
> Now when I execute the Composite Slice query by 1000 and C1, I do get
>
>
> both the columns above.
>
>
>
> I am hoping get #2 only since I am specifically providing "C1" as
>
>
> Start and Finish Composite Range with
>
>
> Composite.ComponentEquality.EQUAL.
>
>
>
>
> I am not sure if this is by design.
>
>
>
> Thanks,
>
>
> Sunit.
>
>
>
>
>
>

Re: Composite Slice Query returning non-sliced data

Posted by aaron morton <aa...@thelastpickle.com>.
Something like:

This is how I did the write in CLI and this is what it printed.

and then

This is how I did the read in the CLI and this is what it printed. 

It's hard to imagine what data is in cassandra based on code. 

cheers
 
-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 7/07/2012, at 1:28 PM, Sunit Randhawa wrote:

> Aaron,
> 
> For writing, i am using cli.
> Below is the piece of code that is reading column names of different types.
> 
> 
> Composite start = new Composite();
> 
> 		start.addComponent(0, beginTime,
> 				Composite.ComponentEquality.EQUAL);
> 		
> 		if (columns != null){
> 			int colCount =1;
> 			for (String colName : columns){
> 				start.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
> 				colCount++;
> 			}
> 		}
> 
> 		Composite finish = new Composite();
> 		finish.addComponent(0, endTime,
> 				Composite.ComponentEquality.EQUAL);
> 		
> 		if (columns != null){
> 			int colCount =1;
> 			for (String colName : columns){
> 				if (colCount == columns.size())
> 					finish.addComponent(colCount,colName+ Character.MAX_VALUE,
> Composite.ComponentEquality.GREATER_THAN_EQUAL);
> 				//Greater_than_equal is meant for any subslices to A:B:C if searched on A:B
> 				else
> 					finish.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
> 				colCount++;
> 			}
> 		}
> 		SliceQuery<String, Composite, String> sq
> 	      =  HFactory.createSliceQuery(keyspace, StringSerializer.get(),
> 	                                   new CompositeSerializer(),
> 	                                   StringSerializer.get());
> 		sq.setColumnFamily(columnFamilyName);
> 
> 		sq.setKey(key);
> 		logger.debug("Start:"+start+",finish:"+finish);
> 		sq.setRange(start, finish, false, 10000);
> 
> 		QueryResult<ColumnSlice<Composite, String>> result = sq
> 				.execute();
> 		ColumnSlice<Composite, String> orderedRows = result.get();
> 
> Please let me know if you additional info.
> 
> Thanks,
> Sunit.
> 
> On Fri, Jul 6, 2012 at 10:59 AM, aaron morton <aa...@thelastpickle.com> wrote:
>> Can you provide an example of writing and reading column names of a
>> different type.
>> 
>> Thanks
>> 
>> -----------------
>> Aaron Morton
>> Freelance Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>> 
>> On 6/07/2012, at 11:30 AM, Sunit Randhawa wrote:
>> 
>> HI Aaron,
>> 
>> It is
>> 
>> create column family CF
>>           with comparator =
>> 'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
>>   and key_validation_class = UTF8Type
>>   and default_validation_class = UTF8Type;
>> 
>> This is allowing me to insert column names of different type.
>> 
>> Thanks,
>> Sunit.
>> On Thu, Jul 5, 2012 at 4:24 PM, aaron morton <aa...@thelastpickle.com>
>> wrote:
>> 
>> #2 has the Composite Column and #1 does not.
>> 
>> 
>> They are both strings.
>> 
>> 
>> All column names *must* be of the same type. What was your CF definition ?
>> 
>> 
>> Cheers
>> 
>> 
>> -----------------
>> 
>> Aaron Morton
>> 
>> Freelance Developer
>> 
>> @aaronmorton
>> 
>> http://www.thelastpickle.com
>> 
>> 
>> On 6/07/2012, at 7:26 AM, Sunit Randhawa wrote:
>> 
>> 
>> Hello,
>> 
>> 
>> I have 2 Columns for a 'RowKey' as below:
>> 
>> 
>> #1 : set CF['RowKey']['1000']='A=1,B=2';
>> 
>> #2: set CF['RowKey']['1000:C1']='A=2,B=3'';
>> 
>> 
>> #2 has the Composite Column and #1 does not.
>> 
>> 
>> Now when I execute the Composite Slice query by 1000 and C1, I do get
>> 
>> both the columns above.
>> 
>> 
>> I am hoping get #2 only since I am specifically providing "C1" as
>> 
>> Start and Finish Composite Range with
>> 
>> Composite.ComponentEquality.EQUAL.
>> 
>> 
>> 
>> I am not sure if this is by design.
>> 
>> 
>> Thanks,
>> 
>> Sunit.
>> 
>> 
>> 
>> 


Re: Composite Slice Query returning non-sliced data

Posted by Sunit Randhawa <su...@gmail.com>.
Aaron,

For writing, i am using cli.
Below is the piece of code that is reading column names of different types.


Composite start = new Composite();

		start.addComponent(0, beginTime,
				Composite.ComponentEquality.EQUAL);
		
		if (columns != null){
			int colCount =1;
			for (String colName : columns){
				start.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
				colCount++;
			}
		}

		Composite finish = new Composite();
		finish.addComponent(0, endTime,
				Composite.ComponentEquality.EQUAL);
		
		if (columns != null){
			int colCount =1;
			for (String colName : columns){
				if (colCount == columns.size())
					finish.addComponent(colCount,colName+ Character.MAX_VALUE,
Composite.ComponentEquality.GREATER_THAN_EQUAL);
				//Greater_than_equal is meant for any subslices to A:B:C if searched on A:B
				else
					finish.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
				colCount++;
			}
		}
		SliceQuery<String, Composite, String> sq
	      =  HFactory.createSliceQuery(keyspace, StringSerializer.get(),
	                                   new CompositeSerializer(),
	                                   StringSerializer.get());
		sq.setColumnFamily(columnFamilyName);

		sq.setKey(key);
		logger.debug("Start:"+start+",finish:"+finish);
		sq.setRange(start, finish, false, 10000);

		QueryResult<ColumnSlice<Composite, String>> result = sq
				.execute();
		ColumnSlice<Composite, String> orderedRows = result.get();

Please let me know if you additional info.

Thanks,
Sunit.

On Fri, Jul 6, 2012 at 10:59 AM, aaron morton <aa...@thelastpickle.com> wrote:
> Can you provide an example of writing and reading column names of a
> different type.
>
> Thanks
>
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 6/07/2012, at 11:30 AM, Sunit Randhawa wrote:
>
> HI Aaron,
>
> It is
>
> create column family CF
>            with comparator =
> 'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
>    and key_validation_class = UTF8Type
>    and default_validation_class = UTF8Type;
>
> This is allowing me to insert column names of different type.
>
> Thanks,
> Sunit.
> On Thu, Jul 5, 2012 at 4:24 PM, aaron morton <aa...@thelastpickle.com>
> wrote:
>
> #2 has the Composite Column and #1 does not.
>
>
> They are both strings.
>
>
> All column names *must* be of the same type. What was your CF definition ?
>
>
> Cheers
>
>
> -----------------
>
> Aaron Morton
>
> Freelance Developer
>
> @aaronmorton
>
> http://www.thelastpickle.com
>
>
> On 6/07/2012, at 7:26 AM, Sunit Randhawa wrote:
>
>
> Hello,
>
>
> I have 2 Columns for a 'RowKey' as below:
>
>
> #1 : set CF['RowKey']['1000']='A=1,B=2';
>
> #2: set CF['RowKey']['1000:C1']='A=2,B=3'';
>
>
> #2 has the Composite Column and #1 does not.
>
>
> Now when I execute the Composite Slice query by 1000 and C1, I do get
>
> both the columns above.
>
>
> I am hoping get #2 only since I am specifically providing "C1" as
>
> Start and Finish Composite Range with
>
> Composite.ComponentEquality.EQUAL.
>
>
>
> I am not sure if this is by design.
>
>
> Thanks,
>
> Sunit.
>
>
>
>

Re: Composite Slice Query returning non-sliced data

Posted by aaron morton <aa...@thelastpickle.com>.
Can you provide an example of writing and reading column names of a different type. 

Thanks

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 6/07/2012, at 11:30 AM, Sunit Randhawa wrote:

> HI Aaron,
> 
> It is
> 
> create column family CF
>            with comparator =
> 'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
>    and key_validation_class = UTF8Type
>    and default_validation_class = UTF8Type;
> 
> This is allowing me to insert column names of different type.
> 
> Thanks,
> Sunit.
> On Thu, Jul 5, 2012 at 4:24 PM, aaron morton <aa...@thelastpickle.com> wrote:
>> #2 has the Composite Column and #1 does not.
>> 
>> They are both strings.
>> 
>> All column names *must* be of the same type. What was your CF definition ?
>> 
>> Cheers
>> 
>> -----------------
>> Aaron Morton
>> Freelance Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>> 
>> On 6/07/2012, at 7:26 AM, Sunit Randhawa wrote:
>> 
>> Hello,
>> 
>> I have 2 Columns for a 'RowKey' as below:
>> 
>> #1 : set CF['RowKey']['1000']='A=1,B=2';
>> #2: set CF['RowKey']['1000:C1']='A=2,B=3'';
>> 
>> #2 has the Composite Column and #1 does not.
>> 
>> Now when I execute the Composite Slice query by 1000 and C1, I do get
>> both the columns above.
>> 
>> I am hoping get #2 only since I am specifically providing "C1" as
>> Start and Finish Composite Range with
>> Composite.ComponentEquality.EQUAL.
>> 
>> 
>> I am not sure if this is by design.
>> 
>> Thanks,
>> Sunit.
>> 
>> 


Re: Composite Slice Query returning non-sliced data

Posted by Sunit Randhawa <su...@gmail.com>.
HI Aaron,

It is

create column family CF
            with comparator =
'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
    and key_validation_class = UTF8Type
    and default_validation_class = UTF8Type;

This is allowing me to insert column names of different type.

Thanks,
Sunit.
On Thu, Jul 5, 2012 at 4:24 PM, aaron morton <aa...@thelastpickle.com> wrote:
> #2 has the Composite Column and #1 does not.
>
> They are both strings.
>
> All column names *must* be of the same type. What was your CF definition ?
>
> Cheers
>
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 6/07/2012, at 7:26 AM, Sunit Randhawa wrote:
>
> Hello,
>
> I have 2 Columns for a 'RowKey' as below:
>
> #1 : set CF['RowKey']['1000']='A=1,B=2';
> #2: set CF['RowKey']['1000:C1']='A=2,B=3'';
>
> #2 has the Composite Column and #1 does not.
>
> Now when I execute the Composite Slice query by 1000 and C1, I do get
> both the columns above.
>
> I am hoping get #2 only since I am specifically providing "C1" as
> Start and Finish Composite Range with
> Composite.ComponentEquality.EQUAL.
>
>
> I am not sure if this is by design.
>
> Thanks,
> Sunit.
>
>

Re: Composite Slice Query returning non-sliced data

Posted by aaron morton <aa...@thelastpickle.com>.
> #2 has the Composite Column and #1 does not.
They are both strings. 

All column names *must* be of the same type. What was your CF definition ?

Cheers

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 6/07/2012, at 7:26 AM, Sunit Randhawa wrote:

> Hello,
> 
> I have 2 Columns for a 'RowKey' as below:
> 
> #1 : set CF['RowKey']['1000']='A=1,B=2';
> #2: set CF['RowKey']['1000:C1']='A=2,B=3'';
> 
> #2 has the Composite Column and #1 does not.
> 
> Now when I execute the Composite Slice query by 1000 and C1, I do get
> both the columns above.
> 
> I am hoping get #2 only since I am specifically providing "C1" as
> Start and Finish Composite Range with
> Composite.ComponentEquality.EQUAL.
> 
> 
> I am not sure if this is by design.
> 
> Thanks,
> Sunit.