Skip to content

Commit

Permalink
Mongodb internals cleanup (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis256 authored Feb 5, 2024
1 parent acd4c5b commit 4f089a8
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ public Optional<BasicPoly> indexData(String dataset, String indexId) {
public BasicPolyList insert(String dataset, InsertOptions insertOptions, Collection<InsertRequest> insertRequests) {
BasicPolyList basicPolyList = new BasicPolyList();

Set<String> polyIds = new HashSet<>();
for (InsertRequest insertRequest : insertRequests) {
BasicPoly data = insertRequest.getData();
polyIds.add(data._id());

Set<String> indexToPersist = insertRequest.getIndexToPersist();
if (CollectionUtils.isEmpty(indexToPersist)) {
Expand Down Expand Up @@ -457,7 +455,12 @@ public void close() throws IOException {
mongoClient.close();
}

private MongoCollection<Document> collection(String collection) {
/**
* Fetch collection for dataset.
* @param collection
* @return
*/
public MongoCollection<Document> collection(String collection) {
return mongoClient.getDatabase(Objects.requireNonNull(mongoClientURI.getDatabase())).getCollection(collection);
}

Expand Down Expand Up @@ -506,11 +509,17 @@ private void persistPolyToCollection(String dataset, String collection, BasicPol
putIfCache(collection + "-poly-from-collection-" + dataset, data);
}

private MongoCollection<Document> indexCollection(String dataset) {
/**
* Fetch dataset collection.
*/
public MongoCollection<Document> indexCollection(String dataset) {
return collection(INDEX_COLLECTION);
}

private void recalculateIndex(String dataset) {
/**
* Recalculate index for dataset
*/
public void recalculateIndex(String dataset) {
MongoCollection<Document> collection = collection(dataset);
AggregateIterable<Document> documents = collection.aggregate(
Arrays.asList(
Expand Down

0 comments on commit 4f089a8

Please sign in to comment.