Skip to main content

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

Hey Dmitry, how are you?

What do you think of opening a PR with this point?

Thank you for the feedback.

On Tue, Jun 13, 2023 at 7:17 PM Dmitry Repchevsky via jnosql-dev <jnosql-dev@xxxxxxxxxxx> wrote:
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


_______________________________________________
jnosql-dev mailing list
jnosql-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jnosql-dev


--

Thanks a lot,

Twitter | Linkedin | Youtube


Back to the top