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

Remove hppc from some "common" classes #85957

Merged
merged 1 commit into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -8,8 +8,6 @@

package org.elasticsearch.common.lucene.search;

import com.carrotsearch.hppc.ObjectHashSet;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
Expand All @@ -27,10 +25,12 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
import java.util.Set;

public class MultiPhrasePrefixQuery extends Query {

Expand Down Expand Up @@ -146,7 +146,7 @@ public Query rewrite(IndexReader reader) throws IOException {
}
Term[] suffixTerms = termArrays.get(sizeMinus1);
int position = positions.get(sizeMinus1);
ObjectHashSet<Term> terms = new ObjectHashSet<>();
Set<Term> terms = new HashSet<>();
for (Term term : suffixTerms) {
getPrefixTerms(terms, term, reader);
if (terms.size() > maxExpansions) {
Expand All @@ -169,11 +169,11 @@ public Query rewrite(IndexReader reader) throws IOException {
)
.build();
}
query.add(terms.toArray(Term.class), position);
query.add(terms.toArray(new Term[0]), position);
return query.build();
}

private void getPrefixTerms(ObjectHashSet<Term> terms, final Term prefix, final IndexReader reader) throws IOException {
private void getPrefixTerms(Set<Term> terms, final Term prefix, final IndexReader reader) throws IOException {
// SlowCompositeReaderWrapper could be used... but this would merge all terms from each segment into one terms
// instance, which is very expensive. Therefore I think it is better to iterate over each leaf individually.
List<LeafReaderContext> leaves = reader.leaves();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

package org.elasticsearch.common.transport;

import com.carrotsearch.hppc.IntArrayList;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class PortsRange {
Expand All @@ -25,15 +25,12 @@ public String getPortRangeString() {
}

public int[] ports() throws NumberFormatException {
final IntArrayList ports = new IntArrayList();
iterate(new PortCallback() {
@Override
public boolean onPortNumber(int portNumber) {
ports.add(portNumber);
return false;
}
final List<Integer> ports = new ArrayList<>();
iterate(portNumber -> {
ports.add(portNumber);
return false;
});
return ports.toArray();
return ports.stream().mapToInt(Integer::intValue).toArray();
}

public boolean iterate(PortCallback callback) throws NumberFormatException {
Expand Down