From 4f089a819df757570306e128850ce9f169756a01 Mon Sep 17 00:00:00 2001 From: Denis O Date: Mon, 5 Feb 2024 20:43:51 +0000 Subject: [PATCH] Mongodb internals cleanup (#31) --- .../polydata4/mongodb/PolydataMongodb.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/polydata-mongodb/src/main/java/com/unidev/polydata4/mongodb/PolydataMongodb.java b/polydata-mongodb/src/main/java/com/unidev/polydata4/mongodb/PolydataMongodb.java index 21e62bd..f354bf2 100644 --- a/polydata-mongodb/src/main/java/com/unidev/polydata4/mongodb/PolydataMongodb.java +++ b/polydata-mongodb/src/main/java/com/unidev/polydata4/mongodb/PolydataMongodb.java @@ -171,10 +171,8 @@ public Optional indexData(String dataset, String indexId) { public BasicPolyList insert(String dataset, InsertOptions insertOptions, Collection insertRequests) { BasicPolyList basicPolyList = new BasicPolyList(); - Set polyIds = new HashSet<>(); for (InsertRequest insertRequest : insertRequests) { BasicPoly data = insertRequest.getData(); - polyIds.add(data._id()); Set indexToPersist = insertRequest.getIndexToPersist(); if (CollectionUtils.isEmpty(indexToPersist)) { @@ -457,7 +455,12 @@ public void close() throws IOException { mongoClient.close(); } - private MongoCollection collection(String collection) { + /** + * Fetch collection for dataset. + * @param collection + * @return + */ + public MongoCollection collection(String collection) { return mongoClient.getDatabase(Objects.requireNonNull(mongoClientURI.getDatabase())).getCollection(collection); } @@ -506,11 +509,17 @@ private void persistPolyToCollection(String dataset, String collection, BasicPol putIfCache(collection + "-poly-from-collection-" + dataset, data); } - private MongoCollection indexCollection(String dataset) { + /** + * Fetch dataset collection. + */ + public MongoCollection indexCollection(String dataset) { return collection(INDEX_COLLECTION); } - private void recalculateIndex(String dataset) { + /** + * Recalculate index for dataset + */ + public void recalculateIndex(String dataset) { MongoCollection collection = collection(dataset); AggregateIterable documents = collection.aggregate( Arrays.asList(