Skip to content

Commit

Permalink
re-enable max page size for queries
Browse files Browse the repository at this point in the history
  • Loading branch information
ghelmling committed Jan 29, 2010
1 parent 59808c2 commit 2f0f999
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 6 additions & 11 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,18 @@ Some query examples from the feeds implementation.
Find all items related to a discussion::

FeedItemService service = new FeedItemService(DiscussionItem.class);
QueryOpts opts = new QueryOpts();
opts.setPageSize(-1); // all items
Query query =
service.query(DiscussionItem.class, opts)
.add( Criteria.require(
Criteria.eq("threadId", threadId) ) );
service.query(DiscussionItem.class)
.using( Criteria.eq("threadId", threadId) );
List items = query.execute();


Find all greetings from a given member::
Find first 5 greetings from a given member::

FeedItemService service = new FeedItemService();
QueryOpts opts = new QueryOpts();
opts.setPageSize(-1); // all items
Query query =
service.query(opts)
.add( Criteria.require(
Criteria.eq("memberId", memberId) ) )
.add( Criteria.eq(“itemType”, “chapter_greeting”) );
.using( Criteria.eq("memberId", memberId) )
.where( Criteria.eq(“itemType”, “chapter_greeting”) )
.limit( 5 );
List items = query.execute();
10 changes: 10 additions & 0 deletions src/java/meetup/beeno/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ public Query<T> using(Criteria.Expression expression) {
return this;
}

/**
* Sets the maximum number of items to retrieve
* @return
* @throws HBaseException
*/
public Query<T> limit(int size) {
this.opts.setPageSize(size);
return this;
}

public List<T> execute() throws HBaseException {
long t1 = System.nanoTime();
List<T> entities = new ArrayList<T>();
Expand Down

0 comments on commit 2f0f999

Please sign in to comment.