Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jnosql-dev] MongoDBDocumentManager optimization

Hi,

Looking at the MongoDBDocumentManager.java I noticed strange conversion between Document -> BsonDocument in select/aggregate methods.

For instance:

MongoCollection<Document> collection = mongoDatabase.getCollection(collectionName);
AggregateIterable<Document> aggregate = collection.aggregate(pipeline);
return stream(aggregate.spliterator(), false)
                .map(Document::toBsonDocument);

It's much faster not to convert Bson (what mongo operates with) to the Document and them back.

MongoCollection<BsonDocument> collection = mongoDatabase.getCollection(collectionName, BsonDocument.class);
AggregateIterable<BsonDocument> aggregate = collection.aggregate(pipeline);
return stream(aggregate.spliterator(), false);

Is there something I am missing?

Kind regards,

Dmitry




Back to the top