/** * Gets the list of files stored in this gridfs, sorted by filename. * * @return cursor of file objects */ public DBCursor getFileList() { return filesCollection.find().sort(new BasicDBObject("filename", 1)); }
/** * Gets a sorted, filtered list of files stored in this gridfs. * * @param query filter to apply * @param sort sorting to apply * @return cursor of file objects */ public DBCursor getFileList(final DBObject query, final DBObject sort) { return filesCollection.find(query).sort(sort); }
/** * Gets a filtered list of files stored in this gridfs, sorted by filename. * * @param query filter to apply * @return cursor of file objects */ public DBCursor getFileList(final DBObject query) { return filesCollection.find(query).sort(new BasicDBObject("filename", 1)); }
protected <T extends Persisted> List<DBObject> query(Class<T> modelClass, DBObject query, DBObject sort) { return cursorToList(collection(modelClass).find(query).sort(sort)); }
private Timestamp<?> getCurrentOplogTimestamp() { try (DBCursor cursor = oplogCollection.find().sort(new BasicDBObject(MongoDBRiver.INSERTION_ORDER_KEY, -1)).limit(1)) { return Timestamp.on(cursor.next()); } }
protected <T extends Persisted> List<DBObject> query(Class<T> modelClass, DBObject query, DBObject sort, int limit, int offset) { return cursorToList( collection(modelClass) .find(query) .sort(sort) .limit(limit) .skip(offset) ); }
/** * Finds a list of files matching the given query. * * @param query the filter to apply * @param sort the fields to sort with * @return list of gridfs files * @throws com.mongodb.MongoException if the operation fails */ public List<GridFSDBFile> find(final DBObject query, final DBObject sort) { List<GridFSDBFile> files = new ArrayList<GridFSDBFile>(); DBCursor cursor = filesCollection.find(query); if (sort != null) { cursor.sort(sort); } try { while (cursor.hasNext()) { files.add(injectGridFSInstance(cursor.next())); } } finally { cursor.close(); } return Collections.unmodifiableList(files); }
private Timestamp<?> getCurrentOplogTimestamp(MongoClient shardClient) { DBCollection oplogCollection = shardClient .getDB(MongoDBRiver.MONGODB_LOCAL_DATABASE) .getCollection(MongoDBRiver.OPLOG_COLLECTION); try (DBCursor cursor = oplogCollection.find().sort(new BasicDBObject("$natural", -1)).limit(1)) { return Timestamp.on(cursor.next()); } }
try(DBCursor cursor = dbCollection.find(andQuery).sort(new BasicDBObject("timestamp", 1))) { final Map<String, Object> metricsData = Maps.newHashMap(); metricsData.put("name", metricName);
min((DBObject) value); } else if ("$orderby".equals(name)) { sort((DBObject) value); } else if ("$returnKey".equals(name)) { returnKey(); snapshot(); } else if ("$natural".equals(name)) { sort(new BasicDBObject("$natural", ((Number) value).intValue())); } else { throw new IllegalArgumentException(name + "is not a supported modifier");
protected DBCursor createCursor(DBCollection collection, @Nullable Predicate where, Expression<?> projection, QueryModifiers modifiers, List<OrderSpecifier<?>> orderBy) { DBCursor cursor = collection.find(createQuery(where), createProjection(projection)); Integer limit = modifiers.getLimitAsInteger(); Integer offset = modifiers.getOffsetAsInteger(); if (limit != null) { cursor.limit(limit); } if (offset != null) { cursor.skip(offset); } if (orderBy.size() > 0) { cursor.sort(serializer.toSort(orderBy)); } if (readPreference != null) { cursor.setReadPreference(readPreference); } return cursor; }
cursor = collection .find(getFilterForInitialImport(definition.getMongoCollectionFilter(), lastId)) .sort(new BasicDBObject("_id", 1)); while (cursor.hasNext() && context.getStatus() == Status.RUNNING) { DBObject object = cursor.next();
if (sort != null) c.sort(sort);
orderBy.append(property, sortBy.getSortOrder() == SortOrder.ASCENDING ? 1 : -1); c = c.sort(orderBy);
DBCursor cursor = orderBy != null ? dbCollection.find(mongoQuery, keys).sort(orderBy) : dbCollection.find(mongoQuery, keys).limit(maxResult).skip(firstResult);
return dbCollection.count(mongoQuery); else cursor = orderBy != null ? dbCollection.find(mongoQuery, keys).sort(orderBy).limit(maxResult) .skip(firstResult) : dbCollection.find(mongoQuery, keys).limit(maxResult).skip(firstResult); return cursor;
/** * Gets the list of files stored in this gridfs, sorted by filename. * * @return cursor of file objects */ public DBCursor getFileList() { return filesCollection.find().sort(new BasicDBObject("filename", 1)); }
/** * Gets a filtered list of files stored in this gridfs, sorted by filename. * * @param query filter to apply * @return cursor of file objects */ public DBCursor getFileList(final DBObject query) { return filesCollection.find(query).sort(new BasicDBObject("filename", 1)); }
private void prepareCursor(){ this.cursor = this.collection .find(getQuery(),getProjection()) .sort(getSort()) .limit(getLimit()); }
@Override public Page<Record> fetchRecords(StoreQuery query) { DBObject mongoQuery = convert(query); final BasicDBObject projection = query.isMetadataOnly() ? new BasicDBObject(BatchConstants.metadataKey, 1) : null; DBCursor cursor = accessor.getCollection().find(mongoQuery, projection); cursor.sort(createOrderBy(query)); cursor = cursor.skip(query.getPageSize() * query.getPageNo()); cursor = cursor.limit(query.getPageSize()); return convert(cursor, query); }