/** * Checks whether this collection is capped * * @return true if this is a capped collection * @mongodb.driver.manual /core/capped-collections/#check-if-a-collection-is-capped Capped Collections */ public boolean isCapped() { CommandResult commandResult = getStats(); Object cappedField = commandResult.get("capped"); return cappedField != null && (cappedField.equals(1) || cappedField.equals(true)); }
/** * 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")); }
/** * gets the collections statistics ("collstats" command) * * @return the stats */ public CommandResult getStats() { return dbCollection.getStats(); }
/** * gets the collections statistics ("collstats" command) * * @return the stats */ public CommandResult getStats() { return dbCollection.getStats(); }
/** * gets the collections statistics ("collstats" command) * * @return the stats */ public CommandResult getStats() { return dbCollection.getStats(); }
CommandResult stats = collection.getStats();
/** * Checks whether this collection is capped * * @return true if this is a capped collection * @mongodb.driver.manual /core/capped-collections/#check-if-a-collection-is-capped Capped Collections */ public boolean isCapped() { CommandResult commandResult = getStats(); Object cappedField = commandResult.get("capped"); return cappedField != null && (cappedField.equals(1) || cappedField.equals(true)); }
private byte[][] calculateRegionSplits(MongoURI uri, String tableName) throws Exception { DBCollection collection = uri.connectDB().getCollection(uri.getCollection()); long size = collection.getStats().getLong("size"); long regionSize = ConfigUtil.getPresplitTableRegionSize(_conf); int numRegions = (int) Math.min((size / regionSize) + 1, 4096); if (numRegions > 1) { log.info("Pre-splitting " + tableName + " into " + numRegions + " regions"); RegionSplitter.UniformSplit splitter = new RegionSplitter.UniformSplit(); return splitter.split(numRegions); } else { log.info("Not splitting " + tableName + ", because the data can fit into a single region"); return new byte[0][0]; } }
final CommandResult stats = coll.getStats();
final CommandResult stats = coll.getStats();
final CommandResult stats = coll.getStats();
final CommandResult stats = coll.getStats();
final CommandResult stats = coll.getStats();
CommandResult stats = collection.getStats();
@Override public int getCollectionCount(String dbCollectionName) { CheckConditions.checkNotNull(dbCollectionName, "Collection name can't be null!"); Integer count = cacheManager.getCountFromCache(dbCollectionName); if (count == null) { DBCollection col = this.mongo.getDB(repo.getRepositoryName()).getCollection(dbCollectionName); // read from primary only col.setReadPreference(ReadPreference.primary()); col.setWriteConcern(WriteConcern.SAFE); count = (Integer) col.getStats().get("count"); if (count == null) { count = 0; } else { cacheManager.putCountToCache(dbCollectionName, count); } } return count; }
CommandResult stats = inputCollection.getStats(); if (stats.containsField("primary")) { DBCursor shards = inputCollection.getDB().getSisterDB("config")
final CommandResult stats = inputCollection.getStats(); if (stats.containsField("primary")) { final DBCursor shards = inputCollection.getDB().getSisterDB("config")