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

com.landawn.abacus.util.AsyncMongoCollectionExecutor Maven / Gradle / Ivy

There is a newer version: 1.10.1
Show newest version
/*
 * Copyright (C) 2015 HaiYang Li
 *
 * 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.landawn.abacus.util;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;

import org.bson.Document;
import org.bson.conversions.Bson;
import org.bson.types.ObjectId;

import com.landawn.abacus.DataSet;
import com.landawn.abacus.annotation.Beta;
import com.landawn.abacus.util.u.Nullable;
import com.landawn.abacus.util.u.Optional;
import com.landawn.abacus.util.u.OptionalBoolean;
import com.landawn.abacus.util.u.OptionalByte;
import com.landawn.abacus.util.u.OptionalChar;
import com.landawn.abacus.util.u.OptionalDouble;
import com.landawn.abacus.util.u.OptionalFloat;
import com.landawn.abacus.util.u.OptionalInt;
import com.landawn.abacus.util.u.OptionalLong;
import com.landawn.abacus.util.u.OptionalShort;
import com.landawn.abacus.util.stream.Stream;
import com.mongodb.bulk.BulkWriteResult;
import com.mongodb.client.model.BulkWriteOptions;
import com.mongodb.client.model.CountOptions;
import com.mongodb.client.model.DeleteOptions;
import com.mongodb.client.model.InsertManyOptions;
import com.mongodb.client.model.InsertOneOptions;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.model.WriteModel;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;

/**
 * Asynchronous MongoCollectionExecutor.
 *
 * @since 0.8
 * 
 * @author Haiyang Li
 */
public final class AsyncMongoCollectionExecutor {
    private final MongoCollectionExecutor collExecutor;
    private final AsyncExecutor asyncExecutor;

    AsyncMongoCollectionExecutor(final MongoCollectionExecutor collExecutor, final AsyncExecutor asyncExecutor) {
        this.collExecutor = collExecutor;
        this.asyncExecutor = asyncExecutor;
    }

    public MongoCollectionExecutor sync() {
        return collExecutor;
    }

    public ContinuableFuture exists(final String objectId) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Boolean call() throws Exception {
                return collExecutor.exists(objectId);
            }
        });
    }

    public ContinuableFuture exists(final ObjectId objectId) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Boolean call() throws Exception {
                return collExecutor.exists(objectId);
            }
        });
    }

    public ContinuableFuture exists(final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Boolean call() throws Exception {
                return collExecutor.exists(filter);
            }
        });
    }

    public ContinuableFuture count() {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Long call() throws Exception {
                return collExecutor.count();
            }
        });
    }

    public ContinuableFuture count(final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Long call() throws Exception {
                return collExecutor.count(filter);
            }
        });
    }

    public ContinuableFuture count(final Bson filter, final CountOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Long call() throws Exception {
                return collExecutor.count(filter, options);
            }
        });
    }

    public ContinuableFuture> get(final String objectId) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.get(objectId);
            }
        });
    }

    public ContinuableFuture> get(final ObjectId objectId) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.get(objectId);
            }
        });
    }

    public  ContinuableFuture> get(final Class targetClass, final String objectId) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.get(targetClass, objectId);
            }
        });
    }

    public  ContinuableFuture> get(final Class targetClass, final ObjectId objectId) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.get(targetClass, objectId);
            }
        });
    }

    public  ContinuableFuture> get(final Class targetClass, final String objectId, final Collection selectPropNames) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.get(targetClass, objectId, selectPropNames);
            }
        });
    }

    public  ContinuableFuture> get(final Class targetClass, final ObjectId objectId, final Collection selectPropNames) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.get(targetClass, objectId, selectPropNames);
            }
        });
    }

    public ContinuableFuture gett(final String objectId) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Document call() throws Exception {
                return collExecutor.gett(objectId);
            }
        });
    }

    public ContinuableFuture gett(final ObjectId objectId) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Document call() throws Exception {
                return collExecutor.gett(objectId);
            }
        });
    }

    public  ContinuableFuture gett(final Class targetClass, final String objectId) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return collExecutor.gett(targetClass, objectId);
            }
        });
    }

    public  ContinuableFuture gett(final Class targetClass, final ObjectId objectId) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return collExecutor.gett(targetClass, objectId);
            }
        });
    }

    public  ContinuableFuture gett(final Class targetClass, final String objectId, final Collection selectPropNames) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return collExecutor.gett(targetClass, objectId, selectPropNames);
            }
        });
    }

    public  ContinuableFuture gett(final Class targetClass, final ObjectId objectId, final Collection selectPropNames) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return collExecutor.gett(targetClass, objectId, selectPropNames);
            }
        });
    }

    public ContinuableFuture> findFirst(final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.findFirst(filter);
            }
        });
    }

    public  ContinuableFuture> findFirst(final Class targetClass, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.findFirst(targetClass, filter);
            }
        });
    }

    public  ContinuableFuture> findFirst(final Class targetClass, final Collection selectPropNames, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.findFirst(targetClass, selectPropNames, filter);
            }
        });
    }

    public  ContinuableFuture> findFirst(final Class targetClass, final Collection selectPropNames, final Bson filter,
            final Bson sort) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.findFirst(targetClass, selectPropNames, filter, sort);
            }
        });
    }

    public  ContinuableFuture> findFirst(final Class targetClass, final Bson filter, final Bson sort, final Bson projection) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return collExecutor.findFirst(targetClass, filter, sort, projection);
            }
        });
    }

    public ContinuableFuture> list(final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return collExecutor.list(filter);
            }
        });
    }

    public  ContinuableFuture> list(final Class targetClass, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return collExecutor.list(targetClass, filter);
            }
        });
    }

    public  ContinuableFuture> list(final Class targetClass, final Collection selectPropNames, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return collExecutor.list(targetClass, selectPropNames, filter);
            }
        });
    }

    public  ContinuableFuture> list(final Class targetClass, final Collection selectPropNames, final Bson filter, final int offset,
            final int count) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return collExecutor.list(targetClass, selectPropNames, filter, offset, count);
            }
        });
    }

    public  ContinuableFuture> list(final Class targetClass, final Collection selectPropNames, final Bson filter, final Bson sort) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return collExecutor.list(targetClass, selectPropNames, filter, sort);
            }
        });
    }

    public  ContinuableFuture> list(final Class targetClass, final Collection selectPropNames, final Bson filter, final Bson sort,
            final int offset, final int count) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return collExecutor.list(targetClass, selectPropNames, filter, sort, offset, count);
            }
        });
    }

    public  ContinuableFuture> list(final Class targetClass, final Bson filter, final Bson sort, final Bson projection) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return collExecutor.list(targetClass, filter, sort, projection);
            }
        });
    }

    public  ContinuableFuture> list(final Class targetClass, final Bson filter, final Bson sort, final Bson projection, final int offset,
            final int count) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return collExecutor.list(targetClass, filter, sort, projection, offset, count);
            }
        });
    }

    public ContinuableFuture queryForBoolean(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalBoolean call() throws Exception {
                return collExecutor.queryForBoolean(propName, filter);
            }
        });
    }

    public ContinuableFuture queryForChar(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalChar call() throws Exception {
                return collExecutor.queryForChar(propName, filter);
            }
        });
    }

    public ContinuableFuture queryForByte(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalByte call() throws Exception {
                return collExecutor.queryForByte(propName, filter);
            }
        });
    }

    public ContinuableFuture queryForShort(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalShort call() throws Exception {
                return collExecutor.queryForShort(propName, filter);
            }
        });
    }

    public ContinuableFuture queryForInt(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalInt call() throws Exception {
                return collExecutor.queryForInt(propName, filter);
            }
        });
    }

    public ContinuableFuture queryForLong(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalLong call() throws Exception {
                return collExecutor.queryForLong(propName, filter);
            }
        });
    }

    public ContinuableFuture queryForFloat(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalFloat call() throws Exception {
                return collExecutor.queryForFloat(propName, filter);
            }
        });
    }

    public ContinuableFuture queryForDouble(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalDouble call() throws Exception {
                return collExecutor.queryForDouble(propName, filter);
            }
        });
    }

    public ContinuableFuture> queryForString(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return collExecutor.queryForString(propName, filter);
            }
        });
    }

    public ContinuableFuture> queryForDate(final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return collExecutor.queryForDate(propName, filter);
            }
        });
    }

    public  ContinuableFuture> queryForDate(final Class targetClass, final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return collExecutor.queryForDate(targetClass, propName, filter);
            }
        });
    }

    public  ContinuableFuture> queryForSingleResult(final Class targetClass, final String propName, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return collExecutor.queryForSingleResult(targetClass, propName, filter);
            }
        });
    }

    public ContinuableFuture query(final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return collExecutor.query(filter);
            }
        });
    }

    public  ContinuableFuture query(final Class targetClass, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return collExecutor.query(targetClass, filter);
            }
        });
    }

    public  ContinuableFuture query(final Class targetClass, final Collection selectPropNames, final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return collExecutor.query(targetClass, selectPropNames, filter);
            }
        });
    }

    public  ContinuableFuture query(final Class targetClass, final Collection selectPropNames, final Bson filter, final int offset,
            final int count) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return collExecutor.query(targetClass, selectPropNames, filter, offset, count);
            }
        });
    }

    public  ContinuableFuture query(final Class targetClass, final Collection selectPropNames, final Bson filter, final Bson sort) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return collExecutor.query(targetClass, selectPropNames, filter, sort);
            }
        });
    }

    public  ContinuableFuture query(final Class targetClass, final Collection selectPropNames, final Bson filter, final Bson sort,
            final int offset, final int count) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return collExecutor.query(targetClass, selectPropNames, filter, sort, offset, count);
            }
        });
    }

    public  ContinuableFuture query(final Class targetClass, final Bson filter, final Bson sort, final Bson projection) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return collExecutor.query(targetClass, filter, sort, projection);
            }
        });
    }

    public  ContinuableFuture query(final Class targetClass, final Bson filter, final Bson sort, final Bson projection, final int offset,
            final int count) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return collExecutor.query(targetClass, filter, sort, projection, offset, count);
            }
        });
    }

    public ContinuableFuture> stream(final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.stream(filter);
            }
        });
    }

    public  ContinuableFuture> stream(final Class targetClass, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.stream(targetClass, filter);
            }
        });
    }

    public  ContinuableFuture> stream(final Class targetClass, final Collection selectPropNames, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.stream(targetClass, selectPropNames, filter);
            }
        });
    }

    public  ContinuableFuture> stream(final Class targetClass, final Collection selectPropNames, final Bson filter, final int offset,
            final int count) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.stream(targetClass, selectPropNames, filter, offset, count);
            }
        });
    }

    public  ContinuableFuture> stream(final Class targetClass, final Collection selectPropNames, final Bson filter, final Bson sort) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.stream(targetClass, selectPropNames, filter, sort);
            }
        });
    }

    public  ContinuableFuture> stream(final Class targetClass, final Collection selectPropNames, final Bson filter, final Bson sort,
            final int offset, final int count) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.stream(targetClass, selectPropNames, filter, sort, offset, count);
            }
        });
    }

    public  ContinuableFuture> stream(final Class targetClass, final Bson filter, final Bson sort, final Bson projection) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.stream(targetClass, filter, sort, projection);
            }
        });
    }

    public  ContinuableFuture> stream(final Class targetClass, final Bson filter, final Bson sort, final Bson projection, final int offset,
            final int count) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.stream(targetClass, filter, sort, projection, offset, count);
            }
        });
    }

    public ContinuableFuture insert(final Object obj) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Void call() throws Exception {
                collExecutor.insert(obj);
                return null;
            }
        });
    }

    public ContinuableFuture insert(final Object obj, final InsertOneOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Void call() throws Exception {
                collExecutor.insert(obj, options);
                return null;
            }
        });
    }

    public ContinuableFuture insertAll(final Collection objList) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Void call() throws Exception {
                collExecutor.insertAll(objList);
                return null;
            }
        });
    }

    public ContinuableFuture insertAll(final Collection objList, final InsertManyOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Void call() throws Exception {
                collExecutor.insertAll(objList, options);
                return null;
            }
        });
    }

    public ContinuableFuture update(final String objectId, final Object update) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.update(objectId, update);
            }
        });
    }

    public ContinuableFuture update(final ObjectId objectId, final Object update) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.update(objectId, update);
            }
        });
    }

    public ContinuableFuture updateOne(final Bson filter, final Object update) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.updateOne(filter, update);
            }
        });
    }

    public ContinuableFuture updateOne(final Bson filter, final Object update, final UpdateOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.updateOne(filter, update, options);
            }
        });
    }

    public ContinuableFuture updateAll(final Bson filter, final Object update) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.updateAll(filter, update);
            }
        });
    }

    public ContinuableFuture updateAll(final Bson filter, final Object update, final UpdateOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.updateAll(filter, update, options);
            }
        });
    }

    public ContinuableFuture replace(final String objectId, final Object replacement) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.replace(objectId, replacement);
            }
        });
    }

    public ContinuableFuture replace(final ObjectId objectId, final Object replacement) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.replace(objectId, replacement);
            }
        });
    }

    public ContinuableFuture replaceOne(final Bson filter, final Object replacement) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.replaceOne(filter, replacement);
            }
        });
    }

    public ContinuableFuture replaceOne(final Bson filter, final Object replacement, final UpdateOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public UpdateResult call() throws Exception {
                return collExecutor.replaceOne(filter, replacement, options);
            }
        });
    }

    public ContinuableFuture delete(final String objectId) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DeleteResult call() throws Exception {
                return collExecutor.delete(objectId);
            }
        });
    }

    public ContinuableFuture delete(final ObjectId objectId) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DeleteResult call() throws Exception {
                return collExecutor.delete(objectId);
            }
        });
    }

    public ContinuableFuture deleteOne(final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DeleteResult call() throws Exception {
                return collExecutor.deleteOne(filter);
            }
        });
    }

    public ContinuableFuture deleteOne(final Bson filter, final DeleteOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DeleteResult call() throws Exception {
                return collExecutor.deleteOne(filter, options);
            }
        });
    }

    public ContinuableFuture deleteAll(final Bson filter) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DeleteResult call() throws Exception {
                return collExecutor.deleteAll(filter);
            }
        });
    }

    public ContinuableFuture deleteAll(final Bson filter, final DeleteOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DeleteResult call() throws Exception {
                return collExecutor.deleteAll(filter, options);
            }
        });
    }

    public ContinuableFuture bulkInsert(final Collection entities) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return collExecutor.bulkInsert(entities);
            }
        });
    }

    public ContinuableFuture bulkInsert(final Collection entities, final BulkWriteOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return collExecutor.bulkInsert(entities, options);
            }
        });
    }

    public ContinuableFuture bulkWrite(final List> requests) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public BulkWriteResult call() throws Exception {
                return collExecutor.bulkWrite(requests);
            }
        });
    }

    public ContinuableFuture bulkWrite(final List> requests, final BulkWriteOptions options) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public BulkWriteResult call() throws Exception {
                return collExecutor.bulkWrite(requests, options);
            }
        });
    }

    public  ContinuableFuture> distinct(final Class targetClass, final String fieldName) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.distinct(targetClass, fieldName);
            }
        });
    }

    public  ContinuableFuture> distinct(final Class targetClass, final String fieldName, final Bson filter) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.distinct(targetClass, fieldName, filter);
            }
        });
    }

    public ContinuableFuture> aggregate(final List pipeline) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.aggregate(pipeline);
            }
        });
    }

    public  ContinuableFuture> aggregate(final Class targetClass, final List pipeline) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.aggregate(targetClass, pipeline);
            }
        });
    }

    public ContinuableFuture> mapReduce(final String mapFunction, final String reduceFunction) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.mapReduce(mapFunction, reduceFunction);
            }
        });
    }

    public  ContinuableFuture> mapReduce(final Class targetClass, final String mapFunction, final String reduceFunction) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.mapReduce(targetClass, mapFunction, reduceFunction);
            }
        });
    }

    @Beta
    public ContinuableFuture> groupBy(final String fieldName) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.groupBy(fieldName);
            }
        });
    }

    @Beta
    public ContinuableFuture> groupBy(final Collection fieldNames) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.groupBy(fieldNames);
            }
        });
    }

    @Beta
    public ContinuableFuture> groupByAndCount(final String fieldName) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.groupByAndCount(fieldName);
            }
        });
    }

    @Beta
    public ContinuableFuture> groupByAndCount(final Collection fieldNames) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Stream call() throws Exception {
                return collExecutor.groupByAndCount(fieldNames);
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy