Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-10945: Remove usage of Guava Function interface #1578

Open
wants to merge 26 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a983c72
OAK-10945: Remove usage of Guava Function interface (oak-upgrade)
reschke Jul 11, 2024
35357ce
OAK-10945: Remove usage of Guava Function interface (oak-store-spi)
reschke Jul 11, 2024
8655e10
OAK-10945: Remove usage of Guava Function interface (oak-it)
reschke Jul 11, 2024
3d2855f
OAK-10945: Remove usage of Guava Function interface (oak-store-document)
reschke Jul 12, 2024
57e9e3a
OAK-10945: Remove usage of Guava Function interface (oak-store-compos…
reschke Jul 12, 2024
77883fb
OAK-10945: Remove usage of Guava Function interface (oak-segment-tar)
reschke Jul 12, 2024
cabbe23
OAK-10945: Remove usage of Guava Function interface (oak-segment-azure)
reschke Jul 12, 2024
a56211e
OAK-10945: Remove usage of Guava Function interface (oak-security-spi)
reschke Jul 12, 2024
2dee099
OAK-10945: Remove usage of Guava Function interface (oak-security-sea…
reschke Jul 12, 2024
441c749
OAK-10945: Remove usage of Guava Function interface (oak-run-commons)
reschke Jul 12, 2024
d35fa3d
OAK-10945: Remove usage of Guava Function interface (oak-run)
reschke Jul 12, 2024
b0b9893
OAK-10945: Remove usage of Guava Function interface (oak-lucene)
reschke Jul 12, 2024
bc9f110
OAK-10945: Remove usage of Guava Function interface (oak-jcr)
reschke Jul 12, 2024
d385fe9
OAK-10945: Remove usage of Guava Function interface (oak-exercise)
reschke Jul 12, 2024
a3c4392
OAK-10945: Remove usage of Guava Function interface (oak-core-spi)
reschke Jul 12, 2024
d277408
OAK-10945: Remove usage of Guava Function interface (oak-core)
reschke Jul 13, 2024
cf5730c
OAK-10945: Remove usage of Guava Function interface (oak-commons)
reschke Jul 13, 2024
a288afe
OAK-10945: Remove usage of Guava Function interface (oak-blob-plugins)
reschke Jul 13, 2024
097690e
OAK-10945: Remove usage of Guava Function interface (oak-blob-cloud, …
reschke Jul 13, 2024
137b18e
OAK-10945: Remove usage of Guava Function interface (oak-upgrade) - c…
reschke Jul 14, 2024
1ece1fe
OAK-10945: Remove usage of Guava Function interface (oak-store-spi) -…
reschke Jul 14, 2024
fd9f62e
OAK-10945: Remove usage of Guava Function interface (oak-store-docume…
reschke Jul 14, 2024
2e9f7ec
OAK-10945: Remove usage of Guava Function interface (oak-store-compos…
reschke Jul 14, 2024
9b7921b
OAK-10945: Remove usage of Guava Function interface (oak-segment-tar)…
reschke Jul 14, 2024
4ae816d
OAK-10945: Remove usage of Guava Function interface (oak-lucene) - cl…
reschke Jul 14, 2024
98e9c30
OAK-10945: Remove usage of Guava Function interface (oak-jcr) - cleanup
reschke Jul 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
Expand All @@ -46,8 +45,8 @@
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.base.Strings;
import org.apache.jackrabbit.guava.common.cache.Cache;
import org.apache.jackrabbit.guava.common.cache.CacheBuilder;
Expand Down Expand Up @@ -463,13 +462,7 @@ public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
@Override
public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException {
return new RecordsIterator<DataIdentifier>(
new Function<AzureBlobInfo, DataIdentifier>() {
@Override
public DataIdentifier apply(AzureBlobInfo input) {
return new DataIdentifier(getIdentifierName(input.getName()));
}
}
);
input -> new DataIdentifier(getIdentifierName(input.getName())));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import com.amazonaws.services.s3.model.GetObjectMetadataRequest;
import com.amazonaws.services.s3.model.GetObjectRequest;
Expand Down Expand Up @@ -89,7 +90,6 @@
import com.amazonaws.services.s3.transfer.TransferManager;
import com.amazonaws.services.s3.transfer.Upload;
import com.amazonaws.util.StringUtils;
import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.base.Predicate;
import org.apache.jackrabbit.guava.common.base.Strings;
import org.apache.jackrabbit.guava.common.cache.Cache;
Expand Down Expand Up @@ -441,13 +441,7 @@ public InputStream read(DataIdentifier identifier)
@Override
public Iterator<DataIdentifier> getAllIdentifiers()
throws DataStoreException {
return new RecordsIterator<DataIdentifier>(
new Function<S3ObjectSummary, DataIdentifier>() {
@Override
public DataIdentifier apply(S3ObjectSummary input) {
return new DataIdentifier(getIdentifierName(input.getKey()));
}
});
return new RecordsIterator<DataIdentifier>(input -> new DataIdentifier(getIdentifierName(input.getKey())));
}

@Override
Expand Down Expand Up @@ -642,14 +636,8 @@ public void deleteAllMetadataRecords(String prefix) {
public Iterator<DataRecord> getAllRecords() {
final AbstractSharedBackend backend = this;
return new RecordsIterator<DataRecord>(
new Function<S3ObjectSummary, DataRecord>() {
@Override
public DataRecord apply(S3ObjectSummary input) {
return new S3DataRecord(backend, s3service, bucket,
new DataIdentifier(getIdentifierName(input.getKey())),
input.getLastModified().getTime(), input.getSize(), s3ReqDecorator);
}
});
input -> new S3DataRecord(backend, s3service, bucket, new DataIdentifier(getIdentifierName(input.getKey())),
input.getLastModified().getTime(), input.getSize(), s3ReqDecorator));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.base.Stopwatch;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterators;
Expand Down Expand Up @@ -277,11 +276,7 @@ public DataRecord addRecord(InputStream inputStream, BlobOptions blobOptions)
@Override
public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException {
return Iterators.concat(Iterators.transform(cache.getStagingCache().getAllIdentifiers(),
new Function<String, DataIdentifier>() {
@Nullable @Override public DataIdentifier apply(@Nullable String id) {
return new DataIdentifier(id);
}
}), backend.getAllIdentifiers());
id -> new DataIdentifier(id)), backend.getAllIdentifiers());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.base.Joiner;
import org.apache.jackrabbit.guava.common.base.StandardSystemProperty;
import org.apache.jackrabbit.guava.common.base.Stopwatch;
Expand Down Expand Up @@ -264,22 +263,14 @@ public List<GarbageCollectionRepoStats> getStats() throws Exception {
List<DataRecord> refFiles =
((SharedDataStore) blobStore).getAllMetadataRecords(SharedStoreRecordType.REFERENCES.getType());
ImmutableListMultimap<String, DataRecord> references =
FluentIterable.from(refFiles).index(new Function<DataRecord, String>() {
@Override public String apply(DataRecord input) {
return SharedStoreRecordType.REFERENCES.getIdFromName(input.getIdentifier().toString());

}
});
FluentIterable.from(refFiles).index(
input -> SharedStoreRecordType.REFERENCES.getIdFromName(input.getIdentifier().toString()));

// Get all the markers available
List<DataRecord> markerFiles =
((SharedDataStore) blobStore).getAllMetadataRecords(SharedStoreRecordType.MARKED_START_MARKER.getType());
Map<String, DataRecord> markers = Maps.uniqueIndex(markerFiles, new Function<DataRecord, String>() {
@Override
public String apply(DataRecord input) {
return input.getIdentifier().toString().substring(SharedStoreRecordType.MARKED_START_MARKER.getType().length() + 1);
}
});
Map<String, DataRecord> markers = Maps.uniqueIndex(markerFiles,
input -> input.getIdentifier().toString().substring(SharedStoreRecordType.MARKED_START_MARKER.getType().length() + 1));

// Get all the repositories registered
List<DataRecord> repoFiles =
Expand Down Expand Up @@ -645,16 +636,12 @@ public void addReference(String blobId, final String nodeId) {
final Joiner delimJoiner = Joiner.on(DELIM).skipNulls();
Iterator<List<String>> partitions = Iterators.partition(idIter, getBatchCount());
while (partitions.hasNext()) {
List<String> idBatch = Lists.transform(partitions.next(), new Function<String,
String>() {
@Nullable @Override
public String apply(@Nullable String id) {
List<String> idBatch = Lists.transform(partitions.next(), id -> {
if (logPath) {
return delimJoiner.join(id, nodeId);
}
return id;
}
});
});
if (debugMode) {
LOG.trace("chunkIds : {}", idBatch);
}
Expand Down Expand Up @@ -891,7 +878,7 @@ long mergeAllMarkedReferences(GarbageCollectableBlobStore blobStore, GarbageColl
List<DataRecord> repoFiles =
((SharedDataStore) blobStore).getAllMetadataRecords(SharedStoreRecordType.REPOSITORY.getType());
LOG.info("Repositories registered {}", repoFiles);

// Retrieve repos for which reference files have not been created
Set<String> unAvailRepos =
SharedDataStoreUtils.refsNotAvailableFromRepos(repoFiles, refFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.base.Predicate;
import org.apache.jackrabbit.guava.common.base.Stopwatch;
import org.apache.jackrabbit.guava.common.collect.Lists;
Expand Down Expand Up @@ -77,7 +75,6 @@
import static org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.BlobIdStore.Type.IN_PROCESS;
import static org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.BlobIdStore.Type.REFS;


/**
* Tracks the blob ids available or added in the blob store using the {@link BlobIdStore} .
*
Expand Down Expand Up @@ -271,8 +268,7 @@ private void globalMerge() throws IOException {
Iterable<DataRecord> refRecords = datastore.getAllMetadataRecords(fileNamePrefix);

// Download all the corresponding files for the records
List<File> refFiles = newArrayList(transform(refRecords, new Function<DataRecord, File>() {
@Override public File apply(DataRecord input) {
List<File> refFiles = newArrayList(transform(refRecords, input -> {
InputStream inputStream = null;
try {
inputStream = input.getStream();
Expand All @@ -283,8 +279,7 @@ private void globalMerge() throws IOException {
closeQuietly(inputStream);
}
return null;
}
}));
}));
LOG.info("Retrieved all blob id files in [{}]", watch.elapsed(TimeUnit.MILLISECONDS));

// Merge all the downloaded files in to the local store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.jackrabbit.guava.common.base.Function;

import org.apache.jackrabbit.guava.common.base.Predicate;
import org.apache.jackrabbit.guava.common.base.Strings;
import org.apache.jackrabbit.guava.common.collect.Iterators;
Expand Down Expand Up @@ -525,15 +525,12 @@ public boolean apply(@Nullable DataRecord input) {
}
return false;
}
}), new Function<DataRecord, String>() {
@Override
public String apply(DataRecord input) {
}), input -> {
if (encodeLengthInId) {
return BlobId.of(input).encodedValue();
}
return input.getIdentifier().toString();
}
});
});
}

@Override
Expand Down Expand Up @@ -775,18 +772,14 @@ public Iterator<DataRecord> getAllRecords() throws DataStoreException {
Iterator<DataRecord> result = delegate instanceof SharedDataStore ?
((SharedDataStore) delegate).getAllRecords() :
Iterators.transform(delegate.getAllIdentifiers(),
new Function<DataIdentifier, DataRecord>() {
@Nullable
@Override
public DataRecord apply(@Nullable DataIdentifier input) {
input -> {
try {
return delegate.getRecord(input);
} catch (DataStoreException e) {
log.warn("Error occurred while fetching DataRecord for identifier {}", input, e);
}
return null;
}
});
});

if (stats instanceof ExtendedBlobStatsCollector) {
((ExtendedBlobStatsCollector) stats).getAllRecordsCalled(System.nanoTime() - start, TimeUnit.NANOSECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.base.Joiner;
import org.apache.jackrabbit.guava.common.base.Splitter;
import org.apache.jackrabbit.guava.common.collect.FluentIterable;
Expand Down Expand Up @@ -61,7 +61,7 @@ public static DataRecord getEarliestRecord(List<DataRecord> recs) {
public Long apply(@NotNull DataRecord input) {
return input.getLastModified();
}
}).min(recs);
}::apply).min(recs);
}

/**
Expand All @@ -73,22 +73,10 @@ public Long apply(@NotNull DataRecord input) {
*/
public static Set<String> refsNotAvailableFromRepos(List<DataRecord> repos,
List<DataRecord> refs) {
return Sets.difference(FluentIterable.from(repos).uniqueIndex(
new Function<DataRecord, String>() {
@Override
@Nullable
public String apply(@NotNull DataRecord input) {
return SharedStoreRecordType.REPOSITORY.getIdFromName(input.getIdentifier().toString());
}
}).keySet(),
FluentIterable.from(refs).index(
new Function<DataRecord, String>() {
@Override
@Nullable
public String apply(@NotNull DataRecord input) {
return SharedStoreRecordType.REFERENCES.getIdFromName(input.getIdentifier().toString());
}
}).keySet());
return Sets.difference(FluentIterable.from(repos)
.uniqueIndex(input -> SharedStoreRecordType.REPOSITORY.getIdFromName(input.getIdentifier().toString())).keySet(),
FluentIterable.from(refs)
.index(input -> SharedStoreRecordType.REFERENCES.getIdFromName(input.getIdentifier().toString())).keySet());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.guava.common.collect.Maps;
Expand All @@ -49,7 +48,6 @@
import org.apache.jackrabbit.oak.plugins.blob.datastore.SharedDataStoreUtils;
import org.apache.jackrabbit.oak.plugins.blob.datastore.SharedDataStoreUtils.SharedStoreRecordType;
import org.apache.jackrabbit.oak.stats.Clock;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -481,11 +479,7 @@ public void testGetAllRecords() throws Exception {
}

Set<String> retrieved = newHashSet(Iterables.transform(newHashSet(dataStore.getAllRecords()),
new Function<DataRecord, String>() {
@Nullable @Override public String apply(@Nullable DataRecord input) {
return input.getIdentifier().toString();
}
}));
input -> input.getIdentifier().toString()));
assertEquals(added, retrieved);
}

Expand Down Expand Up @@ -515,11 +509,7 @@ public void testGetAllRecordsWithMeta() throws Exception {
}

Set<String> retrieved = newHashSet(Iterables.transform(newHashSet(dataStore.getAllRecords()),
new Function<DataRecord, String>() {
@Nullable @Override public String apply(@Nullable DataRecord input) {
return input.getIdentifier().toString();
}
}));
input -> input.getIdentifier().toString()));
assertEquals(added, retrieved);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Set;
import java.util.UUID;

import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Lists;
Expand All @@ -44,7 +43,6 @@
import org.apache.jackrabbit.oak.spi.blob.AbstractBlobStoreTest;
import org.apache.jackrabbit.oak.spi.blob.BlobStoreInputStream;
import org.apache.jackrabbit.oak.spi.blob.stats.BlobStatsCollector;
import org.jetbrains.annotations.Nullable;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -174,13 +172,7 @@ public void testGetAllChunks() throws Exception{
DataIdentifier d30 = new DataIdentifier("d-30");
List<DataIdentifier> dis = ImmutableList.of(d10, d20, d30);
List<DataRecord> recs = Lists.newArrayList(
Iterables.transform(dis, new Function<DataIdentifier, DataRecord>() {
@Nullable
@Override
public DataRecord apply(@Nullable DataIdentifier input) {
return new TimeDataRecord(input);
}
}));
Iterables.transform(dis, input -> new TimeDataRecord(input)));
OakFileDataStore mockedDS = mock(OakFileDataStore.class);
when(mockedDS.getAllRecords()).thenReturn(recs.iterator());
when(mockedDS.getRecord(new DataIdentifier("d-10"))).thenReturn(new TimeDataRecord(d10));
Expand Down
Loading
Loading