incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Hodgson <hodgson_...@hotmail.com>
Subject RE: Pagination
Date Tue, 27 Nov 2012 20:47:12 GMT

Well I know what you mean and i have been doing that however im currently migrating an old
mysql site onto cass and just trying to keep things consistent on the front end for the guy,
i thought i might be missing a trick but if not then yeah I may well ditch the page linkage
if it starts causing problems.
Cheers
Sam

Date: Tue, 27 Nov 2012 13:01:48 -0700
Subject: Re: Pagination
From: derek@fyrie.net
To: user@cassandra.apache.org

Do you really require page numbers? I usually find them annoying while paging through a forum,
especially if it is quite active. Threads from the bottom of the page get bumped to the next
page so you end up seeing the same content again. I much prefer the first page being the current
N results, and the next page being the next N results after the last updated time of the last
thread on the page. It is also much easier to model with Cassandra.


On Tue, Nov 27, 2012 at 12:19 PM, Sam Hodgson <hodgson_sam@hotmail.com> wrote:





Hi All,
Wondering if anyone has any good solutions to pagination? In particular enumerating the number
of pages and linking to each page, a common feature in forums.

This code is untested (using phpcassa) and may need tweaking to get the correct range of records
or maybe completely wrong! however it shows the concept of taking a page number then pulling
out a range of posts belonging to that page:

$cf_threads looks like:thread_ID => (timestamp => post_id)
if($page > 1)        {        $ranger = ($pagenumber * 20);        $low_ranger = $ranger
- 20;
        $arr_range = $cf_threads->get("$thread_id" , $columns=null ,  $column_start=""
, $column_finish="" , $column_reversed=True, $limit=$ranger);        $arr_page = array_slice($arr_range,
$low_ranger , $ranger , TRUE);
        }else                {                $arr_page = $cf_threads->get("$thread_id"
, $columns=null ,  $column_start="" , $column_finish="" , $column_reversed=True, $limit=20);
                }
I think this should be ok? the only concern is if there are some really long threads when
im having to pull the entire CF.
Another idea involved a schema change and using a super CF to include a page number as follows:

Thread_ID => (PageNumber(timestamp => Post_ID))
Probably more efficient but generally page numbers go backwards ie page 1 has newest content
so this would complicate things when writing data and cause load if logic was included to
reorganise page numbers etc.

Cheers
Samhttp://Newsarc.net 		 	   		  


-- 
Derek Williams

 		 	   		  
Mime
View raw message