Skip to content

Commit

Permalink
Spotless apply
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Aug 22, 2024
1 parent cd5f05f commit ea630c8
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 54 deletions.
131 changes: 91 additions & 40 deletions server/src/main/java/org/opensearch/search/SearchHit.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
package org.opensearch.search;

import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.TotalHits;
import org.opensearch.OpenSearchParseException;
import org.opensearch.Version;
import org.opensearch.action.OriginalIndices;
import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.ExperimentalApi;
Expand Down Expand Up @@ -81,13 +79,8 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
import static java.util.Collections.unmodifiableMap;
import static org.opensearch.common.lucene.Lucene.readExplanation;
import static org.opensearch.common.lucene.Lucene.writeExplanation;
import static org.opensearch.core.xcontent.ConstructingObjectParser.constructorArg;
import static org.opensearch.core.xcontent.ConstructingObjectParser.optionalConstructorArg;
import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken;
Expand Down Expand Up @@ -169,22 +162,23 @@ public SearchHit(
this.metaFields = metaFields == null ? emptyMap() : metaFields;
}

public SearchHit(int docId,
float score,
long seqNo,
long version,
long primaryTerm,
Text id,
BytesReference source,
SearchShardTarget shardTarget,
Explanation explanation,
SearchSortValues sortValues,
SearchHit.NestedIdentity nestedIdentity,
Map<String, DocumentField> documentFields,
Map<String, DocumentField> metaFields,
Map<String, HighlightField> highlightFields,
Map<String, Float> matchedQueries,
Map<String, SearchHits> innerHits
public SearchHit(
int docId,
float score,
long seqNo,
long version,
long primaryTerm,
Text id,
BytesReference source,
SearchShardTarget shardTarget,
Explanation explanation,
SearchSortValues sortValues,
SearchHit.NestedIdentity nestedIdentity,
Map<String, DocumentField> documentFields,
Map<String, DocumentField> metaFields,
Map<String, HighlightField> highlightFields,
Map<String, Float> matchedQueries,
Map<String, SearchHits> innerHits
) throws IOException {
this.docId = docId;
this.score = score;
Expand All @@ -206,8 +200,7 @@ public SearchHit(int docId,
shard(shardTarget);
}

public SearchHit(SearchHit hit
) throws IOException {
public SearchHit(SearchHit hit) throws IOException {
this.docId = hit.docId;
this.score = hit.score;
this.seqNo = hit.seqNo;
Expand Down Expand Up @@ -244,39 +237,97 @@ public SearchHit(StreamInput in) throws IOException {
@ExperimentalApi
public interface SerializationAccess {
float getScore();

Text getId();

NestedIdentity getNestedIdentity();

long getVersion();

long getSeqNo();

long getPrimaryTerm();

BytesReference getSource();

Explanation getExplanation();

Map<String, DocumentField> getDocumentFields();

Map<String, DocumentField> getMetaFields();

Map<String, HighlightField> getHighlightedFields();

SearchSortValues getSortValues();

Map<String, Float> getMatchedQueries();

SearchShardTarget getShard();

Map<String, SearchHits> getInnerHits();
}

public SearchHit.SerializationAccess getSerAccess() {
return new SearchHit.SerializationAccess() {
public float getScore() { return score; }
public Text getId() { return id; }
public NestedIdentity getNestedIdentity() { return nestedIdentity; }
public long getVersion() { return version; }
public long getSeqNo() { return seqNo; }
public long getPrimaryTerm() { return primaryTerm; }
public BytesReference getSource() { return source; }
public Explanation getExplanation() { return explanation; }
public Map<String, DocumentField> getDocumentFields() { return documentFields; }
public Map<String, DocumentField> getMetaFields() { return metaFields; }
public Map<String, HighlightField> getHighlightedFields() { return highlightFields; }
public SearchSortValues getSortValues() { return sortValues; }
public Map<String, Float> getMatchedQueries() { return matchedQueries; }
public SearchShardTarget getShard() { return shard; }
public Map<String, SearchHits> getInnerHits() { return innerHits; }
public float getScore() {
return score;
}

public Text getId() {
return id;
}

public NestedIdentity getNestedIdentity() {
return nestedIdentity;
}

public long getVersion() {
return version;
}

public long getSeqNo() {
return seqNo;
}

public long getPrimaryTerm() {
return primaryTerm;
}

public BytesReference getSource() {
return source;
}

public Explanation getExplanation() {
return explanation;
}

public Map<String, DocumentField> getDocumentFields() {
return documentFields;
}

public Map<String, DocumentField> getMetaFields() {
return metaFields;
}

public Map<String, HighlightField> getHighlightedFields() {
return highlightFields;
}

public SearchSortValues getSortValues() {
return sortValues;
}

public Map<String, Float> getMatchedQueries() {
return matchedQueries;
}

public SearchShardTarget getShard() {
return shard;
}

public Map<String, SearchHits> getInnerHits() {
return innerHits;
}
};
}

Expand Down
18 changes: 13 additions & 5 deletions server/src/main/java/org/opensearch/search/SearchHits.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.rest.action.search.RestSearchAction;
import org.opensearch.search.fetch.FetchSearchResult;
import org.opensearch.search.internal.ShardSearchContextId;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -112,15 +110,25 @@ public SearchHits(
@ExperimentalApi
public interface SerializationAccess {
TotalHits getTotalHits();

float getMaxScore();

SearchHit[] getHits();
}

public SearchHits.SerializationAccess getSerAccess() {
return new SearchHits.SerializationAccess() {
public TotalHits getTotalHits() { return totalHits; }
public float getMaxScore() { return maxScore; }
public SearchHit[] getHits() { return hits; }
public TotalHits getTotalHits() {
return totalHits;
}

public float getMaxScore() {
return maxScore;
}

public SearchHit[] getHits() {
return hits;
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ public FetchSearchResult(ShardSearchContextId id, SearchShardTarget shardTarget)
@ExperimentalApi
public interface SerializationAccess {
ShardSearchContextId getShardSearchContextId();

SearchHits getHits();
}

public SerializationAccess getSerAccess() {
return new SerializationAccess() {
public ShardSearchContextId getShardSearchContextId() { return contextId; }
public SearchHits getHits() { return hits; }
public ShardSearchContextId getShardSearchContextId() {
return contextId;
}

public SearchHits getHits() {
return hits;
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

package org.opensearch.search.fetch.serde;

import org.opensearch.search.fetch.FetchSearchResult;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.search.fetch.FetchSearchResult;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import org.opensearch.Version;
import org.opensearch.common.document.DocumentField;
import org.opensearch.core.common.bytes.BytesReference;
import org.opensearch.core.common.text.Text;
import org.opensearch.search.SearchHit;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.text.Text;
import org.opensearch.search.SearchHit;
import org.opensearch.search.SearchHits;
import org.opensearch.search.SearchShardTarget;
import org.opensearch.search.SearchSortValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

package org.opensearch.search.fetch.serde;

import org.opensearch.search.SearchHits;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.search.SearchHits;

import java.io.IOException;

Expand Down
14 changes: 11 additions & 3 deletions server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@
public class SerDe {

public static class SerializationException extends RuntimeException {
public SerializationException(String message) { super(message); }
public SerializationException(String message, Throwable cause) { super(message, cause); }
public SerializationException(Throwable cause) { super(cause); }
public SerializationException(String message) {
super(message);
}

public SerializationException(String message, Throwable cause) {
super(message, cause);
}

public SerializationException(Throwable cause) {
super(cause);
}
}

interface XContentSerializer<T> {
Expand Down

0 comments on commit ea630c8

Please sign in to comment.