Package com.mongodb

Examples of com.mongodb.DBCollection.find()


        queryBuilder.and("_id").greaterThan(parent + "/");
        queryBuilder.and("_id").lessThanEquals(parent + "0");
        DBObject query = queryBuilder.get();
        BasicDBObject keys = new BasicDBObject();
        keys.put("_id", 1);
        DBCursor cursor = nodes.find(query, keys);
        int count = 0;
        log("Query plan: " + cursor.explain());
        long time = System.currentTimeMillis();
        while (cursor.hasNext()) {
            DBObject obj = cursor.next();
View Full Code Here


            queryBuilder.greaterThanEquals(startValue);
        }
        DBObject query = queryBuilder.get();
        long start = start();
        try {
            DBCursor cursor = dbCollection.find(query).sort(BY_ID_ASC);
            List<T> list = new ArrayList<T>();
            for (int i = 0; i < limit && cursor.hasNext(); i++) {
                DBObject o = cursor.next();
                T doc = convertFromDBObject(collection, o);
                if (collection == Collection.NODES && doc != null) {
View Full Code Here

        if (maxLastModifiedTime != 0 && maxLastModifiedTime != -1) {
            builder.and(MongoBlob.KEY_LAST_MOD).lessThanEquals(maxLastModifiedTime);
        }

        final DBCursor cur =
                collection.find(builder.get(), fields).hint(fields)
                        .addOption(Bytes.QUERYOPTION_SLAVEOK);

        return new AbstractIterator<String>() {
            protected String computeNext() {
                if (cur.hasNext()) {
View Full Code Here

        final DBCollection collection = _mongoDb.getCollection(table.getName());

        final DBObject query = createMongoDbQuery(table, whereItems);

        logger.info("Executing MongoDB 'find' query: {}", query);
        DBCursor cursor = collection.find(query);

        if (maxRows > 0) {
            cursor = cursor.limit(maxRows);
        }
        if (firstRow > 1) {
View Full Code Here

     *            the name of the collection
     * @return a table definition for mongo db.
     */
    public static SimpleTableDef detectTable(DB db, String collectionName) {
        final DBCollection collection = db.getCollection(collectionName);
        final DBCursor cursor = collection.find().limit(1000);

        final SortedMap<String, Set<Class<?>>> columnsAndTypes = new TreeMap<String, Set<Class<?>>>();
        while (cursor.hasNext()) {
            DBObject object = cursor.next();
            Set<String> keysInObject = object.keySet();
View Full Code Here

        range.getTargetID()).append("logId", range.getLogID());
    if (high > 0) {
      filter.append("id", new BasicDBObject("$lte", high));
    }

    DBCursor cursor = collection.find(filter);
    cursor.sort(new BasicDBObject("id", 1));

    List<LogEvent> logevents = new ArrayList<LogEvent>();
    while (cursor.hasNext()) {
      DBObject event = cursor.next();
View Full Code Here

    DBCollection collection = m_mongoDBService.getDB().getCollection(m_logname);

    BasicDBObject filter = new BasicDBObject().append("targetId", targetID)
        .append("logId", logID);

    DBCursor cursor = collection.find(filter);
    cursor.sort(new BasicDBObject("id", -1));

    long high = 1;
    if (cursor.hasNext()) {
      DBObject row = cursor.next();
View Full Code Here

        try {
            final DB db = this.getDB(dbname, authusername, authpassword);
            if (null != db) {
                if (db.collectionExists(COLL_SYSTEMUSERS)) {
                    final DBCollection coll = db.getCollection(COLL_SYSTEMUSERS);
                    return coll.find().toArray();
                }
            }
        } catch (Throwable t) {
            throw this.getError500(t);
        }
View Full Code Here

        queryBuilder.and("_id").greaterThan(parent + "/");
        queryBuilder.and("_id").lessThanEquals(parent + "0");
        DBObject query = queryBuilder.get();
        BasicDBObject keys = new BasicDBObject();
        keys.put("_id", 1);
        DBCursor cursor = nodes.find(query, keys);
        int count = 0;
        log("Query plan: " + cursor.explain());
        long time = System.currentTimeMillis();
        while (cursor.hasNext()) {
            DBObject obj = cursor.next();
View Full Code Here

        queryBuilder.greaterThanEquals(fromKey);
        queryBuilder.lessThan(toKey);
        DBObject query = queryBuilder.get();
        long start = start();
        try {
            DBCursor cursor = dbCollection.find(query);
            List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
            for (int i = 0; i < limit && cursor.hasNext(); i++) {
                DBObject o = cursor.next();
                Map<String, Object> map = convertFromDBObject(o);
                if (collection == Collection.NODES) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.