This is an automated email from the ASF dual-hosted git repository. nfsantos pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push: new 759637eb3a OAK-10897 - Delete unused class: DocumentStoreSplitter (#1537) 759637eb3a is described below commit 759637eb3a7c6bf550227569e85c852a58d9762c Author: Nuno Santos <nsan...@adobe.com> AuthorDate: Mon Jun 17 16:41:37 2024 +0200 OAK-10897 - Delete unused class: DocumentStoreSplitter (#1537) --- .../document/mongo/DocumentStoreSplitter.java | 97 ---------------------- 1 file changed, 97 deletions(-) diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/DocumentStoreSplitter.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/DocumentStoreSplitter.java deleted file mode 100644 index e5a2186c0a..0000000000 --- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/DocumentStoreSplitter.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.jackrabbit.oak.plugins.document.mongo; - -import com.mongodb.BasicDBObject; -import com.mongodb.client.MongoCollection; -import org.apache.jackrabbit.oak.plugins.document.Collection; -import org.apache.jackrabbit.oak.plugins.document.Document; -import org.apache.jackrabbit.oak.plugins.document.NodeDocument; -import org.bson.BsonDocument; -import org.bson.BsonInt64; -import org.bson.BsonNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -public class DocumentStoreSplitter { - - private static final Logger log = LoggerFactory.getLogger(DocumentStoreSplitter.class); - - MongoDocumentStore mongoStore; - - public DocumentStoreSplitter(MongoDocumentStore mongoStore) { - this.mongoStore = mongoStore; - } - - public <T extends Document> List<Long> split(Collection<T> collection, long modifiedSinceLowerLimit, int parts) { - MongoCollection<BasicDBObject> dbCollection = mongoStore.getDBCollection(collection); - BsonDocument query = new BsonDocument(); - query.append(NodeDocument.MODIFIED_IN_SECS, new BsonDocument().append("$ne", new BsonNull())); - long oldest; - Iterator<BasicDBObject> cursor; - if (modifiedSinceLowerLimit <= 0) { - cursor = dbCollection.find(query).sort(new BsonDocument(NodeDocument.MODIFIED_IN_SECS, - new BsonInt64(1))).limit(1).iterator(); - if (!cursor.hasNext()) { - return Collections.emptyList(); - } - oldest = cursor.next().getLong(NodeDocument.MODIFIED_IN_SECS); - } else { - oldest = modifiedSinceLowerLimit; - } - cursor = dbCollection.find(query).sort(new BsonDocument(NodeDocument.MODIFIED_IN_SECS, - new BsonInt64(-1))).limit(1).iterator(); - if (!cursor.hasNext()) { - return Collections.emptyList(); - } - long latest = cursor.next().getLong(NodeDocument.MODIFIED_IN_SECS); - return simpleSplit(oldest, latest, parts); - } - - public static List<Long> simpleSplit(long start, long end, int parts) { - if (end < start) { - throw new IllegalArgumentException("start(" + start + ") can't be greater than end (" + end + ")"); - } - if (start == end) { - return Collections.singletonList(start); - } - if (parts > end - start) { - log.debug("Adjusting parts according to given range {} - {}", start, end); - parts = (int)(end - start); - } - long stepSize = (end - start)/parts; - List<Long> steps = new ArrayList<>(); - StringBuilder splitPoints = new StringBuilder(); - for (long i = start; i <= end; i+=stepSize) { - steps.add(i); - splitPoints.append(" ").append(i); - } - if (steps.size() > 0 && steps.get(steps.size() - 1) != end) { - steps.add(end); - splitPoints.append(" ").append(end); - } - log.info("Split points of _modified values {}", splitPoints.toString()); - return steps; - } -}