Skip to content

OAK-11024 : removed usage of Sets.newHashSet#1678

Merged
rishabhdaim merged 5 commits intotrunkfrom
OAK-11024
Sep 10, 2024
Merged

OAK-11024 : removed usage of Sets.newHashSet#1678
rishabhdaim merged 5 commits intotrunkfrom
OAK-11024

Conversation

@rishabhdaim
Copy link
Contributor

No description provided.

Copy link
Contributor

@reschke reschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments; will do full review later on


// membership-nesting is 1 => expect only 'USER_ID' plus the declared group-membership
Set<String> expected = Sets.newHashSet(USER_ID);
Set<String> expected = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe:

Set expected = Stream.of(USER_ID).collect(Collectors.toSet());

?


Set<String> retrieved = newHashSet(Iterables.transform(newHashSet(dataStore.getAllRecords()),
input -> input.getIdentifier().toString()));
Set<DataRecord> recordSet = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

CollectionUtils.toSet(...)

?


Set<String> retrieved = newHashSet(Iterables.transform(newHashSet(dataStore.getAllRecords()),
input -> input.getIdentifier().toString()));
Set<DataRecord> recordSet = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

}

Set<DataRecord> retrieved = newHashSet((dataStore.getAllRecords()));
Set<DataRecord> retrieved = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

@rishabhdaim rishabhdaim force-pushed the OAK-11024 branch 10 times, most recently from 30a5630 to 3db5fe3 Compare September 10, 2024 03:51
@rishabhdaim rishabhdaim requested a review from reschke September 10, 2024 05:07
@rishabhdaim
Copy link
Contributor Author

@reschke @mbaedke Updated this PR with utils from oak-commons. Could you please review and share feedback?

@rishabhdaim rishabhdaim requested a review from mbaedke September 10, 2024 05:16
Copy link
Contributor

@reschke reschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot :-)

  • I believe you missed a few cases where you touched StreamSupport (maybe just because of removing static imports) where we could now use CollectionUtils
  • furthermore it would be good to converge on a strategy whether Collectors.something should be a static import (right now it seems to me mixed)

// that's not stored along with the other mappings
Set<String> prefixes = newHashSet("");
Set<String> uris = newHashSet("");
Set<String> prefixes = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CollectionUtils?

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop

private boolean waitForRunningIndexCycles() {
Map<IndexStatsMBean, Long> origIndexLaneToExecutinoCountMap = Maps.asMap(
Sets.newHashSet(StreamSupport.stream(asyncIndexInfoService.getAsyncLanes().spliterator(), false)
new HashSet<>(StreamSupport.stream(asyncIndexInfoService.getAsyncLanes().spliterator(), false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use CollectionUtils?

Copy link
Contributor Author

@rishabhdaim rishabhdaim Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this would give us any additional benefit.


private List<String> getReindexIndexPaths() {
return stream(store.getRoot().getChildNode(INDEX_DEFINITIONS_NAME).getChildNodeEntries().spliterator(), false)
return StreamSupport.stream(store.getRoot().getChildNode(INDEX_DEFINITIONS_NAME).getChildNodeEntries().spliterator(), false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CollectionUtils?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is returning List not Set

val.append(" = {").append(v).append("}");
} else if (ps.getType() == BINARIES) {
String v = stream(ps.getValue(BINARIES).spliterator(), false)
String v = StreamSupport.stream(ps.getValue(BINARIES).spliterator(), false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CollectionUtils?

import java.util.stream.Collectors;

import static java.util.stream.Collectors.toSet;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should agree on a consistent strategy whether the Collector imports should be static (I'm leaning towards "no")..

*/
public Iterable<NodeDocument> getPossiblyDeletedDocs(final long fromModified, final long toModified) {
return stream(getSelectedDocuments(store, NodeDocument.DELETED_ONCE, 1).spliterator(), false)
return StreamSupport.stream(getSelectedDocuments(store, NodeDocument.DELETED_ONCE, 1).spliterator(), false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CollectionUtils?

@NotNull final Set<String> excludePaths) {
// (_modified = fromModified && _id > fromId || _modified > fromModified && _modified < toModified)
final Stream<NodeDocument> s1 = stream(getSelectedDocuments(store,
final Stream<NodeDocument> s1 = StreamSupport.stream(getSelectedDocuments(store,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CollectionUtils?

@rishabhdaim
Copy link
Contributor Author

rishabhdaim commented Sep 10, 2024

thanks for the review @reschke. I only changed where we are using Guava's newHashSet.

Let's open separate Jiras for other changes instead of piggybacking this one.

For now, I will merge this PR.

@rishabhdaim rishabhdaim merged commit c6bd519 into trunk Sep 10, 2024
@rishabhdaim rishabhdaim deleted the OAK-11024 branch September 10, 2024 17:39
@reschke
Copy link
Contributor

reschke commented Sep 10, 2024

Works for me; at some point we need final cleanup sweep anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments