コード例 #1
0
 /**
  * Returns an object containing basic information about the execution of the query that created
  * this cursor This creates a <code>DBObject</code> with the key/value pairs: "cursor" : cursor
  * type "nScanned" : number of records examined by the database for this query "n" : the number of
  * records that the database returned "millis" : how long it took the database to execute the
  * query
  *
  * @return a <code>DBObject</code>
  * @dochub explain
  */
 public DBObject explain() {
   DBCursor c = copy();
   c._explain = true;
   if (c._limit > 0) {
     // need to pass a negative batchSize as limit for explain
     c._batchSize = c._limit * -1;
     c._limit = 0;
   }
   return c.next();
 }
コード例 #2
0
 /**
  * Creates a copy of an existing database cursor. The new cursor is an iterator, even if the
  * original was an array.
  *
  * @return the new cursor
  */
 public DBCursor copy() {
   DBCursor c = new DBCursor(_collection, _query, _keysWanted, _readPref);
   c._orderBy = _orderBy;
   c._hint = _hint;
   c._hintDBObj = _hintDBObj;
   c._limit = _limit;
   c._skip = _skip;
   c._options = _options;
   c._batchSize = _batchSize;
   c._snapshot = _snapshot;
   c._explain = _explain;
   if (_specialFields != null) c._specialFields = new BasicDBObject(_specialFields.toMap());
   return c;
 }