Skip to content

Commit

Permalink
Cleanup dead code in o.e.common (round 2) (#87825)
Browse files Browse the repository at this point in the history
Another 500+ LoC of simple deletes.
  • Loading branch information
original-brownbear committed Jun 22, 2022
1 parent 78c0ad9 commit a7064ba
Show file tree
Hide file tree
Showing 18 changed files with 8 additions and 551 deletions.
4 changes: 0 additions & 4 deletions server/src/main/java/org/elasticsearch/common/Rounding.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,6 @@ public TemporalField getField() {
return field;
}

public static DateTimeUnit resolve(String name) {
return DateTimeUnit.valueOf(name.toUpperCase(Locale.ROOT));
}

public String shortName() {
return shortName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import java.util.function.Predicate;

/**
* An immutable map implementation based on open hash map.
Expand Down Expand Up @@ -458,13 +457,6 @@ public VType getOrDefault(KType kType, VType vType) {
return mutableMap.getOrDefault(kType, vType);
}

public void putAll(Builder<KType, VType> builder) {
maybeCloneMap();
for (var entry : builder.mutableMap) {
mutableMap.put(entry.key, entry.value);
}
}

public VType remove(KType key) {
maybeCloneMap();
return mutableMap.remove(key);
Expand All @@ -480,16 +472,6 @@ public int size() {
return mutableMap.size();
}

public boolean isEmpty() {
maybeCloneMap();
return mutableMap.isEmpty();
}

public int removeAll(Predicate<? super KType> predicate) {
maybeCloneMap();
return mutableMap.removeAll(predicate::test);
}

public void clear() {
maybeCloneMap();
mutableMap.clear();
Expand All @@ -505,15 +487,5 @@ public int removeAll(BiPredicate<? super KType, ? super VType> predicate) {
return mutableMap.removeAll(predicate::test);
}

public int indexOf(KType key) {
maybeCloneMap();
return mutableMap.indexOf(key);
}

public void release() {
maybeCloneMap();
mutableMap.release();
}

}
}
5 changes: 0 additions & 5 deletions server/src/main/java/org/elasticsearch/common/io/Streams.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ public void close() throws IOException {
flush();
}

@Override
public void reset() throws IOException {
delegate.reset();
}

@Override
public BytesReference bytes() {
return delegate.bytes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public void writeBytes(byte[] b, int offset, int length) {
count += length;
}

@Override
public void reset() {
// shrink list of pages
if (bytes != null && bytes.size() > PageCacheRecycler.PAGE_SIZE_IN_BYTES) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public void flush() throws IOException {
// nothing to do there...
}

@Override
public void reset() throws IOException {
// nothing to do there...
}

@Override
public void close() throws IOException {
if (out instanceof Closeable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,5 @@ public void flush() throws IOException {}

@Override
public void close() throws IOException {}

@Override
public void reset() throws IOException {
size = 0;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,4 @@ public void flush() throws IOException {
public void close() throws IOException {
out.close();
}

@Override
public void reset() throws IOException {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public void writeWithSizePrefix(Writeable writeable) throws IOException {
}
}

@Override
public void reset() {
Releasables.close(pages);
pages.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,6 @@ public void writeOptionalBoolean(@Nullable Boolean b) throws IOException {
@Override
public abstract void close() throws IOException;

public abstract void reset() throws IOException;

@Override
public void write(int b) throws IOException {
writeByte((byte) b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ public void close() throws IOException {

}

@Override
public void reset() throws IOException {
// no-op
}

@Override
public void writeNamedWriteable(NamedWriteable namedWriteable) throws IOException {
if (namedWriteable instanceof VersionedNamedWriteable vnw) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.search.similarities.TFIDFSimilarity;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.Strings;
import org.elasticsearch.index.analysis.NamedAnalyzer;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

Expand Down Expand Up @@ -213,10 +211,6 @@ public String getLikeText() {
return (likeText == null ? null : likeText[0]);
}

public String[] getLikeTexts() {
return likeText;
}

public void setLikeText(String... likeText) {
this.likeText = likeText;
}
Expand All @@ -229,10 +223,6 @@ public void setLikeFields(Fields... likeFields) {
this.likeFields = likeFields;
}

public void setLikeText(List<String> likeText) {
setLikeText(likeText.toArray(Strings.EMPTY_ARRAY));
}

public void setUnlikeFields(Fields... unlikeFields) {
this.unlikeFields = unlikeFields;
}
Expand All @@ -249,10 +239,6 @@ public void setMoreLikeFields(String[] moreLikeFields) {
this.moreLikeFields = moreLikeFields;
}

public Similarity getSimilarity() {
return similarity;
}

public void setSimilarity(Similarity similarity) {
if (similarity == null || similarity instanceof TFIDFSimilarity) {
// LUCENE 4 UPGRADE we need TFIDF similarity here so I only set it if it is an instance of it
Expand All @@ -269,16 +255,6 @@ public void setAnalyzer(String analyzerName, Analyzer analyzer) {
this.analyzerName = analyzerName;
}

/**
* Number of terms that must match the generated query expressed in the
* common syntax for minimum should match.
*
* @see org.elasticsearch.common.lucene.search.Queries#calculateMinShouldMatch(int, String)
*/
public String getMinimumShouldMatch() {
return minimumShouldMatch;
}

/**
* Number of terms that must match the generated query expressed in the
* common syntax for minimum should match. Defaults to {@code 30%}.
Expand Down Expand Up @@ -308,58 +284,30 @@ public void setMaxQueryTerms(int maxQueryTerms) {
this.maxQueryTerms = maxQueryTerms;
}

public Set<?> getStopWords() {
return stopWords;
}

public void setStopWords(Set<?> stopWords) {
this.stopWords = stopWords;
}

public int getMinDocFreq() {
return minDocFreq;
}

public void setMinDocFreq(int minDocFreq) {
this.minDocFreq = minDocFreq;
}

public int getMaxDocFreq() {
return maxDocFreq;
}

public void setMaxDocFreq(int maxDocFreq) {
this.maxDocFreq = maxDocFreq;
}

public int getMinWordLen() {
return minWordLen;
}

public void setMinWordLen(int minWordLen) {
this.minWordLen = minWordLen;
}

public int getMaxWordLen() {
return maxWordLen;
}

public void setMaxWordLen(int maxWordLen) {
this.maxWordLen = maxWordLen;
}

public boolean isBoostTerms() {
return boostTerms;
}

public void setBoostTerms(boolean boostTerms) {
this.boostTerms = boostTerms;
}

public float getBoostTermsFactor() {
return boostTermsFactor;
}

public void setBoostTermsFactor(float boostTermsFactor) {
this.boostTermsFactor = boostTermsFactor;
}
Expand Down

0 comments on commit a7064ba

Please sign in to comment.