Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D4D4D360 for ; Tue, 27 Nov 2012 20:47:43 +0000 (UTC) Received: (qmail 85410 invoked by uid 500); 27 Nov 2012 20:47:40 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 85388 invoked by uid 500); 27 Nov 2012 20:47:40 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 85380 invoked by uid 99); 27 Nov 2012 20:47:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Nov 2012 20:47:40 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of hodgson_sam@hotmail.com designates 157.55.2.11 as permitted sender) Received: from [157.55.2.11] (HELO dub0-omc3-s2.dub0.hotmail.com) (157.55.2.11) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Nov 2012 20:47:34 +0000 Received: from DUB116-W21 ([157.55.2.9]) by dub0-omc3-s2.dub0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 27 Nov 2012 12:47:13 -0800 X-Originating-IP: [77.98.245.69] X-EIP: [ouPZ/yWIRFDetyRyC4lGiho1q/7Y/rzA] X-Originating-Email: [hodgson_sam@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="_c3e54db6-a93e-4af4-97ad-3e4cd7740d0e_" From: Sam Hodgson To: Subject: RE: Pagination Date: Tue, 27 Nov 2012 20:47:12 +0000 Importance: Normal In-Reply-To: References: , MIME-Version: 1.0 X-OriginalArrivalTime: 27 Nov 2012 20:47:13.0073 (UTC) FILETIME=[60B38210:01CDCCE0] X-Virus-Checked: Checked by ClamAV on apache.org --_c3e54db6-a93e-4af4-97ad-3e4cd7740d0e_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Well I know what you mean and i have been doing that however im currently m= igrating an old mysql site onto cass and just trying to keep things consist= ent on the front end for the guy=2C i thought i might be missing a trick bu= t if not then yeah I may well ditch the page linkage if it starts causing p= roblems. Cheers Sam Date: Tue=2C 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 pagi= ng through a forum=2C especially if it is quite active. Threads from the bo= ttom 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=2C = and the next page being the next N results after the last updated time of t= he last thread on the page. It is also much easier to model with Cassandra. On Tue=2C Nov 27=2C 2012 at 12:19 PM=2C Sam Hodgson wrote: Hi All=2C Wondering if anyone has any good solutions to pagination? In particular enu= merating the number of pages and linking to each page=2C a common feature i= n forums. This code is untested (using phpcassa) and may need tweaking to get the cor= rect range of records or maybe completely wrong! however it shows the conce= pt of taking a page number then pulling out a range of posts belonging to t= hat page: $cf_threads looks like:thread_ID =3D> (timestamp =3D> post_id) if($page > 1) { $ranger =3D ($pagenumber * 20)=3B $low= _ranger =3D $ranger - 20=3B $arr_range =3D $cf_threads->get("$thread_id" =2C $columns=3Dnull = =2C $column_start=3D"" =2C $column_finish=3D"" =2C $column_reversed=3DTrue= =2C $limit=3D$ranger)=3B $arr_page =3D array_slice($arr_range=2C $lo= w_ranger =2C $ranger =2C TRUE)=3B }else { $arr_page =3D $cf_threads->ge= t("$thread_id" =2C $columns=3Dnull =2C $column_start=3D"" =2C $column_fini= sh=3D"" =2C $column_reversed=3DTrue=2C $limit=3D20)=3B } I think this should be ok? the only concern is if there are some really lon= g threads when im having to pull the entire CF. Another idea involved a schema change and using a super CF to include a pag= e number as follows: Thread_ID =3D> (PageNumber(timestamp =3D> Post_ID)) Probably more efficient but generally page numbers go backwards ie page 1 h= as newest content so this would complicate things when writing data and cau= se load if logic was included to reorganise page numbers etc. Cheers Samhttp://Newsarc.net =20 --=20 Derek Williams = --_c3e54db6-a93e-4af4-97ad-3e4cd7740d0e_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Well I know what you mean and i have been doing that however im currently m= igrating an old mysql site onto cass and just trying to keep things consist= ent on the front end for the guy=2C i thought i might be missing a trick bu= t if not then yeah I may well ditch the page linkage if it starts causing p= roblems.

Cheers

Sam
Date: Tue=2C 27 Nov 2012 13:01:48 -0700
Subject: Re: Pa= gination
From: derek@fyrie.net
To: user@cassandra.apache.org

D= o you really require page numbers? I usually find them annoying while pagin= g through a forum=2C especially if it is quite active. Threads from the bot= tom of the page get bumped to the next page so you end up seeing the same c= ontent again. I much prefer the first page being the current N results=2C a= nd the next page being the next N results after the last updated time of th= e last thread on the page. It is also much easier to model with Cassandra.<= div class=3D"ecxgmail_extra">

On Tue=2C Nov 27=2C 2012 at 12:19 PM= =2C Sam Hodgson <=3Bhodgson_sam@hotmail.com>=3B wrote:
Hi All=2C

Wondering if anyone has any good so= lutions to pagination? In particular enumerating the number of pages and li= nking to each page=2C a common feature in forums.

This code is untested (using phpcassa) and may need tweaking to get the cor= rect range of records or maybe completely wrong! however it shows the conce= pt of taking a page number then pulling out a range of posts belonging to t= hat page:

$cf_threads looks like:
thread_ID =3D>=3B (= timestamp =3D>=3B post_id)

if($page >=3B 1)
 =3B  =3B  =3B  =3B {
 =3B  =3B &= nbsp=3B  =3B $ranger =3D ($pagenumber * 20)=3B
 =3B  = =3B  =3B  =3B $low_ranger =3D $ranger - 20=3B
 =3B  =3B  =3B  =3B $arr_range =3D $cf_threads->=3Bg= et("$thread_id" =2C $columns=3Dnull =2C  =3B$column_start=3D"" =2C $col= umn_finish=3D"" =2C $column_reversed=3DTrue=2C $limit=3D$ranger)=3B
 =3B  =3B  =3B  =3B $arr_page =3D array_slice($arr_range= =2C $low_ranger =2C $ranger =2C TRUE)=3B
 =3B  =3B  =3B  =3B }else
 =3B  =3B =  =3B  =3B  =3B  =3B  =3B  =3B {
 =3B =  =3B  =3B  =3B  =3B  =3B  =3B  =3B $arr_page = =3D $cf_threads->=3Bget("$thread_id" =2C $columns=3Dnull =2C  =3B$col= umn_start=3D"" =2C $column_finish=3D"" =2C $column_reversed=3DTrue=2C $limi= t=3D20)=3B
 =3B  =3B  =3B  =3B  =3B  =3B  =3B  = =3B }

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 usin= g a super CF to include a page number as follows:

Thread_ID =3D>=3B (PageNumber(timestamp =3D>=3B Pos= t_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

Sam
=



--
Derek W= illiams

= --_c3e54db6-a93e-4af4-97ad-3e4cd7740d0e_--