Search in sources :

Example 1 with MongoCursor

use of com.mongodb.client.MongoCursor in project spring-data-mongodb by spring-projects.

the class MongoTemplate method doRemove.

protected <T> DeleteResult doRemove(final String collectionName, final Query query, @Nullable final Class<T> entityClass) {
    Assert.notNull(query, "Query must not be null!");
    Assert.hasText(collectionName, "Collection name must not be null or empty!");
    final MongoPersistentEntity<?> entity = getPersistentEntity(entityClass);
    final Document queryObject = queryMapper.getMappedObject(query.getQueryObject(), entity);
    return execute(collectionName, new CollectionCallback<DeleteResult>() {

        public DeleteResult doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException {
            maybeEmitEvent(new BeforeDeleteEvent<T>(queryObject, entityClass, collectionName));
            Document removeQuery = queryObject;
            DeleteOptions options = new DeleteOptions();
            query.getCollation().map(Collation::toMongoCollation).ifPresent(options::collation);
            MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.REMOVE, collectionName, entityClass, null, queryObject);
            WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction);
            DeleteResult dr = null;
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Remove using query: {} in collection: {}.", new Object[] { serializeToJsonSafely(removeQuery), collectionName });
            }
            if (query.getLimit() > 0 || query.getSkip() > 0) {
                MongoCursor<Document> cursor = new QueryCursorPreparer(query, entityClass).prepare(collection.find(removeQuery).projection(new Document(ID_FIELD, 1))).iterator();
                Set<Object> ids = new LinkedHashSet<>();
                while (cursor.hasNext()) {
                    ids.add(cursor.next().get(ID_FIELD));
                }
                removeQuery = new Document(ID_FIELD, new Document("$in", ids));
            }
            if (writeConcernToUse == null) {
                dr = collection.deleteMany(removeQuery, options);
            } else {
                dr = collection.withWriteConcern(writeConcernToUse).deleteMany(removeQuery, options);
            }
            maybeEmitEvent(new AfterDeleteEvent<T>(queryObject, entityClass, collectionName));
            return dr;
        }
    });
}
Also used : MongoException(com.mongodb.MongoException) Document(org.bson.Document) BeforeDeleteEvent(org.springframework.data.mongodb.core.mapping.event.BeforeDeleteEvent) Collation(org.springframework.data.mongodb.core.query.Collation) AfterDeleteEvent(org.springframework.data.mongodb.core.mapping.event.AfterDeleteEvent) WriteConcern(com.mongodb.WriteConcern) MongoCursor(com.mongodb.client.MongoCursor) DeleteResult(com.mongodb.client.result.DeleteResult) DataAccessException(org.springframework.dao.DataAccessException)

Example 2 with MongoCursor

use of com.mongodb.client.MongoCursor in project debezium by debezium.

the class ReplicatorIT method shouldReplicateContent.

@Test
public void shouldReplicateContent() throws InterruptedException {
    Testing.Print.disable();
    // Update the configuration to add a collection filter ...
    useConfiguration(config.edit().with(MongoDbConnectorConfig.MAX_FAILED_CONNECTIONS, 1).with(MongoDbConnectorConfig.COLLECTION_WHITELIST, "dbA.contacts").build());
    TestHelper.cleanDatabase(primary, "dbA");
    // ------------------------------------------------------------------------------
    // ADD A DOCUMENT
    // ------------------------------------------------------------------------------
    // Add a document to the 'contacts' database ...
    primary.execute("shouldCreateContactsDatabase", mongo -> {
        Testing.debug("Populating the 'dbA.contacts' collection");
        // Create a database and a collection in that database ...
        MongoDatabase db = mongo.getDatabase("dbA");
        MongoCollection<Document> contacts = db.getCollection("contacts");
        InsertOneOptions insertOptions = new InsertOneOptions().bypassDocumentValidation(true);
        contacts.insertOne(Document.parse("{ \"name\":\"Jon Snow\"}"), insertOptions);
        assertThat(db.getCollection("contacts").count()).isEqualTo(1);
        // Read the collection to make sure we can find our document ...
        Bson filter = Filters.eq("name", "Jon Snow");
        FindIterable<Document> movieResults = db.getCollection("contacts").find(filter);
        try (MongoCursor<Document> cursor = movieResults.iterator()) {
            assertThat(cursor.tryNext().getString("name")).isEqualTo("Jon Snow");
            assertThat(cursor.tryNext()).isNull();
        }
        Testing.debug("Completed document to 'dbA.contacts' collection");
    });
    // Start the replicator ...
    List<SourceRecord> records = new LinkedList<>();
    Replicator replicator = new Replicator(context, replicaSet, records::add, (x) -> {
    });
    Thread thread = new Thread(replicator::run);
    thread.start();
    // Sleep for 2 seconds ...
    Thread.sleep(2000);
    // ------------------------------------------------------------------------------
    // ADD A SECOND DOCUMENT
    // ------------------------------------------------------------------------------
    // Add more documents to the 'contacts' database ...
    final Object[] expectedNames = { "Jon Snow", "Sally Hamm" };
    primary.execute("shouldCreateContactsDatabase", mongo -> {
        Testing.debug("Populating the 'dbA.contacts' collection");
        // Create a database and a collection in that database ...
        MongoDatabase db = mongo.getDatabase("dbA");
        MongoCollection<Document> contacts = db.getCollection("contacts");
        InsertOneOptions insertOptions = new InsertOneOptions().bypassDocumentValidation(true);
        contacts.insertOne(Document.parse("{ \"name\":\"Sally Hamm\"}"), insertOptions);
        assertThat(db.getCollection("contacts").count()).isEqualTo(2);
        // Read the collection to make sure we can find our documents ...
        FindIterable<Document> movieResults = db.getCollection("contacts").find();
        Set<String> foundNames = new HashSet<>();
        try (MongoCursor<Document> cursor = movieResults.iterator()) {
            while (cursor.hasNext()) {
                String name = cursor.next().getString("name");
                foundNames.add(name);
            }
        }
        assertThat(foundNames).containsOnly(expectedNames);
        Testing.debug("Completed document to 'dbA.contacts' collection");
    });
    // For for a minimum number of events or max time ...
    // both documents
    int numEventsExpected = 2;
    long stop = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(3);
    while (records.size() < numEventsExpected && System.currentTimeMillis() < stop) {
        Thread.sleep(100);
    }
    // ------------------------------------------------------------------------------
    // STOP REPLICATOR AND VERIFY WE FOUND A TOTAL OF 2 EVENTS
    // ------------------------------------------------------------------------------
    replicator.stop();
    // Verify each record is valid and that we found the two records we expect ...
    final Set<String> foundNames = new HashSet<>();
    records.forEach(record -> {
        VerifyRecord.isValid(record);
        Struct value = (Struct) record.value();
        String after = value.getString("after");
        Document afterDoc = Document.parse(after);
        foundNames.add(afterDoc.getString("name"));
        Operation op = Operation.forCode(value.getString("op"));
        assertThat(op == Operation.READ || op == Operation.CREATE).isTrue();
    });
    assertThat(records.size()).isEqualTo(2);
    assertThat(foundNames).containsOnly(expectedNames);
    // ------------------------------------------------------------------------------
    // RESTART REPLICATOR FROM SAME POSITON
    // ------------------------------------------------------------------------------
    reuseConfiguration(config);
    // Start the replicator again ...
    records = new LinkedList<>();
    replicator = new Replicator(context, replicaSet, records::add, (x) -> {
    });
    thread = new Thread(replicator::run);
    thread.start();
    // Sleep for 2 seconds ...
    Thread.sleep(2000);
    // Stop the replicator ...
    replicator.stop();
    // We should not have found any new records ...
    records.forEach(record -> {
        VerifyRecord.isValid(record);
    });
    assertThat(records.isEmpty()).isTrue();
    // ------------------------------------------------------------------------------
    // START REPLICATOR AND ALSO REMOVE A DOCUMENT
    // ------------------------------------------------------------------------------
    // Update the configuration and don't use a collection filter ...
    reuseConfiguration(config.edit().with(MongoDbConnectorConfig.MAX_FAILED_CONNECTIONS, 1).build());
    // Start the replicator again ...
    records = new LinkedList<>();
    replicator = new Replicator(context, replicaSet, records::add, (x) -> {
    });
    thread = new Thread(replicator::run);
    thread.start();
    // Sleep for 2 seconds ...
    Thread.sleep(2000);
    // Remove Jon Snow ...
    AtomicReference<ObjectId> jonSnowId = new AtomicReference<>();
    primary.execute("removeJonSnow", mongo -> {
        MongoDatabase db = mongo.getDatabase("dbA");
        MongoCollection<Document> contacts = db.getCollection("contacts");
        // Read the collection to make sure we can find our document ...
        Bson filter = Filters.eq("name", "Jon Snow");
        FindIterable<Document> movieResults = db.getCollection("contacts").find(filter);
        try (MongoCursor<Document> cursor = movieResults.iterator()) {
            Document doc = cursor.tryNext();
            assertThat(doc.getString("name")).isEqualTo("Jon Snow");
            assertThat(cursor.tryNext()).isNull();
            jonSnowId.set(doc.getObjectId("_id"));
            assertThat(jonSnowId.get()).isNotNull();
        }
        // Remove the document by filter ...
        contacts.deleteOne(Filters.eq("name", "Jon Snow"));
        Testing.debug("Removed the Jon Snow document from 'dbA.contacts' collection");
    });
    // For for a minimum number of events or max time ...
    // just one delete event
    numEventsExpected = 1;
    stop = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(3);
    while (records.size() < numEventsExpected && System.currentTimeMillis() < stop) {
        Thread.sleep(100);
    }
    // Stop the replicator ...
    replicator.stop();
    // Verify each record is valid and that we found the one new DELETE record we expect ...
    Set<ObjectId> foundIds = new HashSet<>();
    records.forEach(record -> {
        VerifyRecord.isValid(record);
        Struct key = (Struct) record.key();
        ObjectId id = (ObjectId) (JSON.parse(key.getString("id")));
        foundIds.add(id);
        if (record.value() != null) {
            Struct value = (Struct) record.value();
            Operation op = Operation.forCode(value.getString("op"));
            assertThat(op).isEqualTo(Operation.DELETE);
        }
    });
    // 1 delete and 1 tombstone
    assertThat(records.size()).isEqualTo(2);
    // ------------------------------------------------------------------------------
    // START REPLICATOR TO PERFORM SNAPSHOT
    // ------------------------------------------------------------------------------
    // Update the configuration and don't use a collection filter ...
    useConfiguration(config);
    // Start the replicator again ...
    records = new LinkedList<>();
    replicator = new Replicator(context, replicaSet, records::add, (x) -> {
    });
    thread = new Thread(replicator::run);
    thread.start();
    // Sleep for 2 seconds ...
    Thread.sleep(2000);
    // Stop the replicator ...
    replicator.stop();
    // Verify each record is valid and that we found the two records we expect ...
    foundNames.clear();
    records.forEach(record -> {
        VerifyRecord.isValid(record);
        Struct value = (Struct) record.value();
        String after = value.getString("after");
        Document afterDoc = Document.parse(after);
        foundNames.add(afterDoc.getString("name"));
        Operation op = Operation.forCode(value.getString("op"));
        assertThat(op).isEqualTo(Operation.READ);
    });
    // We should not have found any new records ...
    assertThat(records.size()).isEqualTo(1);
    Object[] allExpectedNames = { "Sally Hamm" };
    assertThat(foundNames).containsOnly(allExpectedNames);
}
Also used : Document(org.bson.Document) MongoCollection(com.mongodb.client.MongoCollection) Set(java.util.Set) Test(org.junit.Test) MongoDatabase(com.mongodb.client.MongoDatabase) AtomicReference(java.util.concurrent.atomic.AtomicReference) SourceRecord(org.apache.kafka.connect.source.SourceRecord) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) Bson(org.bson.conversions.Bson) Filters(com.mongodb.client.model.Filters) Operation(io.debezium.data.Envelope.Operation) List(java.util.List) Testing(io.debezium.util.Testing) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) MongoCursor(com.mongodb.client.MongoCursor) FindIterable(com.mongodb.client.FindIterable) Struct(org.apache.kafka.connect.data.Struct) ObjectId(org.bson.types.ObjectId) JSON(com.mongodb.util.JSON) InsertOneOptions(com.mongodb.client.model.InsertOneOptions) VerifyRecord(io.debezium.data.VerifyRecord) LinkedList(java.util.LinkedList) InsertOneOptions(com.mongodb.client.model.InsertOneOptions) Operation(io.debezium.data.Envelope.Operation) Document(org.bson.Document) SourceRecord(org.apache.kafka.connect.source.SourceRecord) Bson(org.bson.conversions.Bson) Struct(org.apache.kafka.connect.data.Struct) MongoDatabase(com.mongodb.client.MongoDatabase) HashSet(java.util.HashSet) ObjectId(org.bson.types.ObjectId) AtomicReference(java.util.concurrent.atomic.AtomicReference) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with MongoCursor

use of com.mongodb.client.MongoCursor in project drill by apache.

the class MongoGroupScan method init.

@SuppressWarnings({ "rawtypes" })
private void init() {
    List<String> h = storagePluginConfig.getHosts();
    List<ServerAddress> addresses = Lists.newArrayList();
    for (String host : h) {
        addresses.add(new ServerAddress(host));
    }
    MongoClient client = storagePlugin.getClient();
    chunksMapping = Maps.newHashMap();
    chunksInverseMapping = Maps.newLinkedHashMap();
    if (useAggregate && isShardedCluster(client)) {
        handleUnshardedCollection(getPrimaryShardInfo());
    } else if (isShardedCluster(client)) {
        MongoDatabase db = client.getDatabase(CONFIG);
        MongoCollection<Document> chunksCollection = db.getCollection(CHUNKS);
        Document filter = new Document();
        filter.put(NS, this.scanSpec.getDbName() + "." + this.scanSpec.getCollectionName());
        Document projection = new Document();
        projection.put(SHARD, SELECT);
        projection.put(MIN, SELECT);
        projection.put(MAX, SELECT);
        FindIterable<Document> chunkCursor = chunksCollection.find(filter).projection(projection);
        MongoCursor<Document> iterator = chunkCursor.iterator();
        MongoCollection<Document> shardsCollection = db.getCollection(SHARDS);
        projection = new Document();
        projection.put(HOST, SELECT);
        boolean hasChunks = false;
        while (iterator.hasNext()) {
            Document chunkObj = iterator.next();
            String shardName = (String) chunkObj.get(SHARD);
            // creates hexadecimal string representation of ObjectId
            String chunkId = chunkObj.get(ID).toString();
            filter = new Document(ID, shardName);
            FindIterable<Document> hostCursor = shardsCollection.find(filter).projection(projection);
            for (Document hostObj : hostCursor) {
                String hostEntry = (String) hostObj.get(HOST);
                String[] tagAndHost = StringUtils.split(hostEntry, '/');
                String[] hosts = tagAndHost.length > 1 ? StringUtils.split(tagAndHost[1], ',') : StringUtils.split(tagAndHost[0], ',');
                Set<ServerAddress> addressList = getPreferredHosts(storagePlugin.getClient(addresses));
                if (addressList == null) {
                    addressList = Sets.newHashSet();
                    for (String host : hosts) {
                        addressList.add(new ServerAddress(host));
                    }
                }
                chunksMapping.put(chunkId, addressList);
                ServerAddress address = addressList.iterator().next();
                List<ChunkInfo> chunkList = chunksInverseMapping.computeIfAbsent(address.getHost(), k -> new ArrayList<>());
                List<String> chunkHostsList = new ArrayList<>();
                for (ServerAddress serverAddr : addressList) {
                    chunkHostsList.add(serverAddr.toString());
                }
                ChunkInfo chunkInfo = new ChunkInfo(chunkHostsList, chunkId);
                Document minMap = (Document) chunkObj.get(MIN);
                Map<String, Object> minFilters = Maps.newHashMap();
                Set keySet = minMap.keySet();
                for (Object keyObj : keySet) {
                    Object object = minMap.get(keyObj);
                    if (!(object instanceof MinKey)) {
                        minFilters.put(keyObj.toString(), object);
                    }
                }
                chunkInfo.setMinFilters(minFilters);
                Map<String, Object> maxFilters = Maps.newHashMap();
                Map maxMap = (Document) chunkObj.get(MAX);
                keySet = maxMap.keySet();
                for (Object keyObj : keySet) {
                    Object object = maxMap.get(keyObj);
                    if (!(object instanceof MaxKey)) {
                        maxFilters.put(keyObj.toString(), object);
                    }
                }
                chunkInfo.setMaxFilters(maxFilters);
                chunkList.add(chunkInfo);
            }
            hasChunks = true;
        }
        // unsharded collection and it will be stored in the primary shard of that database.
        if (!hasChunks) {
            handleUnshardedCollection(getPrimaryShardInfo());
        }
    } else {
        handleUnshardedCollection(storagePluginConfig.getHosts());
    }
}
Also used : Document(org.bson.Document) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) PriorityQueue(java.util.PriorityQueue) LoggerFactory(org.slf4j.LoggerFactory) Sets(org.apache.drill.shaded.guava.com.google.common.collect.Sets) MongoDatabase(com.mongodb.client.MongoDatabase) VisibleForTesting(org.apache.drill.shaded.guava.com.google.common.annotations.VisibleForTesting) StringUtils(org.apache.commons.lang3.StringUtils) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) Map(java.util.Map) Joiner(org.apache.drill.shaded.guava.com.google.common.base.Joiner) JacksonInject(com.fasterxml.jackson.annotation.JacksonInject) MongoSubScanSpec(org.apache.drill.exec.store.mongo.MongoSubScan.MongoSubScanSpec) MaxKey(org.bson.types.MaxKey) SchemaPath(org.apache.drill.common.expression.SchemaPath) Set(java.util.Set) Objects(java.util.Objects) List(java.util.List) FindIterable(com.mongodb.client.FindIterable) Entry(java.util.Map.Entry) Stopwatch(org.apache.drill.shaded.guava.com.google.common.base.Stopwatch) Preconditions(org.apache.drill.shaded.guava.com.google.common.base.Preconditions) Queue(java.util.Queue) ReadPreference(com.mongodb.ReadPreference) StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) MongoClient(com.mongodb.client.MongoClient) PlanStringBuilder(org.apache.drill.common.PlanStringBuilder) MongoCollection(com.mongodb.client.MongoCollection) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) AbstractGroupScan(org.apache.drill.exec.physical.base.AbstractGroupScan) ShardedMongoSubScanSpec(org.apache.drill.exec.store.mongo.MongoSubScan.ShardedMongoSubScanSpec) ArrayList(java.util.ArrayList) GroupScanProperty(org.apache.drill.exec.physical.base.ScanStats.GroupScanProperty) Bson(org.bson.conversions.Bson) Maps(org.apache.drill.shaded.guava.com.google.common.collect.Maps) JsonTypeName(com.fasterxml.jackson.annotation.JsonTypeName) BsonTypeClassMap(org.bson.codecs.BsonTypeClassMap) MongoCursor(com.mongodb.client.MongoCursor) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) MinKey(org.bson.types.MinKey) DocumentCodec(org.bson.codecs.DocumentCodec) LinkedList(java.util.LinkedList) ServerAddress(com.mongodb.ServerAddress) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ScanStats(org.apache.drill.exec.physical.base.ScanStats) TimeUnit(java.util.concurrent.TimeUnit) Lists(org.apache.drill.shaded.guava.com.google.common.collect.Lists) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) EndpointAffinity(org.apache.drill.exec.physical.EndpointAffinity) GroupScan(org.apache.drill.exec.physical.base.GroupScan) ChunkInfo(org.apache.drill.exec.store.mongo.common.ChunkInfo) Comparator(java.util.Comparator) Collections(java.util.Collections) Set(java.util.Set) ChunkInfo(org.apache.drill.exec.store.mongo.common.ChunkInfo) ServerAddress(com.mongodb.ServerAddress) ArrayList(java.util.ArrayList) MaxKey(org.bson.types.MaxKey) FindIterable(com.mongodb.client.FindIterable) Document(org.bson.Document) MongoClient(com.mongodb.client.MongoClient) MongoCollection(com.mongodb.client.MongoCollection) MinKey(org.bson.types.MinKey) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) MongoCursor(com.mongodb.client.MongoCursor) Map(java.util.Map) BsonTypeClassMap(org.bson.codecs.BsonTypeClassMap) MongoDatabase(com.mongodb.client.MongoDatabase)

Example 4 with MongoCursor

use of com.mongodb.client.MongoCursor in project spring-data-mongodb by spring-projects.

the class MongoTemplateUnitTests method mapReduceShouldPickUpLimitFromOptions.

// DATAMONGO-1334
@Test
void mapReduceShouldPickUpLimitFromOptions() {
    MongoCursor cursor = mock(MongoCursor.class);
    MapReduceIterable output = mock(MapReduceIterable.class);
    when(output.limit(anyInt())).thenReturn(output);
    when(output.sort(any())).thenReturn(output);
    when(output.filter(any(Document.class))).thenReturn(output);
    when(output.iterator()).thenReturn(cursor);
    when(cursor.hasNext()).thenReturn(false);
    when(collection.mapReduce(anyString(), anyString(), eq(Document.class))).thenReturn(output);
    Query query = new BasicQuery("{'foo':'bar'}");
    template.mapReduce(query, "collection", "function(){}", "function(key,values){}", new MapReduceOptions().limit(1000), Wrapper.class);
    verify(output, times(1)).limit(1000);
}
Also used : MapReduceOptions(org.springframework.data.mongodb.core.mapreduce.MapReduceOptions) BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) NearQuery(org.springframework.data.mongodb.core.query.NearQuery) Query(org.springframework.data.mongodb.core.query.Query) BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) MapReduceIterable(com.mongodb.client.MapReduceIterable) MongoCursor(com.mongodb.client.MongoCursor) Document(org.bson.Document) Test(org.junit.jupiter.api.Test)

Example 5 with MongoCursor

use of com.mongodb.client.MongoCursor in project spring-data-mongodb by spring-projects.

the class MongoTemplateUnitTests method mapReduceShouldPickUpLimitFromQuery.

// DATAMONGO-1334
@Test
void mapReduceShouldPickUpLimitFromQuery() {
    MongoCursor cursor = mock(MongoCursor.class);
    MapReduceIterable output = mock(MapReduceIterable.class);
    when(output.limit(anyInt())).thenReturn(output);
    when(output.sort(any())).thenReturn(output);
    when(output.filter(any(Document.class))).thenReturn(output);
    when(output.iterator()).thenReturn(cursor);
    when(cursor.hasNext()).thenReturn(false);
    when(collection.mapReduce(anyString(), anyString(), eq(Document.class))).thenReturn(output);
    Query query = new BasicQuery("{'foo':'bar'}");
    query.limit(100);
    template.mapReduce(query, "collection", "function(){}", "function(key,values){}", Wrapper.class);
    verify(output, times(1)).limit(100);
}
Also used : BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) NearQuery(org.springframework.data.mongodb.core.query.NearQuery) Query(org.springframework.data.mongodb.core.query.Query) BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) MapReduceIterable(com.mongodb.client.MapReduceIterable) MongoCursor(com.mongodb.client.MongoCursor) Document(org.bson.Document) Test(org.junit.jupiter.api.Test)

Aggregations

MongoCursor (com.mongodb.client.MongoCursor)13 Document (org.bson.Document)10 MapReduceIterable (com.mongodb.client.MapReduceIterable)5 MongoCollection (com.mongodb.client.MongoCollection)5 List (java.util.List)5 Test (org.junit.jupiter.api.Test)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 Set (java.util.Set)4 Bson (org.bson.conversions.Bson)4 BasicQuery (org.springframework.data.mongodb.core.query.BasicQuery)4 NearQuery (org.springframework.data.mongodb.core.query.NearQuery)4 Query (org.springframework.data.mongodb.core.query.Query)4 FindIterable (com.mongodb.client.FindIterable)3 MongoDatabase (com.mongodb.client.MongoDatabase)3 Filters (com.mongodb.client.model.Filters)3 HashSet (java.util.HashSet)3 BasicDBObject (com.mongodb.BasicDBObject)2 ServerAddress (com.mongodb.ServerAddress)2 IOException (java.io.IOException)2