Examples of DBCursor


Examples of com.mongodb.DBCursor

        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();
      String targetId = (String) event.get("targetId");
      long logId = (Long) event.get("logId");
      long id = (Long) event.get("id");
      long time = (Long) event.get("time");
      int type = (Integer) event.get("type");
View Full Code Here

Examples of com.mongodb.DBCursor

    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();
      high = (Long) row.get("id");
      return new LogDescriptor(targetID, logID, new SortedRangeSet(
          new Range(1, high).toRepresentation()));
    } else {
      return new LogDescriptor(targetID, logID, SortedRangeSet.FULL_SET);
View Full Code Here

Examples of com.mongodb.DBCursor

        return this.find(filter, null, null, null);
    }

    public List<DBObject> find() {
        if (null != _coll) {
            final DBCursor cursor = _coll.find();
            return null != cursor ? cursor.toArray() : new ArrayList<DBObject>();
        }
        return null;
    }
View Full Code Here

Examples of com.mongodb.DBCursor

    }

    public List<DBObject> find(final DBObject filter, final String[] fieldNames,
            final String[] sortAscBy, final String[] sortDescBy) {
        if (null != _coll) {
            final DBCursor cursor = this.cursor(
                    filter, fieldNames, 0, 0, sortAscBy, sortDescBy);
            return null != cursor
                    ? cursor.toArray()
                    : new ArrayList<DBObject>();
        }
        return null;
    }
View Full Code Here

Examples of com.mongodb.DBCursor

     */
    public List<DBObject> find(final DBObject filter, final String[] fieldNames,
            final int skip, final int limit,
            final String[] sortAscBy, final String[] sortDescBy) {
        if (null != _coll) {
            final DBCursor cursor = this.cursor(
                    filter, fieldNames, skip, limit, sortAscBy, sortDescBy);
            return null != cursor
                    ? cursor.toArray()
                    : new ArrayList<DBObject>();
        }
        return null;
    }
View Full Code Here

Examples of com.mongodb.DBCursor

        return new ArrayList<String>();
    }
    // </editor-fold>

    public int count(final DBObject filter) {
        DBCursor cursor;
        if (null != filter) {
            cursor = null != _coll ? _coll.find(filter) : null;
        } else {
            cursor = null != _coll ? _coll.find() : null;
        }
        return null != cursor ? cursor.count() : 0;
    }
View Full Code Here

Examples of com.mongodb.DBCursor

    private DBCursor cursor(final DBObject filter, final String[] fieldNames,
            final int skip, final int limit,
            final String[] sortAscBy, final String[] sortDescBy) {
        if (null != _coll) {
            DBCursor cursor;
            final DBObject fields = this.getFields(fieldNames, true);
            final DBObject sort = BeeMongoUtils.getSortFields(sortAscBy, sortDescBy);
            if (null != filter) {
                cursor = null != fields
                        ? _coll.find(filter, fields)
                        : _coll.find(filter);
            } else {
                cursor = null != fields
                        ? _coll.find(new BasicDBObject(), fields)
                        : _coll.find();
            }

            // limit data
            if (skip > 0 || limit > 0) {
                if (skip > 0) {
                    cursor = cursor.skip(skip);
                }
                if (limit > 0) {
                    cursor = cursor.limit(limit);
                }
            }

            // sort
            if (null != cursor && null != sort) {
                cursor = cursor.sort(sort);
            }

            return cursor;
        }
        return null;
View Full Code Here

Examples of com.mongodb.DBCursor

        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();
            // dummy read operation (to ensure we did get the data)
            obj.get("_id");
            count++;
            // log(" read " + obj);
        }
View Full Code Here

Examples of com.mongodb.DBCursor

        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) {
                    String key = (String) map.get(UpdateOp.ID);
                    nodesCache.put(key, new CachedDocument(map));
                }
View Full Code Here

Examples of com.mongodb.DBCursor

            if (this.lastHeadRevId < syncMongo.getHeadRevisionId()) {
                DBCollection commitCollection = ((MongoNodeStore)microKernel.getNodeStore()).getCommitCollection();
                DBObject query = QueryBuilder.start(MongoCommit.KEY_REVISION_ID).greaterThan(this.lastRevId)
                        .and(MongoCommit.KEY_REVISION_ID).lessThanEquals(syncMongo.getHeadRevisionId()).get();
                DBObject sort = QueryBuilder.start(MongoCommit.KEY_REVISION_ID).is(1).get();
                DBCursor dbCursor = commitCollection.find(query).sort(sort);
                while (dbCursor.hasNext()) {
                    commitMongos.add((MongoCommit) dbCursor.next());
                }

                if (commitMongos.size() > 0) {
                    LOG.debug(String.format("Found %d new commits", commitMongos.size()));
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.