本文整理了Java中org.apache.usergrid.persistence.Query.setLimit
方法的一些代码示例,展示了Query.setLimit
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setLimit
方法的具体详情如下:
包路径:org.apache.usergrid.persistence.Query
类名称:Query
方法名:setLimit
暂无
代码示例来源:origin: apache/usergrid
public Query withLimit( int limit ) {
setLimit( limit );
return this;
}
代码示例来源:origin: apache/usergrid
@Override
public Results getCollection( String collectionName, UUID startResult, int count, Level resultsLevel,
boolean reversed ) throws Exception {
final String ql;
if (startResult != null ) {
// UUID timestamp is a different measure than 'created' field on entities
Calendar uuidEpoch = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
uuidEpoch.clear();
uuidEpoch.set(1582, 9, 15, 0, 0, 0); // 9 = October
long epochMillis = uuidEpoch.getTime().getTime();
long time = (startResult.timestamp() / 10000L) + epochMillis;
if ( !reversed ) {
ql = "select * where created > " + time;
} else {
ql = "select * where created < " + time;
}
} else {
ql = "select *";
}
Query query = Query.fromQL( ql );
if(query == null ){
throw new RuntimeException("Unable to get data for collection: "+collectionName);
}
query.setLimit( count );
query.setReversed( reversed );
return searchCollection( collectionName, query );
}
代码示例来源:origin: apache/usergrid
private int getConnectionCount(final Import importRoot) {
try {
EntityManager rootEM = emf.getEntityManager(emf.getManagementAppId());
Query query = Query.fromQL("select *");
query.setEntityType("file_import");
query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION);
query.setLimit(MAX_FILE_IMPORTS);
// TODO, this won't work with more than 100 files
Results entities = rootEM.searchTargetEntities(importRoot, query);
return entities.size();
// see ImportConnectsTest()
// Results entities = rootEM.getTargetEntities(
// importRoot, "includes", null, Level.ALL_PROPERTIES );
// PagingResultsIterator itr = new PagingResultsIterator( entities );
// int count = 0;
// while ( itr.hasNext() ) {
// itr.next();
// count++;
// }
// return count;
} catch (Exception e) {
logger.error("application doesn't exist within the current context");
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/usergrid
protected void singleOrderByNoIntersection( IoHelper io ) throws Exception {
io.doSetup();
int size = 20;
int queryLimit = Query.MAX_LIMIT;
// the number of entities that should be written including an intersection
int secondIncrement = 9;
long start = System.currentTimeMillis();
logger.info( "Writing {} entities.", size );
for ( int i = 0; i < size; i++ ) {
Map<String, Object> entity = new HashMap<String, Object>();
entity.put( "name", String.valueOf( i ) );
// if we hit the increment, set this to true
entity.put( "intersect", false );
entity.put( "intersect2", i % secondIncrement == 0 );
io.writeEntity( entity );
}
long stop = System.currentTimeMillis();
logger.info( "Writes took {} ms", stop - start );
Query query = Query.fromQL( "select * where intersect = true AND intersect2 = true order by created" );
query.setLimit( queryLimit );
start = System.currentTimeMillis();
Results results = io.getResults( query );
// now do simple ordering, should be returned in order
stop = System.currentTimeMillis();
logger.info( "Query took {} ms to return {} entities", stop - start, 0 );
assertEquals( 0, results.size() );
}
代码示例来源:origin: apache/usergrid
query.setLimit( queryLimit );
代码示例来源:origin: apache/usergrid
query.setLimit( PAGE_SIZE );
代码示例来源:origin: apache/usergrid
query.setLimit( queryLimit );
代码示例来源:origin: apache/usergrid
query.setLimit( queryLimit );
代码示例来源:origin: apache/usergrid
query.setLimit( PAGE_SIZE );
代码示例来源:origin: apache/usergrid
query.setLimit( 10 );
代码示例来源:origin: apache/usergrid
query.setLimit( PAGE_SIZE );
代码示例来源:origin: apache/usergrid
protected List<EntityRef> getNotificationReceipts(EntityRef notification)
throws Exception {
Query query = new Query();
query.setCollection("receipts");
query.setLimit(100);
PathQuery<Receipt> pathQuery = new PathQuery<Receipt>(
new SimpleEntityRef(app.getEntityManager().getApplicationRef()),
query
);
Iterator<Receipt> it = pathQuery.iterator(app.getEntityManager());
List<EntityRef> list =new ArrayList<EntityRef>();//get all
while(it.hasNext()){
Receipt receipt =it.next();
if(receipt.getNotificationUUID().equals(notification.getUuid())) {
list.add(receipt);
}
}
return list;
}
代码示例来源:origin: apache/usergrid
query.setLimit(limit);
代码示例来源:origin: apache/usergrid
query.setLimit( pageSize );
代码示例来源:origin: apache/usergrid
private int getConnectionCountViaSearch( final Import importRoot ) {
try {
EntityManager emMgmtApp = setup.getEmf()
.getEntityManager(setup.getEmf().getManagementAppId() );
Query query = Query.fromQL("select *");
query.setEntityType("file_import");
query.setConnectionType("includes");
query.setLimit(10000);
Results entities = emMgmtApp.searchTargetEntities(importRoot, query);
return entities.size();
// PagingResultsIterator itr = new PagingResultsIterator( entities );
// int count = 0;
// while ( itr.hasNext() ) {
// itr.next();
// count++;
// }
// return count;
}
catch ( Exception e ) {
logger.error( "application doesn't exist within the current context" );
throw new RuntimeException( e );
}
}
}
代码示例来源:origin: apache/usergrid
query.setLimit( pageSize );
代码示例来源:origin: apache/usergrid
@Override
public ServiceResults putItemsByQuery( ServiceContext context, Query query ) throws Exception {
checkPermissionsForCollection( context );
if ( context.moreParameters() ) {
return getItemsByQuery( context, query );
}
query = new Query( query );
query.setResultsLevel( Level.ALL_PROPERTIES );
query.setLimit( 1000 );
if ( !query.isReversedSet() ) {
query.setReversed( isCollectionReversed( context ) );
}
Results r = em.searchCollection( context.getOwner(), context.getCollectionName(), query );
if ( r.isEmpty() ) {
throw new ServiceResourceNotFoundException( context );
}
updateEntities( context, r );
return new ServiceResults( this, context, Type.COLLECTION, r, null, null );
}
代码示例来源:origin: apache/usergrid
query.setLimit( pageSize );
代码示例来源:origin: apache/usergrid
@Override
public ServiceResults deleteItemsByQuery( ServiceContext context, Query query ) throws Exception {
checkPermissionsForCollection( context );
if ( context.moreParameters() ) {
return getItemsByQuery( context, query );
}
query = new Query( query );
query.setResultsLevel( Level.ALL_PROPERTIES );
query.setLimit( query.getLimit() );
if ( !query.isReversedSet() ) {
query.setReversed( isCollectionReversed( context ) );
}
Results r = em.searchCollection( context.getOwner(), context.getCollectionName(), query );
importEntities( context, r );
for ( Entity entity : r ) {
prepareToDelete( context, entity );
}
for ( Entity entity : r ) {
em.removeFromCollection( context.getOwner(), context.getCollectionName(), entity );
}
return new ServiceResults( this, context, Type.COLLECTION, r, null, null );
}
代码示例来源:origin: apache/usergrid
query.setLimit( query.getLimit( count ) );
内容来源于网络,如有侵权,请联系作者删除!