Skip to content

Commit

Permalink
OAK-11100: remove use of Guava transform/filter - oak-run
Browse files Browse the repository at this point in the history
  • Loading branch information
reschke committed Sep 17, 2024
1 parent f07a446 commit 582caf4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@

import com.mongodb.DBObject;

import java.util.stream.Collectors;

import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
import org.bson.BsonDocument;
import org.bson.BsonInt32;

import static org.apache.jackrabbit.guava.common.collect.Iterables.transform;

/**
* <code>MongoDocumentStoreCheckHelper</code>...
*/
Expand All @@ -35,10 +36,9 @@ public static long getEstimatedDocumentCount(MongoDocumentStore store) {
}

public static Iterable<NodeDocument> getAllNodeDocuments(MongoDocumentStore store) {
return transform(store.getDBCollection(Collection.NODES)
.find(DBObject.class)
.sort(new BsonDocument("$natural", new BsonInt32(1))),
input -> store.convertFromDBObject(Collection.NODES, input)
);
return CollectionUtils.toStream(
store.getDBCollection(Collection.NODES).find(DBObject.class).sort(new BsonDocument("$natural", new BsonInt32(1)))
.map(input -> store.convertFromDBObject(Collection.NODES, input)))
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.run;

import static org.apache.jackrabbit.guava.common.collect.Iterables.transform;
import static org.apache.commons.io.FileUtils.byteCountToDisplaySize;
import static org.apache.jackrabbit.oak.api.Type.BINARIES;
import static org.apache.jackrabbit.oak.api.Type.BINARY;
Expand All @@ -28,9 +27,11 @@

import java.io.PrintWriter;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;

Expand Down Expand Up @@ -126,7 +127,7 @@ private static String toString(PropertyState ps) {
String v = BLOB_LENGTH.apply(ps.getValue(BINARY));
val.append(" = {").append(v).append("}");
} else if (ps.getType() == BINARIES) {
String v = transform(ps.getValue(BINARIES), BLOB_LENGTH::apply).toString();
String v = CollectionUtils.toStream(ps.getValue(BINARIES)).map(BLOB_LENGTH).collect(Collectors.toList()).toString();
val.append("[").append(ps.count()).append("] = ").append(v);
} else if (ps.isArray()) {
val.append("[").append(ps.count()).append("] = ").append(ps.getValue(STRINGS));
Expand Down

0 comments on commit 582caf4

Please sign in to comment.