/** * Get the name of the database that the results of the map reduce were saved into. If the map reduce was an inline operation (i.e . * the results were returned directly from calling the map reduce) this will return null. * * @return the name of the database that holds the collection that the map reduce results are stored in */ public String getDatabaseName() { return collection.getDB().getName(); }
BufferProvider getBufferPool() { return getDB().getBufferPool(); }
private DBCollection getMapReduceOutputCollection(final MapReduceCommand command) { String requestedDatabaseName = command.getOutputDB(); DB database = requestedDatabaseName != null ? getDB().getSisterDB(requestedDatabaseName) : getDB(); return database.getCollection(command.getOutputTargetNonNull()); }
private boolean isCursorFinalizerEnabled() { return collection.getDB().getMongo().getMongoClientOptions().isCursorFinalizerEnabled(); }
MongoNamespace getNamespace() { return new MongoNamespace(getDB().getName(), getName()); }
/** * The collStats command returns a variety of storage statistics for a given collection * * @return a CommandResult containing the statistics about this collection * @mongodb.driver.manual reference/command/collStats/ collStats Command */ public CommandResult getStats() { return getDB().executeCommand(new BsonDocument("collStats", new BsonString(getName())), getReadPreference()); }
private void initializeCursor(final FindOperation<DBObject> operation) { cursor = new MongoBatchCursorAdapter<DBObject>(executor.execute(operation, getReadPreferenceForCursor(), getReadConcern())); if (isCursorFinalizerEnabled() && cursor.getServerCursor() != null) { optionalFinalizer = new OptionalFinalizer(collection.getDB().getMongo(), collection.getNamespace()); } }
/** * Change the name of an existing collection. * * @param newName specifies the new name of the collection * @param dropTarget If {@code true}, mongod will drop the collection with the target name if it exists * @return the collection with new name * @throws MongoException if target is the name of an existing collection and {@code dropTarget=false}. * @mongodb.driver.manual reference/command/renameCollection/ Rename Collection */ public DBCollection rename(final String newName, final boolean dropTarget) { try { executor.execute(new RenameCollectionOperation(getNamespace(), new MongoNamespace(getNamespace().getDatabaseName(), newName), getWriteConcern()) .dropTarget(dropTarget), getReadConcern()); return getDB().getCollection(newName); } catch (MongoWriteConcernException e) { throw createWriteConcernException(e); } }
@SuppressWarnings("deprecation") MapReduceCommand toCommand(final Mapper mapper) { if (query.getOffset() != 0 || query.getFieldsObject() != null) { throw new QueryException("mapReduce does not allow the offset/retrievedFields query "); } final DBCollection dbColl = inputCollection != null ? getQuery().getCollection().getDB().getCollection(inputCollection) : query.getCollection(); final String target = outputCollection != null ? outputCollection : mapper.getMappedClass(resultType).getCollectionName(); final MapReduceCommand command = new MapReduceCommand(dbColl, map, reduce, target, outputType, query.getQueryObject()); command.setBypassDocumentValidation(bypassDocumentValidation); command.setCollation(collation); command.setFinalize(finalize); command.setJsMode(jsMode); command.setLimit(limit); command.setMaxTime(maxTimeMS, TimeUnit.MILLISECONDS); command.setOutputDB(outputDB); command.setReadPreference(readPreference); command.setScope(scope); command.setSort(query.getSortObject()); command.setVerbose(verbose); return command; } }
/** * Returns the database this collection is a member of. * * @return this collection's database */ public DB getDB() { return dbCollection.getDB(); }
/** * Get the name of the database that the results of the map reduce were saved into. If the map reduce was an inline operation (i.e . * the results were returned directly from calling the map reduce) this will return null. * * @return the name of the database that holds the collection that the map reduce results are stored in */ public String getDatabaseName() { return collection.getDB().getName(); }
@Override public void close(final TaskAttemptContext context) { if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { LOG.error("Could not close output stream", e); } } MongoConfigUtil.close(collection.getDB().getMongo()); }
/** * Parameterized constructor with collection. * * @param collection * the collection to set */ public PropertyStoreMongoDB(DBCollection collection) { this.propertiesCollection = collection; this.collectionName = collection.getName(); this.dbName = collection.getDB().getName(); }
/** * Parameterized constructor with collection. * * @param collection * the collection to set */ public FeatureStoreMongoDB(DBCollection collection) { this.featuresCollection = collection; this.collectionName = featuresCollection.getName(); this.dbName = featuresCollection.getDB().getName(); }
@Override public List<ServerAddress> servers() { return rrdCollection.getDB().getMongo().getServerAddressList(); } @Override
private DBCollection getMapReduceOutputCollection(final MapReduceCommand command) { String requestedDatabaseName = command.getOutputDB(); DB database = requestedDatabaseName != null ? getDB().getSisterDB(requestedDatabaseName) : getDB(); return database.getCollection(command.getOutputTargetNonNull()); }
public void close() { if (cursor != null) { cursor.close(); MongoConfigUtil.close(cursor.getCollection().getDB().getMongo()); } }
/** * The collStats command returns a variety of storage statistics for a given collection * * @return a CommandResult containing the statistics about this collection * @mongodb.driver.manual reference/command/collStats/ collStats Command */ public CommandResult getStats() { return getDB().executeCommand(new BsonDocument("collStats", new BsonString(getName())), getReadPreference()); }
private void initializeCursor(final FindOperation<DBObject> operation) { cursor = new MongoBatchCursorAdapter<DBObject>(executor.execute(operation, getReadPreferenceForCursor(), getReadConcern())); if (isCursorFinalizerEnabled() && cursor.getServerCursor() != null) { optionalFinalizer = new OptionalFinalizer(collection.getDB().getMongo(), collection.getNamespace()); } }