paging in fluent cassandra

Showing 21-41 of 41 messages
paging in fluent cassandra Abhijit Chanda 7/14/12 11:32 PM
Hi All,
Using fluent cassandra classes how we can accomplish paging on a particular column family?
And one more thing is there any way via which i can count the number of entries after 
filtration.

Thanks In Advance 
-- 
Abhijit Chanda
Analyst
VeHere Interactive Pvt. Ltd.
+91-9748888395

Re: paging in fluent cassandra Nick Berardi 7/15/12 4:17 AM
What are you trying to page the records or the columns? I know this may seem like a weird question if you are use to relational databases like SQL, but Cassandra supports up to about 2 billion columns, so it is a valid question.

Secondly you can do a count using CQL.  It would be something like 

SELECT COUNT * FROM YourColumnFamily WHERE KEY >= 23
Re: [FluentCassandra:8] Re: paging in fluent cassandra Abhijit Chanda 7/15/12 7:37 AM
Nick,

Thanks for the response. Well I am trying to page the records. I know i can do that using CQL query, but i want to have it using the API. So can you suggest me how to do that? Or rather can you provide equivalent API statement for this CQL query

SELECT column_Names FROM CF_NAME WHERE <Relation Clause condition> ORDER BY column_Name DESC LIMIT 10000


Thanks In Advance
Regards,
Abhijit
Re: [FluentCassandra:8] Re: paging in fluent cassandra Nick Berardi 7/15/12 10:40 AM
There is no equivalent.  CQL doesn't yet support everything that SQL does.  Especially not ORDER BY.  You may find something that works for you in CQL 3 though.


However you need to be using at least version 1.1.0 of Cassandra.  To use CQL3 you can do it with the following code.

var conn = new ConnectionBuilder(keyspace: "your keyspace", host: "your host", cqlVersion: FluentCassandra.Connections.CqlVersion.Cql3);
var session = new CassandraSession(conn);
var context = new CassandraContext(session);

var results = context.ExecquteQuery("your cql 3 query here;");

Hope this helps.


--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluentcassandra?hl=en.

Re: [FluentCassandra:9] Re: paging in fluent cassandra Abhijit Chanda 7/15/12 11:02 AM
Nick,

Thanks for sharing the connection code with cql3. Right now i am using Cassandra 1.1.2, and the query i mentioned in my previous response was in cql3 only. Like other cassandra API's (Hector, Astyanax) does fluent cassandra provide any such functions for handling pagination. Eagerly waiting for your response

Thanks & Regards,
Abhijit

Re: [FluentCassandra:10] Re: paging in fluent cassandra Nick Berardi 7/15/12 11:03 AM
Can you show me an example of how the other use pagination.  Again I am not sure if you are talking about paging many columns or many rows.  These two things would be handled differently.  Please show me examples of what you are talking about in Hector and I can help.


Abhijit

--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluentcassandra?hl=en.

Re: [FluentCassandra:11] Re: paging in fluent cassandra Abhijit Chanda 7/15/12 11:15 AM
Nick,

This is a sample code of pagination supported by Astyanax.
RowQuery
<String, UUID> query = keyspace
                .prepareQuery(CF_TIME_UUID)
                .getKey(rowKey)
                .withColumnRange(new RangeBuilder().setLimit(10)
                                .setStart(TimeUUIDUtils.getTimeUUID(columnTime + startTime))
                                .setEnd(TimeUUIDUtils.getTimeUUID(columnTime + endTime))
                                .
build()).autoPaginate(true);
        OperationResult<ColumnList<UUID>> result;
        int pageCount = 0;
        int rowCount = 0;
        try {
            LOG.info("starting pagination");
            while (!(result = query.execute()).getResult().isEmpty()) {
                pageCount++;
                rowCount += result.getResult().size();
                LOG.info("==== Block ====");
                for (Column<UUID> column : result.getResult()) {
                    LOG.info("Column is " + column.getName());
                    LOG.info("Column Value is " + column.getStringValue());
                }
            }
            LOG.info("pagination complete");
        } catch (ConnectionException e) {
            Assert.fail();
            LOG.info(e.getMessage());
            e.printStackTrace();
        }
Re: [FluentCassandra:12] Re: paging in fluent cassandra Nick Berardi 7/15/12 11:57 AM
Does each call of "execute" advance the page by one?  

If so how does it know how many columns to pull back?  

It looks like you are doing column paging with this since you are setting the row key.  Is this correct?

Are you sure this is actually paging, because this is a very odd way to page, by just calling execute over and over again, with out setting page sizes or anything.

Nick

        }

--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluentcassandra?hl=en.

Re: [FluentCassandra:13] Re: paging in fluent cassandra Abhijit Chanda 7/15/12 10:52 PM
Hi Nick,

if this is a very old way to page then can you suggest me some latest way to page.
Actually Nick i saw an article http://blog.dynatrace.com/2011/12/05/pagination-with-cassandra-and-what-we-can-learn-from-it/ on paging in cassandra, looks quite interesting. Thats why was trying to do that in fluent cassandra.

Thanks
Abhijit
Re: [FluentCassandra:15] Re: paging in fluent cassandra Nick Berardi 7/16/12 5:24 AM
Got it.  So here is how you currently have to page columns in FluentCassandra.  It is not as easy as what you have shown me, so I still have some work to make infinite advancement available.  But here is how you do it none the less.

using (var db = new CassandraContext(keyspace: KeyspaceName, server: Server))
{
var key = "first-blog-post";
var lastDate = DateTime.Now;

// get the comments family
var commentsFamily = db.GetSuperColumnFamily("Comments");

for (int page = 0; page < 2; page++)
{
// lets back the date off by a millisecond so we don't get paging overlaps
lastDate = lastDate.AddMilliseconds(-1D);

ConsoleHeader("showing page " + page + " of comments starting at " + lastDate.ToLocalTime());

// query using API
var comments = commentsFamily.Get(key)
.StartWithColumn(lastDate) // this is the last column you processed
.TakeColumns(3) // this is the number of columns you want to return
.FirstOrDefault(); // this is required since we are only dealing with one row

foreach (dynamic comment in comments)
{
var dateTime = (DateTime)comment.ColumnName;

Console.WriteLine(String.Format("{0:T} : {1} ({2} - {3})",
dateTime.ToLocalTime(),
comment.Name,
comment.Email,
comment.Website
));

lastDate = dateTime;
}
}
}

You can find the whole program here that does this.  And much more with FluentCassandra.


Hope it helps.

--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluentcassandra?hl=en.

Re: [FluentCassandra:17] Re: paging in fluent cassandra Abhijit Chanda 7/16/12 8:22 AM
Nick,

If i don't have the row key rather say i don't want get involve with the row key (something like select * from CF_NAME) and then how i am supposed to do paging.

Regards,
Abhijit
Re: [FluentCassandra:18] Re: paging in fluent cassandra Nick Berardi 7/16/12 8:42 AM
That CQL select statement would imply that you want to do paging by the rows and not the columns as you indicated before.  Can you please tell me what you are trying to solve, because you are sending a lot of mixed messages.  


Abhijit

--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluentcassandra?hl=en.

Re: [FluentCassandra:19] Re: paging in fluent cassandra Abhijit Chanda 7/16/12 9:02 AM
Nick,

Basically i am trying to page by the rows and sincere apologies for unable to express myself.
Now coming to the problem, say in my first page i want to extract result for the first 1000 rows and so on for the next pages.

Thanks
Abhijit
Re: [FluentCassandra:20] Re: paging in fluent cassandra Nick Berardi 7/16/12 9:38 AM
There currently is no way to page rows built into Cassandra. Cassandra cannot be used like a regular SQL database.  You need to know the key to pull any information out of Cassandra.


Abhijit

--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluentcassandra?hl=en.

Re: [FluentCassandra:21] Re: paging in fluent cassandra Abhijit Chanda 7/17/12 4:03 AM
Nick,

If i am not wrong, i guess we can do row wise paging  using CQL query. isn't it? 

Re: [FluentCassandra:22] Re: paging in fluent cassandra Nick Berardi 7/17/12 4:48 AM
You still need to know the key values or some value. There is no anonymous paging mechanism like in SQL. 

If you have an example. I would love to be proved wrong. 

--
Nick Berardi
(484) 302-0125
Sent on the go from my phone. 

On Jul 17, 2012, at 7:03 AM, Abhijit Chanda <abhijit...@gmail.com> wrote:

Nick,

If i am not wrong, i guess we can do row wise paging  using CQL query. isn't it? 

--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Re: [FluentCassandra:23] Re: paging in fluent cassandra Abhijit Chanda 7/17/12 5:08 AM
Nick,

I am getting little confused. In your last to last response you have mentioned " You need to know the key to pull any information out of Cassandra " and now you are saying key value or some other value. 


Re: [FluentCassandra:24] Re: paging in fluent cassandra Nick Berardi 7/17/12 5:15 AM
If you use an index column you can query on that, or the key.  I am not really the best resource to tell you how to use Cassandra, I can tell you anything you want to know about FluentCassandra.  But the rest really needs to be left up to you.  There are many great resources out there.  A good place to start is http://datastax.com

Nick

On Tue, Jul 17, 2012 at 8:08 AM, Abhijit Chanda <abhijit...@gmail.com> wrote:
Nick,

I am getting little confused. In your last to last response you have mentioned " You need to know the key to pull any information out of Cassandra " and now you are saying key value or some other value. 


--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: [FluentCassandra:25] Re: paging in fluent cassandra Abhijit Chanda 7/17/12 5:33 AM

Nick,

One more request. What will be the Fluent Cassandra API equivalent code for this CQL query
SELECT COLUMNNAME(S) FROM CF_NAME WHERE Name = 'xyz'; //NAME column is secondary indexed

Re: [FluentCassandra:25] Re: paging in fluent cassandra Nick Berardi 7/17/12 5:36 AM
It will look like this.

var conn = new ConnectionBuilder(keyspace: "your keyspace", host: "your host");
var session = new CassandraSession(conn);
var context = new CassandraContext(session);

var results = context.ExecquteQuery("SELECT COLUMNNAME(S) FROM CF_NAME WHERE Name = 'xyz';");

Have a good day.
Re: [FluentCassandra:28] Re: paging in fluent cassandra Abhijit Chanda 7/17/12 5:42 AM
Thanks Nick for giving me the time.

Regards,
Abhijit