1

Cassandra ベースの Web アプリケーションでページネーションを行うにはどうすればよいですか。サーバー側でSpring MVCを使用し、クライアント側でjqueryを使用しています。私はこれを試しましたが、満足していませんでした。

私の行キーは UUIDType であり、クライアント ブラウザから開始キーを文字列として送信するたびに、それを UUID に変換する方法がわかりません。簡単な例が評価されます。

4

3 に答える 3

1

カサンドラにPlayOrmを使用すると、クエリ時にカーソルが返され、最初のページが最初の20個の結果を読み取って表示すると、次のページはセッションで同じカーソルを使用でき、中断したところから再開します最初の 20 行を再度スキャンします。

ディーン

于 2013-04-16T13:45:56.540 に答える
1

Spring-data には、次の機能が事前に組み込まれています。

http://static.springsource.org/spring-data/data-jpa/docs/current/reference/html/repositories.html#web-pagination

于 2013-04-15T11:07:18.610 に答える
0

どの言語でも機能する一般的なソリューションをお勧めします。これを解決するためにpython pycassaを使用しました:

最初のアプローチ:

-Say if column_count = 10 (How many results to display on front end) 
-collect first 11 rows, sort first 10, send it to user (front end) as JSON object and also parameter last=11th_column
-User then calls for page 2, with prev = 1st_column_id, column_start=11th_column and column_count = 10. Based on this, I query cassandra like cf.get('cf', key, column_start=11th_column, column_count=10)
-This way, I can traverse, next page and previous page.
-Only issue with this approach is, I don't have all columns in super column sorted. So this did not work.

2番目のアプローチ(私は本番環境で使用しました):

-fetch all super columns and columns for a row key. e.g in python pycassa, cf.get('cf',key)
-Sort this in python using sorted and lambda function based on column values.
-Once sorted, prepare buckets and each bucked size is of page size/column count. Also filter out any rogue data if needed before bucketing.
-Store page by page results in Redis with keys such as 'row_key|page_1|super_column' and keep refreshing redis periodically.

私の 2 番目のアプローチは、少量/中量のデータでかなりうまく機能しました。

于 2013-12-18T22:10:34.620 に答える