This is an automated email from the ASF dual-hosted git repository.
daim 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 f9ab1acd92 OAK-11754 : removed usage of Guava HashMultimap (#2326)
f9ab1acd92 is described below
commit f9ab1acd920ea9002a36b69622784a2ed8b51968
Author: Rishabh Kumar <[email protected]>
AuthorDate: Fri Jun 13 11:20:53 2025 +0530
OAK-11754 : removed usage of Guava HashMultimap (#2326)
Co-authored-by: Rishabh Kumar <[email protected]>
---
.../oak/plugins/index/lucene/hybrid/IndexedPaths.java | 6 +++---
.../index/lucene/hybrid/LuceneJournalPropertyBuilder.java | 8 ++++----
.../lucene/property/UniquenessConstraintValidator.java | 6 +++---
.../index/lucene/hybrid/ExternalIndexObserverTest.java | 15 +++++++--------
.../lucene/hybrid/LuceneJournalPropertyBuilderTest.java | 12 ++++++------
5 files changed, 23 insertions(+), 24 deletions(-)
diff --git
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/IndexedPaths.java
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/IndexedPaths.java
index 3cc5fe88ad..a3bd83092a 100644
---
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/IndexedPaths.java
+++
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/IndexedPaths.java
@@ -20,16 +20,16 @@ package
org.apache.jackrabbit.oak.plugins.index.lucene.hybrid;
import java.util.Iterator;
-import org.apache.jackrabbit.guava.common.collect.Multimap;
+import org.apache.commons.collections4.MultiValuedMap;
import org.apache.jackrabbit.oak.commons.collections.IteratorUtils;
import org.apache.jackrabbit.oak.plugins.document.spi.JournalProperty;
import static java.util.Objects.requireNonNull;
class IndexedPaths implements JournalProperty, Iterable<IndexedPathInfo> {
- private final Multimap<String, String> indexedPaths;
+ private final MultiValuedMap<String, String> indexedPaths;
- public IndexedPaths(Multimap<String, String> indexedPaths) {
+ public IndexedPaths(MultiValuedMap<String, String> indexedPaths) {
this.indexedPaths = requireNonNull(indexedPaths);
}
diff --git
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilder.java
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilder.java
index a5e27f1035..4330d92c6c 100644
---
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilder.java
+++
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilder.java
@@ -22,8 +22,8 @@ package org.apache.jackrabbit.oak.plugins.index.lucene.hybrid;
import java.util.Collection;
import java.util.Map;
-import org.apache.jackrabbit.guava.common.collect.HashMultimap;
-import org.apache.jackrabbit.guava.common.collect.Multimap;
+import org.apache.commons.collections4.MultiValuedMap;
+import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
import org.apache.jackrabbit.oak.commons.json.JsopBuilder;
import org.apache.jackrabbit.oak.commons.json.JsopReader;
import org.apache.jackrabbit.oak.commons.json.JsopTokenizer;
@@ -36,8 +36,8 @@ import org.slf4j.LoggerFactory;
class LuceneJournalPropertyBuilder implements
JournalPropertyBuilder<LuceneDocumentHolder> {
private final static Logger log =
LoggerFactory.getLogger(LuceneJournalPropertyBuilder.class);
- //Use HashMultimap to ensure that indexPath is not duplicated per node path
- private final Multimap<String, String> indexedNodes =
HashMultimap.create();
+ //Use HashSetValuedHashMap to ensure that indexPath is not duplicated per
node path
+ private final MultiValuedMap<String, String> indexedNodes = new
HashSetValuedHashMap<>();
private boolean limitWarningLogged = false;
private final int maxSize;
diff --git
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniquenessConstraintValidator.java
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniquenessConstraintValidator.java
index 74bfa187ba..a26e8b2472 100644
---
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniquenessConstraintValidator.java
+++
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniquenessConstraintValidator.java
@@ -24,8 +24,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.apache.jackrabbit.guava.common.collect.HashMultimap;
-import org.apache.jackrabbit.guava.common.collect.Multimap;
+import org.apache.commons.collections4.MultiValuedMap;
+import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
@@ -50,7 +50,7 @@ import static
org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT;
public class UniquenessConstraintValidator {
private final NodeState rootState;
private final String indexPath;
- private final Multimap<String, String> uniqueKeys = HashMultimap.create();
+ private final MultiValuedMap<String, String> uniqueKeys = new
HashSetValuedHashMap<>();
private final PropertyQuery firstStore;
private PropertyQuery secondStore = PropertyQuery.DEFAULT;
diff --git
a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ExternalIndexObserverTest.java
b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ExternalIndexObserverTest.java
index e7ad6f79d5..348556785d 100644
---
a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ExternalIndexObserverTest.java
+++
b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ExternalIndexObserverTest.java
@@ -18,9 +18,8 @@
*/
package org.apache.jackrabbit.oak.plugins.index.lucene.hybrid;
-import org.apache.jackrabbit.guava.common.collect.HashMultimap;
-
-import org.apache.jackrabbit.guava.common.collect.Multimap;
+import org.apache.commons.collections4.MultiValuedMap;
+import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
import org.apache.jackrabbit.guava.common.util.concurrent.MoreExecutors;
import org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker;
import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition;
@@ -88,7 +87,7 @@ public class ExternalIndexObserverTest {
@Test
public void nonExistingIndexDefn() throws Exception {
- Multimap<String, String> indexedPaths = HashMultimap.create();
+ MultiValuedMap<String, String> indexedPaths = new
HashSetValuedHashMap<>();
indexedPaths.put("/a", "/oak:index/foo");
commitContext.set(LuceneDocumentHolder.NAME, new
IndexedPaths(indexedPaths));
@@ -101,7 +100,7 @@ public class ExternalIndexObserverTest {
@Test
public void nonExistingPath() throws Exception {
- Multimap<String, String> indexedPaths = HashMultimap.create();
+ MultiValuedMap<String, String> indexedPaths = new
HashSetValuedHashMap<>();
indexedPaths.put("/a", "/oak:index/foo");
commitContext.set(LuceneDocumentHolder.NAME, new
IndexedPaths(indexedPaths));
@@ -114,7 +113,7 @@ public class ExternalIndexObserverTest {
@Test
public void nonApplicableRule() throws Exception {
- Multimap<String, String> indexedPaths = HashMultimap.create();
+ MultiValuedMap<String, String> indexedPaths = new
HashSetValuedHashMap<>();
indexedPaths.put("/a", "/oak:index/foo");
commitContext.set(LuceneDocumentHolder.NAME, new
IndexedPaths(indexedPaths));
@@ -132,7 +131,7 @@ public class ExternalIndexObserverTest {
@Test
public void ruleNotResultingInDoc() throws Exception {
- Multimap<String, String> indexedPaths = HashMultimap.create();
+ MultiValuedMap<String, String> indexedPaths = new
HashSetValuedHashMap<>();
indexedPaths.put("/a", "/oak:index/foo");
commitContext.set(LuceneDocumentHolder.NAME, new
IndexedPaths(indexedPaths));
@@ -154,7 +153,7 @@ public class ExternalIndexObserverTest {
}
private void assertIndexing(Observer observer){
- Multimap<String, String> indexedPaths = HashMultimap.create();
+ MultiValuedMap<String, String> indexedPaths = new
HashSetValuedHashMap<>();
indexedPaths.put("/a", "/oak:index/foo");
commitContext.set(LuceneDocumentHolder.NAME, new
IndexedPaths(indexedPaths));
diff --git
a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilderTest.java
b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilderTest.java
index 6913c4aa04..65a4ab4735 100644
---
a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilderTest.java
+++
b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilderTest.java
@@ -19,8 +19,8 @@
package org.apache.jackrabbit.oak.plugins.index.lucene.hybrid;
-import org.apache.jackrabbit.guava.common.collect.HashMultimap;
-import org.apache.jackrabbit.guava.common.collect.Multimap;
+import org.apache.commons.collections4.MultiValuedMap;
+import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.junit.Test;
@@ -84,7 +84,7 @@ public class LuceneJournalPropertyBuilderTest {
builder.addProperty(h2);
IndexedPaths indexedPaths = (IndexedPaths) builder.build();
- Multimap<String, String> map = createdIndexPathMap(indexedPaths);
+ MultiValuedMap<String, String> map = createdIndexPathMap(indexedPaths);
assertThat(map.keySet(), containsInAnyOrder("/oak:index/foo",
"/oak:index/bar"));
assertThat(map.get("/oak:index/foo"), containsInAnyOrder("/a", "/b"));
}
@@ -105,7 +105,7 @@ public class LuceneJournalPropertyBuilderTest {
builder2.addSerializedProperty(json);
IndexedPaths indexedPaths = (IndexedPaths) builder2.build();
- Multimap<String, String> map = createdIndexPathMap(indexedPaths);
+ MultiValuedMap<String, String> map = createdIndexPathMap(indexedPaths);
assertThat(map.keySet(), containsInAnyOrder("/oak:index/foo",
"/oak:index/bar"));
assertThat(map.get("/oak:index/foo"), containsInAnyOrder("/a", "/b"));
}
@@ -124,8 +124,8 @@ public class LuceneJournalPropertyBuilderTest {
assertEquals(maxSize, IterableUtils.size(indexedPaths));
}
- private Multimap<String, String>
createdIndexPathMap(Iterable<IndexedPathInfo> itr){
- Multimap<String, String> map = HashMultimap.create();
+ private MultiValuedMap<String, String>
createdIndexPathMap(Iterable<IndexedPathInfo> itr){
+ MultiValuedMap<String, String> map = new HashSetValuedHashMap<>();
for (IndexedPathInfo i : itr){
for (String indexPath : i.getIndexPaths()){
map.put(indexPath, i.getPath());