All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mongodb.internal.operation.AsyncOperations Maven / Gradle / Ivy

Go to download

The MongoDB Java Driver uber-artifact, containing mongodb-driver, mongodb-driver-core, and bson

There is a newer version: 3.12.14
Show newest version
/*
 * Copyright 2008-present MongoDB, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mongodb.internal.operation;

import com.mongodb.MongoNamespace;
import com.mongodb.ReadPreference;
import com.mongodb.WriteConcern;
import com.mongodb.async.AsyncBatchCursor;
import com.mongodb.bulk.BulkWriteResult;
import com.mongodb.client.model.BulkWriteOptions;
import com.mongodb.client.model.Collation;
import com.mongodb.client.model.CountOptions;
import com.mongodb.internal.client.model.CountStrategy;
import com.mongodb.client.model.CreateIndexOptions;
import com.mongodb.client.model.DeleteOptions;
import com.mongodb.client.model.DropIndexOptions;
import com.mongodb.client.model.FindOneAndDeleteOptions;
import com.mongodb.client.model.FindOneAndReplaceOptions;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.FindOptions;
import com.mongodb.client.model.IndexModel;
import com.mongodb.client.model.InsertManyOptions;
import com.mongodb.client.model.InsertOneOptions;
import com.mongodb.client.model.MapReduceAction;
import com.mongodb.client.model.RenameCollectionOptions;
import com.mongodb.client.model.ReplaceOptions;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.model.WriteModel;
import com.mongodb.operation.AsyncReadOperation;
import com.mongodb.operation.AsyncWriteOperation;
import com.mongodb.operation.MapReduceAsyncBatchCursor;
import com.mongodb.operation.MapReduceStatistics;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.conversions.Bson;

import java.util.List;

/**
 * This class is NOT part of the public API. It may change at any time without notification.
 */
public final class AsyncOperations {
    private final Operations operations;

    public AsyncOperations(final Class documentClass, final ReadPreference readPreference,
                           final CodecRegistry codecRegistry) {
        this(null, documentClass, readPreference, codecRegistry, WriteConcern.ACKNOWLEDGED, false);
    }

    public AsyncOperations(final MongoNamespace namespace, final Class documentClass, final ReadPreference readPreference,
                           final CodecRegistry codecRegistry) {
        this(namespace, documentClass, readPreference, codecRegistry, WriteConcern.ACKNOWLEDGED, false);
    }

    public AsyncOperations(final MongoNamespace namespace, final Class documentClass, final ReadPreference readPreference,
                           final CodecRegistry codecRegistry, final WriteConcern writeConcern, final boolean retryWrites) {
        this.operations = new Operations(namespace, documentClass, readPreference, codecRegistry, writeConcern, retryWrites);
    }

    public AsyncReadOperation count(final Bson filter, final CountOptions options, final CountStrategy countStrategy) {
        return operations.count(filter, options, countStrategy);
    }

    public  AsyncReadOperation> findFirst(final Bson filter, final Class resultClass,
                                                                             final FindOptions options) {
        return operations.findFirst(filter, resultClass, options);
    }

    public  AsyncReadOperation> find(final Bson filter, final Class resultClass,
                                                                        final FindOptions options) {
        return operations.find(filter, resultClass, options);
    }

    public  AsyncReadOperation> find(final MongoNamespace findNamespace, final Bson filter,
                                                                        final Class resultClass, final FindOptions options) {
        return operations.find(findNamespace, filter, resultClass, options);
    }

    public  AsyncReadOperation> distinct(final String fieldName, final Bson filter,
                                                                            final Class resultClass, final long maxTimeMS,
                                                                            final Collation collation) {
        return operations.distinct(fieldName, filter, resultClass, maxTimeMS, collation);
    }

    public  AsyncReadOperation> aggregate(final List pipeline,
                                                                             final Class resultClass,
                                                                             final long maxTimeMS, final long maxAwaitTimeMS,
                                                                             final Integer batchSize, final Collation collation,
                                                                             final Bson hint, final String comment,
                                                                             final Boolean allowDiskUse, final Boolean useCursor) {
        return operations.aggregate(pipeline, resultClass, maxTimeMS, maxAwaitTimeMS, batchSize, collation, hint, comment, allowDiskUse,
                useCursor);
    }

    public AsyncWriteOperation aggregateToCollection(final List pipeline, final long maxTimeMS,
                                                           final Boolean allowDiskUse, final Boolean bypassDocumentValidation,
                                                           final Collation collation, final Bson hint, final String comment) {
        return operations.aggregateToCollection(pipeline, maxTimeMS, allowDiskUse, bypassDocumentValidation, collation, hint, comment);
    }

    public AsyncWriteOperation mapReduceToCollection(final String databaseName, final String collectionName,
                                                                          final String mapFunction, final String reduceFunction,
                                                                          final String finalizeFunction, final Bson filter, final int limit,
                                                                          final long maxTimeMS, final boolean jsMode, final Bson scope,
                                                                          final Bson sort, final boolean verbose,
                                                                          final MapReduceAction action, final boolean nonAtomic,
                                                                          final boolean sharded, final Boolean bypassDocumentValidation,
                                                                          final Collation collation) {
        return operations.mapReduceToCollection(databaseName, collectionName, mapFunction, reduceFunction, finalizeFunction, filter, limit,
                maxTimeMS, jsMode, scope, sort, verbose, action, nonAtomic, sharded, bypassDocumentValidation, collation);
    }

    public  AsyncReadOperation> mapReduce(final String mapFunction, final String reduceFunction,
                                                                                      final String finalizeFunction,
                                                                                      final Class resultClass,
                                                                                      final Bson filter, final int limit,
                                                                                      final long maxTimeMS, final boolean jsMode,
                                                                                      final Bson scope, final Bson sort,
                                                                                      final boolean verbose, final Collation collation) {
        return operations.mapReduce(mapFunction, reduceFunction, finalizeFunction, resultClass, filter, limit, maxTimeMS, jsMode, scope,
                sort, verbose, collation);
    }

    public AsyncWriteOperation findOneAndDelete(final Bson filter, final FindOneAndDeleteOptions options) {
        return operations.findOneAndDelete(filter, options);
    }

    public AsyncWriteOperation findOneAndReplace(final Bson filter, final TDocument replacement,
                                                            final FindOneAndReplaceOptions options) {
        return operations.findOneAndReplace(filter, replacement, options);
    }

    public AsyncWriteOperation findOneAndUpdate(final Bson filter, final Bson update, final FindOneAndUpdateOptions options) {
        return operations.findOneAndUpdate(filter, update, options);
    }

    public AsyncWriteOperation insertOne(final TDocument document, final InsertOneOptions options) {
        return operations.insertOne(document, options);
    }


    public AsyncWriteOperation replaceOne(final Bson filter, final TDocument replacement, final ReplaceOptions options) {
        return operations.replaceOne(filter, replacement, options);
    }

    public AsyncWriteOperation deleteOne(final Bson filter, final DeleteOptions options) {
        return operations.deleteOne(filter, options);
    }

    public AsyncWriteOperation deleteMany(final Bson filter, final DeleteOptions options) {
        return operations.deleteMany(filter, options);
    }

    public AsyncWriteOperation updateOne(final Bson filter, final Bson update, final UpdateOptions updateOptions) {
        return operations.updateOne(filter, update, updateOptions);
    }

    public AsyncWriteOperation updateMany(final Bson filter, final Bson update, final UpdateOptions updateOptions) {
        return operations.updateMany(filter, update, updateOptions);
    }

    public AsyncWriteOperation insertMany(final List documents,
                                                           final InsertManyOptions options) {
        return operations.insertMany(documents, options);
    }

    @SuppressWarnings("unchecked")
    public AsyncWriteOperation bulkWrite(final List> requests,
                                                          final BulkWriteOptions options) {
        return operations.bulkWrite(requests, options);
    }


    public AsyncWriteOperation dropCollection() {
        return operations.dropCollection();
    }

    public AsyncWriteOperation renameCollection(final MongoNamespace newCollectionNamespace,
                                                      final RenameCollectionOptions options) {
        return operations.renameCollection(newCollectionNamespace, options);
    }

    public AsyncWriteOperation createIndexes(final List indexes, final CreateIndexOptions options) {
        return operations.createIndexes(indexes, options);
    }

    public AsyncWriteOperation dropIndex(final String indexName, final DropIndexOptions options) {
        return operations.dropIndex(indexName, options);
    }

    public AsyncWriteOperation dropIndex(final Bson keys, final DropIndexOptions options) {
        return operations.dropIndex(keys, options);
    }

    public  AsyncReadOperation> listCollections(final String databaseName,
                                                                                   final Class resultClass, final Bson filter,
                                                                                   final boolean collectionNamesOnly,
                                                                                   final Integer batchSize, final long maxTimeMS) {
        return operations.listCollections(databaseName, resultClass, filter, collectionNamesOnly, batchSize, maxTimeMS);
    }

    public  AsyncReadOperation> listDatabases(final Class resultClass, final Bson filter,
                                                                                 final Boolean nameOnly, final long maxTimeMS) {
        return operations.listDatabases(resultClass, filter, nameOnly, maxTimeMS);
    }

    public  AsyncReadOperation> listIndexes(final Class resultClass, final Integer batchSize,
                                                                               final long maxTimeMS) {
        return operations.listIndexes(resultClass, batchSize, maxTimeMS);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy