org.apache.usergrid.persistence.Query.setLimit()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(312)

本文整理了Java中org.apache.usergrid.persistence.Query.setLimit方法的一些代码示例,展示了Query.setLimit的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setLimit方法的具体详情如下:
包路径:org.apache.usergrid.persistence.Query
类名称:Query
方法名:setLimit

Query.setLimit介绍

暂无

代码示例

代码示例来源:origin: apache/usergrid

  1. public Query withLimit( int limit ) {
  2. setLimit( limit );
  3. return this;
  4. }

代码示例来源:origin: apache/usergrid

  1. @Override
  2. public Results getCollection( String collectionName, UUID startResult, int count, Level resultsLevel,
  3. boolean reversed ) throws Exception {
  4. final String ql;
  5. if (startResult != null ) {
  6. // UUID timestamp is a different measure than 'created' field on entities
  7. Calendar uuidEpoch = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
  8. uuidEpoch.clear();
  9. uuidEpoch.set(1582, 9, 15, 0, 0, 0); // 9 = October
  10. long epochMillis = uuidEpoch.getTime().getTime();
  11. long time = (startResult.timestamp() / 10000L) + epochMillis;
  12. if ( !reversed ) {
  13. ql = "select * where created > " + time;
  14. } else {
  15. ql = "select * where created < " + time;
  16. }
  17. } else {
  18. ql = "select *";
  19. }
  20. Query query = Query.fromQL( ql );
  21. if(query == null ){
  22. throw new RuntimeException("Unable to get data for collection: "+collectionName);
  23. }
  24. query.setLimit( count );
  25. query.setReversed( reversed );
  26. return searchCollection( collectionName, query );
  27. }

代码示例来源:origin: apache/usergrid

  1. private int getConnectionCount(final Import importRoot) {
  2. try {
  3. EntityManager rootEM = emf.getEntityManager(emf.getManagementAppId());
  4. Query query = Query.fromQL("select *");
  5. query.setEntityType("file_import");
  6. query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION);
  7. query.setLimit(MAX_FILE_IMPORTS);
  8. // TODO, this won't work with more than 100 files
  9. Results entities = rootEM.searchTargetEntities(importRoot, query);
  10. return entities.size();
  11. // see ImportConnectsTest()
  12. // Results entities = rootEM.getTargetEntities(
  13. // importRoot, "includes", null, Level.ALL_PROPERTIES );
  14. // PagingResultsIterator itr = new PagingResultsIterator( entities );
  15. // int count = 0;
  16. // while ( itr.hasNext() ) {
  17. // itr.next();
  18. // count++;
  19. // }
  20. // return count;
  21. } catch (Exception e) {
  22. logger.error("application doesn't exist within the current context");
  23. throw new RuntimeException(e);
  24. }
  25. }

代码示例来源:origin: apache/usergrid

  1. protected void singleOrderByNoIntersection( IoHelper io ) throws Exception {
  2. io.doSetup();
  3. int size = 20;
  4. int queryLimit = Query.MAX_LIMIT;
  5. // the number of entities that should be written including an intersection
  6. int secondIncrement = 9;
  7. long start = System.currentTimeMillis();
  8. logger.info( "Writing {} entities.", size );
  9. for ( int i = 0; i < size; i++ ) {
  10. Map<String, Object> entity = new HashMap<String, Object>();
  11. entity.put( "name", String.valueOf( i ) );
  12. // if we hit the increment, set this to true
  13. entity.put( "intersect", false );
  14. entity.put( "intersect2", i % secondIncrement == 0 );
  15. io.writeEntity( entity );
  16. }
  17. long stop = System.currentTimeMillis();
  18. logger.info( "Writes took {} ms", stop - start );
  19. Query query = Query.fromQL( "select * where intersect = true AND intersect2 = true order by created" );
  20. query.setLimit( queryLimit );
  21. start = System.currentTimeMillis();
  22. Results results = io.getResults( query );
  23. // now do simple ordering, should be returned in order
  24. stop = System.currentTimeMillis();
  25. logger.info( "Query took {} ms to return {} entities", stop - start, 0 );
  26. assertEquals( 0, results.size() );
  27. }

代码示例来源:origin: apache/usergrid

  1. query.setLimit( queryLimit );

代码示例来源:origin: apache/usergrid

  1. query.setLimit( PAGE_SIZE );

代码示例来源:origin: apache/usergrid

  1. query.setLimit( queryLimit );

代码示例来源:origin: apache/usergrid

  1. query.setLimit( queryLimit );

代码示例来源:origin: apache/usergrid

  1. query.setLimit( PAGE_SIZE );

代码示例来源:origin: apache/usergrid

  1. query.setLimit( 10 );

代码示例来源:origin: apache/usergrid

  1. query.setLimit( PAGE_SIZE );

代码示例来源:origin: apache/usergrid

  1. protected List<EntityRef> getNotificationReceipts(EntityRef notification)
  2. throws Exception {
  3. Query query = new Query();
  4. query.setCollection("receipts");
  5. query.setLimit(100);
  6. PathQuery<Receipt> pathQuery = new PathQuery<Receipt>(
  7. new SimpleEntityRef(app.getEntityManager().getApplicationRef()),
  8. query
  9. );
  10. Iterator<Receipt> it = pathQuery.iterator(app.getEntityManager());
  11. List<EntityRef> list =new ArrayList<EntityRef>();//get all
  12. while(it.hasNext()){
  13. Receipt receipt =it.next();
  14. if(receipt.getNotificationUUID().equals(notification.getUuid())) {
  15. list.add(receipt);
  16. }
  17. }
  18. return list;
  19. }

代码示例来源:origin: apache/usergrid

  1. query.setLimit(limit);

代码示例来源:origin: apache/usergrid

  1. query.setLimit( pageSize );

代码示例来源:origin: apache/usergrid

  1. private int getConnectionCountViaSearch( final Import importRoot ) {
  2. try {
  3. EntityManager emMgmtApp = setup.getEmf()
  4. .getEntityManager(setup.getEmf().getManagementAppId() );
  5. Query query = Query.fromQL("select *");
  6. query.setEntityType("file_import");
  7. query.setConnectionType("includes");
  8. query.setLimit(10000);
  9. Results entities = emMgmtApp.searchTargetEntities(importRoot, query);
  10. return entities.size();
  11. // PagingResultsIterator itr = new PagingResultsIterator( entities );
  12. // int count = 0;
  13. // while ( itr.hasNext() ) {
  14. // itr.next();
  15. // count++;
  16. // }
  17. // return count;
  18. }
  19. catch ( Exception e ) {
  20. logger.error( "application doesn't exist within the current context" );
  21. throw new RuntimeException( e );
  22. }
  23. }
  24. }

代码示例来源:origin: apache/usergrid

  1. query.setLimit( pageSize );

代码示例来源:origin: apache/usergrid

  1. @Override
  2. public ServiceResults putItemsByQuery( ServiceContext context, Query query ) throws Exception {
  3. checkPermissionsForCollection( context );
  4. if ( context.moreParameters() ) {
  5. return getItemsByQuery( context, query );
  6. }
  7. query = new Query( query );
  8. query.setResultsLevel( Level.ALL_PROPERTIES );
  9. query.setLimit( 1000 );
  10. if ( !query.isReversedSet() ) {
  11. query.setReversed( isCollectionReversed( context ) );
  12. }
  13. Results r = em.searchCollection( context.getOwner(), context.getCollectionName(), query );
  14. if ( r.isEmpty() ) {
  15. throw new ServiceResourceNotFoundException( context );
  16. }
  17. updateEntities( context, r );
  18. return new ServiceResults( this, context, Type.COLLECTION, r, null, null );
  19. }

代码示例来源:origin: apache/usergrid

  1. query.setLimit( pageSize );

代码示例来源:origin: apache/usergrid

  1. @Override
  2. public ServiceResults deleteItemsByQuery( ServiceContext context, Query query ) throws Exception {
  3. checkPermissionsForCollection( context );
  4. if ( context.moreParameters() ) {
  5. return getItemsByQuery( context, query );
  6. }
  7. query = new Query( query );
  8. query.setResultsLevel( Level.ALL_PROPERTIES );
  9. query.setLimit( query.getLimit() );
  10. if ( !query.isReversedSet() ) {
  11. query.setReversed( isCollectionReversed( context ) );
  12. }
  13. Results r = em.searchCollection( context.getOwner(), context.getCollectionName(), query );
  14. importEntities( context, r );
  15. for ( Entity entity : r ) {
  16. prepareToDelete( context, entity );
  17. }
  18. for ( Entity entity : r ) {
  19. em.removeFromCollection( context.getOwner(), context.getCollectionName(), entity );
  20. }
  21. return new ServiceResults( this, context, Type.COLLECTION, r, null, null );
  22. }

代码示例来源:origin: apache/usergrid

  1. query.setLimit( query.getLimit( count ) );

相关文章