/** * Only calls DBCollection.count() when using vanilla MongoDB; otherwise gets estimate from collection.getStats() */ private String safeCount(DBCollection collection, Class<? extends Timestamp> type) { if (type.equals(Timestamp.BSON.class)) { return "" + collection.count(); // Vanilla MongoDB can quickly return precise count } CommandResult stats = collection.getStats(); return "~" + (!stats.containsField("count") ? 0l : stats.getLong("count")); }
dbStatsResult.getLong("indexes"), dbStatsResult.getLong("indexSize"), dbStatsResult.containsField("fileSize") ? dbStatsResult.getLong("fileSize") : null, dbStatsResult.containsField("nsSizeMB") ? dbStatsResult.getLong("nsSizeMB") : null, extentFreeList, dataFileVersion
/** * @return number of affected documents */ protected int getN() { return wr.getLastError().containsField("n") ? ((Number) wr.getLastError().get("n")).intValue() : 0; }
/** * @return number of affected documents */ protected int getN() { return wr.getLastError().containsField("n") ? ((Number) wr.getLastError().get("n")).intValue() : 0; }
/** @return number of affected documents */ protected int getN() { return wr.getLastError().containsField("n") ? ((Number)wr.getLastError().get("n")).intValue() : 0; }
/** * @return true if updated, false if inserted or none effected */ public boolean getUpdatedExisting() { return wr.getLastError().containsField("updatedExisting") ? (Boolean) wr.getLastError().get("updatedExisting") : false; }
/** @return true if updated, false if inserted or none effected*/ public boolean getUpdatedExisting() { return wr.getLastError().containsField("updatedExisting") ? (Boolean)wr.getLastError().get("updatedExisting") : false; }
/** * @return true if updated, false if inserted or none effected */ public boolean getUpdatedExisting() { return wr.getLastError().containsField("updatedExisting") ? (Boolean) wr.getLastError().get("updatedExisting") : false; }
/** * @return the new _id field if an insert/upsert was performed */ public Object getNewId() { return getInsertedCount() == 1 && wr.getLastError().containsField("upserted") ? wr.getLastError().get("upserted") : null; }
/** * @return the new _id field if an insert/upsert was performed */ public Object getNewId() { return getInsertedCount() == 1 && wr.getLastError().containsField("upserted") ? wr.getLastError().get("upserted") : null; }
/** @return the new _id field if an insert/upsert was performed */ public Object getNewId() { return getInsertedCount() == 1 && wr.getLastError().containsField("upserted") ? wr.getLastError().get("upserted") : null ; }
CommandResult data = coll.getDB().command( cmd ); if ( data.containsField( "$err" ) ) throw new IllegalArgumentException( "Error calculating splits: " + data ); else if ( (Double) data.get( "ok" ) != 1.0 )
CommandResult data = coll.getDB().command( cmd ); if ( data.containsField( "$err" ) ) throw new IllegalArgumentException( "Error calculating splits: " + data ); else if ( (Double) data.get( "ok" ) != 1.0 )
CommandResult data = coll.getDB().command( cmd ); if ( data.containsField( "$err" ) ) throw new IllegalArgumentException( "Error calculating splits: " + data ); else if ( (Double) data.get( "ok" ) != 1.0 )
CommandResult data = coll.getDB().command( cmd ); if ( data.containsField( "$err" ) ) throw new IllegalArgumentException( "Error calculating splits: " + data ); else if ( (Double) data.get( "ok" ) != 1.0 )
CommandResult data = coll.getDB().command( cmd ); if ( data.containsField( "$err" ) ) throw new IllegalArgumentException( "Error calculating splits: " + data ); else if ( (Double) data.get( "ok" ) != 1.0 )
if (data.containsField("$err")) { throw new SplitFailedException("Error calculating splits: " + data); } else if (!data.get("ok").equals(1.0)) { if (stats.containsField("primary")) { DBCursor shards = inputCollection.getDB().getSisterDB("config") .getCollection("shards")
if (data.containsField("$err")) { throw new SplitFailedException("Error calculating splits: " + data); } else if (!data.get("ok").equals(1.0)) { if (stats.containsField("primary")) { final DBCursor shards = inputCollection.getDB().getSisterDB("config") .getCollection("shards")
dbStatsResult.getLong("indexes"), dbStatsResult.getLong("indexSize"), dbStatsResult.containsField("fileSize") ? dbStatsResult.getLong("fileSize") : null, dbStatsResult.containsField("nsSizeMB") ? dbStatsResult.getLong("nsSizeMB") : null, extentFreeList, dataFileVersion