You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Ravi Agrawal <ra...@clearpoolgroup.com> on 2015/02/03 19:28:06 UTC

Smart column searching for a particular rowKey

Hi Guys,
Need help with this.
My rowKey is stockName like GOOGLE, APPLE.
Columns are sorted as per timestamp and they include some set of data fields like price and size. So, data would be like 1. 9:31:00, $520, 100 shares 2. 9:35:09, $530, 1000 shares 3. 9:45:39, $520, 500 shares
I want to search this column family using partition key timestamp.
For a rowkey, if I search for data on partition id 9:33:00 which does not actually exist in columns, I want to return the last value where data was present. In this case 9:31:00, $520, 100 shares, since the next partitionkey is 9:35:09 which is greater than input value entered.
One obvious way would be iterating through each columns and storing last data, if new timestamp is greater than given timestamp then return the last data stored.
Is it any optimized way to achieve the same? Since columns are already sorted.
Thanks



Re: Smart column searching for a particular rowKey

Posted by Eric Stevens <mi...@gmail.com>.
If you're getting started with Cassandra, definitely prefer CQL over Thrift
(Astyanax's default interface).  New features will be coming to CQL in
later versions, and they will not be backported to Thrift, it's a frozen
interface, and will eventually be deprecated.

But with Astyanax you want to look at query.withColumnRange(RangeBuilder...)

On Tue, Feb 3, 2015 at 3:12 PM, Mohammed Guller <mo...@glassbeam.com>
wrote:

>  Astyanax allows you to execute CQL statements. I don’t remember the
> details, but it is there.
>
>
>
> One tip – when you create the column family, use CLUSTERING ORDER WITH
> (timestamp DESC). Then you query becomes straightforward and C* will do all
> the heavy lifting for you.
>
>
>
> Mohammed
>
>
>
> *From:* Ravi Agrawal [mailto:ragrawal@clearpoolgroup.com]
> *Sent:* Tuesday, February 3, 2015 11:54 AM
>
> *To:* user@cassandra.apache.org
> *Subject:* RE: Smart column searching for a particular rowKey
>
>
>
> Cannot find something corresponding to where clause there.
>
>
>
> *From:* Ravi Agrawal [mailto:ragrawal@clearpoolgroup.com
> <ra...@clearpoolgroup.com>]
> *Sent:* Tuesday, February 03, 2015 2:44 PM
> *To:* user@cassandra.apache.org
> *Subject:* RE: Smart column searching for a particular rowKey
>
>
>
> Thanks, it does.
>
> How about in astyanax?
>
>
>
> *From:* Eric Stevens [mailto:mightye@gmail.com <mi...@gmail.com>]
> *Sent:* Tuesday, February 03, 2015 1:49 PM
> *To:* user@cassandra.apache.org
> *Subject:* Re: Smart column searching for a particular rowKey
>
>
>
> WHERE < + ORDER DESC + LIMIT should be able to accomplish that.
>
>
>
> On Tue, Feb 3, 2015 at 11:28 AM, Ravi Agrawal <ra...@clearpoolgroup.com>
> wrote:
>
>   Hi Guys,
>
> Need help with this.
>
> My rowKey is stockName like GOOGLE, APPLE.
>
> Columns are sorted as per timestamp and they include some set of data
> fields like price and size. So, data would be like 1. 9:31:00, $520, 100
> shares 2. 9:35:09, $530, 1000 shares 3. 9:45:39, $520, 500 shares
>
> I want to search this column family using partition key timestamp.
>
> For a rowkey, if I search for data on partition id 9:33:00 which does not
> actually exist in columns, I want to return the last value where data was
> present. In this case 9:31:00, $520, 100 shares, since the next
> partitionkey is 9:35:09 which is greater than input value entered.
>
> One obvious way would be iterating through each columns and storing last
> data, if new timestamp is greater than given timestamp then return the last
> data stored.
>
> Is it any optimized way to achieve the same? Since columns are already
> sorted.
>
> Thanks
>
>
>
>
>
>
>

RE: Smart column searching for a particular rowKey

Posted by Mohammed Guller <mo...@glassbeam.com>.
Astyanax allows you to execute CQL statements. I don’t remember the details, but it is there.

One tip – when you create the column family, use CLUSTERING ORDER WITH (timestamp DESC). Then you query becomes straightforward and C* will do all the heavy lifting for you.

Mohammed

From: Ravi Agrawal [mailto:ragrawal@clearpoolgroup.com]
Sent: Tuesday, February 3, 2015 11:54 AM
To: user@cassandra.apache.org
Subject: RE: Smart column searching for a particular rowKey

Cannot find something corresponding to where clause there.

From: Ravi Agrawal [mailto:ragrawal@clearpoolgroup.com]
Sent: Tuesday, February 03, 2015 2:44 PM
To: user@cassandra.apache.org<ma...@cassandra.apache.org>
Subject: RE: Smart column searching for a particular rowKey

Thanks, it does.
How about in astyanax?

From: Eric Stevens [mailto:mightye@gmail.com]
Sent: Tuesday, February 03, 2015 1:49 PM
To: user@cassandra.apache.org<ma...@cassandra.apache.org>
Subject: Re: Smart column searching for a particular rowKey

WHERE < + ORDER DESC + LIMIT should be able to accomplish that.

On Tue, Feb 3, 2015 at 11:28 AM, Ravi Agrawal <ra...@clearpoolgroup.com>> wrote:
Hi Guys,
Need help with this.
My rowKey is stockName like GOOGLE, APPLE.
Columns are sorted as per timestamp and they include some set of data fields like price and size. So, data would be like 1. 9:31:00, $520, 100 shares 2. 9:35:09, $530, 1000 shares 3. 9:45:39, $520, 500 shares
I want to search this column family using partition key timestamp.
For a rowkey, if I search for data on partition id 9:33:00 which does not actually exist in columns, I want to return the last value where data was present. In this case 9:31:00, $520, 100 shares, since the next partitionkey is 9:35:09 which is greater than input value entered.
One obvious way would be iterating through each columns and storing last data, if new timestamp is greater than given timestamp then return the last data stored.
Is it any optimized way to achieve the same? Since columns are already sorted.
Thanks




RE: Smart column searching for a particular rowKey

Posted by Ravi Agrawal <ra...@clearpoolgroup.com>.
Cannot find something corresponding to where clause there.

From: Ravi Agrawal [mailto:ragrawal@clearpoolgroup.com]
Sent: Tuesday, February 03, 2015 2:44 PM
To: user@cassandra.apache.org
Subject: RE: Smart column searching for a particular rowKey

Thanks, it does.
How about in astyanax?

From: Eric Stevens [mailto:mightye@gmail.com]
Sent: Tuesday, February 03, 2015 1:49 PM
To: user@cassandra.apache.org<ma...@cassandra.apache.org>
Subject: Re: Smart column searching for a particular rowKey

WHERE < + ORDER DESC + LIMIT should be able to accomplish that.

On Tue, Feb 3, 2015 at 11:28 AM, Ravi Agrawal <ra...@clearpoolgroup.com>> wrote:
Hi Guys,
Need help with this.
My rowKey is stockName like GOOGLE, APPLE.
Columns are sorted as per timestamp and they include some set of data fields like price and size. So, data would be like 1. 9:31:00, $520, 100 shares 2. 9:35:09, $530, 1000 shares 3. 9:45:39, $520, 500 shares
I want to search this column family using partition key timestamp.
For a rowkey, if I search for data on partition id 9:33:00 which does not actually exist in columns, I want to return the last value where data was present. In this case 9:31:00, $520, 100 shares, since the next partitionkey is 9:35:09 which is greater than input value entered.
One obvious way would be iterating through each columns and storing last data, if new timestamp is greater than given timestamp then return the last data stored.
Is it any optimized way to achieve the same? Since columns are already sorted.
Thanks




RE: Smart column searching for a particular rowKey

Posted by Ravi Agrawal <ra...@clearpoolgroup.com>.
Thanks, it does.
How about in astyanax?

From: Eric Stevens [mailto:mightye@gmail.com]
Sent: Tuesday, February 03, 2015 1:49 PM
To: user@cassandra.apache.org
Subject: Re: Smart column searching for a particular rowKey

WHERE < + ORDER DESC + LIMIT should be able to accomplish that.

On Tue, Feb 3, 2015 at 11:28 AM, Ravi Agrawal <ra...@clearpoolgroup.com>> wrote:
Hi Guys,
Need help with this.
My rowKey is stockName like GOOGLE, APPLE.
Columns are sorted as per timestamp and they include some set of data fields like price and size. So, data would be like 1. 9:31:00, $520, 100 shares 2. 9:35:09, $530, 1000 shares 3. 9:45:39, $520, 500 shares
I want to search this column family using partition key timestamp.
For a rowkey, if I search for data on partition id 9:33:00 which does not actually exist in columns, I want to return the last value where data was present. In this case 9:31:00, $520, 100 shares, since the next partitionkey is 9:35:09 which is greater than input value entered.
One obvious way would be iterating through each columns and storing last data, if new timestamp is greater than given timestamp then return the last data stored.
Is it any optimized way to achieve the same? Since columns are already sorted.
Thanks




Re: Smart column searching for a particular rowKey

Posted by Eric Stevens <mi...@gmail.com>.
WHERE < + ORDER DESC + LIMIT should be able to accomplish that.

On Tue, Feb 3, 2015 at 11:28 AM, Ravi Agrawal <ra...@clearpoolgroup.com>
wrote:

>  Hi Guys,
>
> Need help with this.
>
> My rowKey is stockName like GOOGLE, APPLE.
>
> Columns are sorted as per timestamp and they include some set of data
> fields like price and size. So, data would be like 1. 9:31:00, $520, 100
> shares 2. 9:35:09, $530, 1000 shares 3. 9:45:39, $520, 500 shares
>
> I want to search this column family using partition key timestamp.
>
> For a rowkey, if I search for data on partition id 9:33:00 which does not
> actually exist in columns, I want to return the last value where data was
> present. In this case 9:31:00, $520, 100 shares, since the next
> partitionkey is 9:35:09 which is greater than input value entered.
>
> One obvious way would be iterating through each columns and storing last
> data, if new timestamp is greater than given timestamp then return the last
> data stored.
>
> Is it any optimized way to achieve the same? Since columns are already
> sorted.
>
> Thanks
>
>
>
>
>