From 0f94bf88bb9e122f939339543721ef7fa7ddb333 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 21 Aug 2024 12:07:04 -0700 Subject: [PATCH 01/61] SerDe interfaces Signed-off-by: Finn Carroll --- .../fetch/serde/FetchSearchResultsSerDe.java | 36 +++++++++++++++++ .../opensearch/search/fetch/serde/SerDe.java | 39 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java create mode 100644 server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java new file mode 100644 index 0000000000000..826a691cbdb5b --- /dev/null +++ b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java @@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +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 java.io.IOException; + +public class FetchSearchResultsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { + + @Override + public FetchSearchResult deserialize(StreamInput in) { + try { + return new FetchSearchResult(in); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); + } + } + + @Override + public void serialize(FetchSearchResult object, StreamOutput out) throws SerDe.SerializationException { + try { + object.writeTo(out); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); + } + } +} diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java new file mode 100644 index 0000000000000..86aa89c22e2a3 --- /dev/null +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java @@ -0,0 +1,39 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.fetch.serde; + +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentParser; + +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); } + } + + interface XContentSerializer { + public XContentBuilder serialize(T object) throws SerializationException; + } + + interface XContentDeserializer { + public V deserialize(XContentParser parser) throws SerializationException; + } + + interface StreamSerializer { + public void serialize(T object, StreamOutput out) throws SerializationException; + } + + interface StreamDeserializer { + public V deserialize(StreamInput in) throws SerializationException; + } +} From 1dbe9c10502ad8675621ec6acf07bd26f17e1e97 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 21 Aug 2024 16:08:32 -0700 Subject: [PATCH 02/61] Nest SerDe interfaces Signed-off-by: Finn Carroll --- .../fetch/serde/FetchSearchResultsSerDe.java | 1 + .../search/fetch/serde/SearchHitSerDe.java | 36 ++++++++++++++++++ .../search/fetch/serde/SearchHitsSerDe.java | 37 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java create mode 100644 server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java index 826a691cbdb5b..c4dc7565ebe3c 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java @@ -15,6 +15,7 @@ import java.io.IOException; public class FetchSearchResultsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { + SearchHitsSerDe searchHitsSerDe; @Override public FetchSearchResult deserialize(StreamInput in) { diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java new file mode 100644 index 0000000000000..a4358faee53c7 --- /dev/null +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.fetch.serde; + +import org.opensearch.search.SearchHit; +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.common.io.stream.StreamOutput; + +import java.io.IOException; + +public class SearchHitSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { + + @Override + public SearchHit deserialize(StreamInput in) { + try { + return new SearchHit(in); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); + } + } + + @Override + public void serialize(SearchHit object, StreamOutput out) throws SerDe.SerializationException { + try { + object.writeTo(out); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); + } + } +} diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java new file mode 100644 index 0000000000000..569efd4fa269f --- /dev/null +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java @@ -0,0 +1,37 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +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 java.io.IOException; + +public class SearchHitsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { + SearchHitSerDe searchHitSerDe; + + @Override + public SearchHits deserialize(StreamInput in) { + try { + return new SearchHits(in); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); + } + } + + @Override + public void serialize(SearchHits object, StreamOutput out) throws SerDe.SerializationException { + try { + object.writeTo(out); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); + } + } +} From cfd3d7fac46d4d5ef97418b8a15b1aa4be30e780 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 21 Aug 2024 16:09:28 -0700 Subject: [PATCH 03/61] Add serialization interface for select serializable classes Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 39 +++++++++++++++++++ .../org/opensearch/search/SearchHits.java | 16 ++++++++ .../search/fetch/FetchSearchResult.java | 14 ++++++- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 6391353cfe5b1..8b5c1853102c9 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -33,6 +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; @@ -236,6 +237,44 @@ public SearchHit(StreamInput in) throws IOException { } } + public interface SerializationAccess { + float getScore(); + Text getId(); + NestedIdentity getNestedIdentity(); + long getVersion(); + long getSeqNo(); + long getPrimaryTerm(); + BytesReference getSource(); + Explanation getExplanation(); + Map getDocumentFields(); + Map getMetaFields(); + Map getHighlightedFields(); + SearchSortValues getSortValues(); + Map getMatchedQueries(); + SearchShardTarget getShard(); + Map 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 getDocumentFields() { return documentFields; } + public Map getMetaFields() { return metaFields; } + public Map getHighlightedFields() { return highlightFields; } + public SearchSortValues getSortValues() { return sortValues; } + public Map getMatchedQueries() { return matchedQueries; } + public SearchShardTarget getShard() { return shard; } + public Map getInnerHits() { return innerHits; } + }; + } + private static final Text SINGLE_MAPPING_TYPE = new Text(MapperService.SINGLE_MAPPING_NAME); @Override diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index 8232643b353f5..a33c24817d84f 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -45,6 +45,8 @@ 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; @@ -102,6 +104,20 @@ public SearchHits( this.collapseValues = collapseValues; } + 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 SearchHits(StreamInput in) throws IOException { if (in.readBoolean()) { totalHits = Lucene.readTotalHits(in); diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index 26fa90141c2a9..dde2c3c8ea5fe 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -50,7 +50,7 @@ * @opensearch.api */ @PublicApi(since = "1.0.0") -public final class FetchSearchResult extends SearchPhaseResult { +public class FetchSearchResult extends SearchPhaseResult { private SearchHits hits; // client side counter @@ -69,6 +69,18 @@ public FetchSearchResult(ShardSearchContextId id, SearchShardTarget shardTarget) setSearchShardTarget(shardTarget); } + public interface SerializationAccess { + ShardSearchContextId getShardSearchContextId(); + SearchHits getHits(); + } + + public SerializationAccess getSerAccess() { + return new SerializationAccess() { + public ShardSearchContextId getShardSearchContextId() { return contextId; } + public SearchHits getHits() { return hits; } + }; + } + @Override public QuerySearchResult queryResult() { return null; From d457b8d83a04753f3669413c2e6cd2ef2196ebc1 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 21 Aug 2024 16:59:25 -0700 Subject: [PATCH 04/61] Port verbatim SearchHit fromstream implementation to SerDe class Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 8b5c1853102c9..4e943c0d5af74 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -167,6 +167,39 @@ public SearchHit( this.metaFields = metaFields == null ? emptyMap() : metaFields; } + public SearchHit(int docId, + float score, + long seqNo, + long version, + long primaryTerm, + Text id, + BytesReference source, + Explanation explanation, + SearchSortValues sortValues, + SearchHit.NestedIdentity nestedIdentity, + Map documentFields, + Map metaFields, + Map highlightFields, + Map matchedQueries, + Map innerHits + ) throws IOException { + this.docId = docId; + this.score = score; + this.seqNo = seqNo; + this.version = version; + this.primaryTerm = primaryTerm; + this.id = id; + this.source = source; + this.explanation = explanation; + this.sortValues = sortValues; + this.nestedIdentity = nestedIdentity; + this.documentFields = documentFields == null ? Collections.emptyMap() : documentFields; + this.metaFields = metaFields == null ? Collections.emptyMap() : metaFields; + this.highlightFields = highlightFields == null ? Collections.emptyMap() : highlightFields; + this.matchedQueries = matchedQueries == null ? Collections.emptyMap() : matchedQueries; + this.innerHits = innerHits == null ? Collections.emptyMap() : innerHits; + } + public SearchHit(StreamInput in) throws IOException { docId = -1; score = in.readFloat(); From f3dc35eb82c716b73c53710ce4297b980be5a048 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 10:15:29 -0700 Subject: [PATCH 05/61] Cleanup SearchHit serialization code move Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 6 +- .../opensearch/search/SearchSortValues.java | 2 +- .../search/fetch/serde/SearchHitSerDe.java | 123 +++++++++++++++++- 3 files changed, 128 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 4e943c0d5af74..41ace413a0a9e 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -174,6 +174,7 @@ public SearchHit(int docId, long primaryTerm, Text id, BytesReference source, + SearchShardTarget shardTarget, Explanation explanation, SearchSortValues sortValues, SearchHit.NestedIdentity nestedIdentity, @@ -198,6 +199,9 @@ public SearchHit(int docId, this.highlightFields = highlightFields == null ? Collections.emptyMap() : highlightFields; this.matchedQueries = matchedQueries == null ? Collections.emptyMap() : matchedQueries; this.innerHits = innerHits == null ? Collections.emptyMap() : innerHits; + + // we call the setter here because that also sets the local index parameter + shard(shardTarget); } public SearchHit(StreamInput in) throws IOException { @@ -1129,7 +1133,7 @@ public NestedIdentity(String field, int offset, NestedIdentity child) { this.child = child; } - NestedIdentity(StreamInput in) throws IOException { + public NestedIdentity(StreamInput in) throws IOException { field = in.readOptionalText(); offset = in.readInt(); child = in.readOptionalWriteable(NestedIdentity::new); diff --git a/server/src/main/java/org/opensearch/search/SearchSortValues.java b/server/src/main/java/org/opensearch/search/SearchSortValues.java index cbc3900f72f79..659dd9f204a10 100644 --- a/server/src/main/java/org/opensearch/search/SearchSortValues.java +++ b/server/src/main/java/org/opensearch/search/SearchSortValues.java @@ -89,7 +89,7 @@ public SearchSortValues(Object[] rawSortValues, DocValueFormat[] sortValueFormat } } - SearchSortValues(StreamInput in) throws IOException { + public SearchSortValues(StreamInput in) throws IOException { this.formattedSortValues = in.readArray(Lucene::readSortValue, Object[]::new); this.rawSortValues = in.readArray(Lucene::readSortValue, Object[]::new); } diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java index a4358faee53c7..550e4bea757ff 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -8,18 +8,34 @@ package org.opensearch.search.fetch.serde; +import org.apache.lucene.search.Explanation; +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.search.SearchHits; +import org.opensearch.search.SearchShardTarget; +import org.opensearch.search.SearchSortValues; +import org.opensearch.search.fetch.subphase.highlight.HighlightField; import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.stream.Collectors; + +import static java.util.Collections.*; +import static org.opensearch.common.lucene.Lucene.readExplanation; public class SearchHitSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { @Override public SearchHit deserialize(StreamInput in) { try { - return new SearchHit(in); + return fromStream(in); } catch (IOException e) { throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); } @@ -33,4 +49,109 @@ public void serialize(SearchHit object, StreamOutput out) throws SerDe.Serializa throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); } } + + private SearchHit fromStream(StreamInput in) throws IOException { + int docId; + float score; + long seqNo; + long version; + long primaryTerm; + Text id; + BytesReference source; + SearchShardTarget shard; + Explanation explanation = null; + SearchSortValues sortValues; + SearchHit.NestedIdentity nestedIdentity; + Map documentFields; + Map metaFields; + Map highlightFields; + Map matchedQueries = Map.of(); + Map innerHits; + + docId = -1; + score = in.readFloat(); + id = in.readOptionalText(); + if (in.getVersion().before(Version.V_2_0_0)) { + in.readOptionalText(); + } + nestedIdentity = in.readOptionalWriteable(SearchHit.NestedIdentity::new); + version = in.readLong(); + seqNo = in.readZLong(); + primaryTerm = in.readVLong(); + source = in.readBytesReference(); + if (source.length() == 0) { + source = null; + } + if (in.readBoolean()) { + explanation = readExplanation(in); + } + documentFields = in.readMap(StreamInput::readString, DocumentField::new); + metaFields = in.readMap(StreamInput::readString, DocumentField::new); + + int size = in.readVInt(); + if (size == 0) { + highlightFields = emptyMap(); + } else if (size == 1) { + HighlightField field = new HighlightField(in); + highlightFields = singletonMap(field.name(), field); + } else { + Map hlFields = new HashMap<>(); + for (int i = 0; i < size; i++) { + HighlightField field = new HighlightField(in); + hlFields.put(field.name(), field); + } + highlightFields = unmodifiableMap(hlFields); + } + + sortValues = new SearchSortValues(in); + + size = in.readVInt(); + if (in.getVersion().onOrAfter(Version.V_2_13_0)) { + if (size > 0) { + Map tempMap = in.readMap(StreamInput::readString, StreamInput::readFloat); + matchedQueries = tempMap.entrySet() + .stream() + .sorted(Map.Entry.comparingByKey()) + .collect( + Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new) + ); + } + } else { + matchedQueries = new LinkedHashMap<>(size); + for (int i = 0; i < size; i++) { + matchedQueries.put(in.readString(), Float.NaN); + } + } + shard = in.readOptionalWriteable(SearchShardTarget::new); + size = in.readVInt(); + if (size > 0) { + innerHits = new HashMap<>(size); + for (int i = 0; i < size; i++) { + String key = in.readString(); + SearchHits value = new SearchHits(in); + innerHits.put(key, value); + } + } else { + innerHits = null; + } + + return new SearchHit( + docId, + score, + seqNo, + version, + primaryTerm, + id, + source, + shard, + explanation, + sortValues, + nestedIdentity, + documentFields, + metaFields, + highlightFields, + matchedQueries, + innerHits + ); + } } From 992a032308ab09b8f63a3265ceec09a28a9df6c4 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 10:26:39 -0700 Subject: [PATCH 06/61] Move SearchHit serialization to SerDe class Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 2 +- .../search/fetch/serde/SearchHitSerDe.java | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 41ace413a0a9e..d354d7f598081 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -312,7 +312,7 @@ public SearchHit.SerializationAccess getSerAccess() { }; } - private static final Text SINGLE_MAPPING_TYPE = new Text(MapperService.SINGLE_MAPPING_NAME); + public static final Text SINGLE_MAPPING_TYPE = new Text(MapperService.SINGLE_MAPPING_NAME); @Override public void writeTo(StreamOutput out) throws IOException { diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java index 550e4bea757ff..ce50ec5c30af6 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -29,6 +29,8 @@ import static java.util.Collections.*; import static org.opensearch.common.lucene.Lucene.readExplanation; +import static org.opensearch.common.lucene.Lucene.writeExplanation; +import static org.opensearch.search.SearchHit.SINGLE_MAPPING_TYPE; public class SearchHitSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { @@ -154,4 +156,72 @@ private SearchHit fromStream(StreamInput in) throws IOException { innerHits ); } + + private void toStream(SearchHit object, StreamOutput out) throws IOException { + SearchHit.SerializationAccess serI = object.getSerAccess(); + float score = serI.getScore(); + long seqNo = serI.getSeqNo(); + long version = serI.getVersion(); + long primaryTerm = serI.getPrimaryTerm(); + Text id = serI.getId(); + BytesReference source = serI.getSource(); + SearchShardTarget shard = serI.getShard(); + Explanation explanation = serI.getExplanation(); + SearchSortValues sortValues = serI.getSortValues(); + SearchHit.NestedIdentity nestedIdentity = serI.getNestedIdentity(); + Map documentFields = serI.getDocumentFields(); + Map metaFields = serI.getMetaFields(); + Map highlightFields = serI.getHighlightedFields(); + Map matchedQueries = serI.getMatchedQueries(); + Map innerHits = serI.getInnerHits(); + + out.writeFloat(score); + out.writeOptionalText(id); + if (out.getVersion().before(Version.V_2_0_0)) { + out.writeOptionalText(SINGLE_MAPPING_TYPE); + } + out.writeOptionalWriteable(nestedIdentity); + out.writeLong(version); + out.writeZLong(seqNo); + out.writeVLong(primaryTerm); + out.writeBytesReference(source); + if (explanation == null) { + out.writeBoolean(false); + } else { + out.writeBoolean(true); + writeExplanation(out, explanation); + } + out.writeMap(documentFields, StreamOutput::writeString, (stream, documentField) -> documentField.writeTo(stream)); + out.writeMap(metaFields, StreamOutput::writeString, (stream, documentField) -> documentField.writeTo(stream)); + if (highlightFields == null) { + out.writeVInt(0); + } else { + out.writeVInt(highlightFields.size()); + for (HighlightField highlightField : highlightFields.values()) { + highlightField.writeTo(out); + } + } + sortValues.writeTo(out); + + out.writeVInt(matchedQueries.size()); + if (out.getVersion().onOrAfter(Version.V_2_13_0)) { + if (!matchedQueries.isEmpty()) { + out.writeMap(matchedQueries, StreamOutput::writeString, StreamOutput::writeFloat); + } + } else { + for (String matchedFilter : matchedQueries.keySet()) { + out.writeString(matchedFilter); + } + } + out.writeOptionalWriteable(shard); + if (innerHits == null) { + out.writeVInt(0); + } else { + out.writeVInt(innerHits.size()); + for (Map.Entry entry : innerHits.entrySet()) { + out.writeString(entry.getKey()); + entry.getValue().writeTo(out); + } + } + } } From 8a31e75331551428bb0b1ab9e9d7754ca636298d Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 10:48:55 -0700 Subject: [PATCH 07/61] Swap out old serde in SearchHit - prefer serde done through dedicated class Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 148 ++++-------------- 1 file changed, 34 insertions(+), 114 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index d354d7f598081..e0c42422c4e34 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -66,6 +66,7 @@ import org.opensearch.index.mapper.SourceFieldMapper; import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.rest.action.search.RestSearchAction; +import org.opensearch.search.fetch.serde.SearchHitSerDe; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.search.lookup.SourceLookup; import org.opensearch.transport.RemoteClusterAware; @@ -204,74 +205,35 @@ public SearchHit(int docId, shard(shardTarget); } - public SearchHit(StreamInput in) throws IOException { - docId = -1; - score = in.readFloat(); - id = in.readOptionalText(); - if (in.getVersion().before(Version.V_2_0_0)) { - in.readOptionalText(); - } - nestedIdentity = in.readOptionalWriteable(NestedIdentity::new); - version = in.readLong(); - seqNo = in.readZLong(); - primaryTerm = in.readVLong(); - source = in.readBytesReference(); - if (source.length() == 0) { - source = null; - } - if (in.readBoolean()) { - explanation = readExplanation(in); - } - documentFields = in.readMap(StreamInput::readString, DocumentField::new); - metaFields = in.readMap(StreamInput::readString, DocumentField::new); - - int size = in.readVInt(); - if (size == 0) { - highlightFields = emptyMap(); - } else if (size == 1) { - HighlightField field = new HighlightField(in); - highlightFields = singletonMap(field.name(), field); - } else { - Map highlightFields = new HashMap<>(); - for (int i = 0; i < size; i++) { - HighlightField field = new HighlightField(in); - highlightFields.put(field.name(), field); - } - this.highlightFields = unmodifiableMap(highlightFields); - } + public SearchHit(SearchHit hit + ) throws IOException { + this.docId = hit.docId; + this.score = hit.score; + this.seqNo = hit.seqNo; + this.version = hit.version; + this.primaryTerm = hit.primaryTerm; + this.id = hit.id; + this.source = hit.source; + this.explanation = hit.explanation; + this.sortValues = hit.sortValues; + this.nestedIdentity = hit.nestedIdentity; + this.documentFields = hit.documentFields == null ? Collections.emptyMap() : hit.documentFields; + this.metaFields = hit.metaFields == null ? Collections.emptyMap() : hit.metaFields; + this.highlightFields = hit.highlightFields == null ? Collections.emptyMap() : hit.highlightFields; + this.matchedQueries = hit.matchedQueries == null ? Collections.emptyMap() : hit.matchedQueries; + this.innerHits = hit.innerHits == null ? Collections.emptyMap() : hit.innerHits; + this.sourceAsMap = hit.sourceAsMap == null ? Collections.emptyMap() : hit.sourceAsMap; - sortValues = new SearchSortValues(in); - - size = in.readVInt(); - if (in.getVersion().onOrAfter(Version.V_2_13_0)) { - if (size > 0) { - Map tempMap = in.readMap(StreamInput::readString, StreamInput::readFloat); - matchedQueries = tempMap.entrySet() - .stream() - .sorted(Map.Entry.comparingByKey()) - .collect( - Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new) - ); - } - } else { - matchedQueries = new LinkedHashMap<>(size); - for (int i = 0; i < size; i++) { - matchedQueries.put(in.readString(), Float.NaN); - } - } // we call the setter here because that also sets the local index parameter - shard(in.readOptionalWriteable(SearchShardTarget::new)); - size = in.readVInt(); - if (size > 0) { - innerHits = new HashMap<>(size); - for (int i = 0; i < size; i++) { - String key = in.readString(); - SearchHits value = new SearchHits(in); - innerHits.put(key, value); - } - } else { - innerHits = null; - } + shard(hit.shard); + } + + /** + * Preserving this constructor for compatibility. + * Going forward deserialize with dedicated SearchHitSerDe object. + */ + public SearchHit(StreamInput in) throws IOException { + this(new SearchHitSerDe().deserialize(in)); } public interface SerializationAccess { @@ -314,56 +276,14 @@ public SearchHit.SerializationAccess getSerAccess() { public static final Text SINGLE_MAPPING_TYPE = new Text(MapperService.SINGLE_MAPPING_NAME); + /** + * Preserving for compatibility. + * Going forward serialize with dedicated SearchHitSerDe object. + */ @Override public void writeTo(StreamOutput out) throws IOException { - out.writeFloat(score); - out.writeOptionalText(id); - if (out.getVersion().before(Version.V_2_0_0)) { - out.writeOptionalText(SINGLE_MAPPING_TYPE); - } - out.writeOptionalWriteable(nestedIdentity); - out.writeLong(version); - out.writeZLong(seqNo); - out.writeVLong(primaryTerm); - out.writeBytesReference(source); - if (explanation == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - writeExplanation(out, explanation); - } - out.writeMap(documentFields, StreamOutput::writeString, (stream, documentField) -> documentField.writeTo(stream)); - out.writeMap(metaFields, StreamOutput::writeString, (stream, documentField) -> documentField.writeTo(stream)); - if (highlightFields == null) { - out.writeVInt(0); - } else { - out.writeVInt(highlightFields.size()); - for (HighlightField highlightField : highlightFields.values()) { - highlightField.writeTo(out); - } - } - sortValues.writeTo(out); - - out.writeVInt(matchedQueries.size()); - if (out.getVersion().onOrAfter(Version.V_2_13_0)) { - if (!matchedQueries.isEmpty()) { - out.writeMap(matchedQueries, StreamOutput::writeString, StreamOutput::writeFloat); - } - } else { - for (String matchedFilter : matchedQueries.keySet()) { - out.writeString(matchedFilter); - } - } - out.writeOptionalWriteable(shard); - if (innerHits == null) { - out.writeVInt(0); - } else { - out.writeVInt(innerHits.size()); - for (Map.Entry entry : innerHits.entrySet()) { - out.writeString(entry.getKey()); - entry.getValue().writeTo(out); - } - } + SearchHitSerDe serDe = new SearchHitSerDe(); + serDe.serialize(this, out); } public int docId() { From e6be014373fbdf7e39a24e78214ae990f003190b Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 10:50:29 -0700 Subject: [PATCH 08/61] Use toStream with serialize Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/fetch/serde/SearchHitSerDe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java index ce50ec5c30af6..aa9605478d6f0 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -46,7 +46,7 @@ public SearchHit deserialize(StreamInput in) { @Override public void serialize(SearchHit object, StreamOutput out) throws SerDe.SerializationException { try { - object.writeTo(out); + toStream(object, out); } catch (IOException e) { throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); } From 61746b66aa0001bea0de29225c66084929359787 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 11:07:46 -0700 Subject: [PATCH 09/61] Decorator + import housekeeping Signed-off-by: Finn Carroll --- server/src/main/java/org/opensearch/search/SearchHit.java | 6 ++++++ server/src/main/java/org/opensearch/search/SearchHits.java | 6 ++++++ .../java/org/opensearch/search/fetch/FetchSearchResult.java | 6 ++++++ .../org/opensearch/search/fetch/serde/SearchHitSerDe.java | 4 +++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index e0c42422c4e34..aad6116ed38a9 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -38,6 +38,7 @@ import org.opensearch.Version; import org.opensearch.action.OriginalIndices; import org.opensearch.common.Nullable; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.annotation.PublicApi; import org.opensearch.common.document.DocumentField; import org.opensearch.common.xcontent.XContentHelper; @@ -236,6 +237,11 @@ public SearchHit(StreamInput in) throws IOException { this(new SearchHitSerDe().deserialize(in)); } + /** + * Internal access for serialization interface. + * @opensearch.api + */ + @ExperimentalApi public interface SerializationAccess { float getScore(); Text getId(); diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index a33c24817d84f..2747e76d3677b 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -36,6 +36,7 @@ import org.apache.lucene.search.TotalHits; import org.apache.lucene.search.TotalHits.Relation; import org.opensearch.common.Nullable; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.annotation.PublicApi; import org.opensearch.common.lucene.Lucene; import org.opensearch.core.common.io.stream.StreamInput; @@ -104,6 +105,11 @@ public SearchHits( this.collapseValues = collapseValues; } + /** + * Internal access for serialization interface. + * @opensearch.api + */ + @ExperimentalApi public interface SerializationAccess { TotalHits getTotalHits(); float getMaxScore(); diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index dde2c3c8ea5fe..bcbc682b11d27 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -32,6 +32,7 @@ package org.opensearch.search.fetch; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.annotation.PublicApi; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; @@ -69,6 +70,11 @@ public FetchSearchResult(ShardSearchContextId id, SearchShardTarget shardTarget) setSearchShardTarget(shardTarget); } + /** + * Internal access for serialization interface. + * @opensearch.api + */ + @ExperimentalApi public interface SerializationAccess { ShardSearchContextId getShardSearchContextId(); SearchHits getHits(); diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java index aa9605478d6f0..8092751e0ff6f 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -27,7 +27,9 @@ import java.util.Map; import java.util.stream.Collectors; -import static java.util.Collections.*; +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.search.SearchHit.SINGLE_MAPPING_TYPE; From c2d3856c5ca7a2a596684ed7d13b5f010946708f Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 11:08:30 -0700 Subject: [PATCH 10/61] Spotless apply Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 131 ++++++++++++------ .../org/opensearch/search/SearchHits.java | 18 ++- .../search/fetch/FetchSearchResult.java | 10 +- .../fetch/serde/FetchSearchResultsSerDe.java | 2 +- .../search/fetch/serde/SearchHitSerDe.java | 4 +- .../search/fetch/serde/SearchHitsSerDe.java | 2 +- .../opensearch/search/fetch/serde/SerDe.java | 14 +- 7 files changed, 127 insertions(+), 54 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index aad6116ed38a9..e5e502ace9f22 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -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; @@ -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; @@ -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 documentFields, - Map metaFields, - Map highlightFields, - Map matchedQueries, - Map 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 documentFields, + Map metaFields, + Map highlightFields, + Map matchedQueries, + Map innerHits ) throws IOException { this.docId = docId; this.score = score; @@ -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; @@ -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 getDocumentFields(); + Map getMetaFields(); + Map getHighlightedFields(); + SearchSortValues getSortValues(); + Map getMatchedQueries(); + SearchShardTarget getShard(); + Map 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 getDocumentFields() { return documentFields; } - public Map getMetaFields() { return metaFields; } - public Map getHighlightedFields() { return highlightFields; } - public SearchSortValues getSortValues() { return sortValues; } - public Map getMatchedQueries() { return matchedQueries; } - public SearchShardTarget getShard() { return shard; } - public Map 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 getDocumentFields() { + return documentFields; + } + + public Map getMetaFields() { + return metaFields; + } + + public Map getHighlightedFields() { + return highlightFields; + } + + public SearchSortValues getSortValues() { + return sortValues; + } + + public Map getMatchedQueries() { + return matchedQueries; + } + + public SearchShardTarget getShard() { + return shard; + } + + public Map getInnerHits() { + return innerHits; + } }; } diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index 2747e76d3677b..56dc7d825d69f 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -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; @@ -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; + } }; } diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index bcbc682b11d27..817f57be21306 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -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; + } }; } diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java index c4dc7565ebe3c..b1f9fcbe18003 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java @@ -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; diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java index 8092751e0ff6f..6bff68a9be8ab 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -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; diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java index 569efd4fa269f..ef27dccf99a0b 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java @@ -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; diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java index 86aa89c22e2a3..ebfeaca9469e7 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java @@ -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 { From abbefe9b5ba435f4ebc8872ecc33d8fc3b16cf0f Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 12:15:24 -0700 Subject: [PATCH 11/61] Move SearchHitS serialization to SerDe class Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 4 +- .../org/opensearch/search/SearchHits.java | 74 ++++++++++--------- .../search/fetch/serde/SearchHitsSerDe.java | 67 ++++++++++++++++- 3 files changed, 107 insertions(+), 38 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index e5e502ace9f22..5a7c6af2cd6bb 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -224,7 +224,7 @@ public SearchHit(SearchHit hit) throws IOException { /** * Preserving this constructor for compatibility. - * Going forward deserialize with dedicated SearchHitSerDe object. + * Going forward deserialize with dedicated SearchHitSerDe. */ public SearchHit(StreamInput in) throws IOException { this(new SearchHitSerDe().deserialize(in)); @@ -335,7 +335,7 @@ public Map getInnerHits() { /** * Preserving for compatibility. - * Going forward serialize with dedicated SearchHitSerDe object. + * Going forward serialize with dedicated SearchHitSerDe. */ @Override public void writeTo(StreamOutput out) throws IOException { diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index 56dc7d825d69f..b5dd3709cfbcc 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -46,6 +46,8 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.rest.action.search.RestSearchAction; +import org.opensearch.search.fetch.serde.SearchHitSerDe; +import org.opensearch.search.fetch.serde.SearchHitsSerDe; import java.io.IOException; import java.util.ArrayList; @@ -103,6 +105,15 @@ public SearchHits( this.collapseValues = collapseValues; } + public SearchHits(SearchHits SrchHits) { + this(SrchHits.hits, + SrchHits.totalHits, + SrchHits.maxScore, + SrchHits.sortFields, + SrchHits.collapseField, + SrchHits.collapseValues); + } + /** * Internal access for serialization interface. * @opensearch.api @@ -114,6 +125,12 @@ public interface SerializationAccess { float getMaxScore(); SearchHit[] getHits(); + + SortField[] getSortFields(); + + String getCollapseField(); + + Object[] getCollapseValues(); } public SearchHits.SerializationAccess getSerAccess() { @@ -129,48 +146,37 @@ public float getMaxScore() { public SearchHit[] getHits() { return hits; } + + public SortField[] getSortFields() { + return sortFields; + } + + public String getCollapseField() { + return collapseField; + } + + public Object[] getCollapseValues() { + return collapseValues; + } }; } + /** + * Preserving for compatibility. + * Going forward serialize with dedicated SearchHitsSerDe. + */ public SearchHits(StreamInput in) throws IOException { - if (in.readBoolean()) { - totalHits = Lucene.readTotalHits(in); - } else { - // track_total_hits is false - totalHits = null; - } - maxScore = in.readFloat(); - int size = in.readVInt(); - if (size == 0) { - hits = EMPTY; - } else { - hits = new SearchHit[size]; - for (int i = 0; i < hits.length; i++) { - hits[i] = new SearchHit(in); - } - } - sortFields = in.readOptionalArray(Lucene::readSortField, SortField[]::new); - collapseField = in.readOptionalString(); - collapseValues = in.readOptionalArray(Lucene::readSortValue, Object[]::new); + this(new SearchHitsSerDe().deserialize(in)); } + /** + * Preserving for compatibility. + * Going forward deserialize with dedicated SearchHitSerDe. + */ @Override public void writeTo(StreamOutput out) throws IOException { - final boolean hasTotalHits = totalHits != null; - out.writeBoolean(hasTotalHits); - if (hasTotalHits) { - Lucene.writeTotalHits(out, totalHits); - } - out.writeFloat(maxScore); - out.writeVInt(hits.length); - if (hits.length > 0) { - for (SearchHit hit : hits) { - hit.writeTo(out); - } - } - out.writeOptionalArray(Lucene::writeSortField, sortFields); - out.writeOptionalString(collapseField); - out.writeOptionalArray(Lucene::writeSortValue, collapseValues); + SearchHitsSerDe serDe = new SearchHitsSerDe(); + serDe.serialize(this, out); } /** diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java index ef27dccf99a0b..7be979c04a78b 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java @@ -8,19 +8,25 @@ package org.opensearch.search.fetch.serde; +import org.apache.lucene.search.SortField; +import org.apache.lucene.search.TotalHits; +import org.opensearch.common.lucene.Lucene; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; import java.io.IOException; +import static org.opensearch.search.SearchHits.EMPTY; + public class SearchHitsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { SearchHitSerDe searchHitSerDe; @Override public SearchHits deserialize(StreamInput in) { try { - return new SearchHits(in); + return fromStream(in); } catch (IOException e) { throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); } @@ -29,9 +35,66 @@ public SearchHits deserialize(StreamInput in) { @Override public void serialize(SearchHits object, StreamOutput out) throws SerDe.SerializationException { try { - object.writeTo(out); + toStream(object, out); } catch (IOException e) { throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); } } + + private SearchHits fromStream(StreamInput in) throws IOException { + SearchHit[] hits; + TotalHits totalHits; + float maxScore; + SortField[] sortFields; + String collapseField; + Object[] collapseValues; + + if (in.readBoolean()) { + totalHits = Lucene.readTotalHits(in); + } else { + // track_total_hits is false + totalHits = null; + } + maxScore = in.readFloat(); + int size = in.readVInt(); + if (size == 0) { + hits = EMPTY; + } else { + hits = new SearchHit[size]; + for (int i = 0; i < hits.length; i++) { + hits[i] = new SearchHit(in); + } + } + sortFields = in.readOptionalArray(Lucene::readSortField, SortField[]::new); + collapseField = in.readOptionalString(); + collapseValues = in.readOptionalArray(Lucene::readSortValue, Object[]::new); + + return new SearchHits(hits, totalHits, maxScore, sortFields, collapseField, collapseValues); + } + + private void toStream(SearchHits object, StreamOutput out) throws IOException { + SearchHits.SerializationAccess serI = object.getSerAccess(); + SearchHit[] hits = serI.getHits(); + TotalHits totalHits = serI.getTotalHits(); + float maxScore = serI.getMaxScore(); + SortField[] sortFields = serI.getSortFields(); + String collapseField = serI.getCollapseField(); + Object[] collapseValues = serI.getCollapseValues(); + + final boolean hasTotalHits = totalHits != null; + out.writeBoolean(hasTotalHits); + if (hasTotalHits) { + Lucene.writeTotalHits(out, totalHits); + } + out.writeFloat(maxScore); + out.writeVInt(hits.length); + if (hits.length > 0) { + for (SearchHit hit : hits) { + hit.writeTo(out); + } + } + out.writeOptionalArray(Lucene::writeSortField, sortFields); + out.writeOptionalString(collapseField); + out.writeOptionalArray(Lucene::writeSortValue, collapseValues); + } } From 127ab381027f9ec61f3aa3db0366f4f53d3fa185 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 13:54:03 -0700 Subject: [PATCH 12/61] Move FetchSearchResults serialization to FetchSearchResultsSerDe Signed-off-by: Finn Carroll --- .../org/opensearch/search/SearchHits.java | 2 +- .../search/fetch/FetchSearchResult.java | 28 +++++++++++++--- .../fetch/serde/FetchSearchResultsSerDe.java | 32 +++++++++++++++++-- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index b5dd3709cfbcc..8839c31ca21b8 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -171,7 +171,7 @@ public SearchHits(StreamInput in) throws IOException { /** * Preserving for compatibility. - * Going forward deserialize with dedicated SearchHitSerDe. + * Going forward deserialize with dedicated SearchHitsSerDe. */ @Override public void writeTo(StreamOutput out) throws IOException { diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index 817f57be21306..25a72cbc8f103 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -40,6 +40,8 @@ import org.opensearch.search.SearchHits; import org.opensearch.search.SearchPhaseResult; import org.opensearch.search.SearchShardTarget; +import org.opensearch.search.fetch.serde.FetchSearchResultsSerDe; +import org.opensearch.search.fetch.serde.SearchHitsSerDe; import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.search.query.QuerySearchResult; @@ -59,10 +61,22 @@ public class FetchSearchResult extends SearchPhaseResult { public FetchSearchResult() {} + /** + * Preserving for compatibility. + * Going forward deserialize with dedicated FetchSearchResultsSerDe. + */ public FetchSearchResult(StreamInput in) throws IOException { - super(in); - contextId = new ShardSearchContextId(in); - hits = new SearchHits(in); + this(new FetchSearchResultsSerDe().deserialize(in)); + } + + public FetchSearchResult(FetchSearchResult result) { + this.contextId = result.contextId; + this.hits = result.hits; + } + + public FetchSearchResult(ShardSearchContextId id, SearchHits hits) throws IOException { + this.contextId = id; + this.hits = hits; } public FetchSearchResult(ShardSearchContextId id, SearchShardTarget shardTarget) { @@ -128,9 +142,13 @@ public int counterGetAndIncrement() { return counter++; } + /** + * Preserving for compatibility. + * Going forward serialize with dedicated FetchSearchResultsSerDe. + */ @Override public void writeTo(StreamOutput out) throws IOException { - contextId.writeTo(out); - hits.writeTo(out); + FetchSearchResultsSerDe serDe = new FetchSearchResultsSerDe(); + serDe.serialize(this, out); } } diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java index b1f9fcbe18003..5433645658b10 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java @@ -10,17 +10,30 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.search.SearchHits; import org.opensearch.search.fetch.FetchSearchResult; +import org.opensearch.search.internal.ShardSearchContextId; import java.io.IOException; public class FetchSearchResultsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { + /** + * TODO NOTE: FetchSearchResult inheritance structure is as follows. + * TransportMessage -> TransportResponse -> SearchPhaseResult -> FetchSearchResult. + * Serialization of parent classes is currently a no-op. + * For completeness these parent classes should be mirrored here respectively with: + * TransportMessageSerDe, TransportResponseSerDe, SearchPhaseResultSerDe. + * However, currently only SearchHitsSerDe is needed for serialization. + * + * This is implicitely enforced by FetchSearchResult as well on the serialization side. + * writeTo doesn't call a parent implementation... + */ SearchHitsSerDe searchHitsSerDe; @Override public FetchSearchResult deserialize(StreamInput in) { try { - return new FetchSearchResult(in); + return fromStream(in); } catch (IOException e) { throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); } @@ -29,9 +42,24 @@ public FetchSearchResult deserialize(StreamInput in) { @Override public void serialize(FetchSearchResult object, StreamOutput out) throws SerDe.SerializationException { try { - object.writeTo(out); + toStream(object, out); } catch (IOException e) { throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); } } + + private FetchSearchResult fromStream(StreamInput in) throws IOException { + ShardSearchContextId contextId = new ShardSearchContextId(in); + SearchHits hits = new SearchHits(in); + return new FetchSearchResult(contextId, hits); + } + + private void toStream(FetchSearchResult object, StreamOutput out) throws IOException { + FetchSearchResult.SerializationAccess serI = object.getSerAccess(); + ShardSearchContextId contextId = serI.getShardSearchContextId(); + SearchHits hits = serI.getHits(); + + contextId.writeTo(out); + hits.writeTo(out); + } } From 8e696bc45e1f13ed65cba9a8965745713ccca717 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 13:57:03 -0700 Subject: [PATCH 13/61] Spotless apply Signed-off-by: Finn Carroll --- .../src/main/java/org/opensearch/search/SearchHits.java | 9 +-------- .../org/opensearch/search/fetch/FetchSearchResult.java | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index 8839c31ca21b8..1153b182e95d7 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -38,7 +38,6 @@ import org.opensearch.common.Nullable; import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.annotation.PublicApi; -import org.opensearch.common.lucene.Lucene; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; @@ -46,7 +45,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.serde.SearchHitSerDe; import org.opensearch.search.fetch.serde.SearchHitsSerDe; import java.io.IOException; @@ -106,12 +104,7 @@ public SearchHits( } public SearchHits(SearchHits SrchHits) { - this(SrchHits.hits, - SrchHits.totalHits, - SrchHits.maxScore, - SrchHits.sortFields, - SrchHits.collapseField, - SrchHits.collapseValues); + this(SrchHits.hits, SrchHits.totalHits, SrchHits.maxScore, SrchHits.sortFields, SrchHits.collapseField, SrchHits.collapseValues); } /** diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index 25a72cbc8f103..e8b6806d304c2 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -41,7 +41,6 @@ import org.opensearch.search.SearchPhaseResult; import org.opensearch.search.SearchShardTarget; import org.opensearch.search.fetch.serde.FetchSearchResultsSerDe; -import org.opensearch.search.fetch.serde.SearchHitsSerDe; import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.search.query.QuerySearchResult; From 97f9f03bb110f3d13857c48b580298b6808c683c Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 15:39:54 -0700 Subject: [PATCH 14/61] Fix deserialize - leave null maps null, not empty Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 5a7c6af2cd6bb..932330610699e 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -190,11 +190,11 @@ public SearchHit( this.explanation = explanation; this.sortValues = sortValues; this.nestedIdentity = nestedIdentity; - this.documentFields = documentFields == null ? Collections.emptyMap() : documentFields; - this.metaFields = metaFields == null ? Collections.emptyMap() : metaFields; - this.highlightFields = highlightFields == null ? Collections.emptyMap() : highlightFields; - this.matchedQueries = matchedQueries == null ? Collections.emptyMap() : matchedQueries; - this.innerHits = innerHits == null ? Collections.emptyMap() : innerHits; + this.documentFields = documentFields; + this.metaFields = metaFields; + this.highlightFields = highlightFields; + this.matchedQueries = matchedQueries; + this.innerHits = innerHits; // we call the setter here because that also sets the local index parameter shard(shardTarget); @@ -211,12 +211,12 @@ public SearchHit(SearchHit hit) throws IOException { this.explanation = hit.explanation; this.sortValues = hit.sortValues; this.nestedIdentity = hit.nestedIdentity; - this.documentFields = hit.documentFields == null ? Collections.emptyMap() : hit.documentFields; - this.metaFields = hit.metaFields == null ? Collections.emptyMap() : hit.metaFields; - this.highlightFields = hit.highlightFields == null ? Collections.emptyMap() : hit.highlightFields; - this.matchedQueries = hit.matchedQueries == null ? Collections.emptyMap() : hit.matchedQueries; - this.innerHits = hit.innerHits == null ? Collections.emptyMap() : hit.innerHits; - this.sourceAsMap = hit.sourceAsMap == null ? Collections.emptyMap() : hit.sourceAsMap; + this.documentFields = hit.documentFields; + this.metaFields = hit.metaFields; + this.highlightFields = hit.highlightFields; + this.matchedQueries = hit.matchedQueries; + this.innerHits = hit.innerHits; + this.sourceAsMap = hit.sourceAsMap; // we call the setter here because that also sets the local index parameter shard(hit.shard); From 7c7322f5a8a78c37af5b5f09cab6292929cc4ab1 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 20:10:37 -0700 Subject: [PATCH 15/61] index & clusterAlias set by helper Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 16 +++++++++------- .../search/fetch/serde/SearchHitSerDe.java | 11 ++++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 932330610699e..46928a3816490 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -178,7 +178,9 @@ public SearchHit( Map metaFields, Map highlightFields, Map matchedQueries, - Map innerHits + Map innerHits, + String index, + String clusterAlias ) throws IOException { this.docId = docId; this.score = score; @@ -187,6 +189,7 @@ public SearchHit( this.primaryTerm = primaryTerm; this.id = id; this.source = source; + this.shard = shardTarget; this.explanation = explanation; this.sortValues = sortValues; this.nestedIdentity = nestedIdentity; @@ -195,9 +198,8 @@ public SearchHit( this.highlightFields = highlightFields; this.matchedQueries = matchedQueries; this.innerHits = innerHits; - - // we call the setter here because that also sets the local index parameter - shard(shardTarget); + this.index = index; + this.clusterAlias = clusterAlias; } public SearchHit(SearchHit hit) throws IOException { @@ -208,6 +210,7 @@ public SearchHit(SearchHit hit) throws IOException { this.primaryTerm = hit.primaryTerm; this.id = hit.id; this.source = hit.source; + this.shard = hit.shard; this.explanation = hit.explanation; this.sortValues = hit.sortValues; this.nestedIdentity = hit.nestedIdentity; @@ -217,9 +220,8 @@ public SearchHit(SearchHit hit) throws IOException { this.matchedQueries = hit.matchedQueries; this.innerHits = hit.innerHits; this.sourceAsMap = hit.sourceAsMap; - - // we call the setter here because that also sets the local index parameter - shard(hit.shard); + this.index = hit.index; + this.clusterAlias = hit.clusterAlias; } /** diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java index 6bff68a9be8ab..754a3d0fa9468 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -71,6 +71,8 @@ private SearchHit fromStream(StreamInput in) throws IOException { Map highlightFields; Map matchedQueries = Map.of(); Map innerHits; + String index = null; + String clusterAlias = null; docId = -1; score = in.readFloat(); @@ -127,6 +129,11 @@ private SearchHit fromStream(StreamInput in) throws IOException { } } shard = in.readOptionalWriteable(SearchShardTarget::new); + if (shard != null) { + index = shard.getIndex(); + clusterAlias = shard.getClusterAlias(); + } + size = in.readVInt(); if (size > 0) { innerHits = new HashMap<>(size); @@ -155,7 +162,9 @@ private SearchHit fromStream(StreamInput in) throws IOException { metaFields, highlightFields, matchedQueries, - innerHits + innerHits, + index, + clusterAlias ); } From df7cdb32cd5b7052a0bee0a198a2b028d5cc97fd Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 20:36:17 -0700 Subject: [PATCH 16/61] Javadoc Signed-off-by: Finn Carroll --- .../opensearch/search/fetch/serde/FetchSearchResultsSerDe.java | 3 +++ .../java/org/opensearch/search/fetch/serde/SearchHitSerDe.java | 3 +++ .../org/opensearch/search/fetch/serde/SearchHitsSerDe.java | 3 +++ .../src/main/java/org/opensearch/search/fetch/serde/SerDe.java | 3 +++ 4 files changed, 12 insertions(+) diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java index 5433645658b10..d56d706261627 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java @@ -16,6 +16,9 @@ import java.io.IOException; +/** + * Serialization/Deserialization implementations for SearchHit. + */ public class FetchSearchResultsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { /** * TODO NOTE: FetchSearchResult inheritance structure is as follows. diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java index 754a3d0fa9468..667ad2551f94f 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -34,6 +34,9 @@ import static org.opensearch.common.lucene.Lucene.writeExplanation; import static org.opensearch.search.SearchHit.SINGLE_MAPPING_TYPE; +/** + * Serialization/Deserialization implementations for SearchHit. + */ public class SearchHitSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { @Override diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java index 7be979c04a78b..7a549bf79f109 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java @@ -20,6 +20,9 @@ import static org.opensearch.search.SearchHits.EMPTY; +/** + * Serialization/Deserialization implementations for SearchHits. + */ public class SearchHitsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { SearchHitSerDe searchHitSerDe; diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java index ebfeaca9469e7..9f5292fa6e563 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java @@ -13,6 +13,9 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; +/** + * Base class for supported serialization/deserialization implementations. + */ public class SerDe { public static class SerializationException extends RuntimeException { From 298182c2edb2e311497d1656c24b32cbbcf5224f Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 22 Aug 2024 20:40:33 -0700 Subject: [PATCH 17/61] Comment Signed-off-by: Finn Carroll --- .../search/fetch/serde/FetchSearchResultsSerDe.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java index d56d706261627..b418a798112c9 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java @@ -21,15 +21,10 @@ */ public class FetchSearchResultsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { /** - * TODO NOTE: FetchSearchResult inheritance structure is as follows. + * NOTE: FetchSearchResultSerDe should mirror class inheritence strucutre. * TransportMessage -> TransportResponse -> SearchPhaseResult -> FetchSearchResult. - * Serialization of parent classes is currently a no-op. - * For completeness these parent classes should be mirrored here respectively with: - * TransportMessageSerDe, TransportResponseSerDe, SearchPhaseResultSerDe. - * However, currently only SearchHitsSerDe is needed for serialization. * - * This is implicitely enforced by FetchSearchResult as well on the serialization side. - * writeTo doesn't call a parent implementation... + * Serialization of parent classes is currently a no-op so leaving as is for now. */ SearchHitsSerDe searchHitsSerDe; From fbb1febcc7420ed9d780519e72286614f10709a6 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Fri, 23 Aug 2024 03:57:24 +0000 Subject: [PATCH 18/61] Javadocs Signed-off-by: Finn Carroll --- .../search/fetch/serde/FetchSearchResultsSerDe.java | 1 + .../opensearch/search/fetch/serde/SearchHitSerDe.java | 1 + .../opensearch/search/fetch/serde/SearchHitsSerDe.java | 1 + .../java/org/opensearch/search/fetch/serde/SerDe.java | 5 +++++ .../opensearch/search/fetch/serde/package-info.java | 10 ++++++++++ 5 files changed, 18 insertions(+) create mode 100644 server/src/main/java/org/opensearch/search/fetch/serde/package-info.java diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java index b418a798112c9..5bbadae3bd1da 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java @@ -18,6 +18,7 @@ /** * Serialization/Deserialization implementations for SearchHit. + * @opensearch.internal */ public class FetchSearchResultsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { /** diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java index 667ad2551f94f..9ee0a3eb87964 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java @@ -36,6 +36,7 @@ /** * Serialization/Deserialization implementations for SearchHit. + * @opensearch.internal */ public class SearchHitSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java index 7a549bf79f109..199bcc2ee564b 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java @@ -22,6 +22,7 @@ /** * Serialization/Deserialization implementations for SearchHits. + * @opensearch.internal */ public class SearchHitsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { SearchHitSerDe searchHitSerDe; diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java b/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java index 9f5292fa6e563..8f36e0a2a8c4a 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java +++ b/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java @@ -15,9 +15,14 @@ /** * Base class for supported serialization/deserialization implementations. + * @opensearch.internal */ public class SerDe { + /** + * Serialization/Deserialization exception. + * @opensearch.internal + */ public static class SerializationException extends RuntimeException { public SerializationException(String message) { super(message); diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/package-info.java b/server/src/main/java/org/opensearch/search/fetch/serde/package-info.java new file mode 100644 index 0000000000000..701546ae6289d --- /dev/null +++ b/server/src/main/java/org/opensearch/search/fetch/serde/package-info.java @@ -0,0 +1,10 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/** Serialization/Deserialization implementations for the fetch package. */ +package org.opensearch.search.fetch.serde; From 7db42cbc6fc3f78a8008fda5b16b258c6b191e29 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Fri, 23 Aug 2024 01:48:42 -0700 Subject: [PATCH 19/61] Begin proto implementation Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 2 +- .../org/opensearch/search/SearchHits.java | 2 +- .../search/fetch/FetchSearchResult.java | 2 +- .../serde/FetchSearchResultsSerDe.java | 16 +- .../serde/SearchHitSerDe.java | 144 +- .../serde/SearchHitsSerDe.java | 38 +- .../fetch => transport}/serde/SerDe.java | 2 +- .../serde/package-info.java | 2 +- .../transport/serde/prototemp/SearchHits.java | 10631 ++++++++++++++++ .../serde/prototemp/SearchHits.java.pb.meta | Bin 0 -> 18157 bytes server/src/main/proto/server/SearchHits.proto | 130 + 11 files changed, 10951 insertions(+), 18 deletions(-) rename server/src/main/java/org/opensearch/{search/fetch => transport}/serde/FetchSearchResultsSerDe.java (82%) rename server/src/main/java/org/opensearch/{search/fetch => transport}/serde/SearchHitSerDe.java (60%) rename server/src/main/java/org/opensearch/{search/fetch => transport}/serde/SearchHitsSerDe.java (73%) rename server/src/main/java/org/opensearch/{search/fetch => transport}/serde/SerDe.java (97%) rename server/src/main/java/org/opensearch/{search/fetch => transport}/serde/package-info.java (86%) create mode 100644 server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java create mode 100644 server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java.pb.meta create mode 100644 server/src/main/proto/server/SearchHits.proto diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 46928a3816490..16ef1e4778046 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -65,7 +65,7 @@ import org.opensearch.index.mapper.SourceFieldMapper; import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.rest.action.search.RestSearchAction; -import org.opensearch.search.fetch.serde.SearchHitSerDe; +import org.opensearch.transport.serde.SearchHitSerDe; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.search.lookup.SourceLookup; import org.opensearch.transport.RemoteClusterAware; diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index 1153b182e95d7..4802ecfa5344b 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -45,7 +45,7 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.rest.action.search.RestSearchAction; -import org.opensearch.search.fetch.serde.SearchHitsSerDe; +import org.opensearch.transport.serde.SearchHitsSerDe; import java.io.IOException; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index e8b6806d304c2..dc2a2aa7caaea 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -40,7 +40,7 @@ import org.opensearch.search.SearchHits; import org.opensearch.search.SearchPhaseResult; import org.opensearch.search.SearchShardTarget; -import org.opensearch.search.fetch.serde.FetchSearchResultsSerDe; +import org.opensearch.transport.serde.FetchSearchResultsSerDe; import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.search.query.QuerySearchResult; diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultsSerDe.java similarity index 82% rename from server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java rename to server/src/main/java/org/opensearch/transport/serde/FetchSearchResultsSerDe.java index 5bbadae3bd1da..2b175dd68a06a 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/FetchSearchResultsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultsSerDe.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.search.fetch.serde; +package org.opensearch.transport.serde; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; @@ -21,14 +21,12 @@ * @opensearch.internal */ public class FetchSearchResultsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { - /** - * NOTE: FetchSearchResultSerDe should mirror class inheritence strucutre. - * TransportMessage -> TransportResponse -> SearchPhaseResult -> FetchSearchResult. - * - * Serialization of parent classes is currently a no-op so leaving as is for now. - */ SearchHitsSerDe searchHitsSerDe; + public FetchSearchResultsSerDe () { + this.searchHitsSerDe = new SearchHitsSerDe(); + } + @Override public FetchSearchResult deserialize(StreamInput in) { try { @@ -49,7 +47,7 @@ public void serialize(FetchSearchResult object, StreamOutput out) throws SerDe.S private FetchSearchResult fromStream(StreamInput in) throws IOException { ShardSearchContextId contextId = new ShardSearchContextId(in); - SearchHits hits = new SearchHits(in); + SearchHits hits = searchHitsSerDe.deserialize(in); return new FetchSearchResult(contextId, hits); } @@ -59,6 +57,6 @@ private void toStream(FetchSearchResult object, StreamOutput out) throws IOExcep SearchHits hits = serI.getHits(); contextId.writeTo(out); - hits.writeTo(out); + searchHitsSerDe.serialize(hits, out); } } diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java similarity index 60% rename from server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java rename to server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java index 9ee0a3eb87964..45e92aebaf805 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java @@ -6,9 +6,12 @@ * compatible open source license. */ -package org.opensearch.search.fetch.serde; +package org.opensearch.transport.serde; +import com.google.protobuf.ByteString; +import org.apache.commons.lang.SerializationUtils; import org.apache.lucene.search.Explanation; +import org.apache.lucene.search.TotalHits; import org.opensearch.Version; import org.opensearch.common.document.DocumentField; import org.opensearch.core.common.bytes.BytesReference; @@ -22,8 +25,10 @@ import org.opensearch.search.fetch.subphase.highlight.HighlightField; import java.io.IOException; +import java.io.Serializable; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -34,6 +39,15 @@ import static org.opensearch.common.lucene.Lucene.writeExplanation; import static org.opensearch.search.SearchHit.SINGLE_MAPPING_TYPE; +import org.opensearch.transport.serde.prototemp.SearchHits.SearchHitProto; +import org.opensearch.transport.serde.prototemp.SearchHits.DocumentFieldProto; +import org.opensearch.transport.serde.prototemp.SearchHits.ExplanationProto; +import org.opensearch.transport.serde.prototemp.SearchHits.NestedIdentityProto; +import org.opensearch.transport.serde.prototemp.SearchHits.HighlightFieldProto; +import org.opensearch.transport.serde.prototemp.SearchHits.SearchSortValuesProto; +import org.opensearch.transport.serde.prototemp.SearchHits.SearchShardTargetProto; +import org.opensearch.transport.serde.prototemp.SearchHits.SearchHitsProto; + /** * Serialization/Deserialization implementations for SearchHit. * @opensearch.internal @@ -58,6 +72,134 @@ public void serialize(SearchHit object, StreamOutput out) throws SerDe.Serializa } } + public static SearchHitProto toProto(SearchHit searchHit) { + SearchHit.SerializationAccess serI = searchHit.getSerAccess(); + + SearchHitProto.Builder builder = SearchHitProto.newBuilder() + .setScore(serI.getScore()) + .setId(serI.getId().string()) + .setVersion(serI.getVersion()) + .setSeqNo(serI.getSeqNo()) + .setPrimaryTerm(serI.getPrimaryTerm()); + + if (serI.getSource() != null) { + builder.setSource(ByteString.copyFrom(serI.getSource().toBytesRef().bytes)); + } + + serI.getDocumentFields().forEach((key, value) -> + builder.putDocumentFields(key, documentFieldToProto(value)) + ); + + serI.getMetaFields().forEach((key, value) -> + builder.putMetaFields(key, documentFieldToProto(value)) + ); + + serI.getHighlightedFields().forEach((key, value) -> + builder.putHighlightFields(key, highlightFieldToProto(value)) + ); + + serI.getMatchedQueries().forEach(builder::putMatchedQueries); + + if (serI.getExplanation() != null) { + builder.setExplanation(explanationToProto(serI.getExplanation())); + } + + if (serI.getSortValues() != null) { + builder.setSortValues(shardSearchValuesToProto(serI.getSortValues())); + } + + if (serI.getNestedIdentity() != null) { + builder.setNestedIdentity(nestedIdentityToProto(serI.getNestedIdentity())); + } + + if (serI.getShard() != null) { + builder.setShard(searchShardTargetToProto(serI.getShard())); + } + + if (serI.getInnerHits() != null) { + serI.getInnerHits().forEach((key, value) -> + builder.putInnerHits(key, searchHitsToProto(value)) + ); + } + + return builder.build(); + } + + private static DocumentFieldProto documentFieldToProto(DocumentField field) { + DocumentFieldProto.Builder builder = DocumentFieldProto.newBuilder().setName(field.getName()); + List objList = field.getValues(); + + for (Object obj : objList) { + byte[] data = SerializationUtils.serialize((Serializable) obj); + String jsonString = objectMapper.writeValueAsString(obj); + return ByteString.copyFromUtf8(jsonString); + +// DataOutputStream out = new DataOutputStream(new ByteArrayOutputStream()); +// obj.serialize(out); + obj. + builder.addValues(SerializationUtils.serialize(obj)); + } + + return builder.build(); + } + +// private static ExplanationProto explanationToProto(Explanation explanation) { +// ExplanationProto.Builder builder = ExplanationProto.newBuilder() +// .setValue(explanation.getValue().floatValue()) +// .setDescription(explanation.getDescription()); +// +// for (Explanation detail : explanation.getDetails()) { +// builder.addDetails(explanationToProto(detail)); +// } +// +// return builder.build(); +// } +// +// private static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { +// NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() +// .setField(nestedIdentity.getField().string()) +// .setOffset(nestedIdentity.getOffset()); +// +// if (nestedIdentity.getChild() != null) { +// builder.setChild(nestedIdentityToProto(nestedIdentity.getChild())); +// } +// +// return builder.build(); +// } +// +// private static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { +// return SearchShardTargetProto.newBuilder() +// .setNodeId(shardTarget.getNodeId()) +// .setIndex(shardTarget.getIndex()) +// .setShardId(shardTarget.getShardId().getId()) +// .setClusterAlias(shardTarget.getClusterAlias() != null ? shardTarget.getClusterAlias() : "") +// .build(); +// } +// +// +// private static DocumentField documentFieldFromProto(SearchHitOuterClass.DocumentField protoField) { +// return new DocumentField( +// protoField.getName(), +// protoField.getValuesList().stream() +// .map(ByteString::toStringUtf8) +// .collect(Collectors.toList()) +// ); +// } +// +// private static HighlightFieldProto highlightFieldToProto(HighlightField field) { +// return HighlightFieldProto.newBuilder() +// .setName(field.getName()) +// .addAllFragments(field.getFragments()) +// .build(); +// } +// +// private static HighlightField highlightFieldFromProto(SearchHitOuterClass.HighlightField protoField) { +// return new HighlightField( +// protoField.getName(), +// protoField.getFragmentsList().toArray(new String[0]) +// ); +// } + private SearchHit fromStream(StreamInput in) throws IOException { int docId; float score; diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java similarity index 73% rename from server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java rename to server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java index 199bcc2ee564b..196eafe25ede4 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.search.fetch.serde; +package org.opensearch.transport.serde; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TotalHits; @@ -17,6 +17,9 @@ import org.opensearch.search.SearchHits; import java.io.IOException; +import java.util.Arrays; + +import org.opensearch.transport.serde.prototemp.SearchHits.SearchHitsProto; import static org.opensearch.search.SearchHits.EMPTY; @@ -27,6 +30,10 @@ public class SearchHitsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { SearchHitSerDe searchHitSerDe; + public SearchHitsSerDe () { + this.searchHitSerDe = new SearchHitSerDe(); + } + @Override public SearchHits deserialize(StreamInput in) { try { @@ -45,6 +52,31 @@ public void serialize(SearchHits object, StreamOutput out) throws SerDe.Serializ } } + private SearchHitsProto toProto(SearchHits searchHits) { + SearchHitsProto.Builder builder = SearchHitsProto.newBuilder() + .setTotalHits(searchHits.getTotalHits().value) + .setMaxScore(searchHits.getMaxScore()); + + // Assuming you have a SearchHitProtoUtils.toProto method + Arrays.stream(searchHits.getHits()) + .map(SearchHitProtoUtils::toProto) + .forEach(builder::addHits); + + return builder.build(); + } + + private SearchHits fromProto(SearchHitsProto protoSearchHits) { + SearchHit[] hits = protoSearchHits.getHitsList().stream() + .map(SearchHitProtoUtils::fromProto) + .toArray(SearchHit[]::new); + + return new SearchHits( + hits, + new TotalHits(protoSearchHits.getTotalHits(), TotalHits.Relation.EQUAL_TO), + protoSearchHits.getMaxScore() + ); + } + private SearchHits fromStream(StreamInput in) throws IOException { SearchHit[] hits; TotalHits totalHits; @@ -66,7 +98,7 @@ private SearchHits fromStream(StreamInput in) throws IOException { } else { hits = new SearchHit[size]; for (int i = 0; i < hits.length; i++) { - hits[i] = new SearchHit(in); + hits[i] = searchHitSerDe.deserialize(in); } } sortFields = in.readOptionalArray(Lucene::readSortField, SortField[]::new); @@ -94,7 +126,7 @@ private void toStream(SearchHits object, StreamOutput out) throws IOException { out.writeVInt(hits.length); if (hits.length > 0) { for (SearchHit hit : hits) { - hit.writeTo(out); + searchHitSerDe.serialize(hit, out); } } out.writeOptionalArray(Lucene::writeSortField, sortFields); diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java b/server/src/main/java/org/opensearch/transport/serde/SerDe.java similarity index 97% rename from server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java rename to server/src/main/java/org/opensearch/transport/serde/SerDe.java index 8f36e0a2a8c4a..68d745bd26452 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/SerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SerDe.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.search.fetch.serde; +package org.opensearch.transport.serde; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/search/fetch/serde/package-info.java b/server/src/main/java/org/opensearch/transport/serde/package-info.java similarity index 86% rename from server/src/main/java/org/opensearch/search/fetch/serde/package-info.java rename to server/src/main/java/org/opensearch/transport/serde/package-info.java index 701546ae6289d..fa144e7d4dcfd 100644 --- a/server/src/main/java/org/opensearch/search/fetch/serde/package-info.java +++ b/server/src/main/java/org/opensearch/transport/serde/package-info.java @@ -7,4 +7,4 @@ */ /** Serialization/Deserialization implementations for the fetch package. */ -package org.opensearch.search.fetch.serde; +package org.opensearch.transport.serde; diff --git a/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java b/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java new file mode 100644 index 0000000000000..13f9c3bff67a0 --- /dev/null +++ b/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java @@ -0,0 +1,10631 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.transport.serde.prototemp;// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: server/SearchHits.proto + +@javax.annotation.Generated(value="protoc", comments="annotations:SearchHits.java.pb.meta") +public final class SearchHits { + private SearchHits() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SearchHitsProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:SearchHitsProto) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .SearchHitProto hits = 1; + */ + java.util.List + getHitsList(); + /** + * repeated .SearchHitProto hits = 1; + */ + SearchHits.SearchHitProto getHits(int index); + /** + * repeated .SearchHitProto hits = 1; + */ + int getHitsCount(); + /** + * repeated .SearchHitProto hits = 1; + */ + java.util.List + getHitsOrBuilderList(); + /** + * repeated .SearchHitProto hits = 1; + */ + SearchHits.SearchHitProtoOrBuilder getHitsOrBuilder( + int index); + + /** + * int64 total_hits = 2; + * @return The totalHits. + */ + long getTotalHits(); + + /** + * float max_score = 3; + * @return The maxScore. + */ + float getMaxScore(); + } + /** + *
+   *
+   *SearchHit[] hits
+   *TotalHits totalHits
+   *float maxScore
+   * 
+ * + * Protobuf type {@code SearchHitsProto} + */ + public static final class SearchHitsProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SearchHitsProto) + SearchHitsProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use SearchHitsProto.newBuilder() to construct. + private SearchHitsProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SearchHitsProto() { + hits_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SearchHitsProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_SearchHitsProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_SearchHitsProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.SearchHitsProto.class, SearchHits.SearchHitsProto.Builder.class); + } + + public static final int HITS_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private java.util.List hits_; + /** + * repeated .SearchHitProto hits = 1; + */ + @java.lang.Override + public java.util.List getHitsList() { + return hits_; + } + /** + * repeated .SearchHitProto hits = 1; + */ + @java.lang.Override + public java.util.List + getHitsOrBuilderList() { + return hits_; + } + /** + * repeated .SearchHitProto hits = 1; + */ + @java.lang.Override + public int getHitsCount() { + return hits_.size(); + } + /** + * repeated .SearchHitProto hits = 1; + */ + @java.lang.Override + public SearchHits.SearchHitProto getHits(int index) { + return hits_.get(index); + } + /** + * repeated .SearchHitProto hits = 1; + */ + @java.lang.Override + public SearchHits.SearchHitProtoOrBuilder getHitsOrBuilder( + int index) { + return hits_.get(index); + } + + public static final int TOTAL_HITS_FIELD_NUMBER = 2; + private long totalHits_ = 0L; + /** + * int64 total_hits = 2; + * @return The totalHits. + */ + @java.lang.Override + public long getTotalHits() { + return totalHits_; + } + + public static final int MAX_SCORE_FIELD_NUMBER = 3; + private float maxScore_ = 0F; + /** + * float max_score = 3; + * @return The maxScore. + */ + @java.lang.Override + public float getMaxScore() { + return maxScore_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < hits_.size(); i++) { + output.writeMessage(1, hits_.get(i)); + } + if (totalHits_ != 0L) { + output.writeInt64(2, totalHits_); + } + if (java.lang.Float.floatToRawIntBits(maxScore_) != 0) { + output.writeFloat(3, maxScore_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < hits_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, hits_.get(i)); + } + if (totalHits_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, totalHits_); + } + if (java.lang.Float.floatToRawIntBits(maxScore_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(3, maxScore_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.SearchHitsProto)) { + return super.equals(obj); + } + SearchHits.SearchHitsProto other = (SearchHits.SearchHitsProto) obj; + + if (!getHitsList() + .equals(other.getHitsList())) return false; + if (getTotalHits() + != other.getTotalHits()) return false; + if (java.lang.Float.floatToIntBits(getMaxScore()) + != java.lang.Float.floatToIntBits( + other.getMaxScore())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getHitsCount() > 0) { + hash = (37 * hash) + HITS_FIELD_NUMBER; + hash = (53 * hash) + getHitsList().hashCode(); + } + hash = (37 * hash) + TOTAL_HITS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalHits()); + hash = (37 * hash) + MAX_SCORE_FIELD_NUMBER; + hash = (53 * hash) + java.lang.Float.floatToIntBits( + getMaxScore()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.SearchHitsProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchHitsProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchHitsProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchHitsProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchHitsProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchHitsProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchHitsProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.SearchHitsProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.SearchHitsProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.SearchHitsProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.SearchHitsProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.SearchHitsProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.SearchHitsProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *SearchHit[] hits
+     *TotalHits totalHits
+     *float maxScore
+     * 
+ * + * Protobuf type {@code SearchHitsProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SearchHitsProto) + SearchHits.SearchHitsProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_SearchHitsProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_SearchHitsProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.SearchHitsProto.class, SearchHits.SearchHitsProto.Builder.class); + } + + // Construct using SearchHits.SearchHitsProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (hitsBuilder_ == null) { + hits_ = java.util.Collections.emptyList(); + } else { + hits_ = null; + hitsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + totalHits_ = 0L; + maxScore_ = 0F; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_SearchHitsProto_descriptor; + } + + @java.lang.Override + public SearchHits.SearchHitsProto getDefaultInstanceForType() { + return SearchHits.SearchHitsProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.SearchHitsProto build() { + SearchHits.SearchHitsProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.SearchHitsProto buildPartial() { + SearchHits.SearchHitsProto result = new SearchHits.SearchHitsProto(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(SearchHits.SearchHitsProto result) { + if (hitsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + hits_ = java.util.Collections.unmodifiableList(hits_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.hits_ = hits_; + } else { + result.hits_ = hitsBuilder_.build(); + } + } + + private void buildPartial0(SearchHits.SearchHitsProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.totalHits_ = totalHits_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.maxScore_ = maxScore_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.SearchHitsProto) { + return mergeFrom((SearchHits.SearchHitsProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.SearchHitsProto other) { + if (other == SearchHits.SearchHitsProto.getDefaultInstance()) return this; + if (hitsBuilder_ == null) { + if (!other.hits_.isEmpty()) { + if (hits_.isEmpty()) { + hits_ = other.hits_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureHitsIsMutable(); + hits_.addAll(other.hits_); + } + onChanged(); + } + } else { + if (!other.hits_.isEmpty()) { + if (hitsBuilder_.isEmpty()) { + hitsBuilder_.dispose(); + hitsBuilder_ = null; + hits_ = other.hits_; + bitField0_ = (bitField0_ & ~0x00000001); + hitsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getHitsFieldBuilder() : null; + } else { + hitsBuilder_.addAllMessages(other.hits_); + } + } + } + if (other.getTotalHits() != 0L) { + setTotalHits(other.getTotalHits()); + } + if (other.getMaxScore() != 0F) { + setMaxScore(other.getMaxScore()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + SearchHits.SearchHitProto m = + input.readMessage( + SearchHits.SearchHitProto.parser(), + extensionRegistry); + if (hitsBuilder_ == null) { + ensureHitsIsMutable(); + hits_.add(m); + } else { + hitsBuilder_.addMessage(m); + } + break; + } // case 10 + case 16: { + totalHits_ = input.readInt64(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 29: { + maxScore_ = input.readFloat(); + bitField0_ |= 0x00000004; + break; + } // case 29 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.util.List hits_ = + java.util.Collections.emptyList(); + private void ensureHitsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + hits_ = new java.util.ArrayList(hits_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + SearchHits.SearchHitProto, SearchHits.SearchHitProto.Builder, SearchHits.SearchHitProtoOrBuilder> hitsBuilder_; + + /** + * repeated .SearchHitProto hits = 1; + */ + public java.util.List getHitsList() { + if (hitsBuilder_ == null) { + return java.util.Collections.unmodifiableList(hits_); + } else { + return hitsBuilder_.getMessageList(); + } + } + /** + * repeated .SearchHitProto hits = 1; + */ + public int getHitsCount() { + if (hitsBuilder_ == null) { + return hits_.size(); + } else { + return hitsBuilder_.getCount(); + } + } + /** + * repeated .SearchHitProto hits = 1; + */ + public SearchHits.SearchHitProto getHits(int index) { + if (hitsBuilder_ == null) { + return hits_.get(index); + } else { + return hitsBuilder_.getMessage(index); + } + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder setHits( + int index, SearchHits.SearchHitProto value) { + if (hitsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHitsIsMutable(); + hits_.set(index, value); + onChanged(); + } else { + hitsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder setHits( + int index, SearchHits.SearchHitProto.Builder builderForValue) { + if (hitsBuilder_ == null) { + ensureHitsIsMutable(); + hits_.set(index, builderForValue.build()); + onChanged(); + } else { + hitsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder addHits(SearchHits.SearchHitProto value) { + if (hitsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHitsIsMutable(); + hits_.add(value); + onChanged(); + } else { + hitsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder addHits( + int index, SearchHits.SearchHitProto value) { + if (hitsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHitsIsMutable(); + hits_.add(index, value); + onChanged(); + } else { + hitsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder addHits( + SearchHits.SearchHitProto.Builder builderForValue) { + if (hitsBuilder_ == null) { + ensureHitsIsMutable(); + hits_.add(builderForValue.build()); + onChanged(); + } else { + hitsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder addHits( + int index, SearchHits.SearchHitProto.Builder builderForValue) { + if (hitsBuilder_ == null) { + ensureHitsIsMutable(); + hits_.add(index, builderForValue.build()); + onChanged(); + } else { + hitsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder addAllHits( + java.lang.Iterable values) { + if (hitsBuilder_ == null) { + ensureHitsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, hits_); + onChanged(); + } else { + hitsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder clearHits() { + if (hitsBuilder_ == null) { + hits_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + hitsBuilder_.clear(); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public Builder removeHits(int index) { + if (hitsBuilder_ == null) { + ensureHitsIsMutable(); + hits_.remove(index); + onChanged(); + } else { + hitsBuilder_.remove(index); + } + return this; + } + /** + * repeated .SearchHitProto hits = 1; + */ + public SearchHits.SearchHitProto.Builder getHitsBuilder( + int index) { + return getHitsFieldBuilder().getBuilder(index); + } + /** + * repeated .SearchHitProto hits = 1; + */ + public SearchHits.SearchHitProtoOrBuilder getHitsOrBuilder( + int index) { + if (hitsBuilder_ == null) { + return hits_.get(index); } else { + return hitsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .SearchHitProto hits = 1; + */ + public java.util.List + getHitsOrBuilderList() { + if (hitsBuilder_ != null) { + return hitsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(hits_); + } + } + /** + * repeated .SearchHitProto hits = 1; + */ + public SearchHits.SearchHitProto.Builder addHitsBuilder() { + return getHitsFieldBuilder().addBuilder( + SearchHits.SearchHitProto.getDefaultInstance()); + } + /** + * repeated .SearchHitProto hits = 1; + */ + public SearchHits.SearchHitProto.Builder addHitsBuilder( + int index) { + return getHitsFieldBuilder().addBuilder( + index, SearchHits.SearchHitProto.getDefaultInstance()); + } + /** + * repeated .SearchHitProto hits = 1; + */ + public java.util.List + getHitsBuilderList() { + return getHitsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + SearchHits.SearchHitProto, SearchHits.SearchHitProto.Builder, SearchHits.SearchHitProtoOrBuilder> + getHitsFieldBuilder() { + if (hitsBuilder_ == null) { + hitsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + SearchHits.SearchHitProto, SearchHits.SearchHitProto.Builder, SearchHits.SearchHitProtoOrBuilder>( + hits_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + hits_ = null; + } + return hitsBuilder_; + } + + private long totalHits_ ; + /** + * int64 total_hits = 2; + * @return The totalHits. + */ + @java.lang.Override + public long getTotalHits() { + return totalHits_; + } + /** + * int64 total_hits = 2; + * @param value The totalHits to set. + * @return This builder for chaining. + */ + public Builder setTotalHits(long value) { + + totalHits_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * int64 total_hits = 2; + * @return This builder for chaining. + */ + public Builder clearTotalHits() { + bitField0_ = (bitField0_ & ~0x00000002); + totalHits_ = 0L; + onChanged(); + return this; + } + + private float maxScore_ ; + /** + * float max_score = 3; + * @return The maxScore. + */ + @java.lang.Override + public float getMaxScore() { + return maxScore_; + } + /** + * float max_score = 3; + * @param value The maxScore to set. + * @return This builder for chaining. + */ + public Builder setMaxScore(float value) { + + maxScore_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * float max_score = 3; + * @return This builder for chaining. + */ + public Builder clearMaxScore() { + bitField0_ = (bitField0_ & ~0x00000004); + maxScore_ = 0F; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SearchHitsProto) + } + + // @@protoc_insertion_point(class_scope:SearchHitsProto) + private static final SearchHits.SearchHitsProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.SearchHitsProto(); + } + + public static SearchHits.SearchHitsProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SearchHitsProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.SearchHitsProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SearchHitProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:SearchHitProto) + com.google.protobuf.MessageOrBuilder { + + /** + * float score = 1; + * @return The score. + */ + float getScore(); + + /** + * string id = 2; + * @return The id. + */ + java.lang.String getId(); + /** + * string id = 2; + * @return The bytes for id. + */ + com.google.protobuf.ByteString + getIdBytes(); + + /** + * .NestedIdentityProto nested_identity = 3; + * @return Whether the nestedIdentity field is set. + */ + boolean hasNestedIdentity(); + /** + * .NestedIdentityProto nested_identity = 3; + * @return The nestedIdentity. + */ + SearchHits.NestedIdentityProto getNestedIdentity(); + /** + * .NestedIdentityProto nested_identity = 3; + */ + SearchHits.NestedIdentityProtoOrBuilder getNestedIdentityOrBuilder(); + + /** + * int64 version = 4; + * @return The version. + */ + long getVersion(); + + /** + * int64 seq_no = 5; + * @return The seqNo. + */ + long getSeqNo(); + + /** + * int64 primary_term = 6; + * @return The primaryTerm. + */ + long getPrimaryTerm(); + + /** + * bytes source = 7; + * @return The source. + */ + com.google.protobuf.ByteString getSource(); + + /** + * .ExplanationProto explanation = 8; + * @return Whether the explanation field is set. + */ + boolean hasExplanation(); + /** + * .ExplanationProto explanation = 8; + * @return The explanation. + */ + SearchHits.ExplanationProto getExplanation(); + /** + * .ExplanationProto explanation = 8; + */ + SearchHits.ExplanationProtoOrBuilder getExplanationOrBuilder(); + + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + int getDocumentFieldsCount(); + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + boolean containsDocumentFields( + java.lang.String key); + /** + * Use {@link #getDocumentFieldsMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getDocumentFields(); + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + java.util.Map + getDocumentFieldsMap(); + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + /* nullable */ +SearchHits.DocumentFieldProto getDocumentFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.DocumentFieldProto defaultValue); + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + SearchHits.DocumentFieldProto getDocumentFieldsOrThrow( + java.lang.String key); + + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + int getMetaFieldsCount(); + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + boolean containsMetaFields( + java.lang.String key); + /** + * Use {@link #getMetaFieldsMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getMetaFields(); + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + java.util.Map + getMetaFieldsMap(); + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + /* nullable */ +SearchHits.DocumentFieldProto getMetaFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.DocumentFieldProto defaultValue); + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + SearchHits.DocumentFieldProto getMetaFieldsOrThrow( + java.lang.String key); + + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + int getHighlightFieldsCount(); + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + boolean containsHighlightFields( + java.lang.String key); + /** + * Use {@link #getHighlightFieldsMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getHighlightFields(); + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + java.util.Map + getHighlightFieldsMap(); + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + /* nullable */ +SearchHits.HighlightFieldProto getHighlightFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.HighlightFieldProto defaultValue); + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + SearchHits.HighlightFieldProto getHighlightFieldsOrThrow( + java.lang.String key); + + /** + * .SearchSortValuesProto sort_values = 12; + * @return Whether the sortValues field is set. + */ + boolean hasSortValues(); + /** + * .SearchSortValuesProto sort_values = 12; + * @return The sortValues. + */ + SearchHits.SearchSortValuesProto getSortValues(); + /** + * .SearchSortValuesProto sort_values = 12; + */ + SearchHits.SearchSortValuesProtoOrBuilder getSortValuesOrBuilder(); + + /** + * map<string, float> matched_queries = 13; + */ + int getMatchedQueriesCount(); + /** + * map<string, float> matched_queries = 13; + */ + boolean containsMatchedQueries( + java.lang.String key); + /** + * Use {@link #getMatchedQueriesMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getMatchedQueries(); + /** + * map<string, float> matched_queries = 13; + */ + java.util.Map + getMatchedQueriesMap(); + /** + * map<string, float> matched_queries = 13; + */ + float getMatchedQueriesOrDefault( + java.lang.String key, + float defaultValue); + /** + * map<string, float> matched_queries = 13; + */ + float getMatchedQueriesOrThrow( + java.lang.String key); + + /** + * .SearchShardTargetProto shard = 14; + * @return Whether the shard field is set. + */ + boolean hasShard(); + /** + * .SearchShardTargetProto shard = 14; + * @return The shard. + */ + SearchHits.SearchShardTargetProto getShard(); + /** + * .SearchShardTargetProto shard = 14; + */ + SearchHits.SearchShardTargetProtoOrBuilder getShardOrBuilder(); + + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + int getInnerHitsCount(); + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + boolean containsInnerHits( + java.lang.String key); + /** + * Use {@link #getInnerHitsMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getInnerHits(); + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + java.util.Map + getInnerHitsMap(); + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + /* nullable */ +SearchHits.SearchHitsProto getInnerHitsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.SearchHitsProto defaultValue); + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + SearchHits.SearchHitsProto getInnerHitsOrThrow( + java.lang.String key); + } + /** + *
+   **
+   *float score
+   *Text id
+   *NestedIdentity nestedIdentity
+   *long version
+   *long seqNo
+   *long primaryTerm
+   *BytesReference source
+   *Explanation explanation
+   *Map<String, DocumentField> documentFields
+   *Map<String, DocumentField> metaFields
+   *Map<String, HighlightField> highlightedFields
+   *SearchSortValues sortValues
+   *Map<String, Float> matchedQueries
+   *SearchShardTarget shard
+   *Map<String, SearchHits> innerHits
+   * 
+ * + * Protobuf type {@code SearchHitProto} + */ + public static final class SearchHitProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SearchHitProto) + SearchHitProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use SearchHitProto.newBuilder() to construct. + private SearchHitProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SearchHitProto() { + id_ = ""; + source_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SearchHitProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_SearchHitProto_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 9: + return internalGetDocumentFields(); + case 10: + return internalGetMetaFields(); + case 11: + return internalGetHighlightFields(); + case 13: + return internalGetMatchedQueries(); + case 15: + return internalGetInnerHits(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_SearchHitProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.SearchHitProto.class, SearchHits.SearchHitProto.Builder.class); + } + + public static final int SCORE_FIELD_NUMBER = 1; + private float score_ = 0F; + /** + * float score = 1; + * @return The score. + */ + @java.lang.Override + public float getScore() { + return score_; + } + + public static final int ID_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private volatile java.lang.Object id_ = ""; + /** + * string id = 2; + * @return The id. + */ + @java.lang.Override + public java.lang.String getId() { + java.lang.Object ref = id_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + id_ = s; + return s; + } + } + /** + * string id = 2; + * @return The bytes for id. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getIdBytes() { + java.lang.Object ref = id_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NESTED_IDENTITY_FIELD_NUMBER = 3; + private SearchHits.NestedIdentityProto nestedIdentity_; + /** + * .NestedIdentityProto nested_identity = 3; + * @return Whether the nestedIdentity field is set. + */ + @java.lang.Override + public boolean hasNestedIdentity() { + return nestedIdentity_ != null; + } + /** + * .NestedIdentityProto nested_identity = 3; + * @return The nestedIdentity. + */ + @java.lang.Override + public SearchHits.NestedIdentityProto getNestedIdentity() { + return nestedIdentity_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : nestedIdentity_; + } + /** + * .NestedIdentityProto nested_identity = 3; + */ + @java.lang.Override + public SearchHits.NestedIdentityProtoOrBuilder getNestedIdentityOrBuilder() { + return nestedIdentity_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : nestedIdentity_; + } + + public static final int VERSION_FIELD_NUMBER = 4; + private long version_ = 0L; + /** + * int64 version = 4; + * @return The version. + */ + @java.lang.Override + public long getVersion() { + return version_; + } + + public static final int SEQ_NO_FIELD_NUMBER = 5; + private long seqNo_ = 0L; + /** + * int64 seq_no = 5; + * @return The seqNo. + */ + @java.lang.Override + public long getSeqNo() { + return seqNo_; + } + + public static final int PRIMARY_TERM_FIELD_NUMBER = 6; + private long primaryTerm_ = 0L; + /** + * int64 primary_term = 6; + * @return The primaryTerm. + */ + @java.lang.Override + public long getPrimaryTerm() { + return primaryTerm_; + } + + public static final int SOURCE_FIELD_NUMBER = 7; + private com.google.protobuf.ByteString source_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes source = 7; + * @return The source. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSource() { + return source_; + } + + public static final int EXPLANATION_FIELD_NUMBER = 8; + private SearchHits.ExplanationProto explanation_; + /** + * .ExplanationProto explanation = 8; + * @return Whether the explanation field is set. + */ + @java.lang.Override + public boolean hasExplanation() { + return explanation_ != null; + } + /** + * .ExplanationProto explanation = 8; + * @return The explanation. + */ + @java.lang.Override + public SearchHits.ExplanationProto getExplanation() { + return explanation_ == null ? SearchHits.ExplanationProto.getDefaultInstance() : explanation_; + } + /** + * .ExplanationProto explanation = 8; + */ + @java.lang.Override + public SearchHits.ExplanationProtoOrBuilder getExplanationOrBuilder() { + return explanation_ == null ? SearchHits.ExplanationProto.getDefaultInstance() : explanation_; + } + + public static final int DOCUMENT_FIELDS_FIELD_NUMBER = 9; + private static final class DocumentFieldsDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, SearchHits.DocumentFieldProto> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + SearchHits.internal_static_SearchHitProto_DocumentFieldsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + SearchHits.DocumentFieldProto.getDefaultInstance()); + } + @SuppressWarnings("serial") + private com.google.protobuf.MapField< + java.lang.String, SearchHits.DocumentFieldProto> documentFields_; + private com.google.protobuf.MapField + internalGetDocumentFields() { + if (documentFields_ == null) { + return com.google.protobuf.MapField.emptyMapField( + DocumentFieldsDefaultEntryHolder.defaultEntry); + } + return documentFields_; + } + public int getDocumentFieldsCount() { + return internalGetDocumentFields().getMap().size(); + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + @java.lang.Override + public boolean containsDocumentFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetDocumentFields().getMap().containsKey(key); + } + /** + * Use {@link #getDocumentFieldsMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getDocumentFields() { + return getDocumentFieldsMap(); + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + @java.lang.Override + public java.util.Map getDocumentFieldsMap() { + return internalGetDocumentFields().getMap(); + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + @java.lang.Override + public /* nullable */ +SearchHits.DocumentFieldProto getDocumentFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.DocumentFieldProto defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetDocumentFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + @java.lang.Override + public SearchHits.DocumentFieldProto getDocumentFieldsOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetDocumentFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int META_FIELDS_FIELD_NUMBER = 10; + private static final class MetaFieldsDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, SearchHits.DocumentFieldProto> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + SearchHits.internal_static_SearchHitProto_MetaFieldsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + SearchHits.DocumentFieldProto.getDefaultInstance()); + } + @SuppressWarnings("serial") + private com.google.protobuf.MapField< + java.lang.String, SearchHits.DocumentFieldProto> metaFields_; + private com.google.protobuf.MapField + internalGetMetaFields() { + if (metaFields_ == null) { + return com.google.protobuf.MapField.emptyMapField( + MetaFieldsDefaultEntryHolder.defaultEntry); + } + return metaFields_; + } + public int getMetaFieldsCount() { + return internalGetMetaFields().getMap().size(); + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + @java.lang.Override + public boolean containsMetaFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetMetaFields().getMap().containsKey(key); + } + /** + * Use {@link #getMetaFieldsMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getMetaFields() { + return getMetaFieldsMap(); + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + @java.lang.Override + public java.util.Map getMetaFieldsMap() { + return internalGetMetaFields().getMap(); + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + @java.lang.Override + public /* nullable */ +SearchHits.DocumentFieldProto getMetaFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.DocumentFieldProto defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetMetaFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + @java.lang.Override + public SearchHits.DocumentFieldProto getMetaFieldsOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetMetaFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int HIGHLIGHT_FIELDS_FIELD_NUMBER = 11; + private static final class HighlightFieldsDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, SearchHits.HighlightFieldProto> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + SearchHits.internal_static_SearchHitProto_HighlightFieldsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + SearchHits.HighlightFieldProto.getDefaultInstance()); + } + @SuppressWarnings("serial") + private com.google.protobuf.MapField< + java.lang.String, SearchHits.HighlightFieldProto> highlightFields_; + private com.google.protobuf.MapField + internalGetHighlightFields() { + if (highlightFields_ == null) { + return com.google.protobuf.MapField.emptyMapField( + HighlightFieldsDefaultEntryHolder.defaultEntry); + } + return highlightFields_; + } + public int getHighlightFieldsCount() { + return internalGetHighlightFields().getMap().size(); + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + @java.lang.Override + public boolean containsHighlightFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetHighlightFields().getMap().containsKey(key); + } + /** + * Use {@link #getHighlightFieldsMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getHighlightFields() { + return getHighlightFieldsMap(); + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + @java.lang.Override + public java.util.Map getHighlightFieldsMap() { + return internalGetHighlightFields().getMap(); + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + @java.lang.Override + public /* nullable */ +SearchHits.HighlightFieldProto getHighlightFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.HighlightFieldProto defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetHighlightFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + @java.lang.Override + public SearchHits.HighlightFieldProto getHighlightFieldsOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetHighlightFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int SORT_VALUES_FIELD_NUMBER = 12; + private SearchHits.SearchSortValuesProto sortValues_; + /** + * .SearchSortValuesProto sort_values = 12; + * @return Whether the sortValues field is set. + */ + @java.lang.Override + public boolean hasSortValues() { + return sortValues_ != null; + } + /** + * .SearchSortValuesProto sort_values = 12; + * @return The sortValues. + */ + @java.lang.Override + public SearchHits.SearchSortValuesProto getSortValues() { + return sortValues_ == null ? SearchHits.SearchSortValuesProto.getDefaultInstance() : sortValues_; + } + /** + * .SearchSortValuesProto sort_values = 12; + */ + @java.lang.Override + public SearchHits.SearchSortValuesProtoOrBuilder getSortValuesOrBuilder() { + return sortValues_ == null ? SearchHits.SearchSortValuesProto.getDefaultInstance() : sortValues_; + } + + public static final int MATCHED_QUERIES_FIELD_NUMBER = 13; + private static final class MatchedQueriesDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Float> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + SearchHits.internal_static_SearchHitProto_MatchedQueriesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.FLOAT, + 0F); + } + @SuppressWarnings("serial") + private com.google.protobuf.MapField< + java.lang.String, java.lang.Float> matchedQueries_; + private com.google.protobuf.MapField + internalGetMatchedQueries() { + if (matchedQueries_ == null) { + return com.google.protobuf.MapField.emptyMapField( + MatchedQueriesDefaultEntryHolder.defaultEntry); + } + return matchedQueries_; + } + public int getMatchedQueriesCount() { + return internalGetMatchedQueries().getMap().size(); + } + /** + * map<string, float> matched_queries = 13; + */ + @java.lang.Override + public boolean containsMatchedQueries( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetMatchedQueries().getMap().containsKey(key); + } + /** + * Use {@link #getMatchedQueriesMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getMatchedQueries() { + return getMatchedQueriesMap(); + } + /** + * map<string, float> matched_queries = 13; + */ + @java.lang.Override + public java.util.Map getMatchedQueriesMap() { + return internalGetMatchedQueries().getMap(); + } + /** + * map<string, float> matched_queries = 13; + */ + @java.lang.Override + public float getMatchedQueriesOrDefault( + java.lang.String key, + float defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetMatchedQueries().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, float> matched_queries = 13; + */ + @java.lang.Override + public float getMatchedQueriesOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetMatchedQueries().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int SHARD_FIELD_NUMBER = 14; + private SearchHits.SearchShardTargetProto shard_; + /** + * .SearchShardTargetProto shard = 14; + * @return Whether the shard field is set. + */ + @java.lang.Override + public boolean hasShard() { + return shard_ != null; + } + /** + * .SearchShardTargetProto shard = 14; + * @return The shard. + */ + @java.lang.Override + public SearchHits.SearchShardTargetProto getShard() { + return shard_ == null ? SearchHits.SearchShardTargetProto.getDefaultInstance() : shard_; + } + /** + * .SearchShardTargetProto shard = 14; + */ + @java.lang.Override + public SearchHits.SearchShardTargetProtoOrBuilder getShardOrBuilder() { + return shard_ == null ? SearchHits.SearchShardTargetProto.getDefaultInstance() : shard_; + } + + public static final int INNER_HITS_FIELD_NUMBER = 15; + private static final class InnerHitsDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, SearchHits.SearchHitsProto> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + SearchHits.internal_static_SearchHitProto_InnerHitsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + SearchHits.SearchHitsProto.getDefaultInstance()); + } + @SuppressWarnings("serial") + private com.google.protobuf.MapField< + java.lang.String, SearchHits.SearchHitsProto> innerHits_; + private com.google.protobuf.MapField + internalGetInnerHits() { + if (innerHits_ == null) { + return com.google.protobuf.MapField.emptyMapField( + InnerHitsDefaultEntryHolder.defaultEntry); + } + return innerHits_; + } + public int getInnerHitsCount() { + return internalGetInnerHits().getMap().size(); + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + @java.lang.Override + public boolean containsInnerHits( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetInnerHits().getMap().containsKey(key); + } + /** + * Use {@link #getInnerHitsMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getInnerHits() { + return getInnerHitsMap(); + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + @java.lang.Override + public java.util.Map getInnerHitsMap() { + return internalGetInnerHits().getMap(); + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + @java.lang.Override + public /* nullable */ +SearchHits.SearchHitsProto getInnerHitsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.SearchHitsProto defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetInnerHits().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + @java.lang.Override + public SearchHits.SearchHitsProto getInnerHitsOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetInnerHits().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (java.lang.Float.floatToRawIntBits(score_) != 0) { + output.writeFloat(1, score_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, id_); + } + if (nestedIdentity_ != null) { + output.writeMessage(3, getNestedIdentity()); + } + if (version_ != 0L) { + output.writeInt64(4, version_); + } + if (seqNo_ != 0L) { + output.writeInt64(5, seqNo_); + } + if (primaryTerm_ != 0L) { + output.writeInt64(6, primaryTerm_); + } + if (!source_.isEmpty()) { + output.writeBytes(7, source_); + } + if (explanation_ != null) { + output.writeMessage(8, getExplanation()); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetDocumentFields(), + DocumentFieldsDefaultEntryHolder.defaultEntry, + 9); + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetMetaFields(), + MetaFieldsDefaultEntryHolder.defaultEntry, + 10); + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetHighlightFields(), + HighlightFieldsDefaultEntryHolder.defaultEntry, + 11); + if (sortValues_ != null) { + output.writeMessage(12, getSortValues()); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetMatchedQueries(), + MatchedQueriesDefaultEntryHolder.defaultEntry, + 13); + if (shard_ != null) { + output.writeMessage(14, getShard()); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetInnerHits(), + InnerHitsDefaultEntryHolder.defaultEntry, + 15); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (java.lang.Float.floatToRawIntBits(score_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(1, score_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, id_); + } + if (nestedIdentity_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getNestedIdentity()); + } + if (version_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, version_); + } + if (seqNo_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, seqNo_); + } + if (primaryTerm_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, primaryTerm_); + } + if (!source_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(7, source_); + } + if (explanation_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, getExplanation()); + } + for (java.util.Map.Entry entry + : internalGetDocumentFields().getMap().entrySet()) { + com.google.protobuf.MapEntry + documentFields__ = DocumentFieldsDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(9, documentFields__); + } + for (java.util.Map.Entry entry + : internalGetMetaFields().getMap().entrySet()) { + com.google.protobuf.MapEntry + metaFields__ = MetaFieldsDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(10, metaFields__); + } + for (java.util.Map.Entry entry + : internalGetHighlightFields().getMap().entrySet()) { + com.google.protobuf.MapEntry + highlightFields__ = HighlightFieldsDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(11, highlightFields__); + } + if (sortValues_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(12, getSortValues()); + } + for (java.util.Map.Entry entry + : internalGetMatchedQueries().getMap().entrySet()) { + com.google.protobuf.MapEntry + matchedQueries__ = MatchedQueriesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(13, matchedQueries__); + } + if (shard_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(14, getShard()); + } + for (java.util.Map.Entry entry + : internalGetInnerHits().getMap().entrySet()) { + com.google.protobuf.MapEntry + innerHits__ = InnerHitsDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(15, innerHits__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.SearchHitProto)) { + return super.equals(obj); + } + SearchHits.SearchHitProto other = (SearchHits.SearchHitProto) obj; + + if (java.lang.Float.floatToIntBits(getScore()) + != java.lang.Float.floatToIntBits( + other.getScore())) return false; + if (!getId() + .equals(other.getId())) return false; + if (hasNestedIdentity() != other.hasNestedIdentity()) return false; + if (hasNestedIdentity()) { + if (!getNestedIdentity() + .equals(other.getNestedIdentity())) return false; + } + if (getVersion() + != other.getVersion()) return false; + if (getSeqNo() + != other.getSeqNo()) return false; + if (getPrimaryTerm() + != other.getPrimaryTerm()) return false; + if (!getSource() + .equals(other.getSource())) return false; + if (hasExplanation() != other.hasExplanation()) return false; + if (hasExplanation()) { + if (!getExplanation() + .equals(other.getExplanation())) return false; + } + if (!internalGetDocumentFields().equals( + other.internalGetDocumentFields())) return false; + if (!internalGetMetaFields().equals( + other.internalGetMetaFields())) return false; + if (!internalGetHighlightFields().equals( + other.internalGetHighlightFields())) return false; + if (hasSortValues() != other.hasSortValues()) return false; + if (hasSortValues()) { + if (!getSortValues() + .equals(other.getSortValues())) return false; + } + if (!internalGetMatchedQueries().equals( + other.internalGetMatchedQueries())) return false; + if (hasShard() != other.hasShard()) return false; + if (hasShard()) { + if (!getShard() + .equals(other.getShard())) return false; + } + if (!internalGetInnerHits().equals( + other.internalGetInnerHits())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCORE_FIELD_NUMBER; + hash = (53 * hash) + java.lang.Float.floatToIntBits( + getScore()); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId().hashCode(); + if (hasNestedIdentity()) { + hash = (37 * hash) + NESTED_IDENTITY_FIELD_NUMBER; + hash = (53 * hash) + getNestedIdentity().hashCode(); + } + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getVersion()); + hash = (37 * hash) + SEQ_NO_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSeqNo()); + hash = (37 * hash) + PRIMARY_TERM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPrimaryTerm()); + hash = (37 * hash) + SOURCE_FIELD_NUMBER; + hash = (53 * hash) + getSource().hashCode(); + if (hasExplanation()) { + hash = (37 * hash) + EXPLANATION_FIELD_NUMBER; + hash = (53 * hash) + getExplanation().hashCode(); + } + if (!internalGetDocumentFields().getMap().isEmpty()) { + hash = (37 * hash) + DOCUMENT_FIELDS_FIELD_NUMBER; + hash = (53 * hash) + internalGetDocumentFields().hashCode(); + } + if (!internalGetMetaFields().getMap().isEmpty()) { + hash = (37 * hash) + META_FIELDS_FIELD_NUMBER; + hash = (53 * hash) + internalGetMetaFields().hashCode(); + } + if (!internalGetHighlightFields().getMap().isEmpty()) { + hash = (37 * hash) + HIGHLIGHT_FIELDS_FIELD_NUMBER; + hash = (53 * hash) + internalGetHighlightFields().hashCode(); + } + if (hasSortValues()) { + hash = (37 * hash) + SORT_VALUES_FIELD_NUMBER; + hash = (53 * hash) + getSortValues().hashCode(); + } + if (!internalGetMatchedQueries().getMap().isEmpty()) { + hash = (37 * hash) + MATCHED_QUERIES_FIELD_NUMBER; + hash = (53 * hash) + internalGetMatchedQueries().hashCode(); + } + if (hasShard()) { + hash = (37 * hash) + SHARD_FIELD_NUMBER; + hash = (53 * hash) + getShard().hashCode(); + } + if (!internalGetInnerHits().getMap().isEmpty()) { + hash = (37 * hash) + INNER_HITS_FIELD_NUMBER; + hash = (53 * hash) + internalGetInnerHits().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.SearchHitProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchHitProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchHitProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchHitProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchHitProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchHitProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchHitProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.SearchHitProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.SearchHitProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.SearchHitProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.SearchHitProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.SearchHitProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.SearchHitProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     **
+     *float score
+     *Text id
+     *NestedIdentity nestedIdentity
+     *long version
+     *long seqNo
+     *long primaryTerm
+     *BytesReference source
+     *Explanation explanation
+     *Map<String, DocumentField> documentFields
+     *Map<String, DocumentField> metaFields
+     *Map<String, HighlightField> highlightedFields
+     *SearchSortValues sortValues
+     *Map<String, Float> matchedQueries
+     *SearchShardTarget shard
+     *Map<String, SearchHits> innerHits
+     * 
+ * + * Protobuf type {@code SearchHitProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SearchHitProto) + SearchHits.SearchHitProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_SearchHitProto_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 9: + return internalGetDocumentFields(); + case 10: + return internalGetMetaFields(); + case 11: + return internalGetHighlightFields(); + case 13: + return internalGetMatchedQueries(); + case 15: + return internalGetInnerHits(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 9: + return internalGetMutableDocumentFields(); + case 10: + return internalGetMutableMetaFields(); + case 11: + return internalGetMutableHighlightFields(); + case 13: + return internalGetMutableMatchedQueries(); + case 15: + return internalGetMutableInnerHits(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_SearchHitProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.SearchHitProto.class, SearchHits.SearchHitProto.Builder.class); + } + + // Construct using SearchHits.SearchHitProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + score_ = 0F; + id_ = ""; + nestedIdentity_ = null; + if (nestedIdentityBuilder_ != null) { + nestedIdentityBuilder_.dispose(); + nestedIdentityBuilder_ = null; + } + version_ = 0L; + seqNo_ = 0L; + primaryTerm_ = 0L; + source_ = com.google.protobuf.ByteString.EMPTY; + explanation_ = null; + if (explanationBuilder_ != null) { + explanationBuilder_.dispose(); + explanationBuilder_ = null; + } + internalGetMutableDocumentFields().clear(); + internalGetMutableMetaFields().clear(); + internalGetMutableHighlightFields().clear(); + sortValues_ = null; + if (sortValuesBuilder_ != null) { + sortValuesBuilder_.dispose(); + sortValuesBuilder_ = null; + } + internalGetMutableMatchedQueries().clear(); + shard_ = null; + if (shardBuilder_ != null) { + shardBuilder_.dispose(); + shardBuilder_ = null; + } + internalGetMutableInnerHits().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_SearchHitProto_descriptor; + } + + @java.lang.Override + public SearchHits.SearchHitProto getDefaultInstanceForType() { + return SearchHits.SearchHitProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.SearchHitProto build() { + SearchHits.SearchHitProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.SearchHitProto buildPartial() { + SearchHits.SearchHitProto result = new SearchHits.SearchHitProto(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(SearchHits.SearchHitProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.score_ = score_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.id_ = id_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.nestedIdentity_ = nestedIdentityBuilder_ == null + ? nestedIdentity_ + : nestedIdentityBuilder_.build(); + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.version_ = version_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.seqNo_ = seqNo_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.primaryTerm_ = primaryTerm_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.source_ = source_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.explanation_ = explanationBuilder_ == null + ? explanation_ + : explanationBuilder_.build(); + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.documentFields_ = internalGetDocumentFields(); + result.documentFields_.makeImmutable(); + } + if (((from_bitField0_ & 0x00000200) != 0)) { + result.metaFields_ = internalGetMetaFields(); + result.metaFields_.makeImmutable(); + } + if (((from_bitField0_ & 0x00000400) != 0)) { + result.highlightFields_ = internalGetHighlightFields(); + result.highlightFields_.makeImmutable(); + } + if (((from_bitField0_ & 0x00000800) != 0)) { + result.sortValues_ = sortValuesBuilder_ == null + ? sortValues_ + : sortValuesBuilder_.build(); + } + if (((from_bitField0_ & 0x00001000) != 0)) { + result.matchedQueries_ = internalGetMatchedQueries(); + result.matchedQueries_.makeImmutable(); + } + if (((from_bitField0_ & 0x00002000) != 0)) { + result.shard_ = shardBuilder_ == null + ? shard_ + : shardBuilder_.build(); + } + if (((from_bitField0_ & 0x00004000) != 0)) { + result.innerHits_ = internalGetInnerHits(); + result.innerHits_.makeImmutable(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.SearchHitProto) { + return mergeFrom((SearchHits.SearchHitProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.SearchHitProto other) { + if (other == SearchHits.SearchHitProto.getDefaultInstance()) return this; + if (other.getScore() != 0F) { + setScore(other.getScore()); + } + if (!other.getId().isEmpty()) { + id_ = other.id_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasNestedIdentity()) { + mergeNestedIdentity(other.getNestedIdentity()); + } + if (other.getVersion() != 0L) { + setVersion(other.getVersion()); + } + if (other.getSeqNo() != 0L) { + setSeqNo(other.getSeqNo()); + } + if (other.getPrimaryTerm() != 0L) { + setPrimaryTerm(other.getPrimaryTerm()); + } + if (other.getSource() != com.google.protobuf.ByteString.EMPTY) { + setSource(other.getSource()); + } + if (other.hasExplanation()) { + mergeExplanation(other.getExplanation()); + } + internalGetMutableDocumentFields().mergeFrom( + other.internalGetDocumentFields()); + bitField0_ |= 0x00000100; + internalGetMutableMetaFields().mergeFrom( + other.internalGetMetaFields()); + bitField0_ |= 0x00000200; + internalGetMutableHighlightFields().mergeFrom( + other.internalGetHighlightFields()); + bitField0_ |= 0x00000400; + if (other.hasSortValues()) { + mergeSortValues(other.getSortValues()); + } + internalGetMutableMatchedQueries().mergeFrom( + other.internalGetMatchedQueries()); + bitField0_ |= 0x00001000; + if (other.hasShard()) { + mergeShard(other.getShard()); + } + internalGetMutableInnerHits().mergeFrom( + other.internalGetInnerHits()); + bitField0_ |= 0x00004000; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 13: { + score_ = input.readFloat(); + bitField0_ |= 0x00000001; + break; + } // case 13 + case 18: { + id_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: { + input.readMessage( + getNestedIdentityFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: { + version_ = input.readInt64(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 40: { + seqNo_ = input.readInt64(); + bitField0_ |= 0x00000010; + break; + } // case 40 + case 48: { + primaryTerm_ = input.readInt64(); + bitField0_ |= 0x00000020; + break; + } // case 48 + case 58: { + source_ = input.readBytes(); + bitField0_ |= 0x00000040; + break; + } // case 58 + case 66: { + input.readMessage( + getExplanationFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000080; + break; + } // case 66 + case 74: { + com.google.protobuf.MapEntry + documentFields__ = input.readMessage( + DocumentFieldsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + internalGetMutableDocumentFields().getMutableMap().put( + documentFields__.getKey(), documentFields__.getValue()); + bitField0_ |= 0x00000100; + break; + } // case 74 + case 82: { + com.google.protobuf.MapEntry + metaFields__ = input.readMessage( + MetaFieldsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + internalGetMutableMetaFields().getMutableMap().put( + metaFields__.getKey(), metaFields__.getValue()); + bitField0_ |= 0x00000200; + break; + } // case 82 + case 90: { + com.google.protobuf.MapEntry + highlightFields__ = input.readMessage( + HighlightFieldsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + internalGetMutableHighlightFields().getMutableMap().put( + highlightFields__.getKey(), highlightFields__.getValue()); + bitField0_ |= 0x00000400; + break; + } // case 90 + case 98: { + input.readMessage( + getSortValuesFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000800; + break; + } // case 98 + case 106: { + com.google.protobuf.MapEntry + matchedQueries__ = input.readMessage( + MatchedQueriesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + internalGetMutableMatchedQueries().getMutableMap().put( + matchedQueries__.getKey(), matchedQueries__.getValue()); + bitField0_ |= 0x00001000; + break; + } // case 106 + case 114: { + input.readMessage( + getShardFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00002000; + break; + } // case 114 + case 122: { + com.google.protobuf.MapEntry + innerHits__ = input.readMessage( + InnerHitsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + internalGetMutableInnerHits().getMutableMap().put( + innerHits__.getKey(), innerHits__.getValue()); + bitField0_ |= 0x00004000; + break; + } // case 122 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private float score_ ; + /** + * float score = 1; + * @return The score. + */ + @java.lang.Override + public float getScore() { + return score_; + } + /** + * float score = 1; + * @param value The score to set. + * @return This builder for chaining. + */ + public Builder setScore(float value) { + + score_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * float score = 1; + * @return This builder for chaining. + */ + public Builder clearScore() { + bitField0_ = (bitField0_ & ~0x00000001); + score_ = 0F; + onChanged(); + return this; + } + + private java.lang.Object id_ = ""; + /** + * string id = 2; + * @return The id. + */ + public java.lang.String getId() { + java.lang.Object ref = id_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + id_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string id = 2; + * @return The bytes for id. + */ + public com.google.protobuf.ByteString + getIdBytes() { + java.lang.Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string id = 2; + * @param value The id to set. + * @return This builder for chaining. + */ + public Builder setId( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + id_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * string id = 2; + * @return This builder for chaining. + */ + public Builder clearId() { + id_ = getDefaultInstance().getId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * string id = 2; + * @param value The bytes for id to set. + * @return This builder for chaining. + */ + public Builder setIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + id_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private SearchHits.NestedIdentityProto nestedIdentity_; + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder> nestedIdentityBuilder_; + /** + * .NestedIdentityProto nested_identity = 3; + * @return Whether the nestedIdentity field is set. + */ + public boolean hasNestedIdentity() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * .NestedIdentityProto nested_identity = 3; + * @return The nestedIdentity. + */ + public SearchHits.NestedIdentityProto getNestedIdentity() { + if (nestedIdentityBuilder_ == null) { + return nestedIdentity_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : nestedIdentity_; + } else { + return nestedIdentityBuilder_.getMessage(); + } + } + /** + * .NestedIdentityProto nested_identity = 3; + */ + public Builder setNestedIdentity(SearchHits.NestedIdentityProto value) { + if (nestedIdentityBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + nestedIdentity_ = value; + } else { + nestedIdentityBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * .NestedIdentityProto nested_identity = 3; + */ + public Builder setNestedIdentity( + SearchHits.NestedIdentityProto.Builder builderForValue) { + if (nestedIdentityBuilder_ == null) { + nestedIdentity_ = builderForValue.build(); + } else { + nestedIdentityBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * .NestedIdentityProto nested_identity = 3; + */ + public Builder mergeNestedIdentity(SearchHits.NestedIdentityProto value) { + if (nestedIdentityBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) && + nestedIdentity_ != null && + nestedIdentity_ != SearchHits.NestedIdentityProto.getDefaultInstance()) { + getNestedIdentityBuilder().mergeFrom(value); + } else { + nestedIdentity_ = value; + } + } else { + nestedIdentityBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * .NestedIdentityProto nested_identity = 3; + */ + public Builder clearNestedIdentity() { + bitField0_ = (bitField0_ & ~0x00000004); + nestedIdentity_ = null; + if (nestedIdentityBuilder_ != null) { + nestedIdentityBuilder_.dispose(); + nestedIdentityBuilder_ = null; + } + onChanged(); + return this; + } + /** + * .NestedIdentityProto nested_identity = 3; + */ + public SearchHits.NestedIdentityProto.Builder getNestedIdentityBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getNestedIdentityFieldBuilder().getBuilder(); + } + /** + * .NestedIdentityProto nested_identity = 3; + */ + public SearchHits.NestedIdentityProtoOrBuilder getNestedIdentityOrBuilder() { + if (nestedIdentityBuilder_ != null) { + return nestedIdentityBuilder_.getMessageOrBuilder(); + } else { + return nestedIdentity_ == null ? + SearchHits.NestedIdentityProto.getDefaultInstance() : nestedIdentity_; + } + } + /** + * .NestedIdentityProto nested_identity = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder> + getNestedIdentityFieldBuilder() { + if (nestedIdentityBuilder_ == null) { + nestedIdentityBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder>( + getNestedIdentity(), + getParentForChildren(), + isClean()); + nestedIdentity_ = null; + } + return nestedIdentityBuilder_; + } + + private long version_ ; + /** + * int64 version = 4; + * @return The version. + */ + @java.lang.Override + public long getVersion() { + return version_; + } + /** + * int64 version = 4; + * @param value The version to set. + * @return This builder for chaining. + */ + public Builder setVersion(long value) { + + version_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * int64 version = 4; + * @return This builder for chaining. + */ + public Builder clearVersion() { + bitField0_ = (bitField0_ & ~0x00000008); + version_ = 0L; + onChanged(); + return this; + } + + private long seqNo_ ; + /** + * int64 seq_no = 5; + * @return The seqNo. + */ + @java.lang.Override + public long getSeqNo() { + return seqNo_; + } + /** + * int64 seq_no = 5; + * @param value The seqNo to set. + * @return This builder for chaining. + */ + public Builder setSeqNo(long value) { + + seqNo_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * int64 seq_no = 5; + * @return This builder for chaining. + */ + public Builder clearSeqNo() { + bitField0_ = (bitField0_ & ~0x00000010); + seqNo_ = 0L; + onChanged(); + return this; + } + + private long primaryTerm_ ; + /** + * int64 primary_term = 6; + * @return The primaryTerm. + */ + @java.lang.Override + public long getPrimaryTerm() { + return primaryTerm_; + } + /** + * int64 primary_term = 6; + * @param value The primaryTerm to set. + * @return This builder for chaining. + */ + public Builder setPrimaryTerm(long value) { + + primaryTerm_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + /** + * int64 primary_term = 6; + * @return This builder for chaining. + */ + public Builder clearPrimaryTerm() { + bitField0_ = (bitField0_ & ~0x00000020); + primaryTerm_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString source_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes source = 7; + * @return The source. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSource() { + return source_; + } + /** + * bytes source = 7; + * @param value The source to set. + * @return This builder for chaining. + */ + public Builder setSource(com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + source_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + /** + * bytes source = 7; + * @return This builder for chaining. + */ + public Builder clearSource() { + bitField0_ = (bitField0_ & ~0x00000040); + source_ = getDefaultInstance().getSource(); + onChanged(); + return this; + } + + private SearchHits.ExplanationProto explanation_; + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder> explanationBuilder_; + /** + * .ExplanationProto explanation = 8; + * @return Whether the explanation field is set. + */ + public boolean hasExplanation() { + return ((bitField0_ & 0x00000080) != 0); + } + /** + * .ExplanationProto explanation = 8; + * @return The explanation. + */ + public SearchHits.ExplanationProto getExplanation() { + if (explanationBuilder_ == null) { + return explanation_ == null ? SearchHits.ExplanationProto.getDefaultInstance() : explanation_; + } else { + return explanationBuilder_.getMessage(); + } + } + /** + * .ExplanationProto explanation = 8; + */ + public Builder setExplanation(SearchHits.ExplanationProto value) { + if (explanationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + explanation_ = value; + } else { + explanationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + /** + * .ExplanationProto explanation = 8; + */ + public Builder setExplanation( + SearchHits.ExplanationProto.Builder builderForValue) { + if (explanationBuilder_ == null) { + explanation_ = builderForValue.build(); + } else { + explanationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + /** + * .ExplanationProto explanation = 8; + */ + public Builder mergeExplanation(SearchHits.ExplanationProto value) { + if (explanationBuilder_ == null) { + if (((bitField0_ & 0x00000080) != 0) && + explanation_ != null && + explanation_ != SearchHits.ExplanationProto.getDefaultInstance()) { + getExplanationBuilder().mergeFrom(value); + } else { + explanation_ = value; + } + } else { + explanationBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + /** + * .ExplanationProto explanation = 8; + */ + public Builder clearExplanation() { + bitField0_ = (bitField0_ & ~0x00000080); + explanation_ = null; + if (explanationBuilder_ != null) { + explanationBuilder_.dispose(); + explanationBuilder_ = null; + } + onChanged(); + return this; + } + /** + * .ExplanationProto explanation = 8; + */ + public SearchHits.ExplanationProto.Builder getExplanationBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return getExplanationFieldBuilder().getBuilder(); + } + /** + * .ExplanationProto explanation = 8; + */ + public SearchHits.ExplanationProtoOrBuilder getExplanationOrBuilder() { + if (explanationBuilder_ != null) { + return explanationBuilder_.getMessageOrBuilder(); + } else { + return explanation_ == null ? + SearchHits.ExplanationProto.getDefaultInstance() : explanation_; + } + } + /** + * .ExplanationProto explanation = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder> + getExplanationFieldBuilder() { + if (explanationBuilder_ == null) { + explanationBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder>( + getExplanation(), + getParentForChildren(), + isClean()); + explanation_ = null; + } + return explanationBuilder_; + } + + private com.google.protobuf.MapField< + java.lang.String, SearchHits.DocumentFieldProto> documentFields_; + private com.google.protobuf.MapField + internalGetDocumentFields() { + if (documentFields_ == null) { + return com.google.protobuf.MapField.emptyMapField( + DocumentFieldsDefaultEntryHolder.defaultEntry); + } + return documentFields_; + } + private com.google.protobuf.MapField + internalGetMutableDocumentFields() { + if (documentFields_ == null) { + documentFields_ = com.google.protobuf.MapField.newMapField( + DocumentFieldsDefaultEntryHolder.defaultEntry); + } + if (!documentFields_.isMutable()) { + documentFields_ = documentFields_.copy(); + } + bitField0_ |= 0x00000100; + onChanged(); + return documentFields_; + } + public int getDocumentFieldsCount() { + return internalGetDocumentFields().getMap().size(); + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + @java.lang.Override + public boolean containsDocumentFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetDocumentFields().getMap().containsKey(key); + } + /** + * Use {@link #getDocumentFieldsMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getDocumentFields() { + return getDocumentFieldsMap(); + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + @java.lang.Override + public java.util.Map getDocumentFieldsMap() { + return internalGetDocumentFields().getMap(); + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + @java.lang.Override + public /* nullable */ +SearchHits.DocumentFieldProto getDocumentFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.DocumentFieldProto defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetDocumentFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + @java.lang.Override + public SearchHits.DocumentFieldProto getDocumentFieldsOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetDocumentFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + public Builder clearDocumentFields() { + bitField0_ = (bitField0_ & ~0x00000100); + internalGetMutableDocumentFields().getMutableMap() + .clear(); + return this; + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + public Builder removeDocumentFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + internalGetMutableDocumentFields().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableDocumentFields() { + bitField0_ |= 0x00000100; + return internalGetMutableDocumentFields().getMutableMap(); + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + public Builder putDocumentFields( + java.lang.String key, + SearchHits.DocumentFieldProto value) { + if (key == null) { throw new NullPointerException("map key"); } + if (value == null) { throw new NullPointerException("map value"); } + internalGetMutableDocumentFields().getMutableMap() + .put(key, value); + bitField0_ |= 0x00000100; + return this; + } + /** + * map<string, .DocumentFieldProto> document_fields = 9; + */ + public Builder putAllDocumentFields( + java.util.Map values) { + internalGetMutableDocumentFields().getMutableMap() + .putAll(values); + bitField0_ |= 0x00000100; + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, SearchHits.DocumentFieldProto> metaFields_; + private com.google.protobuf.MapField + internalGetMetaFields() { + if (metaFields_ == null) { + return com.google.protobuf.MapField.emptyMapField( + MetaFieldsDefaultEntryHolder.defaultEntry); + } + return metaFields_; + } + private com.google.protobuf.MapField + internalGetMutableMetaFields() { + if (metaFields_ == null) { + metaFields_ = com.google.protobuf.MapField.newMapField( + MetaFieldsDefaultEntryHolder.defaultEntry); + } + if (!metaFields_.isMutable()) { + metaFields_ = metaFields_.copy(); + } + bitField0_ |= 0x00000200; + onChanged(); + return metaFields_; + } + public int getMetaFieldsCount() { + return internalGetMetaFields().getMap().size(); + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + @java.lang.Override + public boolean containsMetaFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetMetaFields().getMap().containsKey(key); + } + /** + * Use {@link #getMetaFieldsMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getMetaFields() { + return getMetaFieldsMap(); + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + @java.lang.Override + public java.util.Map getMetaFieldsMap() { + return internalGetMetaFields().getMap(); + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + @java.lang.Override + public /* nullable */ +SearchHits.DocumentFieldProto getMetaFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.DocumentFieldProto defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetMetaFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + @java.lang.Override + public SearchHits.DocumentFieldProto getMetaFieldsOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetMetaFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + public Builder clearMetaFields() { + bitField0_ = (bitField0_ & ~0x00000200); + internalGetMutableMetaFields().getMutableMap() + .clear(); + return this; + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + public Builder removeMetaFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + internalGetMutableMetaFields().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableMetaFields() { + bitField0_ |= 0x00000200; + return internalGetMutableMetaFields().getMutableMap(); + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + public Builder putMetaFields( + java.lang.String key, + SearchHits.DocumentFieldProto value) { + if (key == null) { throw new NullPointerException("map key"); } + if (value == null) { throw new NullPointerException("map value"); } + internalGetMutableMetaFields().getMutableMap() + .put(key, value); + bitField0_ |= 0x00000200; + return this; + } + /** + * map<string, .DocumentFieldProto> meta_fields = 10; + */ + public Builder putAllMetaFields( + java.util.Map values) { + internalGetMutableMetaFields().getMutableMap() + .putAll(values); + bitField0_ |= 0x00000200; + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, SearchHits.HighlightFieldProto> highlightFields_; + private com.google.protobuf.MapField + internalGetHighlightFields() { + if (highlightFields_ == null) { + return com.google.protobuf.MapField.emptyMapField( + HighlightFieldsDefaultEntryHolder.defaultEntry); + } + return highlightFields_; + } + private com.google.protobuf.MapField + internalGetMutableHighlightFields() { + if (highlightFields_ == null) { + highlightFields_ = com.google.protobuf.MapField.newMapField( + HighlightFieldsDefaultEntryHolder.defaultEntry); + } + if (!highlightFields_.isMutable()) { + highlightFields_ = highlightFields_.copy(); + } + bitField0_ |= 0x00000400; + onChanged(); + return highlightFields_; + } + public int getHighlightFieldsCount() { + return internalGetHighlightFields().getMap().size(); + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + @java.lang.Override + public boolean containsHighlightFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetHighlightFields().getMap().containsKey(key); + } + /** + * Use {@link #getHighlightFieldsMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getHighlightFields() { + return getHighlightFieldsMap(); + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + @java.lang.Override + public java.util.Map getHighlightFieldsMap() { + return internalGetHighlightFields().getMap(); + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + @java.lang.Override + public /* nullable */ +SearchHits.HighlightFieldProto getHighlightFieldsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.HighlightFieldProto defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetHighlightFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + @java.lang.Override + public SearchHits.HighlightFieldProto getHighlightFieldsOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetHighlightFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + public Builder clearHighlightFields() { + bitField0_ = (bitField0_ & ~0x00000400); + internalGetMutableHighlightFields().getMutableMap() + .clear(); + return this; + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + public Builder removeHighlightFields( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + internalGetMutableHighlightFields().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableHighlightFields() { + bitField0_ |= 0x00000400; + return internalGetMutableHighlightFields().getMutableMap(); + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + public Builder putHighlightFields( + java.lang.String key, + SearchHits.HighlightFieldProto value) { + if (key == null) { throw new NullPointerException("map key"); } + if (value == null) { throw new NullPointerException("map value"); } + internalGetMutableHighlightFields().getMutableMap() + .put(key, value); + bitField0_ |= 0x00000400; + return this; + } + /** + * map<string, .HighlightFieldProto> highlight_fields = 11; + */ + public Builder putAllHighlightFields( + java.util.Map values) { + internalGetMutableHighlightFields().getMutableMap() + .putAll(values); + bitField0_ |= 0x00000400; + return this; + } + + private SearchHits.SearchSortValuesProto sortValues_; + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.SearchSortValuesProto, SearchHits.SearchSortValuesProto.Builder, SearchHits.SearchSortValuesProtoOrBuilder> sortValuesBuilder_; + /** + * .SearchSortValuesProto sort_values = 12; + * @return Whether the sortValues field is set. + */ + public boolean hasSortValues() { + return ((bitField0_ & 0x00000800) != 0); + } + /** + * .SearchSortValuesProto sort_values = 12; + * @return The sortValues. + */ + public SearchHits.SearchSortValuesProto getSortValues() { + if (sortValuesBuilder_ == null) { + return sortValues_ == null ? SearchHits.SearchSortValuesProto.getDefaultInstance() : sortValues_; + } else { + return sortValuesBuilder_.getMessage(); + } + } + /** + * .SearchSortValuesProto sort_values = 12; + */ + public Builder setSortValues(SearchHits.SearchSortValuesProto value) { + if (sortValuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sortValues_ = value; + } else { + sortValuesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000800; + onChanged(); + return this; + } + /** + * .SearchSortValuesProto sort_values = 12; + */ + public Builder setSortValues( + SearchHits.SearchSortValuesProto.Builder builderForValue) { + if (sortValuesBuilder_ == null) { + sortValues_ = builderForValue.build(); + } else { + sortValuesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000800; + onChanged(); + return this; + } + /** + * .SearchSortValuesProto sort_values = 12; + */ + public Builder mergeSortValues(SearchHits.SearchSortValuesProto value) { + if (sortValuesBuilder_ == null) { + if (((bitField0_ & 0x00000800) != 0) && + sortValues_ != null && + sortValues_ != SearchHits.SearchSortValuesProto.getDefaultInstance()) { + getSortValuesBuilder().mergeFrom(value); + } else { + sortValues_ = value; + } + } else { + sortValuesBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000800; + onChanged(); + return this; + } + /** + * .SearchSortValuesProto sort_values = 12; + */ + public Builder clearSortValues() { + bitField0_ = (bitField0_ & ~0x00000800); + sortValues_ = null; + if (sortValuesBuilder_ != null) { + sortValuesBuilder_.dispose(); + sortValuesBuilder_ = null; + } + onChanged(); + return this; + } + /** + * .SearchSortValuesProto sort_values = 12; + */ + public SearchHits.SearchSortValuesProto.Builder getSortValuesBuilder() { + bitField0_ |= 0x00000800; + onChanged(); + return getSortValuesFieldBuilder().getBuilder(); + } + /** + * .SearchSortValuesProto sort_values = 12; + */ + public SearchHits.SearchSortValuesProtoOrBuilder getSortValuesOrBuilder() { + if (sortValuesBuilder_ != null) { + return sortValuesBuilder_.getMessageOrBuilder(); + } else { + return sortValues_ == null ? + SearchHits.SearchSortValuesProto.getDefaultInstance() : sortValues_; + } + } + /** + * .SearchSortValuesProto sort_values = 12; + */ + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.SearchSortValuesProto, SearchHits.SearchSortValuesProto.Builder, SearchHits.SearchSortValuesProtoOrBuilder> + getSortValuesFieldBuilder() { + if (sortValuesBuilder_ == null) { + sortValuesBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + SearchHits.SearchSortValuesProto, SearchHits.SearchSortValuesProto.Builder, SearchHits.SearchSortValuesProtoOrBuilder>( + getSortValues(), + getParentForChildren(), + isClean()); + sortValues_ = null; + } + return sortValuesBuilder_; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Float> matchedQueries_; + private com.google.protobuf.MapField + internalGetMatchedQueries() { + if (matchedQueries_ == null) { + return com.google.protobuf.MapField.emptyMapField( + MatchedQueriesDefaultEntryHolder.defaultEntry); + } + return matchedQueries_; + } + private com.google.protobuf.MapField + internalGetMutableMatchedQueries() { + if (matchedQueries_ == null) { + matchedQueries_ = com.google.protobuf.MapField.newMapField( + MatchedQueriesDefaultEntryHolder.defaultEntry); + } + if (!matchedQueries_.isMutable()) { + matchedQueries_ = matchedQueries_.copy(); + } + bitField0_ |= 0x00001000; + onChanged(); + return matchedQueries_; + } + public int getMatchedQueriesCount() { + return internalGetMatchedQueries().getMap().size(); + } + /** + * map<string, float> matched_queries = 13; + */ + @java.lang.Override + public boolean containsMatchedQueries( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetMatchedQueries().getMap().containsKey(key); + } + /** + * Use {@link #getMatchedQueriesMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getMatchedQueries() { + return getMatchedQueriesMap(); + } + /** + * map<string, float> matched_queries = 13; + */ + @java.lang.Override + public java.util.Map getMatchedQueriesMap() { + return internalGetMatchedQueries().getMap(); + } + /** + * map<string, float> matched_queries = 13; + */ + @java.lang.Override + public float getMatchedQueriesOrDefault( + java.lang.String key, + float defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetMatchedQueries().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, float> matched_queries = 13; + */ + @java.lang.Override + public float getMatchedQueriesOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetMatchedQueries().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + public Builder clearMatchedQueries() { + bitField0_ = (bitField0_ & ~0x00001000); + internalGetMutableMatchedQueries().getMutableMap() + .clear(); + return this; + } + /** + * map<string, float> matched_queries = 13; + */ + public Builder removeMatchedQueries( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + internalGetMutableMatchedQueries().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableMatchedQueries() { + bitField0_ |= 0x00001000; + return internalGetMutableMatchedQueries().getMutableMap(); + } + /** + * map<string, float> matched_queries = 13; + */ + public Builder putMatchedQueries( + java.lang.String key, + float value) { + if (key == null) { throw new NullPointerException("map key"); } + + internalGetMutableMatchedQueries().getMutableMap() + .put(key, value); + bitField0_ |= 0x00001000; + return this; + } + /** + * map<string, float> matched_queries = 13; + */ + public Builder putAllMatchedQueries( + java.util.Map values) { + internalGetMutableMatchedQueries().getMutableMap() + .putAll(values); + bitField0_ |= 0x00001000; + return this; + } + + private SearchHits.SearchShardTargetProto shard_; + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.SearchShardTargetProto, SearchHits.SearchShardTargetProto.Builder, SearchHits.SearchShardTargetProtoOrBuilder> shardBuilder_; + /** + * .SearchShardTargetProto shard = 14; + * @return Whether the shard field is set. + */ + public boolean hasShard() { + return ((bitField0_ & 0x00002000) != 0); + } + /** + * .SearchShardTargetProto shard = 14; + * @return The shard. + */ + public SearchHits.SearchShardTargetProto getShard() { + if (shardBuilder_ == null) { + return shard_ == null ? SearchHits.SearchShardTargetProto.getDefaultInstance() : shard_; + } else { + return shardBuilder_.getMessage(); + } + } + /** + * .SearchShardTargetProto shard = 14; + */ + public Builder setShard(SearchHits.SearchShardTargetProto value) { + if (shardBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + shard_ = value; + } else { + shardBuilder_.setMessage(value); + } + bitField0_ |= 0x00002000; + onChanged(); + return this; + } + /** + * .SearchShardTargetProto shard = 14; + */ + public Builder setShard( + SearchHits.SearchShardTargetProto.Builder builderForValue) { + if (shardBuilder_ == null) { + shard_ = builderForValue.build(); + } else { + shardBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00002000; + onChanged(); + return this; + } + /** + * .SearchShardTargetProto shard = 14; + */ + public Builder mergeShard(SearchHits.SearchShardTargetProto value) { + if (shardBuilder_ == null) { + if (((bitField0_ & 0x00002000) != 0) && + shard_ != null && + shard_ != SearchHits.SearchShardTargetProto.getDefaultInstance()) { + getShardBuilder().mergeFrom(value); + } else { + shard_ = value; + } + } else { + shardBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00002000; + onChanged(); + return this; + } + /** + * .SearchShardTargetProto shard = 14; + */ + public Builder clearShard() { + bitField0_ = (bitField0_ & ~0x00002000); + shard_ = null; + if (shardBuilder_ != null) { + shardBuilder_.dispose(); + shardBuilder_ = null; + } + onChanged(); + return this; + } + /** + * .SearchShardTargetProto shard = 14; + */ + public SearchHits.SearchShardTargetProto.Builder getShardBuilder() { + bitField0_ |= 0x00002000; + onChanged(); + return getShardFieldBuilder().getBuilder(); + } + /** + * .SearchShardTargetProto shard = 14; + */ + public SearchHits.SearchShardTargetProtoOrBuilder getShardOrBuilder() { + if (shardBuilder_ != null) { + return shardBuilder_.getMessageOrBuilder(); + } else { + return shard_ == null ? + SearchHits.SearchShardTargetProto.getDefaultInstance() : shard_; + } + } + /** + * .SearchShardTargetProto shard = 14; + */ + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.SearchShardTargetProto, SearchHits.SearchShardTargetProto.Builder, SearchHits.SearchShardTargetProtoOrBuilder> + getShardFieldBuilder() { + if (shardBuilder_ == null) { + shardBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + SearchHits.SearchShardTargetProto, SearchHits.SearchShardTargetProto.Builder, SearchHits.SearchShardTargetProtoOrBuilder>( + getShard(), + getParentForChildren(), + isClean()); + shard_ = null; + } + return shardBuilder_; + } + + private com.google.protobuf.MapField< + java.lang.String, SearchHits.SearchHitsProto> innerHits_; + private com.google.protobuf.MapField + internalGetInnerHits() { + if (innerHits_ == null) { + return com.google.protobuf.MapField.emptyMapField( + InnerHitsDefaultEntryHolder.defaultEntry); + } + return innerHits_; + } + private com.google.protobuf.MapField + internalGetMutableInnerHits() { + if (innerHits_ == null) { + innerHits_ = com.google.protobuf.MapField.newMapField( + InnerHitsDefaultEntryHolder.defaultEntry); + } + if (!innerHits_.isMutable()) { + innerHits_ = innerHits_.copy(); + } + bitField0_ |= 0x00004000; + onChanged(); + return innerHits_; + } + public int getInnerHitsCount() { + return internalGetInnerHits().getMap().size(); + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + @java.lang.Override + public boolean containsInnerHits( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetInnerHits().getMap().containsKey(key); + } + /** + * Use {@link #getInnerHitsMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getInnerHits() { + return getInnerHitsMap(); + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + @java.lang.Override + public java.util.Map getInnerHitsMap() { + return internalGetInnerHits().getMap(); + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + @java.lang.Override + public /* nullable */ +SearchHits.SearchHitsProto getInnerHitsOrDefault( + java.lang.String key, + /* nullable */ +SearchHits.SearchHitsProto defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetInnerHits().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + @java.lang.Override + public SearchHits.SearchHitsProto getInnerHitsOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetInnerHits().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + public Builder clearInnerHits() { + bitField0_ = (bitField0_ & ~0x00004000); + internalGetMutableInnerHits().getMutableMap() + .clear(); + return this; + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + public Builder removeInnerHits( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + internalGetMutableInnerHits().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableInnerHits() { + bitField0_ |= 0x00004000; + return internalGetMutableInnerHits().getMutableMap(); + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + public Builder putInnerHits( + java.lang.String key, + SearchHits.SearchHitsProto value) { + if (key == null) { throw new NullPointerException("map key"); } + if (value == null) { throw new NullPointerException("map value"); } + internalGetMutableInnerHits().getMutableMap() + .put(key, value); + bitField0_ |= 0x00004000; + return this; + } + /** + * map<string, .SearchHitsProto> inner_hits = 15; + */ + public Builder putAllInnerHits( + java.util.Map values) { + internalGetMutableInnerHits().getMutableMap() + .putAll(values); + bitField0_ |= 0x00004000; + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SearchHitProto) + } + + // @@protoc_insertion_point(class_scope:SearchHitProto) + private static final SearchHits.SearchHitProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.SearchHitProto(); + } + + public static SearchHits.SearchHitProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SearchHitProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.SearchHitProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface NestedIdentityProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:NestedIdentityProto) + com.google.protobuf.MessageOrBuilder { + + /** + * string field = 1; + * @return The field. + */ + java.lang.String getField(); + /** + * string field = 1; + * @return The bytes for field. + */ + com.google.protobuf.ByteString + getFieldBytes(); + + /** + * int32 offset = 2; + * @return The offset. + */ + int getOffset(); + + /** + * .NestedIdentityProto child = 3; + * @return Whether the child field is set. + */ + boolean hasChild(); + /** + * .NestedIdentityProto child = 3; + * @return The child. + */ + SearchHits.NestedIdentityProto getChild(); + /** + * .NestedIdentityProto child = 3; + */ + SearchHits.NestedIdentityProtoOrBuilder getChildOrBuilder(); + } + /** + *
+   *
+   *Text field;
+   *int offset;
+   *NestedIdentity child;
+   * 
+ * + * Protobuf type {@code NestedIdentityProto} + */ + public static final class NestedIdentityProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:NestedIdentityProto) + NestedIdentityProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use NestedIdentityProto.newBuilder() to construct. + private NestedIdentityProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private NestedIdentityProto() { + field_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new NestedIdentityProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_NestedIdentityProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_NestedIdentityProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.NestedIdentityProto.class, SearchHits.NestedIdentityProto.Builder.class); + } + + public static final int FIELD_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object field_ = ""; + /** + * string field = 1; + * @return The field. + */ + @java.lang.Override + public java.lang.String getField() { + java.lang.Object ref = field_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + field_ = s; + return s; + } + } + /** + * string field = 1; + * @return The bytes for field. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getFieldBytes() { + java.lang.Object ref = field_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + field_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OFFSET_FIELD_NUMBER = 2; + private int offset_ = 0; + /** + * int32 offset = 2; + * @return The offset. + */ + @java.lang.Override + public int getOffset() { + return offset_; + } + + public static final int CHILD_FIELD_NUMBER = 3; + private SearchHits.NestedIdentityProto child_; + /** + * .NestedIdentityProto child = 3; + * @return Whether the child field is set. + */ + @java.lang.Override + public boolean hasChild() { + return child_ != null; + } + /** + * .NestedIdentityProto child = 3; + * @return The child. + */ + @java.lang.Override + public SearchHits.NestedIdentityProto getChild() { + return child_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : child_; + } + /** + * .NestedIdentityProto child = 3; + */ + @java.lang.Override + public SearchHits.NestedIdentityProtoOrBuilder getChildOrBuilder() { + return child_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : child_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(field_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, field_); + } + if (offset_ != 0) { + output.writeInt32(2, offset_); + } + if (child_ != null) { + output.writeMessage(3, getChild()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(field_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, field_); + } + if (offset_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, offset_); + } + if (child_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getChild()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.NestedIdentityProto)) { + return super.equals(obj); + } + SearchHits.NestedIdentityProto other = (SearchHits.NestedIdentityProto) obj; + + if (!getField() + .equals(other.getField())) return false; + if (getOffset() + != other.getOffset()) return false; + if (hasChild() != other.hasChild()) return false; + if (hasChild()) { + if (!getChild() + .equals(other.getChild())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FIELD_FIELD_NUMBER; + hash = (53 * hash) + getField().hashCode(); + hash = (37 * hash) + OFFSET_FIELD_NUMBER; + hash = (53 * hash) + getOffset(); + if (hasChild()) { + hash = (37 * hash) + CHILD_FIELD_NUMBER; + hash = (53 * hash) + getChild().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.NestedIdentityProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.NestedIdentityProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.NestedIdentityProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.NestedIdentityProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.NestedIdentityProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.NestedIdentityProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.NestedIdentityProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.NestedIdentityProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.NestedIdentityProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.NestedIdentityProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.NestedIdentityProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.NestedIdentityProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.NestedIdentityProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *Text field;
+     *int offset;
+     *NestedIdentity child;
+     * 
+ * + * Protobuf type {@code NestedIdentityProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:NestedIdentityProto) + SearchHits.NestedIdentityProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_NestedIdentityProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_NestedIdentityProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.NestedIdentityProto.class, SearchHits.NestedIdentityProto.Builder.class); + } + + // Construct using SearchHits.NestedIdentityProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + field_ = ""; + offset_ = 0; + child_ = null; + if (childBuilder_ != null) { + childBuilder_.dispose(); + childBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_NestedIdentityProto_descriptor; + } + + @java.lang.Override + public SearchHits.NestedIdentityProto getDefaultInstanceForType() { + return SearchHits.NestedIdentityProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.NestedIdentityProto build() { + SearchHits.NestedIdentityProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.NestedIdentityProto buildPartial() { + SearchHits.NestedIdentityProto result = new SearchHits.NestedIdentityProto(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(SearchHits.NestedIdentityProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.field_ = field_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.offset_ = offset_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.child_ = childBuilder_ == null + ? child_ + : childBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.NestedIdentityProto) { + return mergeFrom((SearchHits.NestedIdentityProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.NestedIdentityProto other) { + if (other == SearchHits.NestedIdentityProto.getDefaultInstance()) return this; + if (!other.getField().isEmpty()) { + field_ = other.field_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.getOffset() != 0) { + setOffset(other.getOffset()); + } + if (other.hasChild()) { + mergeChild(other.getChild()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + field_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: { + offset_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: { + input.readMessage( + getChildFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.lang.Object field_ = ""; + /** + * string field = 1; + * @return The field. + */ + public java.lang.String getField() { + java.lang.Object ref = field_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + field_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string field = 1; + * @return The bytes for field. + */ + public com.google.protobuf.ByteString + getFieldBytes() { + java.lang.Object ref = field_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + field_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string field = 1; + * @param value The field to set. + * @return This builder for chaining. + */ + public Builder setField( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + field_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * string field = 1; + * @return This builder for chaining. + */ + public Builder clearField() { + field_ = getDefaultInstance().getField(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * string field = 1; + * @param value The bytes for field to set. + * @return This builder for chaining. + */ + public Builder setFieldBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + field_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private int offset_ ; + /** + * int32 offset = 2; + * @return The offset. + */ + @java.lang.Override + public int getOffset() { + return offset_; + } + /** + * int32 offset = 2; + * @param value The offset to set. + * @return This builder for chaining. + */ + public Builder setOffset(int value) { + + offset_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * int32 offset = 2; + * @return This builder for chaining. + */ + public Builder clearOffset() { + bitField0_ = (bitField0_ & ~0x00000002); + offset_ = 0; + onChanged(); + return this; + } + + private SearchHits.NestedIdentityProto child_; + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder> childBuilder_; + /** + * .NestedIdentityProto child = 3; + * @return Whether the child field is set. + */ + public boolean hasChild() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * .NestedIdentityProto child = 3; + * @return The child. + */ + public SearchHits.NestedIdentityProto getChild() { + if (childBuilder_ == null) { + return child_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : child_; + } else { + return childBuilder_.getMessage(); + } + } + /** + * .NestedIdentityProto child = 3; + */ + public Builder setChild(SearchHits.NestedIdentityProto value) { + if (childBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + child_ = value; + } else { + childBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * .NestedIdentityProto child = 3; + */ + public Builder setChild( + SearchHits.NestedIdentityProto.Builder builderForValue) { + if (childBuilder_ == null) { + child_ = builderForValue.build(); + } else { + childBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * .NestedIdentityProto child = 3; + */ + public Builder mergeChild(SearchHits.NestedIdentityProto value) { + if (childBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) && + child_ != null && + child_ != SearchHits.NestedIdentityProto.getDefaultInstance()) { + getChildBuilder().mergeFrom(value); + } else { + child_ = value; + } + } else { + childBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * .NestedIdentityProto child = 3; + */ + public Builder clearChild() { + bitField0_ = (bitField0_ & ~0x00000004); + child_ = null; + if (childBuilder_ != null) { + childBuilder_.dispose(); + childBuilder_ = null; + } + onChanged(); + return this; + } + /** + * .NestedIdentityProto child = 3; + */ + public SearchHits.NestedIdentityProto.Builder getChildBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getChildFieldBuilder().getBuilder(); + } + /** + * .NestedIdentityProto child = 3; + */ + public SearchHits.NestedIdentityProtoOrBuilder getChildOrBuilder() { + if (childBuilder_ != null) { + return childBuilder_.getMessageOrBuilder(); + } else { + return child_ == null ? + SearchHits.NestedIdentityProto.getDefaultInstance() : child_; + } + } + /** + * .NestedIdentityProto child = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder> + getChildFieldBuilder() { + if (childBuilder_ == null) { + childBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder>( + getChild(), + getParentForChildren(), + isClean()); + child_ = null; + } + return childBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:NestedIdentityProto) + } + + // @@protoc_insertion_point(class_scope:NestedIdentityProto) + private static final SearchHits.NestedIdentityProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.NestedIdentityProto(); + } + + public static SearchHits.NestedIdentityProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public NestedIdentityProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.NestedIdentityProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DocumentFieldProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:DocumentFieldProto) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + * @return The name. + */ + java.lang.String getName(); + /** + * string name = 1; + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * repeated bytes values = 2; + * @return A list containing the values. + */ + java.util.List getValuesList(); + /** + * repeated bytes values = 2; + * @return The count of values. + */ + int getValuesCount(); + /** + * repeated bytes values = 2; + * @param index The index of the element to return. + * @return The values at the given index. + */ + com.google.protobuf.ByteString getValues(int index); + } + /** + *
+   *
+   *String name
+   *List<Object> values
+   * 
+ * + * Protobuf type {@code DocumentFieldProto} + */ + public static final class DocumentFieldProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:DocumentFieldProto) + DocumentFieldProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use DocumentFieldProto.newBuilder() to construct. + private DocumentFieldProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DocumentFieldProto() { + name_ = ""; + values_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new DocumentFieldProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_DocumentFieldProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_DocumentFieldProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.DocumentFieldProto.class, SearchHits.DocumentFieldProto.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * string name = 1; + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 1; + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VALUES_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private java.util.List values_; + /** + * repeated bytes values = 2; + * @return A list containing the values. + */ + @java.lang.Override + public java.util.List + getValuesList() { + return values_; + } + /** + * repeated bytes values = 2; + * @return The count of values. + */ + public int getValuesCount() { + return values_.size(); + } + /** + * repeated bytes values = 2; + * @param index The index of the element to return. + * @return The values at the given index. + */ + public com.google.protobuf.ByteString getValues(int index) { + return values_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + for (int i = 0; i < values_.size(); i++) { + output.writeBytes(2, values_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + { + int dataSize = 0; + for (int i = 0; i < values_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(values_.get(i)); + } + size += dataSize; + size += 1 * getValuesList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.DocumentFieldProto)) { + return super.equals(obj); + } + SearchHits.DocumentFieldProto other = (SearchHits.DocumentFieldProto) obj; + + if (!getName() + .equals(other.getName())) return false; + if (!getValuesList() + .equals(other.getValuesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getValuesCount() > 0) { + hash = (37 * hash) + VALUES_FIELD_NUMBER; + hash = (53 * hash) + getValuesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.DocumentFieldProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.DocumentFieldProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.DocumentFieldProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.DocumentFieldProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.DocumentFieldProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.DocumentFieldProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.DocumentFieldProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.DocumentFieldProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.DocumentFieldProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.DocumentFieldProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.DocumentFieldProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.DocumentFieldProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.DocumentFieldProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *String name
+     *List<Object> values
+     * 
+ * + * Protobuf type {@code DocumentFieldProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:DocumentFieldProto) + SearchHits.DocumentFieldProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_DocumentFieldProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_DocumentFieldProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.DocumentFieldProto.class, SearchHits.DocumentFieldProto.Builder.class); + } + + // Construct using SearchHits.DocumentFieldProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + values_ = java.util.Collections.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_DocumentFieldProto_descriptor; + } + + @java.lang.Override + public SearchHits.DocumentFieldProto getDefaultInstanceForType() { + return SearchHits.DocumentFieldProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.DocumentFieldProto build() { + SearchHits.DocumentFieldProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.DocumentFieldProto buildPartial() { + SearchHits.DocumentFieldProto result = new SearchHits.DocumentFieldProto(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(SearchHits.DocumentFieldProto result) { + if (((bitField0_ & 0x00000002) != 0)) { + values_ = java.util.Collections.unmodifiableList(values_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.values_ = values_; + } + + private void buildPartial0(SearchHits.DocumentFieldProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.DocumentFieldProto) { + return mergeFrom((SearchHits.DocumentFieldProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.DocumentFieldProto other) { + if (other == SearchHits.DocumentFieldProto.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.values_.isEmpty()) { + if (values_.isEmpty()) { + values_ = other.values_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureValuesIsMutable(); + values_.addAll(other.values_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: { + com.google.protobuf.ByteString v = input.readBytes(); + ensureValuesIsMutable(); + values_.add(v); + break; + } // case 18 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * string name = 1; + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 1; + * @return The bytes for name. + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 1; + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * string name = 1; + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * string name = 1; + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List values_ = java.util.Collections.emptyList(); + private void ensureValuesIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + values_ = new java.util.ArrayList(values_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bytes values = 2; + * @return A list containing the values. + */ + public java.util.List + getValuesList() { + return ((bitField0_ & 0x00000002) != 0) ? + java.util.Collections.unmodifiableList(values_) : values_; + } + /** + * repeated bytes values = 2; + * @return The count of values. + */ + public int getValuesCount() { + return values_.size(); + } + /** + * repeated bytes values = 2; + * @param index The index of the element to return. + * @return The values at the given index. + */ + public com.google.protobuf.ByteString getValues(int index) { + return values_.get(index); + } + /** + * repeated bytes values = 2; + * @param index The index to set the value at. + * @param value The values to set. + * @return This builder for chaining. + */ + public Builder setValues( + int index, com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + ensureValuesIsMutable(); + values_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes values = 2; + * @param value The values to add. + * @return This builder for chaining. + */ + public Builder addValues(com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + ensureValuesIsMutable(); + values_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes values = 2; + * @param values The values to add. + * @return This builder for chaining. + */ + public Builder addAllValues( + java.lang.Iterable values) { + ensureValuesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, values_); + onChanged(); + return this; + } + /** + * repeated bytes values = 2; + * @return This builder for chaining. + */ + public Builder clearValues() { + values_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:DocumentFieldProto) + } + + // @@protoc_insertion_point(class_scope:DocumentFieldProto) + private static final SearchHits.DocumentFieldProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.DocumentFieldProto(); + } + + public static SearchHits.DocumentFieldProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentFieldProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.DocumentFieldProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface HighlightFieldProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:HighlightFieldProto) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + * @return The name. + */ + java.lang.String getName(); + /** + * string name = 1; + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * repeated string fragments = 2; + * @return A list containing the fragments. + */ + java.util.List + getFragmentsList(); + /** + * repeated string fragments = 2; + * @return The count of fragments. + */ + int getFragmentsCount(); + /** + * repeated string fragments = 2; + * @param index The index of the element to return. + * @return The fragments at the given index. + */ + java.lang.String getFragments(int index); + /** + * repeated string fragments = 2; + * @param index The index of the value to return. + * @return The bytes of the fragments at the given index. + */ + com.google.protobuf.ByteString + getFragmentsBytes(int index); + } + /** + *
+   *
+   *String name
+   *Text[] fragments
+   * 
+ * + * Protobuf type {@code HighlightFieldProto} + */ + public static final class HighlightFieldProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:HighlightFieldProto) + HighlightFieldProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use HighlightFieldProto.newBuilder() to construct. + private HighlightFieldProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private HighlightFieldProto() { + name_ = ""; + fragments_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new HighlightFieldProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_HighlightFieldProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_HighlightFieldProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.HighlightFieldProto.class, SearchHits.HighlightFieldProto.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * string name = 1; + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 1; + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FRAGMENTS_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList fragments_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + /** + * repeated string fragments = 2; + * @return A list containing the fragments. + */ + public com.google.protobuf.ProtocolStringList + getFragmentsList() { + return fragments_; + } + /** + * repeated string fragments = 2; + * @return The count of fragments. + */ + public int getFragmentsCount() { + return fragments_.size(); + } + /** + * repeated string fragments = 2; + * @param index The index of the element to return. + * @return The fragments at the given index. + */ + public java.lang.String getFragments(int index) { + return fragments_.get(index); + } + /** + * repeated string fragments = 2; + * @param index The index of the value to return. + * @return The bytes of the fragments at the given index. + */ + public com.google.protobuf.ByteString + getFragmentsBytes(int index) { + return fragments_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + for (int i = 0; i < fragments_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, fragments_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + { + int dataSize = 0; + for (int i = 0; i < fragments_.size(); i++) { + dataSize += computeStringSizeNoTag(fragments_.getRaw(i)); + } + size += dataSize; + size += 1 * getFragmentsList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.HighlightFieldProto)) { + return super.equals(obj); + } + SearchHits.HighlightFieldProto other = (SearchHits.HighlightFieldProto) obj; + + if (!getName() + .equals(other.getName())) return false; + if (!getFragmentsList() + .equals(other.getFragmentsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getFragmentsCount() > 0) { + hash = (37 * hash) + FRAGMENTS_FIELD_NUMBER; + hash = (53 * hash) + getFragmentsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.HighlightFieldProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.HighlightFieldProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.HighlightFieldProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.HighlightFieldProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.HighlightFieldProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.HighlightFieldProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.HighlightFieldProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.HighlightFieldProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.HighlightFieldProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.HighlightFieldProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.HighlightFieldProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.HighlightFieldProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.HighlightFieldProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *String name
+     *Text[] fragments
+     * 
+ * + * Protobuf type {@code HighlightFieldProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:HighlightFieldProto) + SearchHits.HighlightFieldProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_HighlightFieldProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_HighlightFieldProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.HighlightFieldProto.class, SearchHits.HighlightFieldProto.Builder.class); + } + + // Construct using SearchHits.HighlightFieldProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + fragments_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_HighlightFieldProto_descriptor; + } + + @java.lang.Override + public SearchHits.HighlightFieldProto getDefaultInstanceForType() { + return SearchHits.HighlightFieldProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.HighlightFieldProto build() { + SearchHits.HighlightFieldProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.HighlightFieldProto buildPartial() { + SearchHits.HighlightFieldProto result = new SearchHits.HighlightFieldProto(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(SearchHits.HighlightFieldProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + fragments_.makeImmutable(); + result.fragments_ = fragments_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.HighlightFieldProto) { + return mergeFrom((SearchHits.HighlightFieldProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.HighlightFieldProto other) { + if (other == SearchHits.HighlightFieldProto.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.fragments_.isEmpty()) { + if (fragments_.isEmpty()) { + fragments_ = other.fragments_; + bitField0_ |= 0x00000002; + } else { + ensureFragmentsIsMutable(); + fragments_.addAll(other.fragments_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + ensureFragmentsIsMutable(); + fragments_.add(s); + break; + } // case 18 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * string name = 1; + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 1; + * @return The bytes for name. + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 1; + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * string name = 1; + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * string name = 1; + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList fragments_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + private void ensureFragmentsIsMutable() { + if (!fragments_.isModifiable()) { + fragments_ = new com.google.protobuf.LazyStringArrayList(fragments_); + } + bitField0_ |= 0x00000002; + } + /** + * repeated string fragments = 2; + * @return A list containing the fragments. + */ + public com.google.protobuf.ProtocolStringList + getFragmentsList() { + fragments_.makeImmutable(); + return fragments_; + } + /** + * repeated string fragments = 2; + * @return The count of fragments. + */ + public int getFragmentsCount() { + return fragments_.size(); + } + /** + * repeated string fragments = 2; + * @param index The index of the element to return. + * @return The fragments at the given index. + */ + public java.lang.String getFragments(int index) { + return fragments_.get(index); + } + /** + * repeated string fragments = 2; + * @param index The index of the value to return. + * @return The bytes of the fragments at the given index. + */ + public com.google.protobuf.ByteString + getFragmentsBytes(int index) { + return fragments_.getByteString(index); + } + /** + * repeated string fragments = 2; + * @param index The index to set the value at. + * @param value The fragments to set. + * @return This builder for chaining. + */ + public Builder setFragments( + int index, java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + ensureFragmentsIsMutable(); + fragments_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * repeated string fragments = 2; + * @param value The fragments to add. + * @return This builder for chaining. + */ + public Builder addFragments( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + ensureFragmentsIsMutable(); + fragments_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * repeated string fragments = 2; + * @param values The fragments to add. + * @return This builder for chaining. + */ + public Builder addAllFragments( + java.lang.Iterable values) { + ensureFragmentsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, fragments_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * repeated string fragments = 2; + * @return This builder for chaining. + */ + public Builder clearFragments() { + fragments_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002);; + onChanged(); + return this; + } + /** + * repeated string fragments = 2; + * @param value The bytes of the fragments to add. + * @return This builder for chaining. + */ + public Builder addFragmentsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + ensureFragmentsIsMutable(); + fragments_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:HighlightFieldProto) + } + + // @@protoc_insertion_point(class_scope:HighlightFieldProto) + private static final SearchHits.HighlightFieldProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.HighlightFieldProto(); + } + + public static SearchHits.HighlightFieldProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public HighlightFieldProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.HighlightFieldProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SearchSortValuesProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:SearchSortValuesProto) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated bytes formatted_sort_values = 1; + * @return A list containing the formattedSortValues. + */ + java.util.List getFormattedSortValuesList(); + /** + * repeated bytes formatted_sort_values = 1; + * @return The count of formattedSortValues. + */ + int getFormattedSortValuesCount(); + /** + * repeated bytes formatted_sort_values = 1; + * @param index The index of the element to return. + * @return The formattedSortValues at the given index. + */ + com.google.protobuf.ByteString getFormattedSortValues(int index); + + /** + * repeated bytes raw_sort_values = 2; + * @return A list containing the rawSortValues. + */ + java.util.List getRawSortValuesList(); + /** + * repeated bytes raw_sort_values = 2; + * @return The count of rawSortValues. + */ + int getRawSortValuesCount(); + /** + * repeated bytes raw_sort_values = 2; + * @param index The index of the element to return. + * @return The rawSortValues at the given index. + */ + com.google.protobuf.ByteString getRawSortValues(int index); + } + /** + *
+   *
+   *Object[] formattedSortValues
+   *Object[] rawSortValues
+   * 
+ * + * Protobuf type {@code SearchSortValuesProto} + */ + public static final class SearchSortValuesProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SearchSortValuesProto) + SearchSortValuesProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use SearchSortValuesProto.newBuilder() to construct. + private SearchSortValuesProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SearchSortValuesProto() { + formattedSortValues_ = java.util.Collections.emptyList(); + rawSortValues_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SearchSortValuesProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_SearchSortValuesProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_SearchSortValuesProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.SearchSortValuesProto.class, SearchHits.SearchSortValuesProto.Builder.class); + } + + public static final int FORMATTED_SORT_VALUES_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private java.util.List formattedSortValues_; + /** + * repeated bytes formatted_sort_values = 1; + * @return A list containing the formattedSortValues. + */ + @java.lang.Override + public java.util.List + getFormattedSortValuesList() { + return formattedSortValues_; + } + /** + * repeated bytes formatted_sort_values = 1; + * @return The count of formattedSortValues. + */ + public int getFormattedSortValuesCount() { + return formattedSortValues_.size(); + } + /** + * repeated bytes formatted_sort_values = 1; + * @param index The index of the element to return. + * @return The formattedSortValues at the given index. + */ + public com.google.protobuf.ByteString getFormattedSortValues(int index) { + return formattedSortValues_.get(index); + } + + public static final int RAW_SORT_VALUES_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private java.util.List rawSortValues_; + /** + * repeated bytes raw_sort_values = 2; + * @return A list containing the rawSortValues. + */ + @java.lang.Override + public java.util.List + getRawSortValuesList() { + return rawSortValues_; + } + /** + * repeated bytes raw_sort_values = 2; + * @return The count of rawSortValues. + */ + public int getRawSortValuesCount() { + return rawSortValues_.size(); + } + /** + * repeated bytes raw_sort_values = 2; + * @param index The index of the element to return. + * @return The rawSortValues at the given index. + */ + public com.google.protobuf.ByteString getRawSortValues(int index) { + return rawSortValues_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < formattedSortValues_.size(); i++) { + output.writeBytes(1, formattedSortValues_.get(i)); + } + for (int i = 0; i < rawSortValues_.size(); i++) { + output.writeBytes(2, rawSortValues_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < formattedSortValues_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(formattedSortValues_.get(i)); + } + size += dataSize; + size += 1 * getFormattedSortValuesList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < rawSortValues_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(rawSortValues_.get(i)); + } + size += dataSize; + size += 1 * getRawSortValuesList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.SearchSortValuesProto)) { + return super.equals(obj); + } + SearchHits.SearchSortValuesProto other = (SearchHits.SearchSortValuesProto) obj; + + if (!getFormattedSortValuesList() + .equals(other.getFormattedSortValuesList())) return false; + if (!getRawSortValuesList() + .equals(other.getRawSortValuesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getFormattedSortValuesCount() > 0) { + hash = (37 * hash) + FORMATTED_SORT_VALUES_FIELD_NUMBER; + hash = (53 * hash) + getFormattedSortValuesList().hashCode(); + } + if (getRawSortValuesCount() > 0) { + hash = (37 * hash) + RAW_SORT_VALUES_FIELD_NUMBER; + hash = (53 * hash) + getRawSortValuesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.SearchSortValuesProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchSortValuesProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchSortValuesProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchSortValuesProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchSortValuesProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchSortValuesProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchSortValuesProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.SearchSortValuesProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.SearchSortValuesProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.SearchSortValuesProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.SearchSortValuesProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.SearchSortValuesProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.SearchSortValuesProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *Object[] formattedSortValues
+     *Object[] rawSortValues
+     * 
+ * + * Protobuf type {@code SearchSortValuesProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SearchSortValuesProto) + SearchHits.SearchSortValuesProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_SearchSortValuesProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_SearchSortValuesProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.SearchSortValuesProto.class, SearchHits.SearchSortValuesProto.Builder.class); + } + + // Construct using SearchHits.SearchSortValuesProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + formattedSortValues_ = java.util.Collections.emptyList(); + rawSortValues_ = java.util.Collections.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_SearchSortValuesProto_descriptor; + } + + @java.lang.Override + public SearchHits.SearchSortValuesProto getDefaultInstanceForType() { + return SearchHits.SearchSortValuesProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.SearchSortValuesProto build() { + SearchHits.SearchSortValuesProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.SearchSortValuesProto buildPartial() { + SearchHits.SearchSortValuesProto result = new SearchHits.SearchSortValuesProto(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(SearchHits.SearchSortValuesProto result) { + if (((bitField0_ & 0x00000001) != 0)) { + formattedSortValues_ = java.util.Collections.unmodifiableList(formattedSortValues_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.formattedSortValues_ = formattedSortValues_; + if (((bitField0_ & 0x00000002) != 0)) { + rawSortValues_ = java.util.Collections.unmodifiableList(rawSortValues_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.rawSortValues_ = rawSortValues_; + } + + private void buildPartial0(SearchHits.SearchSortValuesProto result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.SearchSortValuesProto) { + return mergeFrom((SearchHits.SearchSortValuesProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.SearchSortValuesProto other) { + if (other == SearchHits.SearchSortValuesProto.getDefaultInstance()) return this; + if (!other.formattedSortValues_.isEmpty()) { + if (formattedSortValues_.isEmpty()) { + formattedSortValues_ = other.formattedSortValues_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureFormattedSortValuesIsMutable(); + formattedSortValues_.addAll(other.formattedSortValues_); + } + onChanged(); + } + if (!other.rawSortValues_.isEmpty()) { + if (rawSortValues_.isEmpty()) { + rawSortValues_ = other.rawSortValues_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureRawSortValuesIsMutable(); + rawSortValues_.addAll(other.rawSortValues_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + com.google.protobuf.ByteString v = input.readBytes(); + ensureFormattedSortValuesIsMutable(); + formattedSortValues_.add(v); + break; + } // case 10 + case 18: { + com.google.protobuf.ByteString v = input.readBytes(); + ensureRawSortValuesIsMutable(); + rawSortValues_.add(v); + break; + } // case 18 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.util.List formattedSortValues_ = java.util.Collections.emptyList(); + private void ensureFormattedSortValuesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + formattedSortValues_ = new java.util.ArrayList(formattedSortValues_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated bytes formatted_sort_values = 1; + * @return A list containing the formattedSortValues. + */ + public java.util.List + getFormattedSortValuesList() { + return ((bitField0_ & 0x00000001) != 0) ? + java.util.Collections.unmodifiableList(formattedSortValues_) : formattedSortValues_; + } + /** + * repeated bytes formatted_sort_values = 1; + * @return The count of formattedSortValues. + */ + public int getFormattedSortValuesCount() { + return formattedSortValues_.size(); + } + /** + * repeated bytes formatted_sort_values = 1; + * @param index The index of the element to return. + * @return The formattedSortValues at the given index. + */ + public com.google.protobuf.ByteString getFormattedSortValues(int index) { + return formattedSortValues_.get(index); + } + /** + * repeated bytes formatted_sort_values = 1; + * @param index The index to set the value at. + * @param value The formattedSortValues to set. + * @return This builder for chaining. + */ + public Builder setFormattedSortValues( + int index, com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + ensureFormattedSortValuesIsMutable(); + formattedSortValues_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes formatted_sort_values = 1; + * @param value The formattedSortValues to add. + * @return This builder for chaining. + */ + public Builder addFormattedSortValues(com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + ensureFormattedSortValuesIsMutable(); + formattedSortValues_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes formatted_sort_values = 1; + * @param values The formattedSortValues to add. + * @return This builder for chaining. + */ + public Builder addAllFormattedSortValues( + java.lang.Iterable values) { + ensureFormattedSortValuesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, formattedSortValues_); + onChanged(); + return this; + } + /** + * repeated bytes formatted_sort_values = 1; + * @return This builder for chaining. + */ + public Builder clearFormattedSortValues() { + formattedSortValues_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + private java.util.List rawSortValues_ = java.util.Collections.emptyList(); + private void ensureRawSortValuesIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + rawSortValues_ = new java.util.ArrayList(rawSortValues_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bytes raw_sort_values = 2; + * @return A list containing the rawSortValues. + */ + public java.util.List + getRawSortValuesList() { + return ((bitField0_ & 0x00000002) != 0) ? + java.util.Collections.unmodifiableList(rawSortValues_) : rawSortValues_; + } + /** + * repeated bytes raw_sort_values = 2; + * @return The count of rawSortValues. + */ + public int getRawSortValuesCount() { + return rawSortValues_.size(); + } + /** + * repeated bytes raw_sort_values = 2; + * @param index The index of the element to return. + * @return The rawSortValues at the given index. + */ + public com.google.protobuf.ByteString getRawSortValues(int index) { + return rawSortValues_.get(index); + } + /** + * repeated bytes raw_sort_values = 2; + * @param index The index to set the value at. + * @param value The rawSortValues to set. + * @return This builder for chaining. + */ + public Builder setRawSortValues( + int index, com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + ensureRawSortValuesIsMutable(); + rawSortValues_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes raw_sort_values = 2; + * @param value The rawSortValues to add. + * @return This builder for chaining. + */ + public Builder addRawSortValues(com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + ensureRawSortValuesIsMutable(); + rawSortValues_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes raw_sort_values = 2; + * @param values The rawSortValues to add. + * @return This builder for chaining. + */ + public Builder addAllRawSortValues( + java.lang.Iterable values) { + ensureRawSortValuesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, rawSortValues_); + onChanged(); + return this; + } + /** + * repeated bytes raw_sort_values = 2; + * @return This builder for chaining. + */ + public Builder clearRawSortValues() { + rawSortValues_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SearchSortValuesProto) + } + + // @@protoc_insertion_point(class_scope:SearchSortValuesProto) + private static final SearchHits.SearchSortValuesProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.SearchSortValuesProto(); + } + + public static SearchHits.SearchSortValuesProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SearchSortValuesProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.SearchSortValuesProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ExplanationProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:ExplanationProto) + com.google.protobuf.MessageOrBuilder { + + /** + * bool match = 1; + * @return The match. + */ + boolean getMatch(); + + /** + *
+     * value used as long
+     * 
+ * + * int64 value = 2; + * @return The value. + */ + long getValue(); + + /** + * string description = 3; + * @return The description. + */ + java.lang.String getDescription(); + /** + * string description = 3; + * @return The bytes for description. + */ + com.google.protobuf.ByteString + getDescriptionBytes(); + + /** + * repeated .ExplanationProto details = 4; + */ + java.util.List + getDetailsList(); + /** + * repeated .ExplanationProto details = 4; + */ + SearchHits.ExplanationProto getDetails(int index); + /** + * repeated .ExplanationProto details = 4; + */ + int getDetailsCount(); + /** + * repeated .ExplanationProto details = 4; + */ + java.util.List + getDetailsOrBuilderList(); + /** + * repeated .ExplanationProto details = 4; + */ + SearchHits.ExplanationProtoOrBuilder getDetailsOrBuilder( + int index); + } + /** + *
+   *
+   *boolean match
+   *Number value
+   *String description
+   *List<Explanation> details
+   * 
+ * + * Protobuf type {@code ExplanationProto} + */ + public static final class ExplanationProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:ExplanationProto) + ExplanationProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExplanationProto.newBuilder() to construct. + private ExplanationProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExplanationProto() { + description_ = ""; + details_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ExplanationProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_ExplanationProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_ExplanationProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.ExplanationProto.class, SearchHits.ExplanationProto.Builder.class); + } + + public static final int MATCH_FIELD_NUMBER = 1; + private boolean match_ = false; + /** + * bool match = 1; + * @return The match. + */ + @java.lang.Override + public boolean getMatch() { + return match_; + } + + public static final int VALUE_FIELD_NUMBER = 2; + private long value_ = 0L; + /** + *
+     * value used as long
+     * 
+ * + * int64 value = 2; + * @return The value. + */ + @java.lang.Override + public long getValue() { + return value_; + } + + public static final int DESCRIPTION_FIELD_NUMBER = 3; + @SuppressWarnings("serial") + private volatile java.lang.Object description_ = ""; + /** + * string description = 3; + * @return The description. + */ + @java.lang.Override + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } + } + /** + * string description = 3; + * @return The bytes for description. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DETAILS_FIELD_NUMBER = 4; + @SuppressWarnings("serial") + private java.util.List details_; + /** + * repeated .ExplanationProto details = 4; + */ + @java.lang.Override + public java.util.List getDetailsList() { + return details_; + } + /** + * repeated .ExplanationProto details = 4; + */ + @java.lang.Override + public java.util.List + getDetailsOrBuilderList() { + return details_; + } + /** + * repeated .ExplanationProto details = 4; + */ + @java.lang.Override + public int getDetailsCount() { + return details_.size(); + } + /** + * repeated .ExplanationProto details = 4; + */ + @java.lang.Override + public SearchHits.ExplanationProto getDetails(int index) { + return details_.get(index); + } + /** + * repeated .ExplanationProto details = 4; + */ + @java.lang.Override + public SearchHits.ExplanationProtoOrBuilder getDetailsOrBuilder( + int index) { + return details_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (match_ != false) { + output.writeBool(1, match_); + } + if (value_ != 0L) { + output.writeInt64(2, value_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(description_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, description_); + } + for (int i = 0; i < details_.size(); i++) { + output.writeMessage(4, details_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (match_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, match_); + } + if (value_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, value_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(description_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, description_); + } + for (int i = 0; i < details_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, details_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.ExplanationProto)) { + return super.equals(obj); + } + SearchHits.ExplanationProto other = (SearchHits.ExplanationProto) obj; + + if (getMatch() + != other.getMatch()) return false; + if (getValue() + != other.getValue()) return false; + if (!getDescription() + .equals(other.getDescription())) return false; + if (!getDetailsList() + .equals(other.getDetailsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + MATCH_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getMatch()); + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getValue()); + hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER; + hash = (53 * hash) + getDescription().hashCode(); + if (getDetailsCount() > 0) { + hash = (37 * hash) + DETAILS_FIELD_NUMBER; + hash = (53 * hash) + getDetailsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.ExplanationProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.ExplanationProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.ExplanationProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.ExplanationProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.ExplanationProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.ExplanationProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.ExplanationProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.ExplanationProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.ExplanationProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.ExplanationProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.ExplanationProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.ExplanationProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.ExplanationProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *boolean match
+     *Number value
+     *String description
+     *List<Explanation> details
+     * 
+ * + * Protobuf type {@code ExplanationProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:ExplanationProto) + SearchHits.ExplanationProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_ExplanationProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_ExplanationProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.ExplanationProto.class, SearchHits.ExplanationProto.Builder.class); + } + + // Construct using SearchHits.ExplanationProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + match_ = false; + value_ = 0L; + description_ = ""; + if (detailsBuilder_ == null) { + details_ = java.util.Collections.emptyList(); + } else { + details_ = null; + detailsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_ExplanationProto_descriptor; + } + + @java.lang.Override + public SearchHits.ExplanationProto getDefaultInstanceForType() { + return SearchHits.ExplanationProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.ExplanationProto build() { + SearchHits.ExplanationProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.ExplanationProto buildPartial() { + SearchHits.ExplanationProto result = new SearchHits.ExplanationProto(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(SearchHits.ExplanationProto result) { + if (detailsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + details_ = java.util.Collections.unmodifiableList(details_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.details_ = details_; + } else { + result.details_ = detailsBuilder_.build(); + } + } + + private void buildPartial0(SearchHits.ExplanationProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.match_ = match_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.value_ = value_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.description_ = description_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.ExplanationProto) { + return mergeFrom((SearchHits.ExplanationProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.ExplanationProto other) { + if (other == SearchHits.ExplanationProto.getDefaultInstance()) return this; + if (other.getMatch() != false) { + setMatch(other.getMatch()); + } + if (other.getValue() != 0L) { + setValue(other.getValue()); + } + if (!other.getDescription().isEmpty()) { + description_ = other.description_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (detailsBuilder_ == null) { + if (!other.details_.isEmpty()) { + if (details_.isEmpty()) { + details_ = other.details_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureDetailsIsMutable(); + details_.addAll(other.details_); + } + onChanged(); + } + } else { + if (!other.details_.isEmpty()) { + if (detailsBuilder_.isEmpty()) { + detailsBuilder_.dispose(); + detailsBuilder_ = null; + details_ = other.details_; + bitField0_ = (bitField0_ & ~0x00000008); + detailsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getDetailsFieldBuilder() : null; + } else { + detailsBuilder_.addAllMessages(other.details_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + match_ = input.readBool(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: { + value_ = input.readInt64(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: { + description_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: { + SearchHits.ExplanationProto m = + input.readMessage( + SearchHits.ExplanationProto.parser(), + extensionRegistry); + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.add(m); + } else { + detailsBuilder_.addMessage(m); + } + break; + } // case 34 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private boolean match_ ; + /** + * bool match = 1; + * @return The match. + */ + @java.lang.Override + public boolean getMatch() { + return match_; + } + /** + * bool match = 1; + * @param value The match to set. + * @return This builder for chaining. + */ + public Builder setMatch(boolean value) { + + match_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * bool match = 1; + * @return This builder for chaining. + */ + public Builder clearMatch() { + bitField0_ = (bitField0_ & ~0x00000001); + match_ = false; + onChanged(); + return this; + } + + private long value_ ; + /** + *
+       * value used as long
+       * 
+ * + * int64 value = 2; + * @return The value. + */ + @java.lang.Override + public long getValue() { + return value_; + } + /** + *
+       * value used as long
+       * 
+ * + * int64 value = 2; + * @param value The value to set. + * @return This builder for chaining. + */ + public Builder setValue(long value) { + + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + *
+       * value used as long
+       * 
+ * + * int64 value = 2; + * @return This builder for chaining. + */ + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000002); + value_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object description_ = ""; + /** + * string description = 3; + * @return The description. + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string description = 3; + * @return The bytes for description. + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string description = 3; + * @param value The description to set. + * @return This builder for chaining. + */ + public Builder setDescription( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + description_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * string description = 3; + * @return This builder for chaining. + */ + public Builder clearDescription() { + description_ = getDefaultInstance().getDescription(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * string description = 3; + * @param value The bytes for description to set. + * @return This builder for chaining. + */ + public Builder setDescriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + description_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private java.util.List details_ = + java.util.Collections.emptyList(); + private void ensureDetailsIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + details_ = new java.util.ArrayList(details_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder> detailsBuilder_; + + /** + * repeated .ExplanationProto details = 4; + */ + public java.util.List getDetailsList() { + if (detailsBuilder_ == null) { + return java.util.Collections.unmodifiableList(details_); + } else { + return detailsBuilder_.getMessageList(); + } + } + /** + * repeated .ExplanationProto details = 4; + */ + public int getDetailsCount() { + if (detailsBuilder_ == null) { + return details_.size(); + } else { + return detailsBuilder_.getCount(); + } + } + /** + * repeated .ExplanationProto details = 4; + */ + public SearchHits.ExplanationProto getDetails(int index) { + if (detailsBuilder_ == null) { + return details_.get(index); + } else { + return detailsBuilder_.getMessage(index); + } + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder setDetails( + int index, SearchHits.ExplanationProto value) { + if (detailsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDetailsIsMutable(); + details_.set(index, value); + onChanged(); + } else { + detailsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder setDetails( + int index, SearchHits.ExplanationProto.Builder builderForValue) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.set(index, builderForValue.build()); + onChanged(); + } else { + detailsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder addDetails(SearchHits.ExplanationProto value) { + if (detailsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDetailsIsMutable(); + details_.add(value); + onChanged(); + } else { + detailsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder addDetails( + int index, SearchHits.ExplanationProto value) { + if (detailsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDetailsIsMutable(); + details_.add(index, value); + onChanged(); + } else { + detailsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder addDetails( + SearchHits.ExplanationProto.Builder builderForValue) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.add(builderForValue.build()); + onChanged(); + } else { + detailsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder addDetails( + int index, SearchHits.ExplanationProto.Builder builderForValue) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.add(index, builderForValue.build()); + onChanged(); + } else { + detailsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder addAllDetails( + java.lang.Iterable values) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, details_); + onChanged(); + } else { + detailsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder clearDetails() { + if (detailsBuilder_ == null) { + details_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + detailsBuilder_.clear(); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public Builder removeDetails(int index) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.remove(index); + onChanged(); + } else { + detailsBuilder_.remove(index); + } + return this; + } + /** + * repeated .ExplanationProto details = 4; + */ + public SearchHits.ExplanationProto.Builder getDetailsBuilder( + int index) { + return getDetailsFieldBuilder().getBuilder(index); + } + /** + * repeated .ExplanationProto details = 4; + */ + public SearchHits.ExplanationProtoOrBuilder getDetailsOrBuilder( + int index) { + if (detailsBuilder_ == null) { + return details_.get(index); } else { + return detailsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .ExplanationProto details = 4; + */ + public java.util.List + getDetailsOrBuilderList() { + if (detailsBuilder_ != null) { + return detailsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(details_); + } + } + /** + * repeated .ExplanationProto details = 4; + */ + public SearchHits.ExplanationProto.Builder addDetailsBuilder() { + return getDetailsFieldBuilder().addBuilder( + SearchHits.ExplanationProto.getDefaultInstance()); + } + /** + * repeated .ExplanationProto details = 4; + */ + public SearchHits.ExplanationProto.Builder addDetailsBuilder( + int index) { + return getDetailsFieldBuilder().addBuilder( + index, SearchHits.ExplanationProto.getDefaultInstance()); + } + /** + * repeated .ExplanationProto details = 4; + */ + public java.util.List + getDetailsBuilderList() { + return getDetailsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder> + getDetailsFieldBuilder() { + if (detailsBuilder_ == null) { + detailsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder>( + details_, + ((bitField0_ & 0x00000008) != 0), + getParentForChildren(), + isClean()); + details_ = null; + } + return detailsBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:ExplanationProto) + } + + // @@protoc_insertion_point(class_scope:ExplanationProto) + private static final SearchHits.ExplanationProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.ExplanationProto(); + } + + public static SearchHits.ExplanationProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExplanationProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.ExplanationProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SearchShardTargetProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:SearchShardTargetProto) + com.google.protobuf.MessageOrBuilder { + + /** + * string node_id = 1; + * @return The nodeId. + */ + java.lang.String getNodeId(); + /** + * string node_id = 1; + * @return The bytes for nodeId. + */ + com.google.protobuf.ByteString + getNodeIdBytes(); + + /** + * .ShardIdProto shard_id = 2; + * @return Whether the shardId field is set. + */ + boolean hasShardId(); + /** + * .ShardIdProto shard_id = 2; + * @return The shardId. + */ + SearchHits.ShardIdProto getShardId(); + /** + * .ShardIdProto shard_id = 2; + */ + SearchHits.ShardIdProtoOrBuilder getShardIdOrBuilder(); + + /** + * string cluster_alias = 3; + * @return The clusterAlias. + */ + java.lang.String getClusterAlias(); + /** + * string cluster_alias = 3; + * @return The bytes for clusterAlias. + */ + com.google.protobuf.ByteString + getClusterAliasBytes(); + } + /** + *
+   *
+   *Text nodeId
+   *ShardId shardId
+   *String clusterAlias
+   * 
+ * + * Protobuf type {@code SearchShardTargetProto} + */ + public static final class SearchShardTargetProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SearchShardTargetProto) + SearchShardTargetProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use SearchShardTargetProto.newBuilder() to construct. + private SearchShardTargetProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SearchShardTargetProto() { + nodeId_ = ""; + clusterAlias_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SearchShardTargetProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_SearchShardTargetProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_SearchShardTargetProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.SearchShardTargetProto.class, SearchHits.SearchShardTargetProto.Builder.class); + } + + public static final int NODE_ID_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object nodeId_ = ""; + /** + * string node_id = 1; + * @return The nodeId. + */ + @java.lang.Override + public java.lang.String getNodeId() { + java.lang.Object ref = nodeId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nodeId_ = s; + return s; + } + } + /** + * string node_id = 1; + * @return The bytes for nodeId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getNodeIdBytes() { + java.lang.Object ref = nodeId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nodeId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SHARD_ID_FIELD_NUMBER = 2; + private SearchHits.ShardIdProto shardId_; + /** + * .ShardIdProto shard_id = 2; + * @return Whether the shardId field is set. + */ + @java.lang.Override + public boolean hasShardId() { + return shardId_ != null; + } + /** + * .ShardIdProto shard_id = 2; + * @return The shardId. + */ + @java.lang.Override + public SearchHits.ShardIdProto getShardId() { + return shardId_ == null ? SearchHits.ShardIdProto.getDefaultInstance() : shardId_; + } + /** + * .ShardIdProto shard_id = 2; + */ + @java.lang.Override + public SearchHits.ShardIdProtoOrBuilder getShardIdOrBuilder() { + return shardId_ == null ? SearchHits.ShardIdProto.getDefaultInstance() : shardId_; + } + + public static final int CLUSTER_ALIAS_FIELD_NUMBER = 3; + @SuppressWarnings("serial") + private volatile java.lang.Object clusterAlias_ = ""; + /** + * string cluster_alias = 3; + * @return The clusterAlias. + */ + @java.lang.Override + public java.lang.String getClusterAlias() { + java.lang.Object ref = clusterAlias_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + clusterAlias_ = s; + return s; + } + } + /** + * string cluster_alias = 3; + * @return The bytes for clusterAlias. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getClusterAliasBytes() { + java.lang.Object ref = clusterAlias_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clusterAlias_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nodeId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, nodeId_); + } + if (shardId_ != null) { + output.writeMessage(2, getShardId()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clusterAlias_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, clusterAlias_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nodeId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, nodeId_); + } + if (shardId_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getShardId()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clusterAlias_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, clusterAlias_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.SearchShardTargetProto)) { + return super.equals(obj); + } + SearchHits.SearchShardTargetProto other = (SearchHits.SearchShardTargetProto) obj; + + if (!getNodeId() + .equals(other.getNodeId())) return false; + if (hasShardId() != other.hasShardId()) return false; + if (hasShardId()) { + if (!getShardId() + .equals(other.getShardId())) return false; + } + if (!getClusterAlias() + .equals(other.getClusterAlias())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NODE_ID_FIELD_NUMBER; + hash = (53 * hash) + getNodeId().hashCode(); + if (hasShardId()) { + hash = (37 * hash) + SHARD_ID_FIELD_NUMBER; + hash = (53 * hash) + getShardId().hashCode(); + } + hash = (37 * hash) + CLUSTER_ALIAS_FIELD_NUMBER; + hash = (53 * hash) + getClusterAlias().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.SearchShardTargetProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchShardTargetProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchShardTargetProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchShardTargetProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchShardTargetProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.SearchShardTargetProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.SearchShardTargetProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.SearchShardTargetProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.SearchShardTargetProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.SearchShardTargetProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.SearchShardTargetProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.SearchShardTargetProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.SearchShardTargetProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *Text nodeId
+     *ShardId shardId
+     *String clusterAlias
+     * 
+ * + * Protobuf type {@code SearchShardTargetProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SearchShardTargetProto) + SearchHits.SearchShardTargetProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_SearchShardTargetProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_SearchShardTargetProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.SearchShardTargetProto.class, SearchHits.SearchShardTargetProto.Builder.class); + } + + // Construct using SearchHits.SearchShardTargetProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + nodeId_ = ""; + shardId_ = null; + if (shardIdBuilder_ != null) { + shardIdBuilder_.dispose(); + shardIdBuilder_ = null; + } + clusterAlias_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_SearchShardTargetProto_descriptor; + } + + @java.lang.Override + public SearchHits.SearchShardTargetProto getDefaultInstanceForType() { + return SearchHits.SearchShardTargetProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.SearchShardTargetProto build() { + SearchHits.SearchShardTargetProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.SearchShardTargetProto buildPartial() { + SearchHits.SearchShardTargetProto result = new SearchHits.SearchShardTargetProto(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(SearchHits.SearchShardTargetProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.nodeId_ = nodeId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.shardId_ = shardIdBuilder_ == null + ? shardId_ + : shardIdBuilder_.build(); + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.clusterAlias_ = clusterAlias_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.SearchShardTargetProto) { + return mergeFrom((SearchHits.SearchShardTargetProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.SearchShardTargetProto other) { + if (other == SearchHits.SearchShardTargetProto.getDefaultInstance()) return this; + if (!other.getNodeId().isEmpty()) { + nodeId_ = other.nodeId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasShardId()) { + mergeShardId(other.getShardId()); + } + if (!other.getClusterAlias().isEmpty()) { + clusterAlias_ = other.clusterAlias_; + bitField0_ |= 0x00000004; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + nodeId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: { + input.readMessage( + getShardIdFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: { + clusterAlias_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.lang.Object nodeId_ = ""; + /** + * string node_id = 1; + * @return The nodeId. + */ + public java.lang.String getNodeId() { + java.lang.Object ref = nodeId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nodeId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string node_id = 1; + * @return The bytes for nodeId. + */ + public com.google.protobuf.ByteString + getNodeIdBytes() { + java.lang.Object ref = nodeId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nodeId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string node_id = 1; + * @param value The nodeId to set. + * @return This builder for chaining. + */ + public Builder setNodeId( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + nodeId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * string node_id = 1; + * @return This builder for chaining. + */ + public Builder clearNodeId() { + nodeId_ = getDefaultInstance().getNodeId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * string node_id = 1; + * @param value The bytes for nodeId to set. + * @return This builder for chaining. + */ + public Builder setNodeIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + nodeId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private SearchHits.ShardIdProto shardId_; + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.ShardIdProto, SearchHits.ShardIdProto.Builder, SearchHits.ShardIdProtoOrBuilder> shardIdBuilder_; + /** + * .ShardIdProto shard_id = 2; + * @return Whether the shardId field is set. + */ + public boolean hasShardId() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * .ShardIdProto shard_id = 2; + * @return The shardId. + */ + public SearchHits.ShardIdProto getShardId() { + if (shardIdBuilder_ == null) { + return shardId_ == null ? SearchHits.ShardIdProto.getDefaultInstance() : shardId_; + } else { + return shardIdBuilder_.getMessage(); + } + } + /** + * .ShardIdProto shard_id = 2; + */ + public Builder setShardId(SearchHits.ShardIdProto value) { + if (shardIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + shardId_ = value; + } else { + shardIdBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * .ShardIdProto shard_id = 2; + */ + public Builder setShardId( + SearchHits.ShardIdProto.Builder builderForValue) { + if (shardIdBuilder_ == null) { + shardId_ = builderForValue.build(); + } else { + shardIdBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * .ShardIdProto shard_id = 2; + */ + public Builder mergeShardId(SearchHits.ShardIdProto value) { + if (shardIdBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) && + shardId_ != null && + shardId_ != SearchHits.ShardIdProto.getDefaultInstance()) { + getShardIdBuilder().mergeFrom(value); + } else { + shardId_ = value; + } + } else { + shardIdBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * .ShardIdProto shard_id = 2; + */ + public Builder clearShardId() { + bitField0_ = (bitField0_ & ~0x00000002); + shardId_ = null; + if (shardIdBuilder_ != null) { + shardIdBuilder_.dispose(); + shardIdBuilder_ = null; + } + onChanged(); + return this; + } + /** + * .ShardIdProto shard_id = 2; + */ + public SearchHits.ShardIdProto.Builder getShardIdBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getShardIdFieldBuilder().getBuilder(); + } + /** + * .ShardIdProto shard_id = 2; + */ + public SearchHits.ShardIdProtoOrBuilder getShardIdOrBuilder() { + if (shardIdBuilder_ != null) { + return shardIdBuilder_.getMessageOrBuilder(); + } else { + return shardId_ == null ? + SearchHits.ShardIdProto.getDefaultInstance() : shardId_; + } + } + /** + * .ShardIdProto shard_id = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.ShardIdProto, SearchHits.ShardIdProto.Builder, SearchHits.ShardIdProtoOrBuilder> + getShardIdFieldBuilder() { + if (shardIdBuilder_ == null) { + shardIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + SearchHits.ShardIdProto, SearchHits.ShardIdProto.Builder, SearchHits.ShardIdProtoOrBuilder>( + getShardId(), + getParentForChildren(), + isClean()); + shardId_ = null; + } + return shardIdBuilder_; + } + + private java.lang.Object clusterAlias_ = ""; + /** + * string cluster_alias = 3; + * @return The clusterAlias. + */ + public java.lang.String getClusterAlias() { + java.lang.Object ref = clusterAlias_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + clusterAlias_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string cluster_alias = 3; + * @return The bytes for clusterAlias. + */ + public com.google.protobuf.ByteString + getClusterAliasBytes() { + java.lang.Object ref = clusterAlias_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clusterAlias_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string cluster_alias = 3; + * @param value The clusterAlias to set. + * @return This builder for chaining. + */ + public Builder setClusterAlias( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + clusterAlias_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * string cluster_alias = 3; + * @return This builder for chaining. + */ + public Builder clearClusterAlias() { + clusterAlias_ = getDefaultInstance().getClusterAlias(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * string cluster_alias = 3; + * @param value The bytes for clusterAlias to set. + * @return This builder for chaining. + */ + public Builder setClusterAliasBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + clusterAlias_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SearchShardTargetProto) + } + + // @@protoc_insertion_point(class_scope:SearchShardTargetProto) + private static final SearchHits.SearchShardTargetProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.SearchShardTargetProto(); + } + + public static SearchHits.SearchShardTargetProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SearchShardTargetProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.SearchShardTargetProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ShardIdProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:ShardIdProto) + com.google.protobuf.MessageOrBuilder { + + /** + * .IndexProto index = 1; + * @return Whether the index field is set. + */ + boolean hasIndex(); + /** + * .IndexProto index = 1; + * @return The index. + */ + SearchHits.IndexProto getIndex(); + /** + * .IndexProto index = 1; + */ + SearchHits.IndexProtoOrBuilder getIndexOrBuilder(); + + /** + * int32 shard_id = 2; + * @return The shardId. + */ + int getShardId(); + + /** + * int32 hash_code = 3; + * @return The hashCode. + */ + int getHashCode(); + } + /** + *
+   *
+   *Index index
+   *int shardId
+   *int hashCode
+   * 
+ * + * Protobuf type {@code ShardIdProto} + */ + public static final class ShardIdProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:ShardIdProto) + ShardIdProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use ShardIdProto.newBuilder() to construct. + private ShardIdProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ShardIdProto() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ShardIdProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_ShardIdProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_ShardIdProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.ShardIdProto.class, SearchHits.ShardIdProto.Builder.class); + } + + public static final int INDEX_FIELD_NUMBER = 1; + private SearchHits.IndexProto index_; + /** + * .IndexProto index = 1; + * @return Whether the index field is set. + */ + @java.lang.Override + public boolean hasIndex() { + return index_ != null; + } + /** + * .IndexProto index = 1; + * @return The index. + */ + @java.lang.Override + public SearchHits.IndexProto getIndex() { + return index_ == null ? SearchHits.IndexProto.getDefaultInstance() : index_; + } + /** + * .IndexProto index = 1; + */ + @java.lang.Override + public SearchHits.IndexProtoOrBuilder getIndexOrBuilder() { + return index_ == null ? SearchHits.IndexProto.getDefaultInstance() : index_; + } + + public static final int SHARD_ID_FIELD_NUMBER = 2; + private int shardId_ = 0; + /** + * int32 shard_id = 2; + * @return The shardId. + */ + @java.lang.Override + public int getShardId() { + return shardId_; + } + + public static final int HASH_CODE_FIELD_NUMBER = 3; + private int hashCode_ = 0; + /** + * int32 hash_code = 3; + * @return The hashCode. + */ + @java.lang.Override + public int getHashCode() { + return hashCode_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (index_ != null) { + output.writeMessage(1, getIndex()); + } + if (shardId_ != 0) { + output.writeInt32(2, shardId_); + } + if (hashCode_ != 0) { + output.writeInt32(3, hashCode_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (index_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getIndex()); + } + if (shardId_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, shardId_); + } + if (hashCode_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, hashCode_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.ShardIdProto)) { + return super.equals(obj); + } + SearchHits.ShardIdProto other = (SearchHits.ShardIdProto) obj; + + if (hasIndex() != other.hasIndex()) return false; + if (hasIndex()) { + if (!getIndex() + .equals(other.getIndex())) return false; + } + if (getShardId() + != other.getShardId()) return false; + if (getHashCode() + != other.getHashCode()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasIndex()) { + hash = (37 * hash) + INDEX_FIELD_NUMBER; + hash = (53 * hash) + getIndex().hashCode(); + } + hash = (37 * hash) + SHARD_ID_FIELD_NUMBER; + hash = (53 * hash) + getShardId(); + hash = (37 * hash) + HASH_CODE_FIELD_NUMBER; + hash = (53 * hash) + getHashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.ShardIdProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.ShardIdProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.ShardIdProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.ShardIdProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.ShardIdProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.ShardIdProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.ShardIdProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.ShardIdProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.ShardIdProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.ShardIdProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.ShardIdProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.ShardIdProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.ShardIdProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *Index index
+     *int shardId
+     *int hashCode
+     * 
+ * + * Protobuf type {@code ShardIdProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:ShardIdProto) + SearchHits.ShardIdProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_ShardIdProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_ShardIdProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.ShardIdProto.class, SearchHits.ShardIdProto.Builder.class); + } + + // Construct using SearchHits.ShardIdProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + index_ = null; + if (indexBuilder_ != null) { + indexBuilder_.dispose(); + indexBuilder_ = null; + } + shardId_ = 0; + hashCode_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_ShardIdProto_descriptor; + } + + @java.lang.Override + public SearchHits.ShardIdProto getDefaultInstanceForType() { + return SearchHits.ShardIdProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.ShardIdProto build() { + SearchHits.ShardIdProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.ShardIdProto buildPartial() { + SearchHits.ShardIdProto result = new SearchHits.ShardIdProto(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(SearchHits.ShardIdProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.index_ = indexBuilder_ == null + ? index_ + : indexBuilder_.build(); + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.shardId_ = shardId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.hashCode_ = hashCode_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.ShardIdProto) { + return mergeFrom((SearchHits.ShardIdProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.ShardIdProto other) { + if (other == SearchHits.ShardIdProto.getDefaultInstance()) return this; + if (other.hasIndex()) { + mergeIndex(other.getIndex()); + } + if (other.getShardId() != 0) { + setShardId(other.getShardId()); + } + if (other.getHashCode() != 0) { + setHashCode(other.getHashCode()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + input.readMessage( + getIndexFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: { + shardId_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 24: { + hashCode_ = input.readInt32(); + bitField0_ |= 0x00000004; + break; + } // case 24 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private SearchHits.IndexProto index_; + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.IndexProto, SearchHits.IndexProto.Builder, SearchHits.IndexProtoOrBuilder> indexBuilder_; + /** + * .IndexProto index = 1; + * @return Whether the index field is set. + */ + public boolean hasIndex() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * .IndexProto index = 1; + * @return The index. + */ + public SearchHits.IndexProto getIndex() { + if (indexBuilder_ == null) { + return index_ == null ? SearchHits.IndexProto.getDefaultInstance() : index_; + } else { + return indexBuilder_.getMessage(); + } + } + /** + * .IndexProto index = 1; + */ + public Builder setIndex(SearchHits.IndexProto value) { + if (indexBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + index_ = value; + } else { + indexBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * .IndexProto index = 1; + */ + public Builder setIndex( + SearchHits.IndexProto.Builder builderForValue) { + if (indexBuilder_ == null) { + index_ = builderForValue.build(); + } else { + indexBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * .IndexProto index = 1; + */ + public Builder mergeIndex(SearchHits.IndexProto value) { + if (indexBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) && + index_ != null && + index_ != SearchHits.IndexProto.getDefaultInstance()) { + getIndexBuilder().mergeFrom(value); + } else { + index_ = value; + } + } else { + indexBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * .IndexProto index = 1; + */ + public Builder clearIndex() { + bitField0_ = (bitField0_ & ~0x00000001); + index_ = null; + if (indexBuilder_ != null) { + indexBuilder_.dispose(); + indexBuilder_ = null; + } + onChanged(); + return this; + } + /** + * .IndexProto index = 1; + */ + public SearchHits.IndexProto.Builder getIndexBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getIndexFieldBuilder().getBuilder(); + } + /** + * .IndexProto index = 1; + */ + public SearchHits.IndexProtoOrBuilder getIndexOrBuilder() { + if (indexBuilder_ != null) { + return indexBuilder_.getMessageOrBuilder(); + } else { + return index_ == null ? + SearchHits.IndexProto.getDefaultInstance() : index_; + } + } + /** + * .IndexProto index = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + SearchHits.IndexProto, SearchHits.IndexProto.Builder, SearchHits.IndexProtoOrBuilder> + getIndexFieldBuilder() { + if (indexBuilder_ == null) { + indexBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + SearchHits.IndexProto, SearchHits.IndexProto.Builder, SearchHits.IndexProtoOrBuilder>( + getIndex(), + getParentForChildren(), + isClean()); + index_ = null; + } + return indexBuilder_; + } + + private int shardId_ ; + /** + * int32 shard_id = 2; + * @return The shardId. + */ + @java.lang.Override + public int getShardId() { + return shardId_; + } + /** + * int32 shard_id = 2; + * @param value The shardId to set. + * @return This builder for chaining. + */ + public Builder setShardId(int value) { + + shardId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * int32 shard_id = 2; + * @return This builder for chaining. + */ + public Builder clearShardId() { + bitField0_ = (bitField0_ & ~0x00000002); + shardId_ = 0; + onChanged(); + return this; + } + + private int hashCode_ ; + /** + * int32 hash_code = 3; + * @return The hashCode. + */ + @java.lang.Override + public int getHashCode() { + return hashCode_; + } + /** + * int32 hash_code = 3; + * @param value The hashCode to set. + * @return This builder for chaining. + */ + public Builder setHashCode(int value) { + + hashCode_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * int32 hash_code = 3; + * @return This builder for chaining. + */ + public Builder clearHashCode() { + bitField0_ = (bitField0_ & ~0x00000004); + hashCode_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:ShardIdProto) + } + + // @@protoc_insertion_point(class_scope:ShardIdProto) + private static final SearchHits.ShardIdProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.ShardIdProto(); + } + + public static SearchHits.ShardIdProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ShardIdProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.ShardIdProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface IndexProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:IndexProto) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + * @return The name. + */ + java.lang.String getName(); + /** + * string name = 1; + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * string uuid = 2; + * @return The uuid. + */ + java.lang.String getUuid(); + /** + * string uuid = 2; + * @return The bytes for uuid. + */ + com.google.protobuf.ByteString + getUuidBytes(); + } + /** + *
+   *
+   *String name
+   *String uuid
+   * 
+ * + * Protobuf type {@code IndexProto} + */ + public static final class IndexProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:IndexProto) + IndexProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use IndexProto.newBuilder() to construct. + private IndexProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private IndexProto() { + name_ = ""; + uuid_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new IndexProto(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_IndexProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_IndexProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.IndexProto.class, SearchHits.IndexProto.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * string name = 1; + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 1; + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int UUID_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private volatile java.lang.Object uuid_ = ""; + /** + * string uuid = 2; + * @return The uuid. + */ + @java.lang.Override + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uuid_ = s; + return s; + } + } + /** + * string uuid = 2; + * @return The bytes for uuid. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(uuid_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, uuid_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(uuid_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, uuid_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SearchHits.IndexProto)) { + return super.equals(obj); + } + SearchHits.IndexProto other = (SearchHits.IndexProto) obj; + + if (!getName() + .equals(other.getName())) return false; + if (!getUuid() + .equals(other.getUuid())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + UUID_FIELD_NUMBER; + hash = (53 * hash) + getUuid().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SearchHits.IndexProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.IndexProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.IndexProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.IndexProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.IndexProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SearchHits.IndexProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SearchHits.IndexProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.IndexProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.IndexProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SearchHits.IndexProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SearchHits.IndexProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SearchHits.IndexProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SearchHits.IndexProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *
+     *String name
+     *String uuid
+     * 
+ * + * Protobuf type {@code IndexProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:IndexProto) + SearchHits.IndexProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return SearchHits.internal_static_IndexProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return SearchHits.internal_static_IndexProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SearchHits.IndexProto.class, SearchHits.IndexProto.Builder.class); + } + + // Construct using SearchHits.IndexProto.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + uuid_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return SearchHits.internal_static_IndexProto_descriptor; + } + + @java.lang.Override + public SearchHits.IndexProto getDefaultInstanceForType() { + return SearchHits.IndexProto.getDefaultInstance(); + } + + @java.lang.Override + public SearchHits.IndexProto build() { + SearchHits.IndexProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public SearchHits.IndexProto buildPartial() { + SearchHits.IndexProto result = new SearchHits.IndexProto(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(SearchHits.IndexProto result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.uuid_ = uuid_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SearchHits.IndexProto) { + return mergeFrom((SearchHits.IndexProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SearchHits.IndexProto other) { + if (other == SearchHits.IndexProto.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getUuid().isEmpty()) { + uuid_ = other.uuid_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: { + uuid_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * string name = 1; + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 1; + * @return The bytes for name. + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 1; + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * string name = 1; + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * string name = 1; + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object uuid_ = ""; + /** + * string uuid = 2; + * @return The uuid. + */ + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uuid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string uuid = 2; + * @return The bytes for uuid. + */ + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string uuid = 2; + * @param value The uuid to set. + * @return This builder for chaining. + */ + public Builder setUuid( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + uuid_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * string uuid = 2; + * @return This builder for chaining. + */ + public Builder clearUuid() { + uuid_ = getDefaultInstance().getUuid(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * string uuid = 2; + * @param value The bytes for uuid to set. + * @return This builder for chaining. + */ + public Builder setUuidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + checkByteStringIsUtf8(value); + uuid_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:IndexProto) + } + + // @@protoc_insertion_point(class_scope:IndexProto) + private static final SearchHits.IndexProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SearchHits.IndexProto(); + } + + public static SearchHits.IndexProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public IndexProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public SearchHits.IndexProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchHitsProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchHitsProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchHitProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchHitProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchHitProto_DocumentFieldsEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchHitProto_DocumentFieldsEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchHitProto_MetaFieldsEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchHitProto_MetaFieldsEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchHitProto_HighlightFieldsEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchHitProto_HighlightFieldsEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchHitProto_MatchedQueriesEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchHitProto_MatchedQueriesEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchHitProto_InnerHitsEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchHitProto_InnerHitsEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_NestedIdentityProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_NestedIdentityProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_DocumentFieldProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_DocumentFieldProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_HighlightFieldProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_HighlightFieldProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchSortValuesProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchSortValuesProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_ExplanationProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_ExplanationProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SearchShardTargetProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SearchShardTargetProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_ShardIdProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_ShardIdProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_IndexProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_IndexProto_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\027server/SearchHits.proto\"W\n\017SearchHitsP" + + "roto\022\035\n\004hits\030\001 \003(\0132\017.SearchHitProto\022\022\n\nt" + + "otal_hits\030\002 \001(\003\022\021\n\tmax_score\030\003 \001(\002\"\241\007\n\016S" + + "earchHitProto\022\r\n\005score\030\001 \001(\002\022\n\n\002id\030\002 \001(\t" + + "\022-\n\017nested_identity\030\003 \001(\0132\024.NestedIdenti" + + "tyProto\022\017\n\007version\030\004 \001(\003\022\016\n\006seq_no\030\005 \001(\003" + + "\022\024\n\014primary_term\030\006 \001(\003\022\016\n\006source\030\007 \001(\014\022&" + + "\n\013explanation\030\010 \001(\0132\021.ExplanationProto\022<" + + "\n\017document_fields\030\t \003(\0132#.SearchHitProto" + + ".DocumentFieldsEntry\0224\n\013meta_fields\030\n \003(" + + "\0132\037.SearchHitProto.MetaFieldsEntry\022>\n\020hi" + + "ghlight_fields\030\013 \003(\0132$.SearchHitProto.Hi" + + "ghlightFieldsEntry\022+\n\013sort_values\030\014 \001(\0132" + + "\026.SearchSortValuesProto\022<\n\017matched_queri" + + "es\030\r \003(\0132#.SearchHitProto.MatchedQueries" + + "Entry\022&\n\005shard\030\016 \001(\0132\027.SearchShardTarget" + + "Proto\0222\n\ninner_hits\030\017 \003(\0132\036.SearchHitPro" + + "to.InnerHitsEntry\032J\n\023DocumentFieldsEntry" + + "\022\013\n\003key\030\001 \001(\t\022\"\n\005value\030\002 \001(\0132\023.DocumentF" + + "ieldProto:\0028\001\032F\n\017MetaFieldsEntry\022\013\n\003key\030" + + "\001 \001(\t\022\"\n\005value\030\002 \001(\0132\023.DocumentFieldProt" + + "o:\0028\001\032L\n\024HighlightFieldsEntry\022\013\n\003key\030\001 \001" + + "(\t\022#\n\005value\030\002 \001(\0132\024.HighlightFieldProto:" + + "\0028\001\0325\n\023MatchedQueriesEntry\022\013\n\003key\030\001 \001(\t\022" + + "\r\n\005value\030\002 \001(\002:\0028\001\032B\n\016InnerHitsEntry\022\013\n\003" + + "key\030\001 \001(\t\022\037\n\005value\030\002 \001(\0132\020.SearchHitsPro" + + "to:\0028\001\"Y\n\023NestedIdentityProto\022\r\n\005field\030\001" + + " \001(\t\022\016\n\006offset\030\002 \001(\005\022#\n\005child\030\003 \001(\0132\024.Ne" + + "stedIdentityProto\"2\n\022DocumentFieldProto\022" + + "\014\n\004name\030\001 \001(\t\022\016\n\006values\030\002 \003(\014\"6\n\023Highlig" + + "htFieldProto\022\014\n\004name\030\001 \001(\t\022\021\n\tfragments\030" + + "\002 \003(\t\"O\n\025SearchSortValuesProto\022\035\n\025format" + + "ted_sort_values\030\001 \003(\014\022\027\n\017raw_sort_values" + + "\030\002 \003(\014\"i\n\020ExplanationProto\022\r\n\005match\030\001 \001(" + + "\010\022\r\n\005value\030\002 \001(\003\022\023\n\013description\030\003 \001(\t\022\"\n" + + "\007details\030\004 \003(\0132\021.ExplanationProto\"a\n\026Sea" + + "rchShardTargetProto\022\017\n\007node_id\030\001 \001(\t\022\037\n\010" + + "shard_id\030\002 \001(\0132\r.ShardIdProto\022\025\n\rcluster" + + "_alias\030\003 \001(\t\"O\n\014ShardIdProto\022\032\n\005index\030\001 " + + "\001(\0132\013.IndexProto\022\020\n\010shard_id\030\002 \001(\005\022\021\n\tha" + + "sh_code\030\003 \001(\005\"(\n\nIndexProto\022\014\n\004name\030\001 \001(" + + "\t\022\014\n\004uuid\030\002 \001(\tb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_SearchHitsProto_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_SearchHitsProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchHitsProto_descriptor, + new java.lang.String[] { "Hits", "TotalHits", "MaxScore", }); + internal_static_SearchHitProto_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_SearchHitProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchHitProto_descriptor, + new java.lang.String[] { "Score", "Id", "NestedIdentity", "Version", "SeqNo", "PrimaryTerm", "Source", "Explanation", "DocumentFields", "MetaFields", "HighlightFields", "SortValues", "MatchedQueries", "Shard", "InnerHits", }); + internal_static_SearchHitProto_DocumentFieldsEntry_descriptor = + internal_static_SearchHitProto_descriptor.getNestedTypes().get(0); + internal_static_SearchHitProto_DocumentFieldsEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchHitProto_DocumentFieldsEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_SearchHitProto_MetaFieldsEntry_descriptor = + internal_static_SearchHitProto_descriptor.getNestedTypes().get(1); + internal_static_SearchHitProto_MetaFieldsEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchHitProto_MetaFieldsEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_SearchHitProto_HighlightFieldsEntry_descriptor = + internal_static_SearchHitProto_descriptor.getNestedTypes().get(2); + internal_static_SearchHitProto_HighlightFieldsEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchHitProto_HighlightFieldsEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_SearchHitProto_MatchedQueriesEntry_descriptor = + internal_static_SearchHitProto_descriptor.getNestedTypes().get(3); + internal_static_SearchHitProto_MatchedQueriesEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchHitProto_MatchedQueriesEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_SearchHitProto_InnerHitsEntry_descriptor = + internal_static_SearchHitProto_descriptor.getNestedTypes().get(4); + internal_static_SearchHitProto_InnerHitsEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchHitProto_InnerHitsEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_NestedIdentityProto_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_NestedIdentityProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_NestedIdentityProto_descriptor, + new java.lang.String[] { "Field", "Offset", "Child", }); + internal_static_DocumentFieldProto_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_DocumentFieldProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_DocumentFieldProto_descriptor, + new java.lang.String[] { "Name", "Values", }); + internal_static_HighlightFieldProto_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_HighlightFieldProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_HighlightFieldProto_descriptor, + new java.lang.String[] { "Name", "Fragments", }); + internal_static_SearchSortValuesProto_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_SearchSortValuesProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchSortValuesProto_descriptor, + new java.lang.String[] { "FormattedSortValues", "RawSortValues", }); + internal_static_ExplanationProto_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_ExplanationProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_ExplanationProto_descriptor, + new java.lang.String[] { "Match", "Value", "Description", "Details", }); + internal_static_SearchShardTargetProto_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_SearchShardTargetProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SearchShardTargetProto_descriptor, + new java.lang.String[] { "NodeId", "ShardId", "ClusterAlias", }); + internal_static_ShardIdProto_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_ShardIdProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_ShardIdProto_descriptor, + new java.lang.String[] { "Index", "ShardId", "HashCode", }); + internal_static_IndexProto_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_IndexProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_IndexProto_descriptor, + new java.lang.String[] { "Name", "Uuid", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java.pb.meta b/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java.pb.meta new file mode 100644 index 0000000000000000000000000000000000000000..488a81c235b90d564d07f3d95f2b55c8ba27b3c7 GIT binary patch literal 18157 zcma*u*Ha_godSgpc2=hUKP*OPT;rjp32L=5~ z5{$L-0}g)(%(j1xqhAMRZ-0a7-vnmszs3G<1G9|ZA@6sA*~*VN`0+bay}WAuzzPDh zr+-Jv@4qwY<-UgaFweH4Abo@IP3(hEKs4LfPn3VD)bf- zu%J|hvQh$iD^%F6AfTg0h4LB#KGmy`&_KYNCKZ~R2zcmH;oL>Qkv0`(+6dU(sX|vL z0gJlj$aE7hwpWGBUIHHVsqolGz`j8hrUwZ)JgmYm!vyq?s*p9NKtc5-%*b$tfCsZG zT+9;ia$W`VFA5Zts&i3}%pw6(msQAHCScyG3YDuWxl2evf;nFtsgQj9Z9J8vd%2nP z+{(*+OTfW96;|&ESp1-Z^MQctk1Bk6B%sBwLXn?=W(f|n^xVr-Qpn4*F1JW{V2|97&e2maIVi%d_53k?@d0z|W}?tZ4+CwMlqq zBVa~`gsKbzx-;d;WD;;VTf%0x0z+S(b+cWu&nC_8K>LFm( zaL%U2o=t&*J<49D8nIafd@N8S*FnIKg=+W<33yeahP9M{k7a6PmlH6dQjM}o0=Czx zFCdbJZvgZu+hxf2}b@70n_$^k+(;{{KH@r z9}@8JC>W5VRd=1X?3E1t> zV8}tho+1rKixeo>hkq%N*Rhm<+hrQ~$_RK~p@F$lfr1UYxkiJO8UilYYOq~Pz}5y0 z+zkp8?Cg)78r(PuIP212(?!6hHyZT3Az)&s2Cq5^=;_vAy_VAZ)e{1ae3IAk69MPWHP|~>py1$Rz1JZBo`9bp`STC6tk2`Ry% z#VZQ|Q{uHKizi@zk`{|e1l&s1!k0?G_;f9D(+OCcrA1E`0n2l=aON=3u0@Mofr7(X zZn+k(%L!I5DBc@&p0vr?u#qCg8=K z7Up>Z+SlZKTq9tsSBnX+0tIK+*kdj7jtO{pqQ&D00l%DTVf{?NlQS*+X9OI-&|>$3 zfKAt0j9wFP^j3?tTLK>6Yw>hXz(l_mrG5hXV|B%RAJL1Y~9IymDMC^%nNCF{_b zOu)EQ9a2*XIAzme(MG`BEFFrn2soOn!(1)_Ym0Q~C?a56i4LPB3KSgeo0@d!Ya(D~ zvkv9W1a!3OP}534dz%c~2$<8MLtO^}ySjC9eP7_*02s$!vsti z)gfz?fDaRLK6-S|Z@C1=$2XgD?ra8RS^M(+?SH$hB>D{N)2R;rQvzG0u|ZHR@GxWNs}2`m323|3A@5d!g2h>q;Q<5P_j0}56C>Ilb$Iniz*N6n{C))r9tst{ z4?*Sokmr^sj7;T02wVpQ>^ly@*f9a~K82v{69JDthv53N0tF!~xeP(=B>^w4LgW`D z1iZQqf&W^8f>_7jhal~qfSV5?`0zl$Vt)v#{RG^x=y7P#e-EMH9+Rzl?YuOzXAS!0$PXUSq~Agam0Z35dwP04cHqepl{NE zn@Iv%W(}~-8lDSF@MP4nYe2_tKz4d!fZ6x$vO%K4D!ewJ@tT0v8~Ofj2>5t!K=OkE z1#vd}4Y2zO_|Y7S8*}J$b_Yp<5nsiHq9%@j1qq?3P9We|VklM<6)32{)`L)V9T2en zI241&1e`hz#lk58%g#ele@?*D%TU~1Dp0VFj=NAa+!65hJ`^br1hhScqTq>u)3IUL ziVYm<^tdoM;sU#O)-d?2fn9k@7+fiV-K;GPo3_AiGcydIGM}qi@Up>C9fr5nfz(t> z7~Zu!Uo%)#%T>K$80!t}O8djm)gRb>83;q>U|{DOmajYf-3ijFdL#^kBY|Dgco>St z1G}+_Fl?jvB=P&np> z2$((=j@mH-dOhK|@F-9azSX&KoXin0b0Hkn3j`cq3diCS0TWl{|MaX9(CZDyv6p~Z z+u^9%CgA99I97N6^?xEMNbv41?Tb9;F9Dg~9Dxi=#B+*iM74aC8Xxr$E8^Vx=Gg#{~rZR2YH# zLIN%oN8qHGfU%`=2ule#To!?uG6LEwBG6EwKtY4bw;NGrHwMn0!+aw?=M(VAVZ^0F zfr9K=EjD7On1Cmx@`$AbY_2e(t3rW-G&`v>; z`i&89-zZR!xF_B6WV#7h?l!{ZCZMO^h{b*a`UZ`-9wgwws8N3RLO{32h;a`Ab7qVv zo*|&^7bEPy5O8YAh~*^$R;(G(yhgxRn?{sx5-@AWh>{%w=Ds(g`aJ;?J{Xbzfq>>i z86Fbw=*Wn>BLY627?JKH;KZpBTc^h7-$B8LB&F6!^jRYVv6;+B>}5ticQUQ$cW~bk ziCYH&y+!hfMFiX|i^Or60tGGapfVEol?0rsj>K{`0rP4jQC3U9r20q{)+7SZ6u(_6^SjE0tG)t^93fX7nlNvaJ$$9UoipwACX=KIPi=nQ-k3$hI#{IKKRL zS)Hgsc^~BLejs4WlL=i<1pMqb;j5p33+5>7nWLU7P$zmWwrz>RrGSD+vv zHe`6tz#MB7O03F=f_C!ZAPT+%0ycb%LhDBYt{+EX_n3gmr%}i{C1Ck^6keYbaP%e$ zOE(1Ux{Jc(odN|7YS|Kv9ZPiJSUcmR@iv}-ZPsWESQRLU^+8fJ&XWi@oDz-M6ar4C zMPofJ`ngm^pX`-Jqo6b(tErBLtNPnzLqw(OazLTDxZ#3fF3KSGpw><`f_L%3)5iXCrFb1AN0xp)uz*|bdx{4UIR1omG uDh8Hn1q#-&t}X`6bp(9f7=zA60uH)jFySI#-kTVdz9Ha;_86SC$NUonq%FSy literal 0 HcmV?d00001 diff --git a/server/src/main/proto/server/SearchHits.proto b/server/src/main/proto/server/SearchHits.proto new file mode 100644 index 0000000000000..47345438e40bf --- /dev/null +++ b/server/src/main/proto/server/SearchHits.proto @@ -0,0 +1,130 @@ +syntax = "proto3"; + +/* +SearchHit[] hits +TotalHits totalHits +float maxScore + */ +message SearchHitsProto { + repeated SearchHitProto hits = 1; + int64 total_hits = 2; + float max_score = 3; +} + +/** +float score +Text id +NestedIdentity nestedIdentity +long version +long seqNo +long primaryTerm +BytesReference source +Explanation explanation +Map documentFields +Map metaFields +Map highlightedFields +SearchSortValues sortValues +Map matchedQueries +SearchShardTarget shard +Map innerHits +*/ +message SearchHitProto { + float score = 1; + string id = 2; + NestedIdentityProto nested_identity = 3; + int64 version = 4; + int64 seq_no = 5; + int64 primary_term = 6; + bytes source = 7; + ExplanationProto explanation = 8; + map document_fields = 9; + map meta_fields = 10; + map highlight_fields = 11; + SearchSortValuesProto sort_values = 12; + map matched_queries = 13; + SearchShardTargetProto shard = 14; + map inner_hits = 15; +} + +/* +Text field; +int offset; +NestedIdentity child; + */ +message NestedIdentityProto { + string field = 1; + int32 offset = 2; + NestedIdentityProto child = 3; +} + +/* +String name +List values + */ +message DocumentFieldProto { + string name = 1; + repeated bytes values = 2; +} + +/* +String name +Text[] fragments + */ +message HighlightFieldProto { + string name = 1; + repeated string fragments = 2; +} + +/* +Object[] formattedSortValues +Object[] rawSortValues + */ +message SearchSortValuesProto { + repeated bytes formatted_sort_values = 1; + repeated bytes raw_sort_values = 2; +} + +/* +boolean match +Number value +String description +List details + */ +message ExplanationProto { + bool match = 1; + // value used as long + int64 value = 2; + string description = 3; + repeated ExplanationProto details = 4; +} + +/* +Text nodeId +ShardId shardId +String clusterAlias + */ +message SearchShardTargetProto { + string node_id = 1; + ShardIdProto shard_id = 2; + string cluster_alias = 3; +} + +/* +Index index +int shardId +int hashCode + */ +message ShardIdProto { + IndexProto index = 1; + int32 shard_id = 2; + int32 hash_code = 3; +} + +/* +String name +String uuid + */ +message IndexProto { + string name = 1; + string uuid = 2; +} From a183e6397145d78efc8bb367692ffc34f6b46894 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Fri, 23 Aug 2024 11:37:34 -0700 Subject: [PATCH 20/61] SearchHits to proto initial implementation - Not tested Signed-off-by: Finn Carroll --- .../transport/serde/SearchHitSerDe.java | 190 ++++++++++-------- .../transport/serde/SearchHitsSerDe.java | 28 +-- .../org/opensearch/transport/serde/SerDe.java | 6 + 3 files changed, 122 insertions(+), 102 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java index 45e92aebaf805..693218fe90983 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java @@ -9,15 +9,17 @@ package org.opensearch.transport.serde; import com.google.protobuf.ByteString; -import org.apache.commons.lang.SerializationUtils; import org.apache.lucene.search.Explanation; -import org.apache.lucene.search.TotalHits; import org.opensearch.Version; import org.opensearch.common.document.DocumentField; +import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.common.lucene.Lucene; import org.opensearch.core.common.bytes.BytesReference; 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.core.index.Index; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; import org.opensearch.search.SearchShardTarget; @@ -25,10 +27,8 @@ import org.opensearch.search.fetch.subphase.highlight.HighlightField; import java.io.IOException; -import java.io.Serializable; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -46,6 +46,8 @@ import org.opensearch.transport.serde.prototemp.SearchHits.HighlightFieldProto; import org.opensearch.transport.serde.prototemp.SearchHits.SearchSortValuesProto; import org.opensearch.transport.serde.prototemp.SearchHits.SearchShardTargetProto; +import org.opensearch.transport.serde.prototemp.SearchHits.ShardIdProto; +import org.opensearch.transport.serde.prototemp.SearchHits.IndexProto; import org.opensearch.transport.serde.prototemp.SearchHits.SearchHitsProto; /** @@ -53,6 +55,7 @@ * @opensearch.internal */ public class SearchHitSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { + SearchHitsSerDe searchHitsSerDe = new SearchHitsSerDe(); @Override public SearchHit deserialize(StreamInput in) { @@ -72,7 +75,7 @@ public void serialize(SearchHit object, StreamOutput out) throws SerDe.Serializa } } - public static SearchHitProto toProto(SearchHit searchHit) { + SearchHitProto toProto(SearchHit searchHit) { SearchHit.SerializationAccess serI = searchHit.getSerAccess(); SearchHitProto.Builder builder = SearchHitProto.newBuilder() @@ -82,10 +85,18 @@ public static SearchHitProto toProto(SearchHit searchHit) { .setSeqNo(serI.getSeqNo()) .setPrimaryTerm(serI.getPrimaryTerm()); + if (serI.getNestedIdentity() != null) { + builder.setNestedIdentity(nestedIdentityToProto(serI.getNestedIdentity())); + } + if (serI.getSource() != null) { builder.setSource(ByteString.copyFrom(serI.getSource().toBytesRef().bytes)); } + if (serI.getExplanation() != null) { + builder.setExplanation(explanationToProto(serI.getExplanation())); + } + serI.getDocumentFields().forEach((key, value) -> builder.putDocumentFields(key, documentFieldToProto(value)) ); @@ -98,19 +109,11 @@ public static SearchHitProto toProto(SearchHit searchHit) { builder.putHighlightFields(key, highlightFieldToProto(value)) ); - serI.getMatchedQueries().forEach(builder::putMatchedQueries); - - if (serI.getExplanation() != null) { - builder.setExplanation(explanationToProto(serI.getExplanation())); - } - if (serI.getSortValues() != null) { - builder.setSortValues(shardSearchValuesToProto(serI.getSortValues())); + builder.setSortValues(searchSortValuesToProto(serI.getSortValues())); } - if (serI.getNestedIdentity() != null) { - builder.setNestedIdentity(nestedIdentityToProto(serI.getNestedIdentity())); - } + serI.getMatchedQueries().forEach(builder::putMatchedQueries); if (serI.getShard() != null) { builder.setShard(searchShardTargetToProto(serI.getShard())); @@ -118,87 +121,110 @@ public static SearchHitProto toProto(SearchHit searchHit) { if (serI.getInnerHits() != null) { serI.getInnerHits().forEach((key, value) -> - builder.putInnerHits(key, searchHitsToProto(value)) + builder.putInnerHits(key, searchHitsSerDe.toProto(value)) ); } return builder.build(); } - private static DocumentFieldProto documentFieldToProto(DocumentField field) { + static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { + NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() + .setField(nestedIdentity.getField().string()) + .setOffset(nestedIdentity.getOffset()); + + if (nestedIdentity.getChild() != null) { + builder.setChild(nestedIdentityToProto(nestedIdentity.getChild())); + } + + return builder.build(); + } + + static ExplanationProto explanationToProto(Explanation explanation) { + ExplanationProto.Builder builder = ExplanationProto.newBuilder() + .setMatch(explanation.isMatch()) + .setValue(explanation.getValue().longValue()) + .setDescription(explanation.getDescription()); + + for (Explanation detail : explanation.getDetails()) { + builder.addDetails(explanationToProto(detail)); + } + + return builder.build(); + } + + // Experimenting with this object. + // Proto definition gives 'repeated bytes' for values. + // However since these are just byte arrays it might be easier to just write them all to one buffer at once + // and avoid the overhead of opening a new StreamOutput for each value. + static DocumentFieldProto documentFieldToProto(DocumentField field) { DocumentFieldProto.Builder builder = DocumentFieldProto.newBuilder().setName(field.getName()); - List objList = field.getValues(); - for (Object obj : objList) { - byte[] data = SerializationUtils.serialize((Serializable) obj); - String jsonString = objectMapper.writeValueAsString(obj); - return ByteString.copyFromUtf8(jsonString); + try (BytesStreamOutput docsOut = new BytesStreamOutput()) { + docsOut.writeCollection(field.getValues(), StreamOutput::writeGenericValue); + builder.addValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); + } catch (IOException e){ + builder.addValues(ByteString.EMPTY); + } + + return builder.build(); + } + + static HighlightFieldProto highlightFieldToProto(HighlightField field) { + HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder() + .setName(field.getName()); + + for (Text frag : field.getFragments()) { + builder.addFragments(frag.string()); + } + + return builder.build(); + } + + // Experimenting with this object. + // See above comment for documentFieldToProto. + static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { + SearchSortValuesProto.Builder builder = SearchSortValuesProto.newBuilder(); + + try (BytesStreamOutput formOut = new BytesStreamOutput()) { + formOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); + builder.addFormattedSortValues(ByteString.copyFrom(formOut.bytes().toBytesRef().bytes)); + } catch (IOException e){ + builder.addFormattedSortValues(ByteString.EMPTY); + } -// DataOutputStream out = new DataOutputStream(new ByteArrayOutputStream()); -// obj.serialize(out); - obj. - builder.addValues(SerializationUtils.serialize(obj)); + try (BytesStreamOutput rawOut = new BytesStreamOutput()) { + rawOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); + builder.addRawSortValues(ByteString.copyFrom(rawOut.bytes().toBytesRef().bytes)); + } catch (IOException e){ + builder.addRawSortValues(ByteString.EMPTY); } return builder.build(); } -// private static ExplanationProto explanationToProto(Explanation explanation) { -// ExplanationProto.Builder builder = ExplanationProto.newBuilder() -// .setValue(explanation.getValue().floatValue()) -// .setDescription(explanation.getDescription()); -// -// for (Explanation detail : explanation.getDetails()) { -// builder.addDetails(explanationToProto(detail)); -// } -// -// return builder.build(); -// } -// -// private static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { -// NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() -// .setField(nestedIdentity.getField().string()) -// .setOffset(nestedIdentity.getOffset()); -// -// if (nestedIdentity.getChild() != null) { -// builder.setChild(nestedIdentityToProto(nestedIdentity.getChild())); -// } -// -// return builder.build(); -// } -// -// private static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { -// return SearchShardTargetProto.newBuilder() -// .setNodeId(shardTarget.getNodeId()) -// .setIndex(shardTarget.getIndex()) -// .setShardId(shardTarget.getShardId().getId()) -// .setClusterAlias(shardTarget.getClusterAlias() != null ? shardTarget.getClusterAlias() : "") -// .build(); -// } -// -// -// private static DocumentField documentFieldFromProto(SearchHitOuterClass.DocumentField protoField) { -// return new DocumentField( -// protoField.getName(), -// protoField.getValuesList().stream() -// .map(ByteString::toStringUtf8) -// .collect(Collectors.toList()) -// ); -// } -// -// private static HighlightFieldProto highlightFieldToProto(HighlightField field) { -// return HighlightFieldProto.newBuilder() -// .setName(field.getName()) -// .addAllFragments(field.getFragments()) -// .build(); -// } -// -// private static HighlightField highlightFieldFromProto(SearchHitOuterClass.HighlightField protoField) { -// return new HighlightField( -// protoField.getName(), -// protoField.getFragmentsList().toArray(new String[0]) -// ); -// } + static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { + return SearchShardTargetProto.newBuilder() + .setNodeId(shardTarget.getNodeId()) + .setShardId(shardIdToProto(shardTarget.getShardId())) + .setClusterAlias(shardTarget.getClusterAlias()) + .build(); + } + + static ShardIdProto shardIdToProto(ShardId shardId) { + return ShardIdProto.newBuilder() + .setIndex(indexToProto(shardId.getIndex())) + .setShardId(shardId.id()) + .setHashCode(shardId.hashCode()) + .build(); + } + + static IndexProto indexToProto(Index index) { + return IndexProto.newBuilder() + .setName(index.getName()) + .setUuid(index.getUUID()) + .build(); + } private SearchHit fromStream(StreamInput in) throws IOException { int docId; diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java index 196eafe25ede4..9604a64af5d41 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java @@ -17,7 +17,6 @@ import org.opensearch.search.SearchHits; import java.io.IOException; -import java.util.Arrays; import org.opensearch.transport.serde.prototemp.SearchHits.SearchHitsProto; @@ -52,31 +51,20 @@ public void serialize(SearchHits object, StreamOutput out) throws SerDe.Serializ } } - private SearchHitsProto toProto(SearchHits searchHits) { + SearchHitsProto toProto(SearchHits searchHits) { + SearchHits.SerializationAccess serI = searchHits.getSerAccess(); + SearchHitsProto.Builder builder = SearchHitsProto.newBuilder() - .setTotalHits(searchHits.getTotalHits().value) - .setMaxScore(searchHits.getMaxScore()); + .setTotalHits(serI.getTotalHits().value) + .setMaxScore(serI.getMaxScore()); - // Assuming you have a SearchHitProtoUtils.toProto method - Arrays.stream(searchHits.getHits()) - .map(SearchHitProtoUtils::toProto) - .forEach(builder::addHits); + for (SearchHit hit : searchHits.getHits()) { + builder.addHits(searchHitSerDe.toProto(hit)); + } return builder.build(); } - private SearchHits fromProto(SearchHitsProto protoSearchHits) { - SearchHit[] hits = protoSearchHits.getHitsList().stream() - .map(SearchHitProtoUtils::fromProto) - .toArray(SearchHit[]::new); - - return new SearchHits( - hits, - new TotalHits(protoSearchHits.getTotalHits(), TotalHits.Relation.EQUAL_TO), - protoSearchHits.getMaxScore() - ); - } - private SearchHits fromStream(StreamInput in) throws IOException { SearchHit[] hits; TotalHits totalHits; diff --git a/server/src/main/java/org/opensearch/transport/serde/SerDe.java b/server/src/main/java/org/opensearch/transport/serde/SerDe.java index 68d745bd26452..ad2270bf1c558 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SerDe.java @@ -8,11 +8,17 @@ package org.opensearch.transport.serde; +import com.google.protobuf.ByteString; +import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; +import java.awt.image.WritableRaster; +import java.io.IOException; + /** * Base class for supported serialization/deserialization implementations. * @opensearch.internal From 60bdf82cdc8b3a59b5acb4a81b6ee5fde771cd4f Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Sat, 24 Aug 2024 19:53:53 -0700 Subject: [PATCH 21/61] SearchHit from proto impl Signed-off-by: Finn Carroll --- .../opensearch/search/SearchShardTarget.java | 7 + .../opensearch/search/SearchSortValues.java | 5 + .../transport/serde/SearchHitSerDe.java | 172 +++++++++++++++++- 3 files changed, 183 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/SearchShardTarget.java b/server/src/main/java/org/opensearch/search/SearchShardTarget.java index 80b4feda374c6..224e2d45c444e 100644 --- a/server/src/main/java/org/opensearch/search/SearchShardTarget.java +++ b/server/src/main/java/org/opensearch/search/SearchShardTarget.java @@ -71,6 +71,13 @@ public SearchShardTarget(StreamInput in) throws IOException { clusterAlias = in.readOptionalString(); } + public SearchShardTarget(String nodeId, ShardId shardId, String clusterAlias) { + this.nodeId = new Text(nodeId); + this.shardId = shardId; + this.originalIndices = null; + this.clusterAlias = clusterAlias; + } + public SearchShardTarget(String nodeId, ShardId shardId, @Nullable String clusterAlias, OriginalIndices originalIndices) { this.nodeId = nodeId == null ? null : new Text(nodeId); this.shardId = shardId; diff --git a/server/src/main/java/org/opensearch/search/SearchSortValues.java b/server/src/main/java/org/opensearch/search/SearchSortValues.java index 659dd9f204a10..a5da011d062c1 100644 --- a/server/src/main/java/org/opensearch/search/SearchSortValues.java +++ b/server/src/main/java/org/opensearch/search/SearchSortValues.java @@ -67,6 +67,11 @@ public class SearchSortValues implements ToXContentFragment, Writeable { this.rawSortValues = EMPTY_ARRAY; } + public SearchSortValues(Object[] formattedSortValues, Object[] rawSortValues) { + this.formattedSortValues = formattedSortValues; + this.rawSortValues = rawSortValues; + } + public SearchSortValues(Object[] rawSortValues, DocValueFormat[] sortValueFormats) { Objects.requireNonNull(rawSortValues); Objects.requireNonNull(sortValueFormats); diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java index 693218fe90983..695825330e6a3 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java @@ -14,6 +14,7 @@ import org.opensearch.common.document.DocumentField; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.lucene.Lucene; +import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; @@ -27,8 +28,13 @@ import org.opensearch.search.fetch.subphase.highlight.HighlightField; import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -48,7 +54,6 @@ import org.opensearch.transport.serde.prototemp.SearchHits.SearchShardTargetProto; import org.opensearch.transport.serde.prototemp.SearchHits.ShardIdProto; import org.opensearch.transport.serde.prototemp.SearchHits.IndexProto; -import org.opensearch.transport.serde.prototemp.SearchHits.SearchHitsProto; /** * Serialization/Deserialization implementations for SearchHit. @@ -128,6 +133,75 @@ SearchHitProto toProto(SearchHit searchHit) { return builder.build(); } + static SearchHit fromProto(SearchHitProto proto) throws IOException { + int docId; + float score; + long seqNo; + long version; + long primaryTerm; + Text id; + BytesReference source; + SearchShardTarget shard; + Explanation explanation = null; + SearchSortValues sortValues; + SearchHit.NestedIdentity nestedIdentity; + Map documentFields = Map.of(); + Map metaFields; + Map highlightFields; + Map matchedQueries = Map.of(); + Map innerHits; + String index = null; + String clusterAlias = null; + + docId = -1; + score = proto.getScore(); + seqNo = proto.getSeqNo(); + version = proto.getVersion(); + primaryTerm = proto.getPrimaryTerm(); + id = new Text(proto.getId()); + source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); + shard = searchShardTargetFromProto(proto.getShard()); + sortValues = searchSortValuesFromProto(proto.getSortValues()); + nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); + + +// proto.getDocumentFieldsMap().forEach((key, value) -> +// documentFields.put(key, documentFieldFromProto(value)) +// ); +// +// // Why is this one optional? What should the default value be? +// // Is it because it's only collections? +// documentFieldsFromProto(); +// documentFields = documentFieldsFromProto(proto.getDocumentFieldsOrDefault(null, null)); +// +// // Need to implement a fromProto() +// metaFields = proto.getMetaFieldsMap(); +// +// highlightFields = protoToHighlightField(); +// +// +// return new SearchHit( +// docId, +// score, +// seqNo, +// version, +// primaryTerm, +// id, +// source, +// shard, +// explanation, +// sortValues, +// nestedIdentity, +// documentFields, +// metaFields, +// highlightFields, +// matchedQueries, +// innerHits, +// index, +// clusterAlias +// ); + } + static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() .setField(nestedIdentity.getField().string()) @@ -140,6 +214,18 @@ static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nested return builder.build(); } + static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityProto proto) { + String field = proto.getField(); + int offset = proto.getOffset(); + + SearchHit.NestedIdentity child = null; + if (proto.hasChild()) { + child = nestedIdentityFromProto(proto.getChild()); + } + + return new SearchHit.NestedIdentity(field, offset, child); + } + static ExplanationProto explanationToProto(Explanation explanation) { ExplanationProto.Builder builder = ExplanationProto.newBuilder() .setMatch(explanation.isMatch()) @@ -153,6 +239,22 @@ static ExplanationProto explanationToProto(Explanation explanation) { return builder.build(); } + static Explanation protoToExplanation(ExplanationProto proto) { + long value = proto.getValue(); + String description = proto.getDescription(); + Collection details = new ArrayList<>(); + + for (ExplanationProto det : proto.getDetailsList()) { + details.add(protoToExplanation(det)); + } + + if (proto.getMatch()) { + return Explanation.match(value, description, details); + } + + return Explanation.noMatch(description, details); + } + // Experimenting with this object. // Proto definition gives 'repeated bytes' for values. // However since these are just byte arrays it might be easier to just write them all to one buffer at once @@ -170,6 +272,23 @@ static DocumentFieldProto documentFieldToProto(DocumentField field) { return builder.build(); } + static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws IOException { + String name = proto.getName(); + List values = new ArrayList<>(0); + + if (proto.getValuesCount() > 0) { + BytesReference valuesBytes = new BytesArray(proto.getValues(0).toByteArray()); + try (StreamInput in = valuesBytes.streamInput()) { + Object readValue = in.readGenericValue(); + values.add(readValue); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize DocumentField values from proto object", e); + } + } + + return new DocumentField(name, values); + } + static HighlightFieldProto highlightFieldToProto(HighlightField field) { HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder() .setName(field.getName()); @@ -181,6 +300,17 @@ static HighlightFieldProto highlightFieldToProto(HighlightField field) { return builder.build(); } + static HighlightField protoToHighlightField(HighlightFieldProto proto) { + String name = proto.getName(); + Text[] fragments = new Text[proto.getFragmentsCount()]; + + for (int i = 0; i < proto.getFragmentsCount(); i++) { + fragments[i] = new Text(proto.getFragments(i)); + } + + return new HighlightField(name, fragments); + } + // Experimenting with this object. // See above comment for documentFieldToProto. static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { @@ -203,6 +333,27 @@ static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSort return builder.build(); } + static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws IOException { + Object[] formattedSortValues = null; + Object[] rawSortValues = null; + + if (proto.getFormattedSortValuesCount() > 0) { + BytesReference formattedBytes = new BytesArray(proto.getFormattedSortValues(0).toByteArray()); + try (StreamInput formattedIn = formattedBytes.streamInput()) { + formattedSortValues = formattedIn.readArray(Lucene::readSortValue, Object[]::new); + } + } + + if (proto.getRawSortValuesCount() > 0) { + BytesReference rawBytes = new BytesArray(proto.getRawSortValues(0).toByteArray()); + try (StreamInput rawIn = rawBytes.streamInput()) { + rawSortValues = rawIn.readArray(Lucene::readSortValue, Object[]::new); + } + } + + return new SearchSortValues(formattedSortValues, rawSortValues); + } + static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { return SearchShardTargetProto.newBuilder() .setNodeId(shardTarget.getNodeId()) @@ -211,6 +362,13 @@ static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTa .build(); } + public static SearchShardTarget searchShardTargetFromProto(SearchShardTargetProto proto) { + String nodeId = proto.getNodeId(); + ShardId shardId = shardIdFromProto(proto.getShardId()); + String clusterAlias = proto.getClusterAlias(); + return new SearchShardTarget(nodeId, shardId, clusterAlias); + } + static ShardIdProto shardIdToProto(ShardId shardId) { return ShardIdProto.newBuilder() .setIndex(indexToProto(shardId.getIndex())) @@ -219,6 +377,12 @@ static ShardIdProto shardIdToProto(ShardId shardId) { .build(); } + public static ShardId shardIdFromProto(ShardIdProto proto) { + Index index = indexFromProto(proto.getIndex()); + int shardId = proto.getShardId(); + return new ShardId(index, shardId); + } + static IndexProto indexToProto(Index index) { return IndexProto.newBuilder() .setName(index.getName()) @@ -226,6 +390,12 @@ static IndexProto indexToProto(Index index) { .build(); } + public static Index indexFromProto(IndexProto proto) { + String name = proto.getName(); + String uuid = proto.getUuid(); + return new Index(name, uuid); + } + private SearchHit fromStream(StreamInput in) throws IOException { int docId; float score; From 0fc2b3ed835095957ec8db7d33dd656900b59472 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Sat, 24 Aug 2024 20:50:45 -0700 Subject: [PATCH 22/61] SearchHit from proto impl Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 2 +- .../transport/serde/SearchHitSerDe.java | 146 ++++++++---------- .../transport/serde/SearchHitsSerDe.java | 9 ++ server/src/main/proto/server/SearchHits.proto | 6 + 4 files changed, 84 insertions(+), 79 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 16ef1e4778046..1286120fffe3a 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -181,7 +181,7 @@ public SearchHit( Map innerHits, String index, String clusterAlias - ) throws IOException { + ) { this.docId = docId; this.score = score; this.seqNo = seqNo; diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java index 695825330e6a3..2129ba84102d1 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java @@ -28,12 +28,10 @@ import org.opensearch.search.fetch.subphase.highlight.HighlightField; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -133,73 +131,64 @@ SearchHitProto toProto(SearchHit searchHit) { return builder.build(); } - static SearchHit fromProto(SearchHitProto proto) throws IOException { - int docId; - float score; - long seqNo; - long version; - long primaryTerm; - Text id; - BytesReference source; - SearchShardTarget shard; - Explanation explanation = null; - SearchSortValues sortValues; - SearchHit.NestedIdentity nestedIdentity; - Map documentFields = Map.of(); - Map metaFields; - Map highlightFields; - Map matchedQueries = Map.of(); - Map innerHits; - String index = null; - String clusterAlias = null; + SearchHit fromProto(SearchHitProto proto) throws SerDe.SerializationException { + int docId = -1; + float score = proto.getScore(); + long seqNo = proto.getSeqNo(); + long version = proto.getVersion(); + long primaryTerm = proto.getPrimaryTerm(); + Text id = new Text(proto.getId()); + BytesReference source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); + SearchShardTarget shard = searchShardTargetFromProto(proto.getShard()); + Explanation explanation = explanationFromProto(proto.getExplanation()); + SearchSortValues sortValues = searchSortValuesFromProto(proto.getSortValues()); + SearchHit.NestedIdentity nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); + + HashMap documentFields = new HashMap<>(); + proto.getDocumentFieldsMap().forEach((key, value) -> + documentFields.put(key, documentFieldFromProto(value)) + ); - docId = -1; - score = proto.getScore(); - seqNo = proto.getSeqNo(); - version = proto.getVersion(); - primaryTerm = proto.getPrimaryTerm(); - id = new Text(proto.getId()); - source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); - shard = searchShardTargetFromProto(proto.getShard()); - sortValues = searchSortValuesFromProto(proto.getSortValues()); - nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); - - -// proto.getDocumentFieldsMap().forEach((key, value) -> -// documentFields.put(key, documentFieldFromProto(value)) -// ); -// -// // Why is this one optional? What should the default value be? -// // Is it because it's only collections? -// documentFieldsFromProto(); -// documentFields = documentFieldsFromProto(proto.getDocumentFieldsOrDefault(null, null)); -// -// // Need to implement a fromProto() -// metaFields = proto.getMetaFieldsMap(); -// -// highlightFields = protoToHighlightField(); -// -// -// return new SearchHit( -// docId, -// score, -// seqNo, -// version, -// primaryTerm, -// id, -// source, -// shard, -// explanation, -// sortValues, -// nestedIdentity, -// documentFields, -// metaFields, -// highlightFields, -// matchedQueries, -// innerHits, -// index, -// clusterAlias -// ); + HashMap metaFields = new HashMap<>(); + proto.getMetaFieldsMap().forEach((key, value) -> + metaFields.put(key, documentFieldFromProto(value)) + ); + + HashMap highlightFields = new HashMap<>(); + proto.getHighlightFieldsMap().forEach((key, value) -> + highlightFields.put(key, highlightFieldFromProto(value)) + ); + + Map matchedQueries = proto.getMatchedQueriesMap(); + + HashMap innerHits = new HashMap<>(); + proto.getInnerHitsMap().forEach((key, value) -> + innerHits.put(key, this.searchHitsSerDe.fromProto(value)) + ); + + String index = shard.getIndex(); + String clusterAlias = shard.getClusterAlias(); + + return new SearchHit( + docId, + score, + seqNo, + version, + primaryTerm, + id, + source, + shard, + explanation, + sortValues, + nestedIdentity, + documentFields, + metaFields, + highlightFields, + matchedQueries, + innerHits, + index, + clusterAlias + ); } static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { @@ -239,13 +228,13 @@ static ExplanationProto explanationToProto(Explanation explanation) { return builder.build(); } - static Explanation protoToExplanation(ExplanationProto proto) { + static Explanation explanationFromProto(ExplanationProto proto) { long value = proto.getValue(); String description = proto.getDescription(); Collection details = new ArrayList<>(); for (ExplanationProto det : proto.getDetailsList()) { - details.add(protoToExplanation(det)); + details.add(explanationFromProto(det)); } if (proto.getMatch()) { @@ -255,10 +244,8 @@ static Explanation protoToExplanation(ExplanationProto proto) { return Explanation.noMatch(description, details); } - // Experimenting with this object. - // Proto definition gives 'repeated bytes' for values. - // However since these are just byte arrays it might be easier to just write them all to one buffer at once - // and avoid the overhead of opening a new StreamOutput for each value. + // Is there a reason to open a new stream for each object? + // Seems simpler to write a single stream. static DocumentFieldProto documentFieldToProto(DocumentField field) { DocumentFieldProto.Builder builder = DocumentFieldProto.newBuilder().setName(field.getName()); @@ -272,7 +259,7 @@ static DocumentFieldProto documentFieldToProto(DocumentField field) { return builder.build(); } - static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws IOException { + static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws SerDe.SerializationException { String name = proto.getName(); List values = new ArrayList<>(0); @@ -300,7 +287,7 @@ static HighlightFieldProto highlightFieldToProto(HighlightField field) { return builder.build(); } - static HighlightField protoToHighlightField(HighlightFieldProto proto) { + static HighlightField highlightFieldFromProto(HighlightFieldProto proto) { String name = proto.getName(); Text[] fragments = new Text[proto.getFragmentsCount()]; @@ -311,7 +298,6 @@ static HighlightField protoToHighlightField(HighlightFieldProto proto) { return new HighlightField(name, fragments); } - // Experimenting with this object. // See above comment for documentFieldToProto. static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { SearchSortValuesProto.Builder builder = SearchSortValuesProto.newBuilder(); @@ -333,7 +319,7 @@ static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSort return builder.build(); } - static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws IOException { + static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws SerDe.SerializationException { Object[] formattedSortValues = null; Object[] rawSortValues = null; @@ -341,6 +327,8 @@ static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) t BytesReference formattedBytes = new BytesArray(proto.getFormattedSortValues(0).toByteArray()); try (StreamInput formattedIn = formattedBytes.streamInput()) { formattedSortValues = formattedIn.readArray(Lucene::readSortValue, Object[]::new); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize SearchSortValues from proto object", e); } } @@ -348,6 +336,8 @@ static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) t BytesReference rawBytes = new BytesArray(proto.getRawSortValues(0).toByteArray()); try (StreamInput rawIn = rawBytes.streamInput()) { rawSortValues = rawIn.readArray(Lucene::readSortValue, Object[]::new); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize SearchSortValues from proto object", e); } } diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java index 9604a64af5d41..dd7ab4cd8b1f1 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java @@ -51,6 +51,7 @@ public void serialize(SearchHits object, StreamOutput out) throws SerDe.Serializ } } + // TODO: Update proto definition SearchHitsProto toProto(SearchHits searchHits) { SearchHits.SerializationAccess serI = searchHits.getSerAccess(); @@ -65,6 +66,14 @@ SearchHitsProto toProto(SearchHits searchHits) { return builder.build(); } + // TODO: Update proto definition + SearchHits fromProto(SearchHitsProto proto) { + long totalHits = proto.getTotalHits(); + float maxScore = proto.getMaxScore(); + + return new SearchHits(); + } + private SearchHits fromStream(StreamInput in) throws IOException { SearchHit[] hits; TotalHits totalHits; diff --git a/server/src/main/proto/server/SearchHits.proto b/server/src/main/proto/server/SearchHits.proto index 47345438e40bf..58d16b4828376 100644 --- a/server/src/main/proto/server/SearchHits.proto +++ b/server/src/main/proto/server/SearchHits.proto @@ -4,11 +4,17 @@ syntax = "proto3"; SearchHit[] hits TotalHits totalHits float maxScore +SortField[] sortFields +String collapseField +Object[] collapseValues */ message SearchHitsProto { repeated SearchHitProto hits = 1; int64 total_hits = 2; float max_score = 3; + repeated SortFieldProto sort_fields = 4; + string collapse_field = 5; + repeated bytes collapse_values = 6; } /** From 5595913b5fe3851a82ba08c823d5a0331ec04f8e Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Sat, 24 Aug 2024 22:30:38 -0700 Subject: [PATCH 23/61] Update SearchHits proto def Signed-off-by: Finn Carroll --- .../logging/OpenSearchJsonLayoutTests.java | 10 +- .../transport/serde/SearchHitSerDe.java | 21 +- .../transport/serde/SearchHitsSerDe.java | 33 +- .../transport/serde/prototemp/SearchHits.java | 10631 ---------------- .../serde/prototemp/SearchHits.java.pb.meta | Bin 18157 -> 0 bytes .../SearchHitsProto.proto} | 6 +- 6 files changed, 37 insertions(+), 10664 deletions(-) delete mode 100644 server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java delete mode 100644 server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java.pb.meta rename server/src/main/proto/{server/SearchHits.proto => serde/SearchHitsProto.proto} (95%) diff --git a/qa/logging-config/src/test/java/org/opensearch/common/logging/OpenSearchJsonLayoutTests.java b/qa/logging-config/src/test/java/org/opensearch/common/logging/OpenSearchJsonLayoutTests.java index 0a8bd46ac96f3..9694c0b6da6d4 100644 --- a/qa/logging-config/src/test/java/org/opensearch/common/logging/OpenSearchJsonLayoutTests.java +++ b/qa/logging-config/src/test/java/org/opensearch/common/logging/OpenSearchJsonLayoutTests.java @@ -49,7 +49,7 @@ public void testEmptyType() { public void testLayout() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("server") + .setType("serde") .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); @@ -68,7 +68,7 @@ public void testLayout() { public void testWithMaxMessageLengthLayout() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("server") + .setType("serde") .setMaxMessageLength(42) .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); @@ -88,7 +88,7 @@ public void testWithMaxMessageLengthLayout() { public void testWithUnrestrictedMaxMessageLengthLayout() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("server") + .setType("serde") .setMaxMessageLength(0) .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); @@ -108,7 +108,7 @@ public void testWithUnrestrictedMaxMessageLengthLayout() { public void testLayoutWithAdditionalFields() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("server") + .setType("serde") .setOpenSearchMessageFields("x-opaque-id,someOtherField") .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); @@ -130,7 +130,7 @@ public void testLayoutWithAdditionalFields() { public void testLayoutWithAdditionalFieldOverride() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("server") + .setType("serde") .setOpenSearchMessageFields("message") .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java index 2129ba84102d1..9d4a21bbe80c6 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java @@ -26,6 +26,16 @@ import org.opensearch.search.SearchShardTarget; import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitsProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.NestedIdentityProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.DocumentFieldProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.HighlightFieldProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchSortValuesProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchShardTargetProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.ExplanationProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.ShardIdProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.IndexProto; import java.io.IOException; import java.util.ArrayList; @@ -43,16 +53,6 @@ import static org.opensearch.common.lucene.Lucene.writeExplanation; import static org.opensearch.search.SearchHit.SINGLE_MAPPING_TYPE; -import org.opensearch.transport.serde.prototemp.SearchHits.SearchHitProto; -import org.opensearch.transport.serde.prototemp.SearchHits.DocumentFieldProto; -import org.opensearch.transport.serde.prototemp.SearchHits.ExplanationProto; -import org.opensearch.transport.serde.prototemp.SearchHits.NestedIdentityProto; -import org.opensearch.transport.serde.prototemp.SearchHits.HighlightFieldProto; -import org.opensearch.transport.serde.prototemp.SearchHits.SearchSortValuesProto; -import org.opensearch.transport.serde.prototemp.SearchHits.SearchShardTargetProto; -import org.opensearch.transport.serde.prototemp.SearchHits.ShardIdProto; -import org.opensearch.transport.serde.prototemp.SearchHits.IndexProto; - /** * Serialization/Deserialization implementations for SearchHit. * @opensearch.internal @@ -215,6 +215,7 @@ static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityProto prot return new SearchHit.NestedIdentity(field, offset, child); } + // TODO: Lucene definitions should maybe be serialized as generic bytes arrays. static ExplanationProto explanationToProto(Explanation explanation) { ExplanationProto.Builder builder = ExplanationProto.newBuilder() .setMatch(explanation.isMatch()) diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java index dd7ab4cd8b1f1..cbb3602efae48 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java @@ -15,11 +15,10 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitsProto; import java.io.IOException; -import org.opensearch.transport.serde.prototemp.SearchHits.SearchHitsProto; - import static org.opensearch.search.SearchHits.EMPTY; /** @@ -53,25 +52,25 @@ public void serialize(SearchHits object, StreamOutput out) throws SerDe.Serializ // TODO: Update proto definition SearchHitsProto toProto(SearchHits searchHits) { - SearchHits.SerializationAccess serI = searchHits.getSerAccess(); - - SearchHitsProto.Builder builder = SearchHitsProto.newBuilder() - .setTotalHits(serI.getTotalHits().value) - .setMaxScore(serI.getMaxScore()); - - for (SearchHit hit : searchHits.getHits()) { - builder.addHits(searchHitSerDe.toProto(hit)); - } - - return builder.build(); +// SearchHits.SerializationAccess serI = searchHits.getSerAccess(); +// +// SearchHitsProto.Builder builder = SearchHitsProto.newBuilder() +// .setTotalHits(serI.getTotalHits().value) +// .setMaxScore(serI.getMaxScore()); +// +// for (SearchHit hit : searchHits.getHits()) { +// builder.addHits(searchHitSerDe.toProto(hit)); +// } +// +// return builder.build(); } // TODO: Update proto definition SearchHits fromProto(SearchHitsProto proto) { - long totalHits = proto.getTotalHits(); - float maxScore = proto.getMaxScore(); - - return new SearchHits(); +// long totalHits = proto.getTotalHits(); +// float maxScore = proto.getMaxScore(); +// +// return new SearchHits();*/ } private SearchHits fromStream(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java b/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java deleted file mode 100644 index 13f9c3bff67a0..0000000000000 --- a/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java +++ /dev/null @@ -1,10631 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.transport.serde.prototemp;// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: server/SearchHits.proto - -@javax.annotation.Generated(value="protoc", comments="annotations:SearchHits.java.pb.meta") -public final class SearchHits { - private SearchHits() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - public interface SearchHitsProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:SearchHitsProto) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .SearchHitProto hits = 1; - */ - java.util.List - getHitsList(); - /** - * repeated .SearchHitProto hits = 1; - */ - SearchHits.SearchHitProto getHits(int index); - /** - * repeated .SearchHitProto hits = 1; - */ - int getHitsCount(); - /** - * repeated .SearchHitProto hits = 1; - */ - java.util.List - getHitsOrBuilderList(); - /** - * repeated .SearchHitProto hits = 1; - */ - SearchHits.SearchHitProtoOrBuilder getHitsOrBuilder( - int index); - - /** - * int64 total_hits = 2; - * @return The totalHits. - */ - long getTotalHits(); - - /** - * float max_score = 3; - * @return The maxScore. - */ - float getMaxScore(); - } - /** - *
-   *
-   *SearchHit[] hits
-   *TotalHits totalHits
-   *float maxScore
-   * 
- * - * Protobuf type {@code SearchHitsProto} - */ - public static final class SearchHitsProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:SearchHitsProto) - SearchHitsProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use SearchHitsProto.newBuilder() to construct. - private SearchHitsProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private SearchHitsProto() { - hits_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new SearchHitsProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_SearchHitsProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_SearchHitsProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.SearchHitsProto.class, SearchHits.SearchHitsProto.Builder.class); - } - - public static final int HITS_FIELD_NUMBER = 1; - @SuppressWarnings("serial") - private java.util.List hits_; - /** - * repeated .SearchHitProto hits = 1; - */ - @java.lang.Override - public java.util.List getHitsList() { - return hits_; - } - /** - * repeated .SearchHitProto hits = 1; - */ - @java.lang.Override - public java.util.List - getHitsOrBuilderList() { - return hits_; - } - /** - * repeated .SearchHitProto hits = 1; - */ - @java.lang.Override - public int getHitsCount() { - return hits_.size(); - } - /** - * repeated .SearchHitProto hits = 1; - */ - @java.lang.Override - public SearchHits.SearchHitProto getHits(int index) { - return hits_.get(index); - } - /** - * repeated .SearchHitProto hits = 1; - */ - @java.lang.Override - public SearchHits.SearchHitProtoOrBuilder getHitsOrBuilder( - int index) { - return hits_.get(index); - } - - public static final int TOTAL_HITS_FIELD_NUMBER = 2; - private long totalHits_ = 0L; - /** - * int64 total_hits = 2; - * @return The totalHits. - */ - @java.lang.Override - public long getTotalHits() { - return totalHits_; - } - - public static final int MAX_SCORE_FIELD_NUMBER = 3; - private float maxScore_ = 0F; - /** - * float max_score = 3; - * @return The maxScore. - */ - @java.lang.Override - public float getMaxScore() { - return maxScore_; - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < hits_.size(); i++) { - output.writeMessage(1, hits_.get(i)); - } - if (totalHits_ != 0L) { - output.writeInt64(2, totalHits_); - } - if (java.lang.Float.floatToRawIntBits(maxScore_) != 0) { - output.writeFloat(3, maxScore_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < hits_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, hits_.get(i)); - } - if (totalHits_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, totalHits_); - } - if (java.lang.Float.floatToRawIntBits(maxScore_) != 0) { - size += com.google.protobuf.CodedOutputStream - .computeFloatSize(3, maxScore_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.SearchHitsProto)) { - return super.equals(obj); - } - SearchHits.SearchHitsProto other = (SearchHits.SearchHitsProto) obj; - - if (!getHitsList() - .equals(other.getHitsList())) return false; - if (getTotalHits() - != other.getTotalHits()) return false; - if (java.lang.Float.floatToIntBits(getMaxScore()) - != java.lang.Float.floatToIntBits( - other.getMaxScore())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getHitsCount() > 0) { - hash = (37 * hash) + HITS_FIELD_NUMBER; - hash = (53 * hash) + getHitsList().hashCode(); - } - hash = (37 * hash) + TOTAL_HITS_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getTotalHits()); - hash = (37 * hash) + MAX_SCORE_FIELD_NUMBER; - hash = (53 * hash) + java.lang.Float.floatToIntBits( - getMaxScore()); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.SearchHitsProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchHitsProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchHitsProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchHitsProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchHitsProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchHitsProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchHitsProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.SearchHitsProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.SearchHitsProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.SearchHitsProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.SearchHitsProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.SearchHitsProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.SearchHitsProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *SearchHit[] hits
-     *TotalHits totalHits
-     *float maxScore
-     * 
- * - * Protobuf type {@code SearchHitsProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:SearchHitsProto) - SearchHits.SearchHitsProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_SearchHitsProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_SearchHitsProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.SearchHitsProto.class, SearchHits.SearchHitsProto.Builder.class); - } - - // Construct using SearchHits.SearchHitsProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - if (hitsBuilder_ == null) { - hits_ = java.util.Collections.emptyList(); - } else { - hits_ = null; - hitsBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - totalHits_ = 0L; - maxScore_ = 0F; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_SearchHitsProto_descriptor; - } - - @java.lang.Override - public SearchHits.SearchHitsProto getDefaultInstanceForType() { - return SearchHits.SearchHitsProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.SearchHitsProto build() { - SearchHits.SearchHitsProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.SearchHitsProto buildPartial() { - SearchHits.SearchHitsProto result = new SearchHits.SearchHitsProto(this); - buildPartialRepeatedFields(result); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartialRepeatedFields(SearchHits.SearchHitsProto result) { - if (hitsBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - hits_ = java.util.Collections.unmodifiableList(hits_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.hits_ = hits_; - } else { - result.hits_ = hitsBuilder_.build(); - } - } - - private void buildPartial0(SearchHits.SearchHitsProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000002) != 0)) { - result.totalHits_ = totalHits_; - } - if (((from_bitField0_ & 0x00000004) != 0)) { - result.maxScore_ = maxScore_; - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.SearchHitsProto) { - return mergeFrom((SearchHits.SearchHitsProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.SearchHitsProto other) { - if (other == SearchHits.SearchHitsProto.getDefaultInstance()) return this; - if (hitsBuilder_ == null) { - if (!other.hits_.isEmpty()) { - if (hits_.isEmpty()) { - hits_ = other.hits_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureHitsIsMutable(); - hits_.addAll(other.hits_); - } - onChanged(); - } - } else { - if (!other.hits_.isEmpty()) { - if (hitsBuilder_.isEmpty()) { - hitsBuilder_.dispose(); - hitsBuilder_ = null; - hits_ = other.hits_; - bitField0_ = (bitField0_ & ~0x00000001); - hitsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getHitsFieldBuilder() : null; - } else { - hitsBuilder_.addAllMessages(other.hits_); - } - } - } - if (other.getTotalHits() != 0L) { - setTotalHits(other.getTotalHits()); - } - if (other.getMaxScore() != 0F) { - setMaxScore(other.getMaxScore()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - SearchHits.SearchHitProto m = - input.readMessage( - SearchHits.SearchHitProto.parser(), - extensionRegistry); - if (hitsBuilder_ == null) { - ensureHitsIsMutable(); - hits_.add(m); - } else { - hitsBuilder_.addMessage(m); - } - break; - } // case 10 - case 16: { - totalHits_ = input.readInt64(); - bitField0_ |= 0x00000002; - break; - } // case 16 - case 29: { - maxScore_ = input.readFloat(); - bitField0_ |= 0x00000004; - break; - } // case 29 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private java.util.List hits_ = - java.util.Collections.emptyList(); - private void ensureHitsIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - hits_ = new java.util.ArrayList(hits_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - SearchHits.SearchHitProto, SearchHits.SearchHitProto.Builder, SearchHits.SearchHitProtoOrBuilder> hitsBuilder_; - - /** - * repeated .SearchHitProto hits = 1; - */ - public java.util.List getHitsList() { - if (hitsBuilder_ == null) { - return java.util.Collections.unmodifiableList(hits_); - } else { - return hitsBuilder_.getMessageList(); - } - } - /** - * repeated .SearchHitProto hits = 1; - */ - public int getHitsCount() { - if (hitsBuilder_ == null) { - return hits_.size(); - } else { - return hitsBuilder_.getCount(); - } - } - /** - * repeated .SearchHitProto hits = 1; - */ - public SearchHits.SearchHitProto getHits(int index) { - if (hitsBuilder_ == null) { - return hits_.get(index); - } else { - return hitsBuilder_.getMessage(index); - } - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder setHits( - int index, SearchHits.SearchHitProto value) { - if (hitsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHitsIsMutable(); - hits_.set(index, value); - onChanged(); - } else { - hitsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder setHits( - int index, SearchHits.SearchHitProto.Builder builderForValue) { - if (hitsBuilder_ == null) { - ensureHitsIsMutable(); - hits_.set(index, builderForValue.build()); - onChanged(); - } else { - hitsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder addHits(SearchHits.SearchHitProto value) { - if (hitsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHitsIsMutable(); - hits_.add(value); - onChanged(); - } else { - hitsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder addHits( - int index, SearchHits.SearchHitProto value) { - if (hitsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHitsIsMutable(); - hits_.add(index, value); - onChanged(); - } else { - hitsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder addHits( - SearchHits.SearchHitProto.Builder builderForValue) { - if (hitsBuilder_ == null) { - ensureHitsIsMutable(); - hits_.add(builderForValue.build()); - onChanged(); - } else { - hitsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder addHits( - int index, SearchHits.SearchHitProto.Builder builderForValue) { - if (hitsBuilder_ == null) { - ensureHitsIsMutable(); - hits_.add(index, builderForValue.build()); - onChanged(); - } else { - hitsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder addAllHits( - java.lang.Iterable values) { - if (hitsBuilder_ == null) { - ensureHitsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, hits_); - onChanged(); - } else { - hitsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder clearHits() { - if (hitsBuilder_ == null) { - hits_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - hitsBuilder_.clear(); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public Builder removeHits(int index) { - if (hitsBuilder_ == null) { - ensureHitsIsMutable(); - hits_.remove(index); - onChanged(); - } else { - hitsBuilder_.remove(index); - } - return this; - } - /** - * repeated .SearchHitProto hits = 1; - */ - public SearchHits.SearchHitProto.Builder getHitsBuilder( - int index) { - return getHitsFieldBuilder().getBuilder(index); - } - /** - * repeated .SearchHitProto hits = 1; - */ - public SearchHits.SearchHitProtoOrBuilder getHitsOrBuilder( - int index) { - if (hitsBuilder_ == null) { - return hits_.get(index); } else { - return hitsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .SearchHitProto hits = 1; - */ - public java.util.List - getHitsOrBuilderList() { - if (hitsBuilder_ != null) { - return hitsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(hits_); - } - } - /** - * repeated .SearchHitProto hits = 1; - */ - public SearchHits.SearchHitProto.Builder addHitsBuilder() { - return getHitsFieldBuilder().addBuilder( - SearchHits.SearchHitProto.getDefaultInstance()); - } - /** - * repeated .SearchHitProto hits = 1; - */ - public SearchHits.SearchHitProto.Builder addHitsBuilder( - int index) { - return getHitsFieldBuilder().addBuilder( - index, SearchHits.SearchHitProto.getDefaultInstance()); - } - /** - * repeated .SearchHitProto hits = 1; - */ - public java.util.List - getHitsBuilderList() { - return getHitsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilderV3< - SearchHits.SearchHitProto, SearchHits.SearchHitProto.Builder, SearchHits.SearchHitProtoOrBuilder> - getHitsFieldBuilder() { - if (hitsBuilder_ == null) { - hitsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - SearchHits.SearchHitProto, SearchHits.SearchHitProto.Builder, SearchHits.SearchHitProtoOrBuilder>( - hits_, - ((bitField0_ & 0x00000001) != 0), - getParentForChildren(), - isClean()); - hits_ = null; - } - return hitsBuilder_; - } - - private long totalHits_ ; - /** - * int64 total_hits = 2; - * @return The totalHits. - */ - @java.lang.Override - public long getTotalHits() { - return totalHits_; - } - /** - * int64 total_hits = 2; - * @param value The totalHits to set. - * @return This builder for chaining. - */ - public Builder setTotalHits(long value) { - - totalHits_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * int64 total_hits = 2; - * @return This builder for chaining. - */ - public Builder clearTotalHits() { - bitField0_ = (bitField0_ & ~0x00000002); - totalHits_ = 0L; - onChanged(); - return this; - } - - private float maxScore_ ; - /** - * float max_score = 3; - * @return The maxScore. - */ - @java.lang.Override - public float getMaxScore() { - return maxScore_; - } - /** - * float max_score = 3; - * @param value The maxScore to set. - * @return This builder for chaining. - */ - public Builder setMaxScore(float value) { - - maxScore_ = value; - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * float max_score = 3; - * @return This builder for chaining. - */ - public Builder clearMaxScore() { - bitField0_ = (bitField0_ & ~0x00000004); - maxScore_ = 0F; - onChanged(); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:SearchHitsProto) - } - - // @@protoc_insertion_point(class_scope:SearchHitsProto) - private static final SearchHits.SearchHitsProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.SearchHitsProto(); - } - - public static SearchHits.SearchHitsProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public SearchHitsProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.SearchHitsProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface SearchHitProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:SearchHitProto) - com.google.protobuf.MessageOrBuilder { - - /** - * float score = 1; - * @return The score. - */ - float getScore(); - - /** - * string id = 2; - * @return The id. - */ - java.lang.String getId(); - /** - * string id = 2; - * @return The bytes for id. - */ - com.google.protobuf.ByteString - getIdBytes(); - - /** - * .NestedIdentityProto nested_identity = 3; - * @return Whether the nestedIdentity field is set. - */ - boolean hasNestedIdentity(); - /** - * .NestedIdentityProto nested_identity = 3; - * @return The nestedIdentity. - */ - SearchHits.NestedIdentityProto getNestedIdentity(); - /** - * .NestedIdentityProto nested_identity = 3; - */ - SearchHits.NestedIdentityProtoOrBuilder getNestedIdentityOrBuilder(); - - /** - * int64 version = 4; - * @return The version. - */ - long getVersion(); - - /** - * int64 seq_no = 5; - * @return The seqNo. - */ - long getSeqNo(); - - /** - * int64 primary_term = 6; - * @return The primaryTerm. - */ - long getPrimaryTerm(); - - /** - * bytes source = 7; - * @return The source. - */ - com.google.protobuf.ByteString getSource(); - - /** - * .ExplanationProto explanation = 8; - * @return Whether the explanation field is set. - */ - boolean hasExplanation(); - /** - * .ExplanationProto explanation = 8; - * @return The explanation. - */ - SearchHits.ExplanationProto getExplanation(); - /** - * .ExplanationProto explanation = 8; - */ - SearchHits.ExplanationProtoOrBuilder getExplanationOrBuilder(); - - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - int getDocumentFieldsCount(); - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - boolean containsDocumentFields( - java.lang.String key); - /** - * Use {@link #getDocumentFieldsMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getDocumentFields(); - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - java.util.Map - getDocumentFieldsMap(); - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - /* nullable */ -SearchHits.DocumentFieldProto getDocumentFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.DocumentFieldProto defaultValue); - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - SearchHits.DocumentFieldProto getDocumentFieldsOrThrow( - java.lang.String key); - - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - int getMetaFieldsCount(); - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - boolean containsMetaFields( - java.lang.String key); - /** - * Use {@link #getMetaFieldsMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getMetaFields(); - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - java.util.Map - getMetaFieldsMap(); - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - /* nullable */ -SearchHits.DocumentFieldProto getMetaFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.DocumentFieldProto defaultValue); - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - SearchHits.DocumentFieldProto getMetaFieldsOrThrow( - java.lang.String key); - - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - int getHighlightFieldsCount(); - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - boolean containsHighlightFields( - java.lang.String key); - /** - * Use {@link #getHighlightFieldsMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getHighlightFields(); - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - java.util.Map - getHighlightFieldsMap(); - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - /* nullable */ -SearchHits.HighlightFieldProto getHighlightFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.HighlightFieldProto defaultValue); - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - SearchHits.HighlightFieldProto getHighlightFieldsOrThrow( - java.lang.String key); - - /** - * .SearchSortValuesProto sort_values = 12; - * @return Whether the sortValues field is set. - */ - boolean hasSortValues(); - /** - * .SearchSortValuesProto sort_values = 12; - * @return The sortValues. - */ - SearchHits.SearchSortValuesProto getSortValues(); - /** - * .SearchSortValuesProto sort_values = 12; - */ - SearchHits.SearchSortValuesProtoOrBuilder getSortValuesOrBuilder(); - - /** - * map<string, float> matched_queries = 13; - */ - int getMatchedQueriesCount(); - /** - * map<string, float> matched_queries = 13; - */ - boolean containsMatchedQueries( - java.lang.String key); - /** - * Use {@link #getMatchedQueriesMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getMatchedQueries(); - /** - * map<string, float> matched_queries = 13; - */ - java.util.Map - getMatchedQueriesMap(); - /** - * map<string, float> matched_queries = 13; - */ - float getMatchedQueriesOrDefault( - java.lang.String key, - float defaultValue); - /** - * map<string, float> matched_queries = 13; - */ - float getMatchedQueriesOrThrow( - java.lang.String key); - - /** - * .SearchShardTargetProto shard = 14; - * @return Whether the shard field is set. - */ - boolean hasShard(); - /** - * .SearchShardTargetProto shard = 14; - * @return The shard. - */ - SearchHits.SearchShardTargetProto getShard(); - /** - * .SearchShardTargetProto shard = 14; - */ - SearchHits.SearchShardTargetProtoOrBuilder getShardOrBuilder(); - - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - int getInnerHitsCount(); - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - boolean containsInnerHits( - java.lang.String key); - /** - * Use {@link #getInnerHitsMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getInnerHits(); - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - java.util.Map - getInnerHitsMap(); - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - /* nullable */ -SearchHits.SearchHitsProto getInnerHitsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.SearchHitsProto defaultValue); - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - SearchHits.SearchHitsProto getInnerHitsOrThrow( - java.lang.String key); - } - /** - *
-   **
-   *float score
-   *Text id
-   *NestedIdentity nestedIdentity
-   *long version
-   *long seqNo
-   *long primaryTerm
-   *BytesReference source
-   *Explanation explanation
-   *Map<String, DocumentField> documentFields
-   *Map<String, DocumentField> metaFields
-   *Map<String, HighlightField> highlightedFields
-   *SearchSortValues sortValues
-   *Map<String, Float> matchedQueries
-   *SearchShardTarget shard
-   *Map<String, SearchHits> innerHits
-   * 
- * - * Protobuf type {@code SearchHitProto} - */ - public static final class SearchHitProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:SearchHitProto) - SearchHitProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use SearchHitProto.newBuilder() to construct. - private SearchHitProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private SearchHitProto() { - id_ = ""; - source_ = com.google.protobuf.ByteString.EMPTY; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new SearchHitProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_SearchHitProto_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 9: - return internalGetDocumentFields(); - case 10: - return internalGetMetaFields(); - case 11: - return internalGetHighlightFields(); - case 13: - return internalGetMatchedQueries(); - case 15: - return internalGetInnerHits(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_SearchHitProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.SearchHitProto.class, SearchHits.SearchHitProto.Builder.class); - } - - public static final int SCORE_FIELD_NUMBER = 1; - private float score_ = 0F; - /** - * float score = 1; - * @return The score. - */ - @java.lang.Override - public float getScore() { - return score_; - } - - public static final int ID_FIELD_NUMBER = 2; - @SuppressWarnings("serial") - private volatile java.lang.Object id_ = ""; - /** - * string id = 2; - * @return The id. - */ - @java.lang.Override - public java.lang.String getId() { - java.lang.Object ref = id_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - id_ = s; - return s; - } - } - /** - * string id = 2; - * @return The bytes for id. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getIdBytes() { - java.lang.Object ref = id_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - id_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int NESTED_IDENTITY_FIELD_NUMBER = 3; - private SearchHits.NestedIdentityProto nestedIdentity_; - /** - * .NestedIdentityProto nested_identity = 3; - * @return Whether the nestedIdentity field is set. - */ - @java.lang.Override - public boolean hasNestedIdentity() { - return nestedIdentity_ != null; - } - /** - * .NestedIdentityProto nested_identity = 3; - * @return The nestedIdentity. - */ - @java.lang.Override - public SearchHits.NestedIdentityProto getNestedIdentity() { - return nestedIdentity_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : nestedIdentity_; - } - /** - * .NestedIdentityProto nested_identity = 3; - */ - @java.lang.Override - public SearchHits.NestedIdentityProtoOrBuilder getNestedIdentityOrBuilder() { - return nestedIdentity_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : nestedIdentity_; - } - - public static final int VERSION_FIELD_NUMBER = 4; - private long version_ = 0L; - /** - * int64 version = 4; - * @return The version. - */ - @java.lang.Override - public long getVersion() { - return version_; - } - - public static final int SEQ_NO_FIELD_NUMBER = 5; - private long seqNo_ = 0L; - /** - * int64 seq_no = 5; - * @return The seqNo. - */ - @java.lang.Override - public long getSeqNo() { - return seqNo_; - } - - public static final int PRIMARY_TERM_FIELD_NUMBER = 6; - private long primaryTerm_ = 0L; - /** - * int64 primary_term = 6; - * @return The primaryTerm. - */ - @java.lang.Override - public long getPrimaryTerm() { - return primaryTerm_; - } - - public static final int SOURCE_FIELD_NUMBER = 7; - private com.google.protobuf.ByteString source_ = com.google.protobuf.ByteString.EMPTY; - /** - * bytes source = 7; - * @return The source. - */ - @java.lang.Override - public com.google.protobuf.ByteString getSource() { - return source_; - } - - public static final int EXPLANATION_FIELD_NUMBER = 8; - private SearchHits.ExplanationProto explanation_; - /** - * .ExplanationProto explanation = 8; - * @return Whether the explanation field is set. - */ - @java.lang.Override - public boolean hasExplanation() { - return explanation_ != null; - } - /** - * .ExplanationProto explanation = 8; - * @return The explanation. - */ - @java.lang.Override - public SearchHits.ExplanationProto getExplanation() { - return explanation_ == null ? SearchHits.ExplanationProto.getDefaultInstance() : explanation_; - } - /** - * .ExplanationProto explanation = 8; - */ - @java.lang.Override - public SearchHits.ExplanationProtoOrBuilder getExplanationOrBuilder() { - return explanation_ == null ? SearchHits.ExplanationProto.getDefaultInstance() : explanation_; - } - - public static final int DOCUMENT_FIELDS_FIELD_NUMBER = 9; - private static final class DocumentFieldsDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, SearchHits.DocumentFieldProto> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - SearchHits.internal_static_SearchHitProto_DocumentFieldsEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.MESSAGE, - SearchHits.DocumentFieldProto.getDefaultInstance()); - } - @SuppressWarnings("serial") - private com.google.protobuf.MapField< - java.lang.String, SearchHits.DocumentFieldProto> documentFields_; - private com.google.protobuf.MapField - internalGetDocumentFields() { - if (documentFields_ == null) { - return com.google.protobuf.MapField.emptyMapField( - DocumentFieldsDefaultEntryHolder.defaultEntry); - } - return documentFields_; - } - public int getDocumentFieldsCount() { - return internalGetDocumentFields().getMap().size(); - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - @java.lang.Override - public boolean containsDocumentFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetDocumentFields().getMap().containsKey(key); - } - /** - * Use {@link #getDocumentFieldsMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getDocumentFields() { - return getDocumentFieldsMap(); - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - @java.lang.Override - public java.util.Map getDocumentFieldsMap() { - return internalGetDocumentFields().getMap(); - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - @java.lang.Override - public /* nullable */ -SearchHits.DocumentFieldProto getDocumentFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.DocumentFieldProto defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetDocumentFields().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - @java.lang.Override - public SearchHits.DocumentFieldProto getDocumentFieldsOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetDocumentFields().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public static final int META_FIELDS_FIELD_NUMBER = 10; - private static final class MetaFieldsDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, SearchHits.DocumentFieldProto> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - SearchHits.internal_static_SearchHitProto_MetaFieldsEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.MESSAGE, - SearchHits.DocumentFieldProto.getDefaultInstance()); - } - @SuppressWarnings("serial") - private com.google.protobuf.MapField< - java.lang.String, SearchHits.DocumentFieldProto> metaFields_; - private com.google.protobuf.MapField - internalGetMetaFields() { - if (metaFields_ == null) { - return com.google.protobuf.MapField.emptyMapField( - MetaFieldsDefaultEntryHolder.defaultEntry); - } - return metaFields_; - } - public int getMetaFieldsCount() { - return internalGetMetaFields().getMap().size(); - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - @java.lang.Override - public boolean containsMetaFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetMetaFields().getMap().containsKey(key); - } - /** - * Use {@link #getMetaFieldsMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getMetaFields() { - return getMetaFieldsMap(); - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - @java.lang.Override - public java.util.Map getMetaFieldsMap() { - return internalGetMetaFields().getMap(); - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - @java.lang.Override - public /* nullable */ -SearchHits.DocumentFieldProto getMetaFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.DocumentFieldProto defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetMetaFields().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - @java.lang.Override - public SearchHits.DocumentFieldProto getMetaFieldsOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetMetaFields().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public static final int HIGHLIGHT_FIELDS_FIELD_NUMBER = 11; - private static final class HighlightFieldsDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, SearchHits.HighlightFieldProto> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - SearchHits.internal_static_SearchHitProto_HighlightFieldsEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.MESSAGE, - SearchHits.HighlightFieldProto.getDefaultInstance()); - } - @SuppressWarnings("serial") - private com.google.protobuf.MapField< - java.lang.String, SearchHits.HighlightFieldProto> highlightFields_; - private com.google.protobuf.MapField - internalGetHighlightFields() { - if (highlightFields_ == null) { - return com.google.protobuf.MapField.emptyMapField( - HighlightFieldsDefaultEntryHolder.defaultEntry); - } - return highlightFields_; - } - public int getHighlightFieldsCount() { - return internalGetHighlightFields().getMap().size(); - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - @java.lang.Override - public boolean containsHighlightFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetHighlightFields().getMap().containsKey(key); - } - /** - * Use {@link #getHighlightFieldsMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getHighlightFields() { - return getHighlightFieldsMap(); - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - @java.lang.Override - public java.util.Map getHighlightFieldsMap() { - return internalGetHighlightFields().getMap(); - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - @java.lang.Override - public /* nullable */ -SearchHits.HighlightFieldProto getHighlightFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.HighlightFieldProto defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetHighlightFields().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - @java.lang.Override - public SearchHits.HighlightFieldProto getHighlightFieldsOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetHighlightFields().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public static final int SORT_VALUES_FIELD_NUMBER = 12; - private SearchHits.SearchSortValuesProto sortValues_; - /** - * .SearchSortValuesProto sort_values = 12; - * @return Whether the sortValues field is set. - */ - @java.lang.Override - public boolean hasSortValues() { - return sortValues_ != null; - } - /** - * .SearchSortValuesProto sort_values = 12; - * @return The sortValues. - */ - @java.lang.Override - public SearchHits.SearchSortValuesProto getSortValues() { - return sortValues_ == null ? SearchHits.SearchSortValuesProto.getDefaultInstance() : sortValues_; - } - /** - * .SearchSortValuesProto sort_values = 12; - */ - @java.lang.Override - public SearchHits.SearchSortValuesProtoOrBuilder getSortValuesOrBuilder() { - return sortValues_ == null ? SearchHits.SearchSortValuesProto.getDefaultInstance() : sortValues_; - } - - public static final int MATCHED_QUERIES_FIELD_NUMBER = 13; - private static final class MatchedQueriesDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, java.lang.Float> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - SearchHits.internal_static_SearchHitProto_MatchedQueriesEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.FLOAT, - 0F); - } - @SuppressWarnings("serial") - private com.google.protobuf.MapField< - java.lang.String, java.lang.Float> matchedQueries_; - private com.google.protobuf.MapField - internalGetMatchedQueries() { - if (matchedQueries_ == null) { - return com.google.protobuf.MapField.emptyMapField( - MatchedQueriesDefaultEntryHolder.defaultEntry); - } - return matchedQueries_; - } - public int getMatchedQueriesCount() { - return internalGetMatchedQueries().getMap().size(); - } - /** - * map<string, float> matched_queries = 13; - */ - @java.lang.Override - public boolean containsMatchedQueries( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetMatchedQueries().getMap().containsKey(key); - } - /** - * Use {@link #getMatchedQueriesMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getMatchedQueries() { - return getMatchedQueriesMap(); - } - /** - * map<string, float> matched_queries = 13; - */ - @java.lang.Override - public java.util.Map getMatchedQueriesMap() { - return internalGetMatchedQueries().getMap(); - } - /** - * map<string, float> matched_queries = 13; - */ - @java.lang.Override - public float getMatchedQueriesOrDefault( - java.lang.String key, - float defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetMatchedQueries().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, float> matched_queries = 13; - */ - @java.lang.Override - public float getMatchedQueriesOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetMatchedQueries().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public static final int SHARD_FIELD_NUMBER = 14; - private SearchHits.SearchShardTargetProto shard_; - /** - * .SearchShardTargetProto shard = 14; - * @return Whether the shard field is set. - */ - @java.lang.Override - public boolean hasShard() { - return shard_ != null; - } - /** - * .SearchShardTargetProto shard = 14; - * @return The shard. - */ - @java.lang.Override - public SearchHits.SearchShardTargetProto getShard() { - return shard_ == null ? SearchHits.SearchShardTargetProto.getDefaultInstance() : shard_; - } - /** - * .SearchShardTargetProto shard = 14; - */ - @java.lang.Override - public SearchHits.SearchShardTargetProtoOrBuilder getShardOrBuilder() { - return shard_ == null ? SearchHits.SearchShardTargetProto.getDefaultInstance() : shard_; - } - - public static final int INNER_HITS_FIELD_NUMBER = 15; - private static final class InnerHitsDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, SearchHits.SearchHitsProto> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - SearchHits.internal_static_SearchHitProto_InnerHitsEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.MESSAGE, - SearchHits.SearchHitsProto.getDefaultInstance()); - } - @SuppressWarnings("serial") - private com.google.protobuf.MapField< - java.lang.String, SearchHits.SearchHitsProto> innerHits_; - private com.google.protobuf.MapField - internalGetInnerHits() { - if (innerHits_ == null) { - return com.google.protobuf.MapField.emptyMapField( - InnerHitsDefaultEntryHolder.defaultEntry); - } - return innerHits_; - } - public int getInnerHitsCount() { - return internalGetInnerHits().getMap().size(); - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - @java.lang.Override - public boolean containsInnerHits( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetInnerHits().getMap().containsKey(key); - } - /** - * Use {@link #getInnerHitsMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getInnerHits() { - return getInnerHitsMap(); - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - @java.lang.Override - public java.util.Map getInnerHitsMap() { - return internalGetInnerHits().getMap(); - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - @java.lang.Override - public /* nullable */ -SearchHits.SearchHitsProto getInnerHitsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.SearchHitsProto defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetInnerHits().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - @java.lang.Override - public SearchHits.SearchHitsProto getInnerHitsOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetInnerHits().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (java.lang.Float.floatToRawIntBits(score_) != 0) { - output.writeFloat(1, score_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, id_); - } - if (nestedIdentity_ != null) { - output.writeMessage(3, getNestedIdentity()); - } - if (version_ != 0L) { - output.writeInt64(4, version_); - } - if (seqNo_ != 0L) { - output.writeInt64(5, seqNo_); - } - if (primaryTerm_ != 0L) { - output.writeInt64(6, primaryTerm_); - } - if (!source_.isEmpty()) { - output.writeBytes(7, source_); - } - if (explanation_ != null) { - output.writeMessage(8, getExplanation()); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetDocumentFields(), - DocumentFieldsDefaultEntryHolder.defaultEntry, - 9); - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetMetaFields(), - MetaFieldsDefaultEntryHolder.defaultEntry, - 10); - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetHighlightFields(), - HighlightFieldsDefaultEntryHolder.defaultEntry, - 11); - if (sortValues_ != null) { - output.writeMessage(12, getSortValues()); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetMatchedQueries(), - MatchedQueriesDefaultEntryHolder.defaultEntry, - 13); - if (shard_ != null) { - output.writeMessage(14, getShard()); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetInnerHits(), - InnerHitsDefaultEntryHolder.defaultEntry, - 15); - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (java.lang.Float.floatToRawIntBits(score_) != 0) { - size += com.google.protobuf.CodedOutputStream - .computeFloatSize(1, score_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, id_); - } - if (nestedIdentity_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, getNestedIdentity()); - } - if (version_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, version_); - } - if (seqNo_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(5, seqNo_); - } - if (primaryTerm_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(6, primaryTerm_); - } - if (!source_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(7, source_); - } - if (explanation_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(8, getExplanation()); - } - for (java.util.Map.Entry entry - : internalGetDocumentFields().getMap().entrySet()) { - com.google.protobuf.MapEntry - documentFields__ = DocumentFieldsDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(9, documentFields__); - } - for (java.util.Map.Entry entry - : internalGetMetaFields().getMap().entrySet()) { - com.google.protobuf.MapEntry - metaFields__ = MetaFieldsDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(10, metaFields__); - } - for (java.util.Map.Entry entry - : internalGetHighlightFields().getMap().entrySet()) { - com.google.protobuf.MapEntry - highlightFields__ = HighlightFieldsDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(11, highlightFields__); - } - if (sortValues_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(12, getSortValues()); - } - for (java.util.Map.Entry entry - : internalGetMatchedQueries().getMap().entrySet()) { - com.google.protobuf.MapEntry - matchedQueries__ = MatchedQueriesDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(13, matchedQueries__); - } - if (shard_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(14, getShard()); - } - for (java.util.Map.Entry entry - : internalGetInnerHits().getMap().entrySet()) { - com.google.protobuf.MapEntry - innerHits__ = InnerHitsDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(15, innerHits__); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.SearchHitProto)) { - return super.equals(obj); - } - SearchHits.SearchHitProto other = (SearchHits.SearchHitProto) obj; - - if (java.lang.Float.floatToIntBits(getScore()) - != java.lang.Float.floatToIntBits( - other.getScore())) return false; - if (!getId() - .equals(other.getId())) return false; - if (hasNestedIdentity() != other.hasNestedIdentity()) return false; - if (hasNestedIdentity()) { - if (!getNestedIdentity() - .equals(other.getNestedIdentity())) return false; - } - if (getVersion() - != other.getVersion()) return false; - if (getSeqNo() - != other.getSeqNo()) return false; - if (getPrimaryTerm() - != other.getPrimaryTerm()) return false; - if (!getSource() - .equals(other.getSource())) return false; - if (hasExplanation() != other.hasExplanation()) return false; - if (hasExplanation()) { - if (!getExplanation() - .equals(other.getExplanation())) return false; - } - if (!internalGetDocumentFields().equals( - other.internalGetDocumentFields())) return false; - if (!internalGetMetaFields().equals( - other.internalGetMetaFields())) return false; - if (!internalGetHighlightFields().equals( - other.internalGetHighlightFields())) return false; - if (hasSortValues() != other.hasSortValues()) return false; - if (hasSortValues()) { - if (!getSortValues() - .equals(other.getSortValues())) return false; - } - if (!internalGetMatchedQueries().equals( - other.internalGetMatchedQueries())) return false; - if (hasShard() != other.hasShard()) return false; - if (hasShard()) { - if (!getShard() - .equals(other.getShard())) return false; - } - if (!internalGetInnerHits().equals( - other.internalGetInnerHits())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + SCORE_FIELD_NUMBER; - hash = (53 * hash) + java.lang.Float.floatToIntBits( - getScore()); - hash = (37 * hash) + ID_FIELD_NUMBER; - hash = (53 * hash) + getId().hashCode(); - if (hasNestedIdentity()) { - hash = (37 * hash) + NESTED_IDENTITY_FIELD_NUMBER; - hash = (53 * hash) + getNestedIdentity().hashCode(); - } - hash = (37 * hash) + VERSION_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getVersion()); - hash = (37 * hash) + SEQ_NO_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getSeqNo()); - hash = (37 * hash) + PRIMARY_TERM_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getPrimaryTerm()); - hash = (37 * hash) + SOURCE_FIELD_NUMBER; - hash = (53 * hash) + getSource().hashCode(); - if (hasExplanation()) { - hash = (37 * hash) + EXPLANATION_FIELD_NUMBER; - hash = (53 * hash) + getExplanation().hashCode(); - } - if (!internalGetDocumentFields().getMap().isEmpty()) { - hash = (37 * hash) + DOCUMENT_FIELDS_FIELD_NUMBER; - hash = (53 * hash) + internalGetDocumentFields().hashCode(); - } - if (!internalGetMetaFields().getMap().isEmpty()) { - hash = (37 * hash) + META_FIELDS_FIELD_NUMBER; - hash = (53 * hash) + internalGetMetaFields().hashCode(); - } - if (!internalGetHighlightFields().getMap().isEmpty()) { - hash = (37 * hash) + HIGHLIGHT_FIELDS_FIELD_NUMBER; - hash = (53 * hash) + internalGetHighlightFields().hashCode(); - } - if (hasSortValues()) { - hash = (37 * hash) + SORT_VALUES_FIELD_NUMBER; - hash = (53 * hash) + getSortValues().hashCode(); - } - if (!internalGetMatchedQueries().getMap().isEmpty()) { - hash = (37 * hash) + MATCHED_QUERIES_FIELD_NUMBER; - hash = (53 * hash) + internalGetMatchedQueries().hashCode(); - } - if (hasShard()) { - hash = (37 * hash) + SHARD_FIELD_NUMBER; - hash = (53 * hash) + getShard().hashCode(); - } - if (!internalGetInnerHits().getMap().isEmpty()) { - hash = (37 * hash) + INNER_HITS_FIELD_NUMBER; - hash = (53 * hash) + internalGetInnerHits().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.SearchHitProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchHitProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchHitProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchHitProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchHitProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchHitProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchHitProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.SearchHitProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.SearchHitProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.SearchHitProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.SearchHitProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.SearchHitProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.SearchHitProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     **
-     *float score
-     *Text id
-     *NestedIdentity nestedIdentity
-     *long version
-     *long seqNo
-     *long primaryTerm
-     *BytesReference source
-     *Explanation explanation
-     *Map<String, DocumentField> documentFields
-     *Map<String, DocumentField> metaFields
-     *Map<String, HighlightField> highlightedFields
-     *SearchSortValues sortValues
-     *Map<String, Float> matchedQueries
-     *SearchShardTarget shard
-     *Map<String, SearchHits> innerHits
-     * 
- * - * Protobuf type {@code SearchHitProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:SearchHitProto) - SearchHits.SearchHitProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_SearchHitProto_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 9: - return internalGetDocumentFields(); - case 10: - return internalGetMetaFields(); - case 11: - return internalGetHighlightFields(); - case 13: - return internalGetMatchedQueries(); - case 15: - return internalGetInnerHits(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 9: - return internalGetMutableDocumentFields(); - case 10: - return internalGetMutableMetaFields(); - case 11: - return internalGetMutableHighlightFields(); - case 13: - return internalGetMutableMatchedQueries(); - case 15: - return internalGetMutableInnerHits(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_SearchHitProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.SearchHitProto.class, SearchHits.SearchHitProto.Builder.class); - } - - // Construct using SearchHits.SearchHitProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - score_ = 0F; - id_ = ""; - nestedIdentity_ = null; - if (nestedIdentityBuilder_ != null) { - nestedIdentityBuilder_.dispose(); - nestedIdentityBuilder_ = null; - } - version_ = 0L; - seqNo_ = 0L; - primaryTerm_ = 0L; - source_ = com.google.protobuf.ByteString.EMPTY; - explanation_ = null; - if (explanationBuilder_ != null) { - explanationBuilder_.dispose(); - explanationBuilder_ = null; - } - internalGetMutableDocumentFields().clear(); - internalGetMutableMetaFields().clear(); - internalGetMutableHighlightFields().clear(); - sortValues_ = null; - if (sortValuesBuilder_ != null) { - sortValuesBuilder_.dispose(); - sortValuesBuilder_ = null; - } - internalGetMutableMatchedQueries().clear(); - shard_ = null; - if (shardBuilder_ != null) { - shardBuilder_.dispose(); - shardBuilder_ = null; - } - internalGetMutableInnerHits().clear(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_SearchHitProto_descriptor; - } - - @java.lang.Override - public SearchHits.SearchHitProto getDefaultInstanceForType() { - return SearchHits.SearchHitProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.SearchHitProto build() { - SearchHits.SearchHitProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.SearchHitProto buildPartial() { - SearchHits.SearchHitProto result = new SearchHits.SearchHitProto(this); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartial0(SearchHits.SearchHitProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.score_ = score_; - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.id_ = id_; - } - if (((from_bitField0_ & 0x00000004) != 0)) { - result.nestedIdentity_ = nestedIdentityBuilder_ == null - ? nestedIdentity_ - : nestedIdentityBuilder_.build(); - } - if (((from_bitField0_ & 0x00000008) != 0)) { - result.version_ = version_; - } - if (((from_bitField0_ & 0x00000010) != 0)) { - result.seqNo_ = seqNo_; - } - if (((from_bitField0_ & 0x00000020) != 0)) { - result.primaryTerm_ = primaryTerm_; - } - if (((from_bitField0_ & 0x00000040) != 0)) { - result.source_ = source_; - } - if (((from_bitField0_ & 0x00000080) != 0)) { - result.explanation_ = explanationBuilder_ == null - ? explanation_ - : explanationBuilder_.build(); - } - if (((from_bitField0_ & 0x00000100) != 0)) { - result.documentFields_ = internalGetDocumentFields(); - result.documentFields_.makeImmutable(); - } - if (((from_bitField0_ & 0x00000200) != 0)) { - result.metaFields_ = internalGetMetaFields(); - result.metaFields_.makeImmutable(); - } - if (((from_bitField0_ & 0x00000400) != 0)) { - result.highlightFields_ = internalGetHighlightFields(); - result.highlightFields_.makeImmutable(); - } - if (((from_bitField0_ & 0x00000800) != 0)) { - result.sortValues_ = sortValuesBuilder_ == null - ? sortValues_ - : sortValuesBuilder_.build(); - } - if (((from_bitField0_ & 0x00001000) != 0)) { - result.matchedQueries_ = internalGetMatchedQueries(); - result.matchedQueries_.makeImmutable(); - } - if (((from_bitField0_ & 0x00002000) != 0)) { - result.shard_ = shardBuilder_ == null - ? shard_ - : shardBuilder_.build(); - } - if (((from_bitField0_ & 0x00004000) != 0)) { - result.innerHits_ = internalGetInnerHits(); - result.innerHits_.makeImmutable(); - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.SearchHitProto) { - return mergeFrom((SearchHits.SearchHitProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.SearchHitProto other) { - if (other == SearchHits.SearchHitProto.getDefaultInstance()) return this; - if (other.getScore() != 0F) { - setScore(other.getScore()); - } - if (!other.getId().isEmpty()) { - id_ = other.id_; - bitField0_ |= 0x00000002; - onChanged(); - } - if (other.hasNestedIdentity()) { - mergeNestedIdentity(other.getNestedIdentity()); - } - if (other.getVersion() != 0L) { - setVersion(other.getVersion()); - } - if (other.getSeqNo() != 0L) { - setSeqNo(other.getSeqNo()); - } - if (other.getPrimaryTerm() != 0L) { - setPrimaryTerm(other.getPrimaryTerm()); - } - if (other.getSource() != com.google.protobuf.ByteString.EMPTY) { - setSource(other.getSource()); - } - if (other.hasExplanation()) { - mergeExplanation(other.getExplanation()); - } - internalGetMutableDocumentFields().mergeFrom( - other.internalGetDocumentFields()); - bitField0_ |= 0x00000100; - internalGetMutableMetaFields().mergeFrom( - other.internalGetMetaFields()); - bitField0_ |= 0x00000200; - internalGetMutableHighlightFields().mergeFrom( - other.internalGetHighlightFields()); - bitField0_ |= 0x00000400; - if (other.hasSortValues()) { - mergeSortValues(other.getSortValues()); - } - internalGetMutableMatchedQueries().mergeFrom( - other.internalGetMatchedQueries()); - bitField0_ |= 0x00001000; - if (other.hasShard()) { - mergeShard(other.getShard()); - } - internalGetMutableInnerHits().mergeFrom( - other.internalGetInnerHits()); - bitField0_ |= 0x00004000; - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 13: { - score_ = input.readFloat(); - bitField0_ |= 0x00000001; - break; - } // case 13 - case 18: { - id_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000002; - break; - } // case 18 - case 26: { - input.readMessage( - getNestedIdentityFieldBuilder().getBuilder(), - extensionRegistry); - bitField0_ |= 0x00000004; - break; - } // case 26 - case 32: { - version_ = input.readInt64(); - bitField0_ |= 0x00000008; - break; - } // case 32 - case 40: { - seqNo_ = input.readInt64(); - bitField0_ |= 0x00000010; - break; - } // case 40 - case 48: { - primaryTerm_ = input.readInt64(); - bitField0_ |= 0x00000020; - break; - } // case 48 - case 58: { - source_ = input.readBytes(); - bitField0_ |= 0x00000040; - break; - } // case 58 - case 66: { - input.readMessage( - getExplanationFieldBuilder().getBuilder(), - extensionRegistry); - bitField0_ |= 0x00000080; - break; - } // case 66 - case 74: { - com.google.protobuf.MapEntry - documentFields__ = input.readMessage( - DocumentFieldsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableDocumentFields().getMutableMap().put( - documentFields__.getKey(), documentFields__.getValue()); - bitField0_ |= 0x00000100; - break; - } // case 74 - case 82: { - com.google.protobuf.MapEntry - metaFields__ = input.readMessage( - MetaFieldsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableMetaFields().getMutableMap().put( - metaFields__.getKey(), metaFields__.getValue()); - bitField0_ |= 0x00000200; - break; - } // case 82 - case 90: { - com.google.protobuf.MapEntry - highlightFields__ = input.readMessage( - HighlightFieldsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableHighlightFields().getMutableMap().put( - highlightFields__.getKey(), highlightFields__.getValue()); - bitField0_ |= 0x00000400; - break; - } // case 90 - case 98: { - input.readMessage( - getSortValuesFieldBuilder().getBuilder(), - extensionRegistry); - bitField0_ |= 0x00000800; - break; - } // case 98 - case 106: { - com.google.protobuf.MapEntry - matchedQueries__ = input.readMessage( - MatchedQueriesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableMatchedQueries().getMutableMap().put( - matchedQueries__.getKey(), matchedQueries__.getValue()); - bitField0_ |= 0x00001000; - break; - } // case 106 - case 114: { - input.readMessage( - getShardFieldBuilder().getBuilder(), - extensionRegistry); - bitField0_ |= 0x00002000; - break; - } // case 114 - case 122: { - com.google.protobuf.MapEntry - innerHits__ = input.readMessage( - InnerHitsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableInnerHits().getMutableMap().put( - innerHits__.getKey(), innerHits__.getValue()); - bitField0_ |= 0x00004000; - break; - } // case 122 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private float score_ ; - /** - * float score = 1; - * @return The score. - */ - @java.lang.Override - public float getScore() { - return score_; - } - /** - * float score = 1; - * @param value The score to set. - * @return This builder for chaining. - */ - public Builder setScore(float value) { - - score_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * float score = 1; - * @return This builder for chaining. - */ - public Builder clearScore() { - bitField0_ = (bitField0_ & ~0x00000001); - score_ = 0F; - onChanged(); - return this; - } - - private java.lang.Object id_ = ""; - /** - * string id = 2; - * @return The id. - */ - public java.lang.String getId() { - java.lang.Object ref = id_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - id_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string id = 2; - * @return The bytes for id. - */ - public com.google.protobuf.ByteString - getIdBytes() { - java.lang.Object ref = id_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - id_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string id = 2; - * @param value The id to set. - * @return This builder for chaining. - */ - public Builder setId( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - id_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * string id = 2; - * @return This builder for chaining. - */ - public Builder clearId() { - id_ = getDefaultInstance().getId(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * string id = 2; - * @param value The bytes for id to set. - * @return This builder for chaining. - */ - public Builder setIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - id_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - - private SearchHits.NestedIdentityProto nestedIdentity_; - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder> nestedIdentityBuilder_; - /** - * .NestedIdentityProto nested_identity = 3; - * @return Whether the nestedIdentity field is set. - */ - public boolean hasNestedIdentity() { - return ((bitField0_ & 0x00000004) != 0); - } - /** - * .NestedIdentityProto nested_identity = 3; - * @return The nestedIdentity. - */ - public SearchHits.NestedIdentityProto getNestedIdentity() { - if (nestedIdentityBuilder_ == null) { - return nestedIdentity_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : nestedIdentity_; - } else { - return nestedIdentityBuilder_.getMessage(); - } - } - /** - * .NestedIdentityProto nested_identity = 3; - */ - public Builder setNestedIdentity(SearchHits.NestedIdentityProto value) { - if (nestedIdentityBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - nestedIdentity_ = value; - } else { - nestedIdentityBuilder_.setMessage(value); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * .NestedIdentityProto nested_identity = 3; - */ - public Builder setNestedIdentity( - SearchHits.NestedIdentityProto.Builder builderForValue) { - if (nestedIdentityBuilder_ == null) { - nestedIdentity_ = builderForValue.build(); - } else { - nestedIdentityBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * .NestedIdentityProto nested_identity = 3; - */ - public Builder mergeNestedIdentity(SearchHits.NestedIdentityProto value) { - if (nestedIdentityBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0) && - nestedIdentity_ != null && - nestedIdentity_ != SearchHits.NestedIdentityProto.getDefaultInstance()) { - getNestedIdentityBuilder().mergeFrom(value); - } else { - nestedIdentity_ = value; - } - } else { - nestedIdentityBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * .NestedIdentityProto nested_identity = 3; - */ - public Builder clearNestedIdentity() { - bitField0_ = (bitField0_ & ~0x00000004); - nestedIdentity_ = null; - if (nestedIdentityBuilder_ != null) { - nestedIdentityBuilder_.dispose(); - nestedIdentityBuilder_ = null; - } - onChanged(); - return this; - } - /** - * .NestedIdentityProto nested_identity = 3; - */ - public SearchHits.NestedIdentityProto.Builder getNestedIdentityBuilder() { - bitField0_ |= 0x00000004; - onChanged(); - return getNestedIdentityFieldBuilder().getBuilder(); - } - /** - * .NestedIdentityProto nested_identity = 3; - */ - public SearchHits.NestedIdentityProtoOrBuilder getNestedIdentityOrBuilder() { - if (nestedIdentityBuilder_ != null) { - return nestedIdentityBuilder_.getMessageOrBuilder(); - } else { - return nestedIdentity_ == null ? - SearchHits.NestedIdentityProto.getDefaultInstance() : nestedIdentity_; - } - } - /** - * .NestedIdentityProto nested_identity = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder> - getNestedIdentityFieldBuilder() { - if (nestedIdentityBuilder_ == null) { - nestedIdentityBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder>( - getNestedIdentity(), - getParentForChildren(), - isClean()); - nestedIdentity_ = null; - } - return nestedIdentityBuilder_; - } - - private long version_ ; - /** - * int64 version = 4; - * @return The version. - */ - @java.lang.Override - public long getVersion() { - return version_; - } - /** - * int64 version = 4; - * @param value The version to set. - * @return This builder for chaining. - */ - public Builder setVersion(long value) { - - version_ = value; - bitField0_ |= 0x00000008; - onChanged(); - return this; - } - /** - * int64 version = 4; - * @return This builder for chaining. - */ - public Builder clearVersion() { - bitField0_ = (bitField0_ & ~0x00000008); - version_ = 0L; - onChanged(); - return this; - } - - private long seqNo_ ; - /** - * int64 seq_no = 5; - * @return The seqNo. - */ - @java.lang.Override - public long getSeqNo() { - return seqNo_; - } - /** - * int64 seq_no = 5; - * @param value The seqNo to set. - * @return This builder for chaining. - */ - public Builder setSeqNo(long value) { - - seqNo_ = value; - bitField0_ |= 0x00000010; - onChanged(); - return this; - } - /** - * int64 seq_no = 5; - * @return This builder for chaining. - */ - public Builder clearSeqNo() { - bitField0_ = (bitField0_ & ~0x00000010); - seqNo_ = 0L; - onChanged(); - return this; - } - - private long primaryTerm_ ; - /** - * int64 primary_term = 6; - * @return The primaryTerm. - */ - @java.lang.Override - public long getPrimaryTerm() { - return primaryTerm_; - } - /** - * int64 primary_term = 6; - * @param value The primaryTerm to set. - * @return This builder for chaining. - */ - public Builder setPrimaryTerm(long value) { - - primaryTerm_ = value; - bitField0_ |= 0x00000020; - onChanged(); - return this; - } - /** - * int64 primary_term = 6; - * @return This builder for chaining. - */ - public Builder clearPrimaryTerm() { - bitField0_ = (bitField0_ & ~0x00000020); - primaryTerm_ = 0L; - onChanged(); - return this; - } - - private com.google.protobuf.ByteString source_ = com.google.protobuf.ByteString.EMPTY; - /** - * bytes source = 7; - * @return The source. - */ - @java.lang.Override - public com.google.protobuf.ByteString getSource() { - return source_; - } - /** - * bytes source = 7; - * @param value The source to set. - * @return This builder for chaining. - */ - public Builder setSource(com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - source_ = value; - bitField0_ |= 0x00000040; - onChanged(); - return this; - } - /** - * bytes source = 7; - * @return This builder for chaining. - */ - public Builder clearSource() { - bitField0_ = (bitField0_ & ~0x00000040); - source_ = getDefaultInstance().getSource(); - onChanged(); - return this; - } - - private SearchHits.ExplanationProto explanation_; - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder> explanationBuilder_; - /** - * .ExplanationProto explanation = 8; - * @return Whether the explanation field is set. - */ - public boolean hasExplanation() { - return ((bitField0_ & 0x00000080) != 0); - } - /** - * .ExplanationProto explanation = 8; - * @return The explanation. - */ - public SearchHits.ExplanationProto getExplanation() { - if (explanationBuilder_ == null) { - return explanation_ == null ? SearchHits.ExplanationProto.getDefaultInstance() : explanation_; - } else { - return explanationBuilder_.getMessage(); - } - } - /** - * .ExplanationProto explanation = 8; - */ - public Builder setExplanation(SearchHits.ExplanationProto value) { - if (explanationBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - explanation_ = value; - } else { - explanationBuilder_.setMessage(value); - } - bitField0_ |= 0x00000080; - onChanged(); - return this; - } - /** - * .ExplanationProto explanation = 8; - */ - public Builder setExplanation( - SearchHits.ExplanationProto.Builder builderForValue) { - if (explanationBuilder_ == null) { - explanation_ = builderForValue.build(); - } else { - explanationBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000080; - onChanged(); - return this; - } - /** - * .ExplanationProto explanation = 8; - */ - public Builder mergeExplanation(SearchHits.ExplanationProto value) { - if (explanationBuilder_ == null) { - if (((bitField0_ & 0x00000080) != 0) && - explanation_ != null && - explanation_ != SearchHits.ExplanationProto.getDefaultInstance()) { - getExplanationBuilder().mergeFrom(value); - } else { - explanation_ = value; - } - } else { - explanationBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000080; - onChanged(); - return this; - } - /** - * .ExplanationProto explanation = 8; - */ - public Builder clearExplanation() { - bitField0_ = (bitField0_ & ~0x00000080); - explanation_ = null; - if (explanationBuilder_ != null) { - explanationBuilder_.dispose(); - explanationBuilder_ = null; - } - onChanged(); - return this; - } - /** - * .ExplanationProto explanation = 8; - */ - public SearchHits.ExplanationProto.Builder getExplanationBuilder() { - bitField0_ |= 0x00000080; - onChanged(); - return getExplanationFieldBuilder().getBuilder(); - } - /** - * .ExplanationProto explanation = 8; - */ - public SearchHits.ExplanationProtoOrBuilder getExplanationOrBuilder() { - if (explanationBuilder_ != null) { - return explanationBuilder_.getMessageOrBuilder(); - } else { - return explanation_ == null ? - SearchHits.ExplanationProto.getDefaultInstance() : explanation_; - } - } - /** - * .ExplanationProto explanation = 8; - */ - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder> - getExplanationFieldBuilder() { - if (explanationBuilder_ == null) { - explanationBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder>( - getExplanation(), - getParentForChildren(), - isClean()); - explanation_ = null; - } - return explanationBuilder_; - } - - private com.google.protobuf.MapField< - java.lang.String, SearchHits.DocumentFieldProto> documentFields_; - private com.google.protobuf.MapField - internalGetDocumentFields() { - if (documentFields_ == null) { - return com.google.protobuf.MapField.emptyMapField( - DocumentFieldsDefaultEntryHolder.defaultEntry); - } - return documentFields_; - } - private com.google.protobuf.MapField - internalGetMutableDocumentFields() { - if (documentFields_ == null) { - documentFields_ = com.google.protobuf.MapField.newMapField( - DocumentFieldsDefaultEntryHolder.defaultEntry); - } - if (!documentFields_.isMutable()) { - documentFields_ = documentFields_.copy(); - } - bitField0_ |= 0x00000100; - onChanged(); - return documentFields_; - } - public int getDocumentFieldsCount() { - return internalGetDocumentFields().getMap().size(); - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - @java.lang.Override - public boolean containsDocumentFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetDocumentFields().getMap().containsKey(key); - } - /** - * Use {@link #getDocumentFieldsMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getDocumentFields() { - return getDocumentFieldsMap(); - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - @java.lang.Override - public java.util.Map getDocumentFieldsMap() { - return internalGetDocumentFields().getMap(); - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - @java.lang.Override - public /* nullable */ -SearchHits.DocumentFieldProto getDocumentFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.DocumentFieldProto defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetDocumentFields().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - @java.lang.Override - public SearchHits.DocumentFieldProto getDocumentFieldsOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetDocumentFields().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - public Builder clearDocumentFields() { - bitField0_ = (bitField0_ & ~0x00000100); - internalGetMutableDocumentFields().getMutableMap() - .clear(); - return this; - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - public Builder removeDocumentFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableDocumentFields().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableDocumentFields() { - bitField0_ |= 0x00000100; - return internalGetMutableDocumentFields().getMutableMap(); - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - public Builder putDocumentFields( - java.lang.String key, - SearchHits.DocumentFieldProto value) { - if (key == null) { throw new NullPointerException("map key"); } - if (value == null) { throw new NullPointerException("map value"); } - internalGetMutableDocumentFields().getMutableMap() - .put(key, value); - bitField0_ |= 0x00000100; - return this; - } - /** - * map<string, .DocumentFieldProto> document_fields = 9; - */ - public Builder putAllDocumentFields( - java.util.Map values) { - internalGetMutableDocumentFields().getMutableMap() - .putAll(values); - bitField0_ |= 0x00000100; - return this; - } - - private com.google.protobuf.MapField< - java.lang.String, SearchHits.DocumentFieldProto> metaFields_; - private com.google.protobuf.MapField - internalGetMetaFields() { - if (metaFields_ == null) { - return com.google.protobuf.MapField.emptyMapField( - MetaFieldsDefaultEntryHolder.defaultEntry); - } - return metaFields_; - } - private com.google.protobuf.MapField - internalGetMutableMetaFields() { - if (metaFields_ == null) { - metaFields_ = com.google.protobuf.MapField.newMapField( - MetaFieldsDefaultEntryHolder.defaultEntry); - } - if (!metaFields_.isMutable()) { - metaFields_ = metaFields_.copy(); - } - bitField0_ |= 0x00000200; - onChanged(); - return metaFields_; - } - public int getMetaFieldsCount() { - return internalGetMetaFields().getMap().size(); - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - @java.lang.Override - public boolean containsMetaFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetMetaFields().getMap().containsKey(key); - } - /** - * Use {@link #getMetaFieldsMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getMetaFields() { - return getMetaFieldsMap(); - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - @java.lang.Override - public java.util.Map getMetaFieldsMap() { - return internalGetMetaFields().getMap(); - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - @java.lang.Override - public /* nullable */ -SearchHits.DocumentFieldProto getMetaFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.DocumentFieldProto defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetMetaFields().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - @java.lang.Override - public SearchHits.DocumentFieldProto getMetaFieldsOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetMetaFields().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - public Builder clearMetaFields() { - bitField0_ = (bitField0_ & ~0x00000200); - internalGetMutableMetaFields().getMutableMap() - .clear(); - return this; - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - public Builder removeMetaFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableMetaFields().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableMetaFields() { - bitField0_ |= 0x00000200; - return internalGetMutableMetaFields().getMutableMap(); - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - public Builder putMetaFields( - java.lang.String key, - SearchHits.DocumentFieldProto value) { - if (key == null) { throw new NullPointerException("map key"); } - if (value == null) { throw new NullPointerException("map value"); } - internalGetMutableMetaFields().getMutableMap() - .put(key, value); - bitField0_ |= 0x00000200; - return this; - } - /** - * map<string, .DocumentFieldProto> meta_fields = 10; - */ - public Builder putAllMetaFields( - java.util.Map values) { - internalGetMutableMetaFields().getMutableMap() - .putAll(values); - bitField0_ |= 0x00000200; - return this; - } - - private com.google.protobuf.MapField< - java.lang.String, SearchHits.HighlightFieldProto> highlightFields_; - private com.google.protobuf.MapField - internalGetHighlightFields() { - if (highlightFields_ == null) { - return com.google.protobuf.MapField.emptyMapField( - HighlightFieldsDefaultEntryHolder.defaultEntry); - } - return highlightFields_; - } - private com.google.protobuf.MapField - internalGetMutableHighlightFields() { - if (highlightFields_ == null) { - highlightFields_ = com.google.protobuf.MapField.newMapField( - HighlightFieldsDefaultEntryHolder.defaultEntry); - } - if (!highlightFields_.isMutable()) { - highlightFields_ = highlightFields_.copy(); - } - bitField0_ |= 0x00000400; - onChanged(); - return highlightFields_; - } - public int getHighlightFieldsCount() { - return internalGetHighlightFields().getMap().size(); - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - @java.lang.Override - public boolean containsHighlightFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetHighlightFields().getMap().containsKey(key); - } - /** - * Use {@link #getHighlightFieldsMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getHighlightFields() { - return getHighlightFieldsMap(); - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - @java.lang.Override - public java.util.Map getHighlightFieldsMap() { - return internalGetHighlightFields().getMap(); - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - @java.lang.Override - public /* nullable */ -SearchHits.HighlightFieldProto getHighlightFieldsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.HighlightFieldProto defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetHighlightFields().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - @java.lang.Override - public SearchHits.HighlightFieldProto getHighlightFieldsOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetHighlightFields().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - public Builder clearHighlightFields() { - bitField0_ = (bitField0_ & ~0x00000400); - internalGetMutableHighlightFields().getMutableMap() - .clear(); - return this; - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - public Builder removeHighlightFields( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableHighlightFields().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableHighlightFields() { - bitField0_ |= 0x00000400; - return internalGetMutableHighlightFields().getMutableMap(); - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - public Builder putHighlightFields( - java.lang.String key, - SearchHits.HighlightFieldProto value) { - if (key == null) { throw new NullPointerException("map key"); } - if (value == null) { throw new NullPointerException("map value"); } - internalGetMutableHighlightFields().getMutableMap() - .put(key, value); - bitField0_ |= 0x00000400; - return this; - } - /** - * map<string, .HighlightFieldProto> highlight_fields = 11; - */ - public Builder putAllHighlightFields( - java.util.Map values) { - internalGetMutableHighlightFields().getMutableMap() - .putAll(values); - bitField0_ |= 0x00000400; - return this; - } - - private SearchHits.SearchSortValuesProto sortValues_; - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.SearchSortValuesProto, SearchHits.SearchSortValuesProto.Builder, SearchHits.SearchSortValuesProtoOrBuilder> sortValuesBuilder_; - /** - * .SearchSortValuesProto sort_values = 12; - * @return Whether the sortValues field is set. - */ - public boolean hasSortValues() { - return ((bitField0_ & 0x00000800) != 0); - } - /** - * .SearchSortValuesProto sort_values = 12; - * @return The sortValues. - */ - public SearchHits.SearchSortValuesProto getSortValues() { - if (sortValuesBuilder_ == null) { - return sortValues_ == null ? SearchHits.SearchSortValuesProto.getDefaultInstance() : sortValues_; - } else { - return sortValuesBuilder_.getMessage(); - } - } - /** - * .SearchSortValuesProto sort_values = 12; - */ - public Builder setSortValues(SearchHits.SearchSortValuesProto value) { - if (sortValuesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - sortValues_ = value; - } else { - sortValuesBuilder_.setMessage(value); - } - bitField0_ |= 0x00000800; - onChanged(); - return this; - } - /** - * .SearchSortValuesProto sort_values = 12; - */ - public Builder setSortValues( - SearchHits.SearchSortValuesProto.Builder builderForValue) { - if (sortValuesBuilder_ == null) { - sortValues_ = builderForValue.build(); - } else { - sortValuesBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000800; - onChanged(); - return this; - } - /** - * .SearchSortValuesProto sort_values = 12; - */ - public Builder mergeSortValues(SearchHits.SearchSortValuesProto value) { - if (sortValuesBuilder_ == null) { - if (((bitField0_ & 0x00000800) != 0) && - sortValues_ != null && - sortValues_ != SearchHits.SearchSortValuesProto.getDefaultInstance()) { - getSortValuesBuilder().mergeFrom(value); - } else { - sortValues_ = value; - } - } else { - sortValuesBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000800; - onChanged(); - return this; - } - /** - * .SearchSortValuesProto sort_values = 12; - */ - public Builder clearSortValues() { - bitField0_ = (bitField0_ & ~0x00000800); - sortValues_ = null; - if (sortValuesBuilder_ != null) { - sortValuesBuilder_.dispose(); - sortValuesBuilder_ = null; - } - onChanged(); - return this; - } - /** - * .SearchSortValuesProto sort_values = 12; - */ - public SearchHits.SearchSortValuesProto.Builder getSortValuesBuilder() { - bitField0_ |= 0x00000800; - onChanged(); - return getSortValuesFieldBuilder().getBuilder(); - } - /** - * .SearchSortValuesProto sort_values = 12; - */ - public SearchHits.SearchSortValuesProtoOrBuilder getSortValuesOrBuilder() { - if (sortValuesBuilder_ != null) { - return sortValuesBuilder_.getMessageOrBuilder(); - } else { - return sortValues_ == null ? - SearchHits.SearchSortValuesProto.getDefaultInstance() : sortValues_; - } - } - /** - * .SearchSortValuesProto sort_values = 12; - */ - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.SearchSortValuesProto, SearchHits.SearchSortValuesProto.Builder, SearchHits.SearchSortValuesProtoOrBuilder> - getSortValuesFieldBuilder() { - if (sortValuesBuilder_ == null) { - sortValuesBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - SearchHits.SearchSortValuesProto, SearchHits.SearchSortValuesProto.Builder, SearchHits.SearchSortValuesProtoOrBuilder>( - getSortValues(), - getParentForChildren(), - isClean()); - sortValues_ = null; - } - return sortValuesBuilder_; - } - - private com.google.protobuf.MapField< - java.lang.String, java.lang.Float> matchedQueries_; - private com.google.protobuf.MapField - internalGetMatchedQueries() { - if (matchedQueries_ == null) { - return com.google.protobuf.MapField.emptyMapField( - MatchedQueriesDefaultEntryHolder.defaultEntry); - } - return matchedQueries_; - } - private com.google.protobuf.MapField - internalGetMutableMatchedQueries() { - if (matchedQueries_ == null) { - matchedQueries_ = com.google.protobuf.MapField.newMapField( - MatchedQueriesDefaultEntryHolder.defaultEntry); - } - if (!matchedQueries_.isMutable()) { - matchedQueries_ = matchedQueries_.copy(); - } - bitField0_ |= 0x00001000; - onChanged(); - return matchedQueries_; - } - public int getMatchedQueriesCount() { - return internalGetMatchedQueries().getMap().size(); - } - /** - * map<string, float> matched_queries = 13; - */ - @java.lang.Override - public boolean containsMatchedQueries( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetMatchedQueries().getMap().containsKey(key); - } - /** - * Use {@link #getMatchedQueriesMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getMatchedQueries() { - return getMatchedQueriesMap(); - } - /** - * map<string, float> matched_queries = 13; - */ - @java.lang.Override - public java.util.Map getMatchedQueriesMap() { - return internalGetMatchedQueries().getMap(); - } - /** - * map<string, float> matched_queries = 13; - */ - @java.lang.Override - public float getMatchedQueriesOrDefault( - java.lang.String key, - float defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetMatchedQueries().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, float> matched_queries = 13; - */ - @java.lang.Override - public float getMatchedQueriesOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetMatchedQueries().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - public Builder clearMatchedQueries() { - bitField0_ = (bitField0_ & ~0x00001000); - internalGetMutableMatchedQueries().getMutableMap() - .clear(); - return this; - } - /** - * map<string, float> matched_queries = 13; - */ - public Builder removeMatchedQueries( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableMatchedQueries().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableMatchedQueries() { - bitField0_ |= 0x00001000; - return internalGetMutableMatchedQueries().getMutableMap(); - } - /** - * map<string, float> matched_queries = 13; - */ - public Builder putMatchedQueries( - java.lang.String key, - float value) { - if (key == null) { throw new NullPointerException("map key"); } - - internalGetMutableMatchedQueries().getMutableMap() - .put(key, value); - bitField0_ |= 0x00001000; - return this; - } - /** - * map<string, float> matched_queries = 13; - */ - public Builder putAllMatchedQueries( - java.util.Map values) { - internalGetMutableMatchedQueries().getMutableMap() - .putAll(values); - bitField0_ |= 0x00001000; - return this; - } - - private SearchHits.SearchShardTargetProto shard_; - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.SearchShardTargetProto, SearchHits.SearchShardTargetProto.Builder, SearchHits.SearchShardTargetProtoOrBuilder> shardBuilder_; - /** - * .SearchShardTargetProto shard = 14; - * @return Whether the shard field is set. - */ - public boolean hasShard() { - return ((bitField0_ & 0x00002000) != 0); - } - /** - * .SearchShardTargetProto shard = 14; - * @return The shard. - */ - public SearchHits.SearchShardTargetProto getShard() { - if (shardBuilder_ == null) { - return shard_ == null ? SearchHits.SearchShardTargetProto.getDefaultInstance() : shard_; - } else { - return shardBuilder_.getMessage(); - } - } - /** - * .SearchShardTargetProto shard = 14; - */ - public Builder setShard(SearchHits.SearchShardTargetProto value) { - if (shardBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - shard_ = value; - } else { - shardBuilder_.setMessage(value); - } - bitField0_ |= 0x00002000; - onChanged(); - return this; - } - /** - * .SearchShardTargetProto shard = 14; - */ - public Builder setShard( - SearchHits.SearchShardTargetProto.Builder builderForValue) { - if (shardBuilder_ == null) { - shard_ = builderForValue.build(); - } else { - shardBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00002000; - onChanged(); - return this; - } - /** - * .SearchShardTargetProto shard = 14; - */ - public Builder mergeShard(SearchHits.SearchShardTargetProto value) { - if (shardBuilder_ == null) { - if (((bitField0_ & 0x00002000) != 0) && - shard_ != null && - shard_ != SearchHits.SearchShardTargetProto.getDefaultInstance()) { - getShardBuilder().mergeFrom(value); - } else { - shard_ = value; - } - } else { - shardBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00002000; - onChanged(); - return this; - } - /** - * .SearchShardTargetProto shard = 14; - */ - public Builder clearShard() { - bitField0_ = (bitField0_ & ~0x00002000); - shard_ = null; - if (shardBuilder_ != null) { - shardBuilder_.dispose(); - shardBuilder_ = null; - } - onChanged(); - return this; - } - /** - * .SearchShardTargetProto shard = 14; - */ - public SearchHits.SearchShardTargetProto.Builder getShardBuilder() { - bitField0_ |= 0x00002000; - onChanged(); - return getShardFieldBuilder().getBuilder(); - } - /** - * .SearchShardTargetProto shard = 14; - */ - public SearchHits.SearchShardTargetProtoOrBuilder getShardOrBuilder() { - if (shardBuilder_ != null) { - return shardBuilder_.getMessageOrBuilder(); - } else { - return shard_ == null ? - SearchHits.SearchShardTargetProto.getDefaultInstance() : shard_; - } - } - /** - * .SearchShardTargetProto shard = 14; - */ - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.SearchShardTargetProto, SearchHits.SearchShardTargetProto.Builder, SearchHits.SearchShardTargetProtoOrBuilder> - getShardFieldBuilder() { - if (shardBuilder_ == null) { - shardBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - SearchHits.SearchShardTargetProto, SearchHits.SearchShardTargetProto.Builder, SearchHits.SearchShardTargetProtoOrBuilder>( - getShard(), - getParentForChildren(), - isClean()); - shard_ = null; - } - return shardBuilder_; - } - - private com.google.protobuf.MapField< - java.lang.String, SearchHits.SearchHitsProto> innerHits_; - private com.google.protobuf.MapField - internalGetInnerHits() { - if (innerHits_ == null) { - return com.google.protobuf.MapField.emptyMapField( - InnerHitsDefaultEntryHolder.defaultEntry); - } - return innerHits_; - } - private com.google.protobuf.MapField - internalGetMutableInnerHits() { - if (innerHits_ == null) { - innerHits_ = com.google.protobuf.MapField.newMapField( - InnerHitsDefaultEntryHolder.defaultEntry); - } - if (!innerHits_.isMutable()) { - innerHits_ = innerHits_.copy(); - } - bitField0_ |= 0x00004000; - onChanged(); - return innerHits_; - } - public int getInnerHitsCount() { - return internalGetInnerHits().getMap().size(); - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - @java.lang.Override - public boolean containsInnerHits( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - return internalGetInnerHits().getMap().containsKey(key); - } - /** - * Use {@link #getInnerHitsMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getInnerHits() { - return getInnerHitsMap(); - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - @java.lang.Override - public java.util.Map getInnerHitsMap() { - return internalGetInnerHits().getMap(); - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - @java.lang.Override - public /* nullable */ -SearchHits.SearchHitsProto getInnerHitsOrDefault( - java.lang.String key, - /* nullable */ -SearchHits.SearchHitsProto defaultValue) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetInnerHits().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - @java.lang.Override - public SearchHits.SearchHitsProto getInnerHitsOrThrow( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetInnerHits().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - public Builder clearInnerHits() { - bitField0_ = (bitField0_ & ~0x00004000); - internalGetMutableInnerHits().getMutableMap() - .clear(); - return this; - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - public Builder removeInnerHits( - java.lang.String key) { - if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableInnerHits().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableInnerHits() { - bitField0_ |= 0x00004000; - return internalGetMutableInnerHits().getMutableMap(); - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - public Builder putInnerHits( - java.lang.String key, - SearchHits.SearchHitsProto value) { - if (key == null) { throw new NullPointerException("map key"); } - if (value == null) { throw new NullPointerException("map value"); } - internalGetMutableInnerHits().getMutableMap() - .put(key, value); - bitField0_ |= 0x00004000; - return this; - } - /** - * map<string, .SearchHitsProto> inner_hits = 15; - */ - public Builder putAllInnerHits( - java.util.Map values) { - internalGetMutableInnerHits().getMutableMap() - .putAll(values); - bitField0_ |= 0x00004000; - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:SearchHitProto) - } - - // @@protoc_insertion_point(class_scope:SearchHitProto) - private static final SearchHits.SearchHitProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.SearchHitProto(); - } - - public static SearchHits.SearchHitProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public SearchHitProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.SearchHitProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface NestedIdentityProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:NestedIdentityProto) - com.google.protobuf.MessageOrBuilder { - - /** - * string field = 1; - * @return The field. - */ - java.lang.String getField(); - /** - * string field = 1; - * @return The bytes for field. - */ - com.google.protobuf.ByteString - getFieldBytes(); - - /** - * int32 offset = 2; - * @return The offset. - */ - int getOffset(); - - /** - * .NestedIdentityProto child = 3; - * @return Whether the child field is set. - */ - boolean hasChild(); - /** - * .NestedIdentityProto child = 3; - * @return The child. - */ - SearchHits.NestedIdentityProto getChild(); - /** - * .NestedIdentityProto child = 3; - */ - SearchHits.NestedIdentityProtoOrBuilder getChildOrBuilder(); - } - /** - *
-   *
-   *Text field;
-   *int offset;
-   *NestedIdentity child;
-   * 
- * - * Protobuf type {@code NestedIdentityProto} - */ - public static final class NestedIdentityProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:NestedIdentityProto) - NestedIdentityProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use NestedIdentityProto.newBuilder() to construct. - private NestedIdentityProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private NestedIdentityProto() { - field_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new NestedIdentityProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_NestedIdentityProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_NestedIdentityProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.NestedIdentityProto.class, SearchHits.NestedIdentityProto.Builder.class); - } - - public static final int FIELD_FIELD_NUMBER = 1; - @SuppressWarnings("serial") - private volatile java.lang.Object field_ = ""; - /** - * string field = 1; - * @return The field. - */ - @java.lang.Override - public java.lang.String getField() { - java.lang.Object ref = field_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - field_ = s; - return s; - } - } - /** - * string field = 1; - * @return The bytes for field. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getFieldBytes() { - java.lang.Object ref = field_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - field_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int OFFSET_FIELD_NUMBER = 2; - private int offset_ = 0; - /** - * int32 offset = 2; - * @return The offset. - */ - @java.lang.Override - public int getOffset() { - return offset_; - } - - public static final int CHILD_FIELD_NUMBER = 3; - private SearchHits.NestedIdentityProto child_; - /** - * .NestedIdentityProto child = 3; - * @return Whether the child field is set. - */ - @java.lang.Override - public boolean hasChild() { - return child_ != null; - } - /** - * .NestedIdentityProto child = 3; - * @return The child. - */ - @java.lang.Override - public SearchHits.NestedIdentityProto getChild() { - return child_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : child_; - } - /** - * .NestedIdentityProto child = 3; - */ - @java.lang.Override - public SearchHits.NestedIdentityProtoOrBuilder getChildOrBuilder() { - return child_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : child_; - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(field_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, field_); - } - if (offset_ != 0) { - output.writeInt32(2, offset_); - } - if (child_ != null) { - output.writeMessage(3, getChild()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(field_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, field_); - } - if (offset_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, offset_); - } - if (child_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, getChild()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.NestedIdentityProto)) { - return super.equals(obj); - } - SearchHits.NestedIdentityProto other = (SearchHits.NestedIdentityProto) obj; - - if (!getField() - .equals(other.getField())) return false; - if (getOffset() - != other.getOffset()) return false; - if (hasChild() != other.hasChild()) return false; - if (hasChild()) { - if (!getChild() - .equals(other.getChild())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + FIELD_FIELD_NUMBER; - hash = (53 * hash) + getField().hashCode(); - hash = (37 * hash) + OFFSET_FIELD_NUMBER; - hash = (53 * hash) + getOffset(); - if (hasChild()) { - hash = (37 * hash) + CHILD_FIELD_NUMBER; - hash = (53 * hash) + getChild().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.NestedIdentityProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.NestedIdentityProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.NestedIdentityProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.NestedIdentityProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.NestedIdentityProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.NestedIdentityProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.NestedIdentityProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.NestedIdentityProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.NestedIdentityProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.NestedIdentityProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.NestedIdentityProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.NestedIdentityProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.NestedIdentityProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *Text field;
-     *int offset;
-     *NestedIdentity child;
-     * 
- * - * Protobuf type {@code NestedIdentityProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:NestedIdentityProto) - SearchHits.NestedIdentityProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_NestedIdentityProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_NestedIdentityProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.NestedIdentityProto.class, SearchHits.NestedIdentityProto.Builder.class); - } - - // Construct using SearchHits.NestedIdentityProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - field_ = ""; - offset_ = 0; - child_ = null; - if (childBuilder_ != null) { - childBuilder_.dispose(); - childBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_NestedIdentityProto_descriptor; - } - - @java.lang.Override - public SearchHits.NestedIdentityProto getDefaultInstanceForType() { - return SearchHits.NestedIdentityProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.NestedIdentityProto build() { - SearchHits.NestedIdentityProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.NestedIdentityProto buildPartial() { - SearchHits.NestedIdentityProto result = new SearchHits.NestedIdentityProto(this); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartial0(SearchHits.NestedIdentityProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.field_ = field_; - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.offset_ = offset_; - } - if (((from_bitField0_ & 0x00000004) != 0)) { - result.child_ = childBuilder_ == null - ? child_ - : childBuilder_.build(); - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.NestedIdentityProto) { - return mergeFrom((SearchHits.NestedIdentityProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.NestedIdentityProto other) { - if (other == SearchHits.NestedIdentityProto.getDefaultInstance()) return this; - if (!other.getField().isEmpty()) { - field_ = other.field_; - bitField0_ |= 0x00000001; - onChanged(); - } - if (other.getOffset() != 0) { - setOffset(other.getOffset()); - } - if (other.hasChild()) { - mergeChild(other.getChild()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - field_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000001; - break; - } // case 10 - case 16: { - offset_ = input.readInt32(); - bitField0_ |= 0x00000002; - break; - } // case 16 - case 26: { - input.readMessage( - getChildFieldBuilder().getBuilder(), - extensionRegistry); - bitField0_ |= 0x00000004; - break; - } // case 26 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private java.lang.Object field_ = ""; - /** - * string field = 1; - * @return The field. - */ - public java.lang.String getField() { - java.lang.Object ref = field_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - field_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string field = 1; - * @return The bytes for field. - */ - public com.google.protobuf.ByteString - getFieldBytes() { - java.lang.Object ref = field_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - field_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string field = 1; - * @param value The field to set. - * @return This builder for chaining. - */ - public Builder setField( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - field_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * string field = 1; - * @return This builder for chaining. - */ - public Builder clearField() { - field_ = getDefaultInstance().getField(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * string field = 1; - * @param value The bytes for field to set. - * @return This builder for chaining. - */ - public Builder setFieldBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - field_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - - private int offset_ ; - /** - * int32 offset = 2; - * @return The offset. - */ - @java.lang.Override - public int getOffset() { - return offset_; - } - /** - * int32 offset = 2; - * @param value The offset to set. - * @return This builder for chaining. - */ - public Builder setOffset(int value) { - - offset_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * int32 offset = 2; - * @return This builder for chaining. - */ - public Builder clearOffset() { - bitField0_ = (bitField0_ & ~0x00000002); - offset_ = 0; - onChanged(); - return this; - } - - private SearchHits.NestedIdentityProto child_; - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder> childBuilder_; - /** - * .NestedIdentityProto child = 3; - * @return Whether the child field is set. - */ - public boolean hasChild() { - return ((bitField0_ & 0x00000004) != 0); - } - /** - * .NestedIdentityProto child = 3; - * @return The child. - */ - public SearchHits.NestedIdentityProto getChild() { - if (childBuilder_ == null) { - return child_ == null ? SearchHits.NestedIdentityProto.getDefaultInstance() : child_; - } else { - return childBuilder_.getMessage(); - } - } - /** - * .NestedIdentityProto child = 3; - */ - public Builder setChild(SearchHits.NestedIdentityProto value) { - if (childBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - child_ = value; - } else { - childBuilder_.setMessage(value); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * .NestedIdentityProto child = 3; - */ - public Builder setChild( - SearchHits.NestedIdentityProto.Builder builderForValue) { - if (childBuilder_ == null) { - child_ = builderForValue.build(); - } else { - childBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * .NestedIdentityProto child = 3; - */ - public Builder mergeChild(SearchHits.NestedIdentityProto value) { - if (childBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0) && - child_ != null && - child_ != SearchHits.NestedIdentityProto.getDefaultInstance()) { - getChildBuilder().mergeFrom(value); - } else { - child_ = value; - } - } else { - childBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * .NestedIdentityProto child = 3; - */ - public Builder clearChild() { - bitField0_ = (bitField0_ & ~0x00000004); - child_ = null; - if (childBuilder_ != null) { - childBuilder_.dispose(); - childBuilder_ = null; - } - onChanged(); - return this; - } - /** - * .NestedIdentityProto child = 3; - */ - public SearchHits.NestedIdentityProto.Builder getChildBuilder() { - bitField0_ |= 0x00000004; - onChanged(); - return getChildFieldBuilder().getBuilder(); - } - /** - * .NestedIdentityProto child = 3; - */ - public SearchHits.NestedIdentityProtoOrBuilder getChildOrBuilder() { - if (childBuilder_ != null) { - return childBuilder_.getMessageOrBuilder(); - } else { - return child_ == null ? - SearchHits.NestedIdentityProto.getDefaultInstance() : child_; - } - } - /** - * .NestedIdentityProto child = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder> - getChildFieldBuilder() { - if (childBuilder_ == null) { - childBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - SearchHits.NestedIdentityProto, SearchHits.NestedIdentityProto.Builder, SearchHits.NestedIdentityProtoOrBuilder>( - getChild(), - getParentForChildren(), - isClean()); - child_ = null; - } - return childBuilder_; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:NestedIdentityProto) - } - - // @@protoc_insertion_point(class_scope:NestedIdentityProto) - private static final SearchHits.NestedIdentityProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.NestedIdentityProto(); - } - - public static SearchHits.NestedIdentityProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public NestedIdentityProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.NestedIdentityProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface DocumentFieldProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:DocumentFieldProto) - com.google.protobuf.MessageOrBuilder { - - /** - * string name = 1; - * @return The name. - */ - java.lang.String getName(); - /** - * string name = 1; - * @return The bytes for name. - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * repeated bytes values = 2; - * @return A list containing the values. - */ - java.util.List getValuesList(); - /** - * repeated bytes values = 2; - * @return The count of values. - */ - int getValuesCount(); - /** - * repeated bytes values = 2; - * @param index The index of the element to return. - * @return The values at the given index. - */ - com.google.protobuf.ByteString getValues(int index); - } - /** - *
-   *
-   *String name
-   *List<Object> values
-   * 
- * - * Protobuf type {@code DocumentFieldProto} - */ - public static final class DocumentFieldProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:DocumentFieldProto) - DocumentFieldProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use DocumentFieldProto.newBuilder() to construct. - private DocumentFieldProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private DocumentFieldProto() { - name_ = ""; - values_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new DocumentFieldProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_DocumentFieldProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_DocumentFieldProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.DocumentFieldProto.class, SearchHits.DocumentFieldProto.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - @SuppressWarnings("serial") - private volatile java.lang.Object name_ = ""; - /** - * string name = 1; - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * string name = 1; - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int VALUES_FIELD_NUMBER = 2; - @SuppressWarnings("serial") - private java.util.List values_; - /** - * repeated bytes values = 2; - * @return A list containing the values. - */ - @java.lang.Override - public java.util.List - getValuesList() { - return values_; - } - /** - * repeated bytes values = 2; - * @return The count of values. - */ - public int getValuesCount() { - return values_.size(); - } - /** - * repeated bytes values = 2; - * @param index The index of the element to return. - * @return The values at the given index. - */ - public com.google.protobuf.ByteString getValues(int index) { - return values_.get(index); - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - for (int i = 0; i < values_.size(); i++) { - output.writeBytes(2, values_.get(i)); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - { - int dataSize = 0; - for (int i = 0; i < values_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(values_.get(i)); - } - size += dataSize; - size += 1 * getValuesList().size(); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.DocumentFieldProto)) { - return super.equals(obj); - } - SearchHits.DocumentFieldProto other = (SearchHits.DocumentFieldProto) obj; - - if (!getName() - .equals(other.getName())) return false; - if (!getValuesList() - .equals(other.getValuesList())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - if (getValuesCount() > 0) { - hash = (37 * hash) + VALUES_FIELD_NUMBER; - hash = (53 * hash) + getValuesList().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.DocumentFieldProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.DocumentFieldProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.DocumentFieldProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.DocumentFieldProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.DocumentFieldProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.DocumentFieldProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.DocumentFieldProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.DocumentFieldProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.DocumentFieldProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.DocumentFieldProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.DocumentFieldProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.DocumentFieldProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.DocumentFieldProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *String name
-     *List<Object> values
-     * 
- * - * Protobuf type {@code DocumentFieldProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:DocumentFieldProto) - SearchHits.DocumentFieldProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_DocumentFieldProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_DocumentFieldProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.DocumentFieldProto.class, SearchHits.DocumentFieldProto.Builder.class); - } - - // Construct using SearchHits.DocumentFieldProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - name_ = ""; - values_ = java.util.Collections.emptyList(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_DocumentFieldProto_descriptor; - } - - @java.lang.Override - public SearchHits.DocumentFieldProto getDefaultInstanceForType() { - return SearchHits.DocumentFieldProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.DocumentFieldProto build() { - SearchHits.DocumentFieldProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.DocumentFieldProto buildPartial() { - SearchHits.DocumentFieldProto result = new SearchHits.DocumentFieldProto(this); - buildPartialRepeatedFields(result); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartialRepeatedFields(SearchHits.DocumentFieldProto result) { - if (((bitField0_ & 0x00000002) != 0)) { - values_ = java.util.Collections.unmodifiableList(values_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.values_ = values_; - } - - private void buildPartial0(SearchHits.DocumentFieldProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.name_ = name_; - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.DocumentFieldProto) { - return mergeFrom((SearchHits.DocumentFieldProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.DocumentFieldProto other) { - if (other == SearchHits.DocumentFieldProto.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - bitField0_ |= 0x00000001; - onChanged(); - } - if (!other.values_.isEmpty()) { - if (values_.isEmpty()) { - values_ = other.values_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureValuesIsMutable(); - values_.addAll(other.values_); - } - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - name_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000001; - break; - } // case 10 - case 18: { - com.google.protobuf.ByteString v = input.readBytes(); - ensureValuesIsMutable(); - values_.add(v); - break; - } // case 18 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private java.lang.Object name_ = ""; - /** - * string name = 1; - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string name = 1; - * @return The bytes for name. - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string name = 1; - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - name_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * string name = 1; - * @return This builder for chaining. - */ - public Builder clearName() { - name_ = getDefaultInstance().getName(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * string name = 1; - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - name_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - - private java.util.List values_ = java.util.Collections.emptyList(); - private void ensureValuesIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { - values_ = new java.util.ArrayList(values_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated bytes values = 2; - * @return A list containing the values. - */ - public java.util.List - getValuesList() { - return ((bitField0_ & 0x00000002) != 0) ? - java.util.Collections.unmodifiableList(values_) : values_; - } - /** - * repeated bytes values = 2; - * @return The count of values. - */ - public int getValuesCount() { - return values_.size(); - } - /** - * repeated bytes values = 2; - * @param index The index of the element to return. - * @return The values at the given index. - */ - public com.google.protobuf.ByteString getValues(int index) { - return values_.get(index); - } - /** - * repeated bytes values = 2; - * @param index The index to set the value at. - * @param value The values to set. - * @return This builder for chaining. - */ - public Builder setValues( - int index, com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - ensureValuesIsMutable(); - values_.set(index, value); - onChanged(); - return this; - } - /** - * repeated bytes values = 2; - * @param value The values to add. - * @return This builder for chaining. - */ - public Builder addValues(com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - ensureValuesIsMutable(); - values_.add(value); - onChanged(); - return this; - } - /** - * repeated bytes values = 2; - * @param values The values to add. - * @return This builder for chaining. - */ - public Builder addAllValues( - java.lang.Iterable values) { - ensureValuesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, values_); - onChanged(); - return this; - } - /** - * repeated bytes values = 2; - * @return This builder for chaining. - */ - public Builder clearValues() { - values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:DocumentFieldProto) - } - - // @@protoc_insertion_point(class_scope:DocumentFieldProto) - private static final SearchHits.DocumentFieldProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.DocumentFieldProto(); - } - - public static SearchHits.DocumentFieldProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DocumentFieldProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.DocumentFieldProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface HighlightFieldProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:HighlightFieldProto) - com.google.protobuf.MessageOrBuilder { - - /** - * string name = 1; - * @return The name. - */ - java.lang.String getName(); - /** - * string name = 1; - * @return The bytes for name. - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * repeated string fragments = 2; - * @return A list containing the fragments. - */ - java.util.List - getFragmentsList(); - /** - * repeated string fragments = 2; - * @return The count of fragments. - */ - int getFragmentsCount(); - /** - * repeated string fragments = 2; - * @param index The index of the element to return. - * @return The fragments at the given index. - */ - java.lang.String getFragments(int index); - /** - * repeated string fragments = 2; - * @param index The index of the value to return. - * @return The bytes of the fragments at the given index. - */ - com.google.protobuf.ByteString - getFragmentsBytes(int index); - } - /** - *
-   *
-   *String name
-   *Text[] fragments
-   * 
- * - * Protobuf type {@code HighlightFieldProto} - */ - public static final class HighlightFieldProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:HighlightFieldProto) - HighlightFieldProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use HighlightFieldProto.newBuilder() to construct. - private HighlightFieldProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private HighlightFieldProto() { - name_ = ""; - fragments_ = - com.google.protobuf.LazyStringArrayList.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new HighlightFieldProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_HighlightFieldProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_HighlightFieldProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.HighlightFieldProto.class, SearchHits.HighlightFieldProto.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - @SuppressWarnings("serial") - private volatile java.lang.Object name_ = ""; - /** - * string name = 1; - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * string name = 1; - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int FRAGMENTS_FIELD_NUMBER = 2; - @SuppressWarnings("serial") - private com.google.protobuf.LazyStringArrayList fragments_ = - com.google.protobuf.LazyStringArrayList.emptyList(); - /** - * repeated string fragments = 2; - * @return A list containing the fragments. - */ - public com.google.protobuf.ProtocolStringList - getFragmentsList() { - return fragments_; - } - /** - * repeated string fragments = 2; - * @return The count of fragments. - */ - public int getFragmentsCount() { - return fragments_.size(); - } - /** - * repeated string fragments = 2; - * @param index The index of the element to return. - * @return The fragments at the given index. - */ - public java.lang.String getFragments(int index) { - return fragments_.get(index); - } - /** - * repeated string fragments = 2; - * @param index The index of the value to return. - * @return The bytes of the fragments at the given index. - */ - public com.google.protobuf.ByteString - getFragmentsBytes(int index) { - return fragments_.getByteString(index); - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - for (int i = 0; i < fragments_.size(); i++) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, fragments_.getRaw(i)); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - { - int dataSize = 0; - for (int i = 0; i < fragments_.size(); i++) { - dataSize += computeStringSizeNoTag(fragments_.getRaw(i)); - } - size += dataSize; - size += 1 * getFragmentsList().size(); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.HighlightFieldProto)) { - return super.equals(obj); - } - SearchHits.HighlightFieldProto other = (SearchHits.HighlightFieldProto) obj; - - if (!getName() - .equals(other.getName())) return false; - if (!getFragmentsList() - .equals(other.getFragmentsList())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - if (getFragmentsCount() > 0) { - hash = (37 * hash) + FRAGMENTS_FIELD_NUMBER; - hash = (53 * hash) + getFragmentsList().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.HighlightFieldProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.HighlightFieldProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.HighlightFieldProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.HighlightFieldProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.HighlightFieldProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.HighlightFieldProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.HighlightFieldProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.HighlightFieldProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.HighlightFieldProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.HighlightFieldProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.HighlightFieldProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.HighlightFieldProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.HighlightFieldProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *String name
-     *Text[] fragments
-     * 
- * - * Protobuf type {@code HighlightFieldProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:HighlightFieldProto) - SearchHits.HighlightFieldProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_HighlightFieldProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_HighlightFieldProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.HighlightFieldProto.class, SearchHits.HighlightFieldProto.Builder.class); - } - - // Construct using SearchHits.HighlightFieldProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - name_ = ""; - fragments_ = - com.google.protobuf.LazyStringArrayList.emptyList(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_HighlightFieldProto_descriptor; - } - - @java.lang.Override - public SearchHits.HighlightFieldProto getDefaultInstanceForType() { - return SearchHits.HighlightFieldProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.HighlightFieldProto build() { - SearchHits.HighlightFieldProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.HighlightFieldProto buildPartial() { - SearchHits.HighlightFieldProto result = new SearchHits.HighlightFieldProto(this); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartial0(SearchHits.HighlightFieldProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.name_ = name_; - } - if (((from_bitField0_ & 0x00000002) != 0)) { - fragments_.makeImmutable(); - result.fragments_ = fragments_; - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.HighlightFieldProto) { - return mergeFrom((SearchHits.HighlightFieldProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.HighlightFieldProto other) { - if (other == SearchHits.HighlightFieldProto.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - bitField0_ |= 0x00000001; - onChanged(); - } - if (!other.fragments_.isEmpty()) { - if (fragments_.isEmpty()) { - fragments_ = other.fragments_; - bitField0_ |= 0x00000002; - } else { - ensureFragmentsIsMutable(); - fragments_.addAll(other.fragments_); - } - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - name_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000001; - break; - } // case 10 - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - ensureFragmentsIsMutable(); - fragments_.add(s); - break; - } // case 18 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private java.lang.Object name_ = ""; - /** - * string name = 1; - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string name = 1; - * @return The bytes for name. - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string name = 1; - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - name_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * string name = 1; - * @return This builder for chaining. - */ - public Builder clearName() { - name_ = getDefaultInstance().getName(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * string name = 1; - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - name_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringArrayList fragments_ = - com.google.protobuf.LazyStringArrayList.emptyList(); - private void ensureFragmentsIsMutable() { - if (!fragments_.isModifiable()) { - fragments_ = new com.google.protobuf.LazyStringArrayList(fragments_); - } - bitField0_ |= 0x00000002; - } - /** - * repeated string fragments = 2; - * @return A list containing the fragments. - */ - public com.google.protobuf.ProtocolStringList - getFragmentsList() { - fragments_.makeImmutable(); - return fragments_; - } - /** - * repeated string fragments = 2; - * @return The count of fragments. - */ - public int getFragmentsCount() { - return fragments_.size(); - } - /** - * repeated string fragments = 2; - * @param index The index of the element to return. - * @return The fragments at the given index. - */ - public java.lang.String getFragments(int index) { - return fragments_.get(index); - } - /** - * repeated string fragments = 2; - * @param index The index of the value to return. - * @return The bytes of the fragments at the given index. - */ - public com.google.protobuf.ByteString - getFragmentsBytes(int index) { - return fragments_.getByteString(index); - } - /** - * repeated string fragments = 2; - * @param index The index to set the value at. - * @param value The fragments to set. - * @return This builder for chaining. - */ - public Builder setFragments( - int index, java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - ensureFragmentsIsMutable(); - fragments_.set(index, value); - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * repeated string fragments = 2; - * @param value The fragments to add. - * @return This builder for chaining. - */ - public Builder addFragments( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - ensureFragmentsIsMutable(); - fragments_.add(value); - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * repeated string fragments = 2; - * @param values The fragments to add. - * @return This builder for chaining. - */ - public Builder addAllFragments( - java.lang.Iterable values) { - ensureFragmentsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, fragments_); - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * repeated string fragments = 2; - * @return This builder for chaining. - */ - public Builder clearFragments() { - fragments_ = - com.google.protobuf.LazyStringArrayList.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002);; - onChanged(); - return this; - } - /** - * repeated string fragments = 2; - * @param value The bytes of the fragments to add. - * @return This builder for chaining. - */ - public Builder addFragmentsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - ensureFragmentsIsMutable(); - fragments_.add(value); - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:HighlightFieldProto) - } - - // @@protoc_insertion_point(class_scope:HighlightFieldProto) - private static final SearchHits.HighlightFieldProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.HighlightFieldProto(); - } - - public static SearchHits.HighlightFieldProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public HighlightFieldProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.HighlightFieldProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface SearchSortValuesProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:SearchSortValuesProto) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated bytes formatted_sort_values = 1; - * @return A list containing the formattedSortValues. - */ - java.util.List getFormattedSortValuesList(); - /** - * repeated bytes formatted_sort_values = 1; - * @return The count of formattedSortValues. - */ - int getFormattedSortValuesCount(); - /** - * repeated bytes formatted_sort_values = 1; - * @param index The index of the element to return. - * @return The formattedSortValues at the given index. - */ - com.google.protobuf.ByteString getFormattedSortValues(int index); - - /** - * repeated bytes raw_sort_values = 2; - * @return A list containing the rawSortValues. - */ - java.util.List getRawSortValuesList(); - /** - * repeated bytes raw_sort_values = 2; - * @return The count of rawSortValues. - */ - int getRawSortValuesCount(); - /** - * repeated bytes raw_sort_values = 2; - * @param index The index of the element to return. - * @return The rawSortValues at the given index. - */ - com.google.protobuf.ByteString getRawSortValues(int index); - } - /** - *
-   *
-   *Object[] formattedSortValues
-   *Object[] rawSortValues
-   * 
- * - * Protobuf type {@code SearchSortValuesProto} - */ - public static final class SearchSortValuesProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:SearchSortValuesProto) - SearchSortValuesProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use SearchSortValuesProto.newBuilder() to construct. - private SearchSortValuesProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private SearchSortValuesProto() { - formattedSortValues_ = java.util.Collections.emptyList(); - rawSortValues_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new SearchSortValuesProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_SearchSortValuesProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_SearchSortValuesProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.SearchSortValuesProto.class, SearchHits.SearchSortValuesProto.Builder.class); - } - - public static final int FORMATTED_SORT_VALUES_FIELD_NUMBER = 1; - @SuppressWarnings("serial") - private java.util.List formattedSortValues_; - /** - * repeated bytes formatted_sort_values = 1; - * @return A list containing the formattedSortValues. - */ - @java.lang.Override - public java.util.List - getFormattedSortValuesList() { - return formattedSortValues_; - } - /** - * repeated bytes formatted_sort_values = 1; - * @return The count of formattedSortValues. - */ - public int getFormattedSortValuesCount() { - return formattedSortValues_.size(); - } - /** - * repeated bytes formatted_sort_values = 1; - * @param index The index of the element to return. - * @return The formattedSortValues at the given index. - */ - public com.google.protobuf.ByteString getFormattedSortValues(int index) { - return formattedSortValues_.get(index); - } - - public static final int RAW_SORT_VALUES_FIELD_NUMBER = 2; - @SuppressWarnings("serial") - private java.util.List rawSortValues_; - /** - * repeated bytes raw_sort_values = 2; - * @return A list containing the rawSortValues. - */ - @java.lang.Override - public java.util.List - getRawSortValuesList() { - return rawSortValues_; - } - /** - * repeated bytes raw_sort_values = 2; - * @return The count of rawSortValues. - */ - public int getRawSortValuesCount() { - return rawSortValues_.size(); - } - /** - * repeated bytes raw_sort_values = 2; - * @param index The index of the element to return. - * @return The rawSortValues at the given index. - */ - public com.google.protobuf.ByteString getRawSortValues(int index) { - return rawSortValues_.get(index); - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < formattedSortValues_.size(); i++) { - output.writeBytes(1, formattedSortValues_.get(i)); - } - for (int i = 0; i < rawSortValues_.size(); i++) { - output.writeBytes(2, rawSortValues_.get(i)); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - for (int i = 0; i < formattedSortValues_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(formattedSortValues_.get(i)); - } - size += dataSize; - size += 1 * getFormattedSortValuesList().size(); - } - { - int dataSize = 0; - for (int i = 0; i < rawSortValues_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(rawSortValues_.get(i)); - } - size += dataSize; - size += 1 * getRawSortValuesList().size(); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.SearchSortValuesProto)) { - return super.equals(obj); - } - SearchHits.SearchSortValuesProto other = (SearchHits.SearchSortValuesProto) obj; - - if (!getFormattedSortValuesList() - .equals(other.getFormattedSortValuesList())) return false; - if (!getRawSortValuesList() - .equals(other.getRawSortValuesList())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getFormattedSortValuesCount() > 0) { - hash = (37 * hash) + FORMATTED_SORT_VALUES_FIELD_NUMBER; - hash = (53 * hash) + getFormattedSortValuesList().hashCode(); - } - if (getRawSortValuesCount() > 0) { - hash = (37 * hash) + RAW_SORT_VALUES_FIELD_NUMBER; - hash = (53 * hash) + getRawSortValuesList().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.SearchSortValuesProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchSortValuesProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchSortValuesProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchSortValuesProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchSortValuesProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchSortValuesProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchSortValuesProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.SearchSortValuesProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.SearchSortValuesProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.SearchSortValuesProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.SearchSortValuesProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.SearchSortValuesProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.SearchSortValuesProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *Object[] formattedSortValues
-     *Object[] rawSortValues
-     * 
- * - * Protobuf type {@code SearchSortValuesProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:SearchSortValuesProto) - SearchHits.SearchSortValuesProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_SearchSortValuesProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_SearchSortValuesProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.SearchSortValuesProto.class, SearchHits.SearchSortValuesProto.Builder.class); - } - - // Construct using SearchHits.SearchSortValuesProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - formattedSortValues_ = java.util.Collections.emptyList(); - rawSortValues_ = java.util.Collections.emptyList(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_SearchSortValuesProto_descriptor; - } - - @java.lang.Override - public SearchHits.SearchSortValuesProto getDefaultInstanceForType() { - return SearchHits.SearchSortValuesProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.SearchSortValuesProto build() { - SearchHits.SearchSortValuesProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.SearchSortValuesProto buildPartial() { - SearchHits.SearchSortValuesProto result = new SearchHits.SearchSortValuesProto(this); - buildPartialRepeatedFields(result); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartialRepeatedFields(SearchHits.SearchSortValuesProto result) { - if (((bitField0_ & 0x00000001) != 0)) { - formattedSortValues_ = java.util.Collections.unmodifiableList(formattedSortValues_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.formattedSortValues_ = formattedSortValues_; - if (((bitField0_ & 0x00000002) != 0)) { - rawSortValues_ = java.util.Collections.unmodifiableList(rawSortValues_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.rawSortValues_ = rawSortValues_; - } - - private void buildPartial0(SearchHits.SearchSortValuesProto result) { - int from_bitField0_ = bitField0_; - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.SearchSortValuesProto) { - return mergeFrom((SearchHits.SearchSortValuesProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.SearchSortValuesProto other) { - if (other == SearchHits.SearchSortValuesProto.getDefaultInstance()) return this; - if (!other.formattedSortValues_.isEmpty()) { - if (formattedSortValues_.isEmpty()) { - formattedSortValues_ = other.formattedSortValues_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureFormattedSortValuesIsMutable(); - formattedSortValues_.addAll(other.formattedSortValues_); - } - onChanged(); - } - if (!other.rawSortValues_.isEmpty()) { - if (rawSortValues_.isEmpty()) { - rawSortValues_ = other.rawSortValues_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureRawSortValuesIsMutable(); - rawSortValues_.addAll(other.rawSortValues_); - } - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - com.google.protobuf.ByteString v = input.readBytes(); - ensureFormattedSortValuesIsMutable(); - formattedSortValues_.add(v); - break; - } // case 10 - case 18: { - com.google.protobuf.ByteString v = input.readBytes(); - ensureRawSortValuesIsMutable(); - rawSortValues_.add(v); - break; - } // case 18 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private java.util.List formattedSortValues_ = java.util.Collections.emptyList(); - private void ensureFormattedSortValuesIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - formattedSortValues_ = new java.util.ArrayList(formattedSortValues_); - bitField0_ |= 0x00000001; - } - } - /** - * repeated bytes formatted_sort_values = 1; - * @return A list containing the formattedSortValues. - */ - public java.util.List - getFormattedSortValuesList() { - return ((bitField0_ & 0x00000001) != 0) ? - java.util.Collections.unmodifiableList(formattedSortValues_) : formattedSortValues_; - } - /** - * repeated bytes formatted_sort_values = 1; - * @return The count of formattedSortValues. - */ - public int getFormattedSortValuesCount() { - return formattedSortValues_.size(); - } - /** - * repeated bytes formatted_sort_values = 1; - * @param index The index of the element to return. - * @return The formattedSortValues at the given index. - */ - public com.google.protobuf.ByteString getFormattedSortValues(int index) { - return formattedSortValues_.get(index); - } - /** - * repeated bytes formatted_sort_values = 1; - * @param index The index to set the value at. - * @param value The formattedSortValues to set. - * @return This builder for chaining. - */ - public Builder setFormattedSortValues( - int index, com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - ensureFormattedSortValuesIsMutable(); - formattedSortValues_.set(index, value); - onChanged(); - return this; - } - /** - * repeated bytes formatted_sort_values = 1; - * @param value The formattedSortValues to add. - * @return This builder for chaining. - */ - public Builder addFormattedSortValues(com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - ensureFormattedSortValuesIsMutable(); - formattedSortValues_.add(value); - onChanged(); - return this; - } - /** - * repeated bytes formatted_sort_values = 1; - * @param values The formattedSortValues to add. - * @return This builder for chaining. - */ - public Builder addAllFormattedSortValues( - java.lang.Iterable values) { - ensureFormattedSortValuesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, formattedSortValues_); - onChanged(); - return this; - } - /** - * repeated bytes formatted_sort_values = 1; - * @return This builder for chaining. - */ - public Builder clearFormattedSortValues() { - formattedSortValues_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - - private java.util.List rawSortValues_ = java.util.Collections.emptyList(); - private void ensureRawSortValuesIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { - rawSortValues_ = new java.util.ArrayList(rawSortValues_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated bytes raw_sort_values = 2; - * @return A list containing the rawSortValues. - */ - public java.util.List - getRawSortValuesList() { - return ((bitField0_ & 0x00000002) != 0) ? - java.util.Collections.unmodifiableList(rawSortValues_) : rawSortValues_; - } - /** - * repeated bytes raw_sort_values = 2; - * @return The count of rawSortValues. - */ - public int getRawSortValuesCount() { - return rawSortValues_.size(); - } - /** - * repeated bytes raw_sort_values = 2; - * @param index The index of the element to return. - * @return The rawSortValues at the given index. - */ - public com.google.protobuf.ByteString getRawSortValues(int index) { - return rawSortValues_.get(index); - } - /** - * repeated bytes raw_sort_values = 2; - * @param index The index to set the value at. - * @param value The rawSortValues to set. - * @return This builder for chaining. - */ - public Builder setRawSortValues( - int index, com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - ensureRawSortValuesIsMutable(); - rawSortValues_.set(index, value); - onChanged(); - return this; - } - /** - * repeated bytes raw_sort_values = 2; - * @param value The rawSortValues to add. - * @return This builder for chaining. - */ - public Builder addRawSortValues(com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - ensureRawSortValuesIsMutable(); - rawSortValues_.add(value); - onChanged(); - return this; - } - /** - * repeated bytes raw_sort_values = 2; - * @param values The rawSortValues to add. - * @return This builder for chaining. - */ - public Builder addAllRawSortValues( - java.lang.Iterable values) { - ensureRawSortValuesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, rawSortValues_); - onChanged(); - return this; - } - /** - * repeated bytes raw_sort_values = 2; - * @return This builder for chaining. - */ - public Builder clearRawSortValues() { - rawSortValues_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:SearchSortValuesProto) - } - - // @@protoc_insertion_point(class_scope:SearchSortValuesProto) - private static final SearchHits.SearchSortValuesProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.SearchSortValuesProto(); - } - - public static SearchHits.SearchSortValuesProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public SearchSortValuesProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.SearchSortValuesProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface ExplanationProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:ExplanationProto) - com.google.protobuf.MessageOrBuilder { - - /** - * bool match = 1; - * @return The match. - */ - boolean getMatch(); - - /** - *
-     * value used as long
-     * 
- * - * int64 value = 2; - * @return The value. - */ - long getValue(); - - /** - * string description = 3; - * @return The description. - */ - java.lang.String getDescription(); - /** - * string description = 3; - * @return The bytes for description. - */ - com.google.protobuf.ByteString - getDescriptionBytes(); - - /** - * repeated .ExplanationProto details = 4; - */ - java.util.List - getDetailsList(); - /** - * repeated .ExplanationProto details = 4; - */ - SearchHits.ExplanationProto getDetails(int index); - /** - * repeated .ExplanationProto details = 4; - */ - int getDetailsCount(); - /** - * repeated .ExplanationProto details = 4; - */ - java.util.List - getDetailsOrBuilderList(); - /** - * repeated .ExplanationProto details = 4; - */ - SearchHits.ExplanationProtoOrBuilder getDetailsOrBuilder( - int index); - } - /** - *
-   *
-   *boolean match
-   *Number value
-   *String description
-   *List<Explanation> details
-   * 
- * - * Protobuf type {@code ExplanationProto} - */ - public static final class ExplanationProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:ExplanationProto) - ExplanationProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use ExplanationProto.newBuilder() to construct. - private ExplanationProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private ExplanationProto() { - description_ = ""; - details_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new ExplanationProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_ExplanationProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_ExplanationProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.ExplanationProto.class, SearchHits.ExplanationProto.Builder.class); - } - - public static final int MATCH_FIELD_NUMBER = 1; - private boolean match_ = false; - /** - * bool match = 1; - * @return The match. - */ - @java.lang.Override - public boolean getMatch() { - return match_; - } - - public static final int VALUE_FIELD_NUMBER = 2; - private long value_ = 0L; - /** - *
-     * value used as long
-     * 
- * - * int64 value = 2; - * @return The value. - */ - @java.lang.Override - public long getValue() { - return value_; - } - - public static final int DESCRIPTION_FIELD_NUMBER = 3; - @SuppressWarnings("serial") - private volatile java.lang.Object description_ = ""; - /** - * string description = 3; - * @return The description. - */ - @java.lang.Override - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } - } - /** - * string description = 3; - * @return The bytes for description. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DETAILS_FIELD_NUMBER = 4; - @SuppressWarnings("serial") - private java.util.List details_; - /** - * repeated .ExplanationProto details = 4; - */ - @java.lang.Override - public java.util.List getDetailsList() { - return details_; - } - /** - * repeated .ExplanationProto details = 4; - */ - @java.lang.Override - public java.util.List - getDetailsOrBuilderList() { - return details_; - } - /** - * repeated .ExplanationProto details = 4; - */ - @java.lang.Override - public int getDetailsCount() { - return details_.size(); - } - /** - * repeated .ExplanationProto details = 4; - */ - @java.lang.Override - public SearchHits.ExplanationProto getDetails(int index) { - return details_.get(index); - } - /** - * repeated .ExplanationProto details = 4; - */ - @java.lang.Override - public SearchHits.ExplanationProtoOrBuilder getDetailsOrBuilder( - int index) { - return details_.get(index); - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (match_ != false) { - output.writeBool(1, match_); - } - if (value_ != 0L) { - output.writeInt64(2, value_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(description_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, description_); - } - for (int i = 0; i < details_.size(); i++) { - output.writeMessage(4, details_.get(i)); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (match_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(1, match_); - } - if (value_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, value_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(description_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, description_); - } - for (int i = 0; i < details_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, details_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.ExplanationProto)) { - return super.equals(obj); - } - SearchHits.ExplanationProto other = (SearchHits.ExplanationProto) obj; - - if (getMatch() - != other.getMatch()) return false; - if (getValue() - != other.getValue()) return false; - if (!getDescription() - .equals(other.getDescription())) return false; - if (!getDetailsList() - .equals(other.getDetailsList())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + MATCH_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( - getMatch()); - hash = (37 * hash) + VALUE_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getValue()); - hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER; - hash = (53 * hash) + getDescription().hashCode(); - if (getDetailsCount() > 0) { - hash = (37 * hash) + DETAILS_FIELD_NUMBER; - hash = (53 * hash) + getDetailsList().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.ExplanationProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.ExplanationProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.ExplanationProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.ExplanationProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.ExplanationProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.ExplanationProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.ExplanationProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.ExplanationProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.ExplanationProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.ExplanationProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.ExplanationProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.ExplanationProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.ExplanationProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *boolean match
-     *Number value
-     *String description
-     *List<Explanation> details
-     * 
- * - * Protobuf type {@code ExplanationProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:ExplanationProto) - SearchHits.ExplanationProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_ExplanationProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_ExplanationProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.ExplanationProto.class, SearchHits.ExplanationProto.Builder.class); - } - - // Construct using SearchHits.ExplanationProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - match_ = false; - value_ = 0L; - description_ = ""; - if (detailsBuilder_ == null) { - details_ = java.util.Collections.emptyList(); - } else { - details_ = null; - detailsBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000008); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_ExplanationProto_descriptor; - } - - @java.lang.Override - public SearchHits.ExplanationProto getDefaultInstanceForType() { - return SearchHits.ExplanationProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.ExplanationProto build() { - SearchHits.ExplanationProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.ExplanationProto buildPartial() { - SearchHits.ExplanationProto result = new SearchHits.ExplanationProto(this); - buildPartialRepeatedFields(result); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartialRepeatedFields(SearchHits.ExplanationProto result) { - if (detailsBuilder_ == null) { - if (((bitField0_ & 0x00000008) != 0)) { - details_ = java.util.Collections.unmodifiableList(details_); - bitField0_ = (bitField0_ & ~0x00000008); - } - result.details_ = details_; - } else { - result.details_ = detailsBuilder_.build(); - } - } - - private void buildPartial0(SearchHits.ExplanationProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.match_ = match_; - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.value_ = value_; - } - if (((from_bitField0_ & 0x00000004) != 0)) { - result.description_ = description_; - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.ExplanationProto) { - return mergeFrom((SearchHits.ExplanationProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.ExplanationProto other) { - if (other == SearchHits.ExplanationProto.getDefaultInstance()) return this; - if (other.getMatch() != false) { - setMatch(other.getMatch()); - } - if (other.getValue() != 0L) { - setValue(other.getValue()); - } - if (!other.getDescription().isEmpty()) { - description_ = other.description_; - bitField0_ |= 0x00000004; - onChanged(); - } - if (detailsBuilder_ == null) { - if (!other.details_.isEmpty()) { - if (details_.isEmpty()) { - details_ = other.details_; - bitField0_ = (bitField0_ & ~0x00000008); - } else { - ensureDetailsIsMutable(); - details_.addAll(other.details_); - } - onChanged(); - } - } else { - if (!other.details_.isEmpty()) { - if (detailsBuilder_.isEmpty()) { - detailsBuilder_.dispose(); - detailsBuilder_ = null; - details_ = other.details_; - bitField0_ = (bitField0_ & ~0x00000008); - detailsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getDetailsFieldBuilder() : null; - } else { - detailsBuilder_.addAllMessages(other.details_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: { - match_ = input.readBool(); - bitField0_ |= 0x00000001; - break; - } // case 8 - case 16: { - value_ = input.readInt64(); - bitField0_ |= 0x00000002; - break; - } // case 16 - case 26: { - description_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000004; - break; - } // case 26 - case 34: { - SearchHits.ExplanationProto m = - input.readMessage( - SearchHits.ExplanationProto.parser(), - extensionRegistry); - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.add(m); - } else { - detailsBuilder_.addMessage(m); - } - break; - } // case 34 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private boolean match_ ; - /** - * bool match = 1; - * @return The match. - */ - @java.lang.Override - public boolean getMatch() { - return match_; - } - /** - * bool match = 1; - * @param value The match to set. - * @return This builder for chaining. - */ - public Builder setMatch(boolean value) { - - match_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * bool match = 1; - * @return This builder for chaining. - */ - public Builder clearMatch() { - bitField0_ = (bitField0_ & ~0x00000001); - match_ = false; - onChanged(); - return this; - } - - private long value_ ; - /** - *
-       * value used as long
-       * 
- * - * int64 value = 2; - * @return The value. - */ - @java.lang.Override - public long getValue() { - return value_; - } - /** - *
-       * value used as long
-       * 
- * - * int64 value = 2; - * @param value The value to set. - * @return This builder for chaining. - */ - public Builder setValue(long value) { - - value_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - *
-       * value used as long
-       * 
- * - * int64 value = 2; - * @return This builder for chaining. - */ - public Builder clearValue() { - bitField0_ = (bitField0_ & ~0x00000002); - value_ = 0L; - onChanged(); - return this; - } - - private java.lang.Object description_ = ""; - /** - * string description = 3; - * @return The description. - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string description = 3; - * @return The bytes for description. - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string description = 3; - * @param value The description to set. - * @return This builder for chaining. - */ - public Builder setDescription( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - description_ = value; - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * string description = 3; - * @return This builder for chaining. - */ - public Builder clearDescription() { - description_ = getDefaultInstance().getDescription(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - return this; - } - /** - * string description = 3; - * @param value The bytes for description to set. - * @return This builder for chaining. - */ - public Builder setDescriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - description_ = value; - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - - private java.util.List details_ = - java.util.Collections.emptyList(); - private void ensureDetailsIsMutable() { - if (!((bitField0_ & 0x00000008) != 0)) { - details_ = new java.util.ArrayList(details_); - bitField0_ |= 0x00000008; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder> detailsBuilder_; - - /** - * repeated .ExplanationProto details = 4; - */ - public java.util.List getDetailsList() { - if (detailsBuilder_ == null) { - return java.util.Collections.unmodifiableList(details_); - } else { - return detailsBuilder_.getMessageList(); - } - } - /** - * repeated .ExplanationProto details = 4; - */ - public int getDetailsCount() { - if (detailsBuilder_ == null) { - return details_.size(); - } else { - return detailsBuilder_.getCount(); - } - } - /** - * repeated .ExplanationProto details = 4; - */ - public SearchHits.ExplanationProto getDetails(int index) { - if (detailsBuilder_ == null) { - return details_.get(index); - } else { - return detailsBuilder_.getMessage(index); - } - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder setDetails( - int index, SearchHits.ExplanationProto value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.set(index, value); - onChanged(); - } else { - detailsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder setDetails( - int index, SearchHits.ExplanationProto.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.set(index, builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder addDetails(SearchHits.ExplanationProto value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.add(value); - onChanged(); - } else { - detailsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder addDetails( - int index, SearchHits.ExplanationProto value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.add(index, value); - onChanged(); - } else { - detailsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder addDetails( - SearchHits.ExplanationProto.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.add(builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder addDetails( - int index, SearchHits.ExplanationProto.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.add(index, builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder addAllDetails( - java.lang.Iterable values) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, details_); - onChanged(); - } else { - detailsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder clearDetails() { - if (detailsBuilder_ == null) { - details_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - onChanged(); - } else { - detailsBuilder_.clear(); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public Builder removeDetails(int index) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.remove(index); - onChanged(); - } else { - detailsBuilder_.remove(index); - } - return this; - } - /** - * repeated .ExplanationProto details = 4; - */ - public SearchHits.ExplanationProto.Builder getDetailsBuilder( - int index) { - return getDetailsFieldBuilder().getBuilder(index); - } - /** - * repeated .ExplanationProto details = 4; - */ - public SearchHits.ExplanationProtoOrBuilder getDetailsOrBuilder( - int index) { - if (detailsBuilder_ == null) { - return details_.get(index); } else { - return detailsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .ExplanationProto details = 4; - */ - public java.util.List - getDetailsOrBuilderList() { - if (detailsBuilder_ != null) { - return detailsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(details_); - } - } - /** - * repeated .ExplanationProto details = 4; - */ - public SearchHits.ExplanationProto.Builder addDetailsBuilder() { - return getDetailsFieldBuilder().addBuilder( - SearchHits.ExplanationProto.getDefaultInstance()); - } - /** - * repeated .ExplanationProto details = 4; - */ - public SearchHits.ExplanationProto.Builder addDetailsBuilder( - int index) { - return getDetailsFieldBuilder().addBuilder( - index, SearchHits.ExplanationProto.getDefaultInstance()); - } - /** - * repeated .ExplanationProto details = 4; - */ - public java.util.List - getDetailsBuilderList() { - return getDetailsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilderV3< - SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder> - getDetailsFieldBuilder() { - if (detailsBuilder_ == null) { - detailsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - SearchHits.ExplanationProto, SearchHits.ExplanationProto.Builder, SearchHits.ExplanationProtoOrBuilder>( - details_, - ((bitField0_ & 0x00000008) != 0), - getParentForChildren(), - isClean()); - details_ = null; - } - return detailsBuilder_; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:ExplanationProto) - } - - // @@protoc_insertion_point(class_scope:ExplanationProto) - private static final SearchHits.ExplanationProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.ExplanationProto(); - } - - public static SearchHits.ExplanationProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ExplanationProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.ExplanationProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface SearchShardTargetProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:SearchShardTargetProto) - com.google.protobuf.MessageOrBuilder { - - /** - * string node_id = 1; - * @return The nodeId. - */ - java.lang.String getNodeId(); - /** - * string node_id = 1; - * @return The bytes for nodeId. - */ - com.google.protobuf.ByteString - getNodeIdBytes(); - - /** - * .ShardIdProto shard_id = 2; - * @return Whether the shardId field is set. - */ - boolean hasShardId(); - /** - * .ShardIdProto shard_id = 2; - * @return The shardId. - */ - SearchHits.ShardIdProto getShardId(); - /** - * .ShardIdProto shard_id = 2; - */ - SearchHits.ShardIdProtoOrBuilder getShardIdOrBuilder(); - - /** - * string cluster_alias = 3; - * @return The clusterAlias. - */ - java.lang.String getClusterAlias(); - /** - * string cluster_alias = 3; - * @return The bytes for clusterAlias. - */ - com.google.protobuf.ByteString - getClusterAliasBytes(); - } - /** - *
-   *
-   *Text nodeId
-   *ShardId shardId
-   *String clusterAlias
-   * 
- * - * Protobuf type {@code SearchShardTargetProto} - */ - public static final class SearchShardTargetProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:SearchShardTargetProto) - SearchShardTargetProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use SearchShardTargetProto.newBuilder() to construct. - private SearchShardTargetProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private SearchShardTargetProto() { - nodeId_ = ""; - clusterAlias_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new SearchShardTargetProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_SearchShardTargetProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_SearchShardTargetProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.SearchShardTargetProto.class, SearchHits.SearchShardTargetProto.Builder.class); - } - - public static final int NODE_ID_FIELD_NUMBER = 1; - @SuppressWarnings("serial") - private volatile java.lang.Object nodeId_ = ""; - /** - * string node_id = 1; - * @return The nodeId. - */ - @java.lang.Override - public java.lang.String getNodeId() { - java.lang.Object ref = nodeId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nodeId_ = s; - return s; - } - } - /** - * string node_id = 1; - * @return The bytes for nodeId. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getNodeIdBytes() { - java.lang.Object ref = nodeId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nodeId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SHARD_ID_FIELD_NUMBER = 2; - private SearchHits.ShardIdProto shardId_; - /** - * .ShardIdProto shard_id = 2; - * @return Whether the shardId field is set. - */ - @java.lang.Override - public boolean hasShardId() { - return shardId_ != null; - } - /** - * .ShardIdProto shard_id = 2; - * @return The shardId. - */ - @java.lang.Override - public SearchHits.ShardIdProto getShardId() { - return shardId_ == null ? SearchHits.ShardIdProto.getDefaultInstance() : shardId_; - } - /** - * .ShardIdProto shard_id = 2; - */ - @java.lang.Override - public SearchHits.ShardIdProtoOrBuilder getShardIdOrBuilder() { - return shardId_ == null ? SearchHits.ShardIdProto.getDefaultInstance() : shardId_; - } - - public static final int CLUSTER_ALIAS_FIELD_NUMBER = 3; - @SuppressWarnings("serial") - private volatile java.lang.Object clusterAlias_ = ""; - /** - * string cluster_alias = 3; - * @return The clusterAlias. - */ - @java.lang.Override - public java.lang.String getClusterAlias() { - java.lang.Object ref = clusterAlias_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - clusterAlias_ = s; - return s; - } - } - /** - * string cluster_alias = 3; - * @return The bytes for clusterAlias. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getClusterAliasBytes() { - java.lang.Object ref = clusterAlias_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - clusterAlias_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nodeId_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, nodeId_); - } - if (shardId_ != null) { - output.writeMessage(2, getShardId()); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clusterAlias_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, clusterAlias_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nodeId_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, nodeId_); - } - if (shardId_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, getShardId()); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(clusterAlias_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, clusterAlias_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.SearchShardTargetProto)) { - return super.equals(obj); - } - SearchHits.SearchShardTargetProto other = (SearchHits.SearchShardTargetProto) obj; - - if (!getNodeId() - .equals(other.getNodeId())) return false; - if (hasShardId() != other.hasShardId()) return false; - if (hasShardId()) { - if (!getShardId() - .equals(other.getShardId())) return false; - } - if (!getClusterAlias() - .equals(other.getClusterAlias())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NODE_ID_FIELD_NUMBER; - hash = (53 * hash) + getNodeId().hashCode(); - if (hasShardId()) { - hash = (37 * hash) + SHARD_ID_FIELD_NUMBER; - hash = (53 * hash) + getShardId().hashCode(); - } - hash = (37 * hash) + CLUSTER_ALIAS_FIELD_NUMBER; - hash = (53 * hash) + getClusterAlias().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.SearchShardTargetProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchShardTargetProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchShardTargetProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchShardTargetProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchShardTargetProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.SearchShardTargetProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.SearchShardTargetProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.SearchShardTargetProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.SearchShardTargetProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.SearchShardTargetProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.SearchShardTargetProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.SearchShardTargetProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.SearchShardTargetProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *Text nodeId
-     *ShardId shardId
-     *String clusterAlias
-     * 
- * - * Protobuf type {@code SearchShardTargetProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:SearchShardTargetProto) - SearchHits.SearchShardTargetProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_SearchShardTargetProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_SearchShardTargetProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.SearchShardTargetProto.class, SearchHits.SearchShardTargetProto.Builder.class); - } - - // Construct using SearchHits.SearchShardTargetProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - nodeId_ = ""; - shardId_ = null; - if (shardIdBuilder_ != null) { - shardIdBuilder_.dispose(); - shardIdBuilder_ = null; - } - clusterAlias_ = ""; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_SearchShardTargetProto_descriptor; - } - - @java.lang.Override - public SearchHits.SearchShardTargetProto getDefaultInstanceForType() { - return SearchHits.SearchShardTargetProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.SearchShardTargetProto build() { - SearchHits.SearchShardTargetProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.SearchShardTargetProto buildPartial() { - SearchHits.SearchShardTargetProto result = new SearchHits.SearchShardTargetProto(this); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartial0(SearchHits.SearchShardTargetProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.nodeId_ = nodeId_; - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.shardId_ = shardIdBuilder_ == null - ? shardId_ - : shardIdBuilder_.build(); - } - if (((from_bitField0_ & 0x00000004) != 0)) { - result.clusterAlias_ = clusterAlias_; - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.SearchShardTargetProto) { - return mergeFrom((SearchHits.SearchShardTargetProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.SearchShardTargetProto other) { - if (other == SearchHits.SearchShardTargetProto.getDefaultInstance()) return this; - if (!other.getNodeId().isEmpty()) { - nodeId_ = other.nodeId_; - bitField0_ |= 0x00000001; - onChanged(); - } - if (other.hasShardId()) { - mergeShardId(other.getShardId()); - } - if (!other.getClusterAlias().isEmpty()) { - clusterAlias_ = other.clusterAlias_; - bitField0_ |= 0x00000004; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - nodeId_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000001; - break; - } // case 10 - case 18: { - input.readMessage( - getShardIdFieldBuilder().getBuilder(), - extensionRegistry); - bitField0_ |= 0x00000002; - break; - } // case 18 - case 26: { - clusterAlias_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000004; - break; - } // case 26 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private java.lang.Object nodeId_ = ""; - /** - * string node_id = 1; - * @return The nodeId. - */ - public java.lang.String getNodeId() { - java.lang.Object ref = nodeId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nodeId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string node_id = 1; - * @return The bytes for nodeId. - */ - public com.google.protobuf.ByteString - getNodeIdBytes() { - java.lang.Object ref = nodeId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nodeId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string node_id = 1; - * @param value The nodeId to set. - * @return This builder for chaining. - */ - public Builder setNodeId( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - nodeId_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * string node_id = 1; - * @return This builder for chaining. - */ - public Builder clearNodeId() { - nodeId_ = getDefaultInstance().getNodeId(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * string node_id = 1; - * @param value The bytes for nodeId to set. - * @return This builder for chaining. - */ - public Builder setNodeIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - nodeId_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - - private SearchHits.ShardIdProto shardId_; - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.ShardIdProto, SearchHits.ShardIdProto.Builder, SearchHits.ShardIdProtoOrBuilder> shardIdBuilder_; - /** - * .ShardIdProto shard_id = 2; - * @return Whether the shardId field is set. - */ - public boolean hasShardId() { - return ((bitField0_ & 0x00000002) != 0); - } - /** - * .ShardIdProto shard_id = 2; - * @return The shardId. - */ - public SearchHits.ShardIdProto getShardId() { - if (shardIdBuilder_ == null) { - return shardId_ == null ? SearchHits.ShardIdProto.getDefaultInstance() : shardId_; - } else { - return shardIdBuilder_.getMessage(); - } - } - /** - * .ShardIdProto shard_id = 2; - */ - public Builder setShardId(SearchHits.ShardIdProto value) { - if (shardIdBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - shardId_ = value; - } else { - shardIdBuilder_.setMessage(value); - } - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * .ShardIdProto shard_id = 2; - */ - public Builder setShardId( - SearchHits.ShardIdProto.Builder builderForValue) { - if (shardIdBuilder_ == null) { - shardId_ = builderForValue.build(); - } else { - shardIdBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * .ShardIdProto shard_id = 2; - */ - public Builder mergeShardId(SearchHits.ShardIdProto value) { - if (shardIdBuilder_ == null) { - if (((bitField0_ & 0x00000002) != 0) && - shardId_ != null && - shardId_ != SearchHits.ShardIdProto.getDefaultInstance()) { - getShardIdBuilder().mergeFrom(value); - } else { - shardId_ = value; - } - } else { - shardIdBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * .ShardIdProto shard_id = 2; - */ - public Builder clearShardId() { - bitField0_ = (bitField0_ & ~0x00000002); - shardId_ = null; - if (shardIdBuilder_ != null) { - shardIdBuilder_.dispose(); - shardIdBuilder_ = null; - } - onChanged(); - return this; - } - /** - * .ShardIdProto shard_id = 2; - */ - public SearchHits.ShardIdProto.Builder getShardIdBuilder() { - bitField0_ |= 0x00000002; - onChanged(); - return getShardIdFieldBuilder().getBuilder(); - } - /** - * .ShardIdProto shard_id = 2; - */ - public SearchHits.ShardIdProtoOrBuilder getShardIdOrBuilder() { - if (shardIdBuilder_ != null) { - return shardIdBuilder_.getMessageOrBuilder(); - } else { - return shardId_ == null ? - SearchHits.ShardIdProto.getDefaultInstance() : shardId_; - } - } - /** - * .ShardIdProto shard_id = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.ShardIdProto, SearchHits.ShardIdProto.Builder, SearchHits.ShardIdProtoOrBuilder> - getShardIdFieldBuilder() { - if (shardIdBuilder_ == null) { - shardIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - SearchHits.ShardIdProto, SearchHits.ShardIdProto.Builder, SearchHits.ShardIdProtoOrBuilder>( - getShardId(), - getParentForChildren(), - isClean()); - shardId_ = null; - } - return shardIdBuilder_; - } - - private java.lang.Object clusterAlias_ = ""; - /** - * string cluster_alias = 3; - * @return The clusterAlias. - */ - public java.lang.String getClusterAlias() { - java.lang.Object ref = clusterAlias_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - clusterAlias_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string cluster_alias = 3; - * @return The bytes for clusterAlias. - */ - public com.google.protobuf.ByteString - getClusterAliasBytes() { - java.lang.Object ref = clusterAlias_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - clusterAlias_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string cluster_alias = 3; - * @param value The clusterAlias to set. - * @return This builder for chaining. - */ - public Builder setClusterAlias( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - clusterAlias_ = value; - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * string cluster_alias = 3; - * @return This builder for chaining. - */ - public Builder clearClusterAlias() { - clusterAlias_ = getDefaultInstance().getClusterAlias(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - return this; - } - /** - * string cluster_alias = 3; - * @param value The bytes for clusterAlias to set. - * @return This builder for chaining. - */ - public Builder setClusterAliasBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - clusterAlias_ = value; - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:SearchShardTargetProto) - } - - // @@protoc_insertion_point(class_scope:SearchShardTargetProto) - private static final SearchHits.SearchShardTargetProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.SearchShardTargetProto(); - } - - public static SearchHits.SearchShardTargetProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public SearchShardTargetProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.SearchShardTargetProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface ShardIdProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:ShardIdProto) - com.google.protobuf.MessageOrBuilder { - - /** - * .IndexProto index = 1; - * @return Whether the index field is set. - */ - boolean hasIndex(); - /** - * .IndexProto index = 1; - * @return The index. - */ - SearchHits.IndexProto getIndex(); - /** - * .IndexProto index = 1; - */ - SearchHits.IndexProtoOrBuilder getIndexOrBuilder(); - - /** - * int32 shard_id = 2; - * @return The shardId. - */ - int getShardId(); - - /** - * int32 hash_code = 3; - * @return The hashCode. - */ - int getHashCode(); - } - /** - *
-   *
-   *Index index
-   *int shardId
-   *int hashCode
-   * 
- * - * Protobuf type {@code ShardIdProto} - */ - public static final class ShardIdProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:ShardIdProto) - ShardIdProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use ShardIdProto.newBuilder() to construct. - private ShardIdProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private ShardIdProto() { - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new ShardIdProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_ShardIdProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_ShardIdProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.ShardIdProto.class, SearchHits.ShardIdProto.Builder.class); - } - - public static final int INDEX_FIELD_NUMBER = 1; - private SearchHits.IndexProto index_; - /** - * .IndexProto index = 1; - * @return Whether the index field is set. - */ - @java.lang.Override - public boolean hasIndex() { - return index_ != null; - } - /** - * .IndexProto index = 1; - * @return The index. - */ - @java.lang.Override - public SearchHits.IndexProto getIndex() { - return index_ == null ? SearchHits.IndexProto.getDefaultInstance() : index_; - } - /** - * .IndexProto index = 1; - */ - @java.lang.Override - public SearchHits.IndexProtoOrBuilder getIndexOrBuilder() { - return index_ == null ? SearchHits.IndexProto.getDefaultInstance() : index_; - } - - public static final int SHARD_ID_FIELD_NUMBER = 2; - private int shardId_ = 0; - /** - * int32 shard_id = 2; - * @return The shardId. - */ - @java.lang.Override - public int getShardId() { - return shardId_; - } - - public static final int HASH_CODE_FIELD_NUMBER = 3; - private int hashCode_ = 0; - /** - * int32 hash_code = 3; - * @return The hashCode. - */ - @java.lang.Override - public int getHashCode() { - return hashCode_; - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (index_ != null) { - output.writeMessage(1, getIndex()); - } - if (shardId_ != 0) { - output.writeInt32(2, shardId_); - } - if (hashCode_ != 0) { - output.writeInt32(3, hashCode_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (index_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getIndex()); - } - if (shardId_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, shardId_); - } - if (hashCode_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, hashCode_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.ShardIdProto)) { - return super.equals(obj); - } - SearchHits.ShardIdProto other = (SearchHits.ShardIdProto) obj; - - if (hasIndex() != other.hasIndex()) return false; - if (hasIndex()) { - if (!getIndex() - .equals(other.getIndex())) return false; - } - if (getShardId() - != other.getShardId()) return false; - if (getHashCode() - != other.getHashCode()) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasIndex()) { - hash = (37 * hash) + INDEX_FIELD_NUMBER; - hash = (53 * hash) + getIndex().hashCode(); - } - hash = (37 * hash) + SHARD_ID_FIELD_NUMBER; - hash = (53 * hash) + getShardId(); - hash = (37 * hash) + HASH_CODE_FIELD_NUMBER; - hash = (53 * hash) + getHashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.ShardIdProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.ShardIdProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.ShardIdProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.ShardIdProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.ShardIdProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.ShardIdProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.ShardIdProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.ShardIdProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.ShardIdProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.ShardIdProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.ShardIdProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.ShardIdProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.ShardIdProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *Index index
-     *int shardId
-     *int hashCode
-     * 
- * - * Protobuf type {@code ShardIdProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:ShardIdProto) - SearchHits.ShardIdProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_ShardIdProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_ShardIdProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.ShardIdProto.class, SearchHits.ShardIdProto.Builder.class); - } - - // Construct using SearchHits.ShardIdProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - index_ = null; - if (indexBuilder_ != null) { - indexBuilder_.dispose(); - indexBuilder_ = null; - } - shardId_ = 0; - hashCode_ = 0; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_ShardIdProto_descriptor; - } - - @java.lang.Override - public SearchHits.ShardIdProto getDefaultInstanceForType() { - return SearchHits.ShardIdProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.ShardIdProto build() { - SearchHits.ShardIdProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.ShardIdProto buildPartial() { - SearchHits.ShardIdProto result = new SearchHits.ShardIdProto(this); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartial0(SearchHits.ShardIdProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.index_ = indexBuilder_ == null - ? index_ - : indexBuilder_.build(); - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.shardId_ = shardId_; - } - if (((from_bitField0_ & 0x00000004) != 0)) { - result.hashCode_ = hashCode_; - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.ShardIdProto) { - return mergeFrom((SearchHits.ShardIdProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.ShardIdProto other) { - if (other == SearchHits.ShardIdProto.getDefaultInstance()) return this; - if (other.hasIndex()) { - mergeIndex(other.getIndex()); - } - if (other.getShardId() != 0) { - setShardId(other.getShardId()); - } - if (other.getHashCode() != 0) { - setHashCode(other.getHashCode()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - input.readMessage( - getIndexFieldBuilder().getBuilder(), - extensionRegistry); - bitField0_ |= 0x00000001; - break; - } // case 10 - case 16: { - shardId_ = input.readInt32(); - bitField0_ |= 0x00000002; - break; - } // case 16 - case 24: { - hashCode_ = input.readInt32(); - bitField0_ |= 0x00000004; - break; - } // case 24 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private SearchHits.IndexProto index_; - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.IndexProto, SearchHits.IndexProto.Builder, SearchHits.IndexProtoOrBuilder> indexBuilder_; - /** - * .IndexProto index = 1; - * @return Whether the index field is set. - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) != 0); - } - /** - * .IndexProto index = 1; - * @return The index. - */ - public SearchHits.IndexProto getIndex() { - if (indexBuilder_ == null) { - return index_ == null ? SearchHits.IndexProto.getDefaultInstance() : index_; - } else { - return indexBuilder_.getMessage(); - } - } - /** - * .IndexProto index = 1; - */ - public Builder setIndex(SearchHits.IndexProto value) { - if (indexBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - index_ = value; - } else { - indexBuilder_.setMessage(value); - } - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * .IndexProto index = 1; - */ - public Builder setIndex( - SearchHits.IndexProto.Builder builderForValue) { - if (indexBuilder_ == null) { - index_ = builderForValue.build(); - } else { - indexBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * .IndexProto index = 1; - */ - public Builder mergeIndex(SearchHits.IndexProto value) { - if (indexBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0) && - index_ != null && - index_ != SearchHits.IndexProto.getDefaultInstance()) { - getIndexBuilder().mergeFrom(value); - } else { - index_ = value; - } - } else { - indexBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * .IndexProto index = 1; - */ - public Builder clearIndex() { - bitField0_ = (bitField0_ & ~0x00000001); - index_ = null; - if (indexBuilder_ != null) { - indexBuilder_.dispose(); - indexBuilder_ = null; - } - onChanged(); - return this; - } - /** - * .IndexProto index = 1; - */ - public SearchHits.IndexProto.Builder getIndexBuilder() { - bitField0_ |= 0x00000001; - onChanged(); - return getIndexFieldBuilder().getBuilder(); - } - /** - * .IndexProto index = 1; - */ - public SearchHits.IndexProtoOrBuilder getIndexOrBuilder() { - if (indexBuilder_ != null) { - return indexBuilder_.getMessageOrBuilder(); - } else { - return index_ == null ? - SearchHits.IndexProto.getDefaultInstance() : index_; - } - } - /** - * .IndexProto index = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - SearchHits.IndexProto, SearchHits.IndexProto.Builder, SearchHits.IndexProtoOrBuilder> - getIndexFieldBuilder() { - if (indexBuilder_ == null) { - indexBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - SearchHits.IndexProto, SearchHits.IndexProto.Builder, SearchHits.IndexProtoOrBuilder>( - getIndex(), - getParentForChildren(), - isClean()); - index_ = null; - } - return indexBuilder_; - } - - private int shardId_ ; - /** - * int32 shard_id = 2; - * @return The shardId. - */ - @java.lang.Override - public int getShardId() { - return shardId_; - } - /** - * int32 shard_id = 2; - * @param value The shardId to set. - * @return This builder for chaining. - */ - public Builder setShardId(int value) { - - shardId_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * int32 shard_id = 2; - * @return This builder for chaining. - */ - public Builder clearShardId() { - bitField0_ = (bitField0_ & ~0x00000002); - shardId_ = 0; - onChanged(); - return this; - } - - private int hashCode_ ; - /** - * int32 hash_code = 3; - * @return The hashCode. - */ - @java.lang.Override - public int getHashCode() { - return hashCode_; - } - /** - * int32 hash_code = 3; - * @param value The hashCode to set. - * @return This builder for chaining. - */ - public Builder setHashCode(int value) { - - hashCode_ = value; - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - /** - * int32 hash_code = 3; - * @return This builder for chaining. - */ - public Builder clearHashCode() { - bitField0_ = (bitField0_ & ~0x00000004); - hashCode_ = 0; - onChanged(); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:ShardIdProto) - } - - // @@protoc_insertion_point(class_scope:ShardIdProto) - private static final SearchHits.ShardIdProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.ShardIdProto(); - } - - public static SearchHits.ShardIdProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ShardIdProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.ShardIdProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface IndexProtoOrBuilder extends - // @@protoc_insertion_point(interface_extends:IndexProto) - com.google.protobuf.MessageOrBuilder { - - /** - * string name = 1; - * @return The name. - */ - java.lang.String getName(); - /** - * string name = 1; - * @return The bytes for name. - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * string uuid = 2; - * @return The uuid. - */ - java.lang.String getUuid(); - /** - * string uuid = 2; - * @return The bytes for uuid. - */ - com.google.protobuf.ByteString - getUuidBytes(); - } - /** - *
-   *
-   *String name
-   *String uuid
-   * 
- * - * Protobuf type {@code IndexProto} - */ - public static final class IndexProto extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:IndexProto) - IndexProtoOrBuilder { - private static final long serialVersionUID = 0L; - // Use IndexProto.newBuilder() to construct. - private IndexProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private IndexProto() { - name_ = ""; - uuid_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new IndexProto(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_IndexProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_IndexProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.IndexProto.class, SearchHits.IndexProto.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - @SuppressWarnings("serial") - private volatile java.lang.Object name_ = ""; - /** - * string name = 1; - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * string name = 1; - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int UUID_FIELD_NUMBER = 2; - @SuppressWarnings("serial") - private volatile java.lang.Object uuid_ = ""; - /** - * string uuid = 2; - * @return The uuid. - */ - @java.lang.Override - public java.lang.String getUuid() { - java.lang.Object ref = uuid_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - uuid_ = s; - return s; - } - } - /** - * string uuid = 2; - * @return The bytes for uuid. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getUuidBytes() { - java.lang.Object ref = uuid_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - uuid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(uuid_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, uuid_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(uuid_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, uuid_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SearchHits.IndexProto)) { - return super.equals(obj); - } - SearchHits.IndexProto other = (SearchHits.IndexProto) obj; - - if (!getName() - .equals(other.getName())) return false; - if (!getUuid() - .equals(other.getUuid())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (37 * hash) + UUID_FIELD_NUMBER; - hash = (53 * hash) + getUuid().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SearchHits.IndexProto parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.IndexProto parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.IndexProto parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.IndexProto parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.IndexProto parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static SearchHits.IndexProto parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static SearchHits.IndexProto parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.IndexProto parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.IndexProto parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static SearchHits.IndexProto parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static SearchHits.IndexProto parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static SearchHits.IndexProto parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(SearchHits.IndexProto prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     *
-     *String name
-     *String uuid
-     * 
- * - * Protobuf type {@code IndexProto} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:IndexProto) - SearchHits.IndexProtoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return SearchHits.internal_static_IndexProto_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return SearchHits.internal_static_IndexProto_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SearchHits.IndexProto.class, SearchHits.IndexProto.Builder.class); - } - - // Construct using SearchHits.IndexProto.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - name_ = ""; - uuid_ = ""; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return SearchHits.internal_static_IndexProto_descriptor; - } - - @java.lang.Override - public SearchHits.IndexProto getDefaultInstanceForType() { - return SearchHits.IndexProto.getDefaultInstance(); - } - - @java.lang.Override - public SearchHits.IndexProto build() { - SearchHits.IndexProto result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public SearchHits.IndexProto buildPartial() { - SearchHits.IndexProto result = new SearchHits.IndexProto(this); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartial0(SearchHits.IndexProto result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.name_ = name_; - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.uuid_ = uuid_; - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SearchHits.IndexProto) { - return mergeFrom((SearchHits.IndexProto)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SearchHits.IndexProto other) { - if (other == SearchHits.IndexProto.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - bitField0_ |= 0x00000001; - onChanged(); - } - if (!other.getUuid().isEmpty()) { - uuid_ = other.uuid_; - bitField0_ |= 0x00000002; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - name_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000001; - break; - } // case 10 - case 18: { - uuid_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000002; - break; - } // case 18 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private java.lang.Object name_ = ""; - /** - * string name = 1; - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string name = 1; - * @return The bytes for name. - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string name = 1; - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - name_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - * string name = 1; - * @return This builder for chaining. - */ - public Builder clearName() { - name_ = getDefaultInstance().getName(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * string name = 1; - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - name_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - - private java.lang.Object uuid_ = ""; - /** - * string uuid = 2; - * @return The uuid. - */ - public java.lang.String getUuid() { - java.lang.Object ref = uuid_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - uuid_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string uuid = 2; - * @return The bytes for uuid. - */ - public com.google.protobuf.ByteString - getUuidBytes() { - java.lang.Object ref = uuid_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - uuid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string uuid = 2; - * @param value The uuid to set. - * @return This builder for chaining. - */ - public Builder setUuid( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - uuid_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - * string uuid = 2; - * @return This builder for chaining. - */ - public Builder clearUuid() { - uuid_ = getDefaultInstance().getUuid(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * string uuid = 2; - * @param value The bytes for uuid to set. - * @return This builder for chaining. - */ - public Builder setUuidBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - uuid_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:IndexProto) - } - - // @@protoc_insertion_point(class_scope:IndexProto) - private static final SearchHits.IndexProto DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new SearchHits.IndexProto(); - } - - public static SearchHits.IndexProto getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public IndexProto parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public SearchHits.IndexProto getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchHitsProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchHitsProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchHitProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchHitProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchHitProto_DocumentFieldsEntry_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchHitProto_DocumentFieldsEntry_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchHitProto_MetaFieldsEntry_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchHitProto_MetaFieldsEntry_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchHitProto_HighlightFieldsEntry_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchHitProto_HighlightFieldsEntry_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchHitProto_MatchedQueriesEntry_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchHitProto_MatchedQueriesEntry_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchHitProto_InnerHitsEntry_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchHitProto_InnerHitsEntry_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_NestedIdentityProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_NestedIdentityProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_DocumentFieldProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_DocumentFieldProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_HighlightFieldProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_HighlightFieldProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchSortValuesProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchSortValuesProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_ExplanationProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_ExplanationProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_SearchShardTargetProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_SearchShardTargetProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_ShardIdProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_ShardIdProto_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_IndexProto_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_IndexProto_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\027server/SearchHits.proto\"W\n\017SearchHitsP" + - "roto\022\035\n\004hits\030\001 \003(\0132\017.SearchHitProto\022\022\n\nt" + - "otal_hits\030\002 \001(\003\022\021\n\tmax_score\030\003 \001(\002\"\241\007\n\016S" + - "earchHitProto\022\r\n\005score\030\001 \001(\002\022\n\n\002id\030\002 \001(\t" + - "\022-\n\017nested_identity\030\003 \001(\0132\024.NestedIdenti" + - "tyProto\022\017\n\007version\030\004 \001(\003\022\016\n\006seq_no\030\005 \001(\003" + - "\022\024\n\014primary_term\030\006 \001(\003\022\016\n\006source\030\007 \001(\014\022&" + - "\n\013explanation\030\010 \001(\0132\021.ExplanationProto\022<" + - "\n\017document_fields\030\t \003(\0132#.SearchHitProto" + - ".DocumentFieldsEntry\0224\n\013meta_fields\030\n \003(" + - "\0132\037.SearchHitProto.MetaFieldsEntry\022>\n\020hi" + - "ghlight_fields\030\013 \003(\0132$.SearchHitProto.Hi" + - "ghlightFieldsEntry\022+\n\013sort_values\030\014 \001(\0132" + - "\026.SearchSortValuesProto\022<\n\017matched_queri" + - "es\030\r \003(\0132#.SearchHitProto.MatchedQueries" + - "Entry\022&\n\005shard\030\016 \001(\0132\027.SearchShardTarget" + - "Proto\0222\n\ninner_hits\030\017 \003(\0132\036.SearchHitPro" + - "to.InnerHitsEntry\032J\n\023DocumentFieldsEntry" + - "\022\013\n\003key\030\001 \001(\t\022\"\n\005value\030\002 \001(\0132\023.DocumentF" + - "ieldProto:\0028\001\032F\n\017MetaFieldsEntry\022\013\n\003key\030" + - "\001 \001(\t\022\"\n\005value\030\002 \001(\0132\023.DocumentFieldProt" + - "o:\0028\001\032L\n\024HighlightFieldsEntry\022\013\n\003key\030\001 \001" + - "(\t\022#\n\005value\030\002 \001(\0132\024.HighlightFieldProto:" + - "\0028\001\0325\n\023MatchedQueriesEntry\022\013\n\003key\030\001 \001(\t\022" + - "\r\n\005value\030\002 \001(\002:\0028\001\032B\n\016InnerHitsEntry\022\013\n\003" + - "key\030\001 \001(\t\022\037\n\005value\030\002 \001(\0132\020.SearchHitsPro" + - "to:\0028\001\"Y\n\023NestedIdentityProto\022\r\n\005field\030\001" + - " \001(\t\022\016\n\006offset\030\002 \001(\005\022#\n\005child\030\003 \001(\0132\024.Ne" + - "stedIdentityProto\"2\n\022DocumentFieldProto\022" + - "\014\n\004name\030\001 \001(\t\022\016\n\006values\030\002 \003(\014\"6\n\023Highlig" + - "htFieldProto\022\014\n\004name\030\001 \001(\t\022\021\n\tfragments\030" + - "\002 \003(\t\"O\n\025SearchSortValuesProto\022\035\n\025format" + - "ted_sort_values\030\001 \003(\014\022\027\n\017raw_sort_values" + - "\030\002 \003(\014\"i\n\020ExplanationProto\022\r\n\005match\030\001 \001(" + - "\010\022\r\n\005value\030\002 \001(\003\022\023\n\013description\030\003 \001(\t\022\"\n" + - "\007details\030\004 \003(\0132\021.ExplanationProto\"a\n\026Sea" + - "rchShardTargetProto\022\017\n\007node_id\030\001 \001(\t\022\037\n\010" + - "shard_id\030\002 \001(\0132\r.ShardIdProto\022\025\n\rcluster" + - "_alias\030\003 \001(\t\"O\n\014ShardIdProto\022\032\n\005index\030\001 " + - "\001(\0132\013.IndexProto\022\020\n\010shard_id\030\002 \001(\005\022\021\n\tha" + - "sh_code\030\003 \001(\005\"(\n\nIndexProto\022\014\n\004name\030\001 \001(" + - "\t\022\014\n\004uuid\030\002 \001(\tb\006proto3" - }; - descriptor = com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }); - internal_static_SearchHitsProto_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_SearchHitsProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchHitsProto_descriptor, - new java.lang.String[] { "Hits", "TotalHits", "MaxScore", }); - internal_static_SearchHitProto_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_SearchHitProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchHitProto_descriptor, - new java.lang.String[] { "Score", "Id", "NestedIdentity", "Version", "SeqNo", "PrimaryTerm", "Source", "Explanation", "DocumentFields", "MetaFields", "HighlightFields", "SortValues", "MatchedQueries", "Shard", "InnerHits", }); - internal_static_SearchHitProto_DocumentFieldsEntry_descriptor = - internal_static_SearchHitProto_descriptor.getNestedTypes().get(0); - internal_static_SearchHitProto_DocumentFieldsEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchHitProto_DocumentFieldsEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_SearchHitProto_MetaFieldsEntry_descriptor = - internal_static_SearchHitProto_descriptor.getNestedTypes().get(1); - internal_static_SearchHitProto_MetaFieldsEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchHitProto_MetaFieldsEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_SearchHitProto_HighlightFieldsEntry_descriptor = - internal_static_SearchHitProto_descriptor.getNestedTypes().get(2); - internal_static_SearchHitProto_HighlightFieldsEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchHitProto_HighlightFieldsEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_SearchHitProto_MatchedQueriesEntry_descriptor = - internal_static_SearchHitProto_descriptor.getNestedTypes().get(3); - internal_static_SearchHitProto_MatchedQueriesEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchHitProto_MatchedQueriesEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_SearchHitProto_InnerHitsEntry_descriptor = - internal_static_SearchHitProto_descriptor.getNestedTypes().get(4); - internal_static_SearchHitProto_InnerHitsEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchHitProto_InnerHitsEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_NestedIdentityProto_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_NestedIdentityProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_NestedIdentityProto_descriptor, - new java.lang.String[] { "Field", "Offset", "Child", }); - internal_static_DocumentFieldProto_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_DocumentFieldProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_DocumentFieldProto_descriptor, - new java.lang.String[] { "Name", "Values", }); - internal_static_HighlightFieldProto_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_HighlightFieldProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_HighlightFieldProto_descriptor, - new java.lang.String[] { "Name", "Fragments", }); - internal_static_SearchSortValuesProto_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_SearchSortValuesProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchSortValuesProto_descriptor, - new java.lang.String[] { "FormattedSortValues", "RawSortValues", }); - internal_static_ExplanationProto_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_ExplanationProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_ExplanationProto_descriptor, - new java.lang.String[] { "Match", "Value", "Description", "Details", }); - internal_static_SearchShardTargetProto_descriptor = - getDescriptor().getMessageTypes().get(7); - internal_static_SearchShardTargetProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_SearchShardTargetProto_descriptor, - new java.lang.String[] { "NodeId", "ShardId", "ClusterAlias", }); - internal_static_ShardIdProto_descriptor = - getDescriptor().getMessageTypes().get(8); - internal_static_ShardIdProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_ShardIdProto_descriptor, - new java.lang.String[] { "Index", "ShardId", "HashCode", }); - internal_static_IndexProto_descriptor = - getDescriptor().getMessageTypes().get(9); - internal_static_IndexProto_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_IndexProto_descriptor, - new java.lang.String[] { "Name", "Uuid", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java.pb.meta b/server/src/main/java/org/opensearch/transport/serde/prototemp/SearchHits.java.pb.meta deleted file mode 100644 index 488a81c235b90d564d07f3d95f2b55c8ba27b3c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18157 zcma*u*Ha_godSgpc2=hUKP*OPT;rjp32L=5~ z5{$L-0}g)(%(j1xqhAMRZ-0a7-vnmszs3G<1G9|ZA@6sA*~*VN`0+bay}WAuzzPDh zr+-Jv@4qwY<-UgaFweH4Abo@IP3(hEKs4LfPn3VD)bf- zu%J|hvQh$iD^%F6AfTg0h4LB#KGmy`&_KYNCKZ~R2zcmH;oL>Qkv0`(+6dU(sX|vL z0gJlj$aE7hwpWGBUIHHVsqolGz`j8hrUwZ)JgmYm!vyq?s*p9NKtc5-%*b$tfCsZG zT+9;ia$W`VFA5Zts&i3}%pw6(msQAHCScyG3YDuWxl2evf;nFtsgQj9Z9J8vd%2nP z+{(*+OTfW96;|&ESp1-Z^MQctk1Bk6B%sBwLXn?=W(f|n^xVr-Qpn4*F1JW{V2|97&e2maIVi%d_53k?@d0z|W}?tZ4+CwMlqq zBVa~`gsKbzx-;d;WD;;VTf%0x0z+S(b+cWu&nC_8K>LFm( zaL%U2o=t&*J<49D8nIafd@N8S*FnIKg=+W<33yeahP9M{k7a6PmlH6dQjM}o0=Czx zFCdbJZvgZu+hxf2}b@70n_$^k+(;{{KH@r z9}@8JC>W5VRd=1X?3E1t> zV8}tho+1rKixeo>hkq%N*Rhm<+hrQ~$_RK~p@F$lfr1UYxkiJO8UilYYOq~Pz}5y0 z+zkp8?Cg)78r(PuIP212(?!6hHyZT3Az)&s2Cq5^=;_vAy_VAZ)e{1ae3IAk69MPWHP|~>py1$Rz1JZBo`9bp`STC6tk2`Ry% z#VZQ|Q{uHKizi@zk`{|e1l&s1!k0?G_;f9D(+OCcrA1E`0n2l=aON=3u0@Mofr7(X zZn+k(%L!I5DBc@&p0vr?u#qCg8=K z7Up>Z+SlZKTq9tsSBnX+0tIK+*kdj7jtO{pqQ&D00l%DTVf{?NlQS*+X9OI-&|>$3 zfKAt0j9wFP^j3?tTLK>6Yw>hXz(l_mrG5hXV|B%RAJL1Y~9IymDMC^%nNCF{_b zOu)EQ9a2*XIAzme(MG`BEFFrn2soOn!(1)_Ym0Q~C?a56i4LPB3KSgeo0@d!Ya(D~ zvkv9W1a!3OP}534dz%c~2$<8MLtO^}ySjC9eP7_*02s$!vsti z)gfz?fDaRLK6-S|Z@C1=$2XgD?ra8RS^M(+?SH$hB>D{N)2R;rQvzG0u|ZHR@GxWNs}2`m323|3A@5d!g2h>q;Q<5P_j0}56C>Ilb$Iniz*N6n{C))r9tst{ z4?*Sokmr^sj7;T02wVpQ>^ly@*f9a~K82v{69JDthv53N0tF!~xeP(=B>^w4LgW`D z1iZQqf&W^8f>_7jhal~qfSV5?`0zl$Vt)v#{RG^x=y7P#e-EMH9+Rzl?YuOzXAS!0$PXUSq~Agam0Z35dwP04cHqepl{NE zn@Iv%W(}~-8lDSF@MP4nYe2_tKz4d!fZ6x$vO%K4D!ewJ@tT0v8~Ofj2>5t!K=OkE z1#vd}4Y2zO_|Y7S8*}J$b_Yp<5nsiHq9%@j1qq?3P9We|VklM<6)32{)`L)V9T2en zI241&1e`hz#lk58%g#ele@?*D%TU~1Dp0VFj=NAa+!65hJ`^br1hhScqTq>u)3IUL ziVYm<^tdoM;sU#O)-d?2fn9k@7+fiV-K;GPo3_AiGcydIGM}qi@Up>C9fr5nfz(t> z7~Zu!Uo%)#%T>K$80!t}O8djm)gRb>83;q>U|{DOmajYf-3ijFdL#^kBY|Dgco>St z1G}+_Fl?jvB=P&np> z2$((=j@mH-dOhK|@F-9azSX&KoXin0b0Hkn3j`cq3diCS0TWl{|MaX9(CZDyv6p~Z z+u^9%CgA99I97N6^?xEMNbv41?Tb9;F9Dg~9Dxi=#B+*iM74aC8Xxr$E8^Vx=Gg#{~rZR2YH# zLIN%oN8qHGfU%`=2ule#To!?uG6LEwBG6EwKtY4bw;NGrHwMn0!+aw?=M(VAVZ^0F zfr9K=EjD7On1Cmx@`$AbY_2e(t3rW-G&`v>; z`i&89-zZR!xF_B6WV#7h?l!{ZCZMO^h{b*a`UZ`-9wgwws8N3RLO{32h;a`Ab7qVv zo*|&^7bEPy5O8YAh~*^$R;(G(yhgxRn?{sx5-@AWh>{%w=Ds(g`aJ;?J{Xbzfq>>i z86Fbw=*Wn>BLY627?JKH;KZpBTc^h7-$B8LB&F6!^jRYVv6;+B>}5ticQUQ$cW~bk ziCYH&y+!hfMFiX|i^Or60tGGapfVEol?0rsj>K{`0rP4jQC3U9r20q{)+7SZ6u(_6^SjE0tG)t^93fX7nlNvaJ$$9UoipwACX=KIPi=nQ-k3$hI#{IKKRL zS)Hgsc^~BLejs4WlL=i<1pMqb;j5p33+5>7nWLU7P$zmWwrz>RrGSD+vv zHe`6tz#MB7O03F=f_C!ZAPT+%0ycb%LhDBYt{+EX_n3gmr%}i{C1Ck^6keYbaP%e$ zOE(1Ux{Jc(odN|7YS|Kv9ZPiJSUcmR@iv}-ZPsWESQRLU^+8fJ&XWi@oDz-M6ar4C zMPofJ`ngm^pX`-Jqo6b(tErBLtNPnzLqw(OazLTDxZ#3fF3KSGpw><`f_L%3)5iXCrFb1AN0xp)uz*|bdx{4UIR1omG uDh8Hn1q#-&t}X`6bp(9f7=zA60uH)jFySI#-kTVdz9Ha;_86SC$NUonq%FSy diff --git a/server/src/main/proto/server/SearchHits.proto b/server/src/main/proto/serde/SearchHitsProto.proto similarity index 95% rename from server/src/main/proto/server/SearchHits.proto rename to server/src/main/proto/serde/SearchHitsProto.proto index 58d16b4828376..30dbb51e2b8e1 100644 --- a/server/src/main/proto/server/SearchHits.proto +++ b/server/src/main/proto/serde/SearchHitsProto.proto @@ -1,5 +1,9 @@ syntax = "proto3"; +package org.opensearch.serde.proto; + +option java_outer_classname = "SearchHitsTransportProto"; + /* SearchHit[] hits TotalHits totalHits @@ -12,7 +16,7 @@ message SearchHitsProto { repeated SearchHitProto hits = 1; int64 total_hits = 2; float max_score = 3; - repeated SortFieldProto sort_fields = 4; + repeated bytes sort_fields = 4; string collapse_field = 5; repeated bytes collapse_values = 6; } From 21cc29e179aa1604618a09be2837a92c07d9f090 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Sun, 25 Aug 2024 00:54:17 -0700 Subject: [PATCH 24/61] Tentative toProto fromProto implementations for topHits Signed-off-by: Finn Carroll --- .../transport/serde/SearchHitsSerDe.java | 86 +++++++++++++++---- .../main/proto/serde/SearchHitsProto.proto | 17 +++- 2 files changed, 80 insertions(+), 23 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java index cbb3602efae48..b22fd0804288e 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java @@ -8,14 +8,18 @@ package org.opensearch.transport.serde; +import com.google.protobuf.ByteString; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TotalHits; +import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.lucene.Lucene; +import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitsProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.TotalHitsProto; import java.io.IOException; @@ -50,27 +54,71 @@ public void serialize(SearchHits object, StreamOutput out) throws SerDe.Serializ } } - // TODO: Update proto definition - SearchHitsProto toProto(SearchHits searchHits) { -// SearchHits.SerializationAccess serI = searchHits.getSerAccess(); -// -// SearchHitsProto.Builder builder = SearchHitsProto.newBuilder() -// .setTotalHits(serI.getTotalHits().value) -// .setMaxScore(serI.getMaxScore()); -// -// for (SearchHit hit : searchHits.getHits()) { -// builder.addHits(searchHitSerDe.toProto(hit)); -// } -// -// return builder.build(); + SearchHitsProto toProto(SearchHits searchHits) throws SerDe.SerializationException{ + SearchHits.SerializationAccess serI = searchHits.getSerAccess(); + SearchHitsProto.Builder builder = SearchHitsProto.newBuilder() + .setMaxScore(serI.getMaxScore()) + .setCollapseField(serI.getCollapseField()); + + for (SearchHit hit : serI.getHits()) { + builder.addHits(searchHitSerDe.toProto(hit)); + } + + TotalHits totHits = serI.getTotalHits(); + TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder() + .setRelation(totHits.relation.ordinal()) + .setValue(totHits.value); + builder.setTotalHits(totHitsBuilder); + + try (BytesStreamOutput sortOut = new BytesStreamOutput()) { + sortOut.writeOptionalArray(Lucene::writeSortField, serI.getSortFields()); + builder.setSortFields(ByteString.copyFrom(sortOut.bytes().toBytesRef().bytes)); + } catch (IOException e){ + throw new SerDe.SerializationException("Failed to serialize SearchHits to proto", e); + } + + try (BytesStreamOutput collapseOut = new BytesStreamOutput()) { + collapseOut.writeOptionalArray(Lucene::writeSortField, serI.getSortFields()); + builder.setCollapseValues(ByteString.copyFrom(collapseOut.bytes().toBytesRef().bytes)); + } catch (IOException e){ + throw new SerDe.SerializationException("Failed to serialize SearchHits to proto", e); + } + + return builder.build(); } - // TODO: Update proto definition - SearchHits fromProto(SearchHitsProto proto) { -// long totalHits = proto.getTotalHits(); -// float maxScore = proto.getMaxScore(); -// -// return new SearchHits();*/ + SearchHits fromProto(SearchHitsProto proto) throws SerDe.SerializationException { + float maxScore = proto.getMaxScore(); + String collapseField = proto.getCollapseField(); + + TotalHitsProto totalHits = proto.getTotalHits(); + long rel = totalHits.getRelation(); + long val = totalHits.getValue(); + if (rel < 0 || rel >= TotalHits.Relation.values().length) { + throw new SerDe.SerializationException("Failed to deserialize TotalHits from proto"); + } + TotalHits totHits = new TotalHits(val, TotalHits.Relation.values()[(int) rel]); + + SortField[] sortFields = null; + try (StreamInput sortBytesInput = new BytesArray(proto.getSortFields().toByteArray()).streamInput()) { + sortFields = sortBytesInput.readOptionalArray(Lucene::readSortField, SortField[]::new); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize SearchHits from proto", e); + } + + Object[] collapseValues = null; + try (StreamInput collapseBytesInput = new BytesArray(proto.getCollapseValues().toByteArray()).streamInput()) { + collapseValues = collapseBytesInput.readOptionalArray(Lucene::readSortValue, Object[]::new); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize SearchHits from proto", e); + } + + SearchHit[] hits = new SearchHit[proto.getHitsCount()]; + for(int i = 0; i < hits.length; i++) { + hits[i] = searchHitSerDe.fromProto(proto.getHits(i)); + } + + return new SearchHits(hits, totHits, maxScore, sortFields, collapseField, collapseValues); } private SearchHits fromStream(StreamInput in) throws IOException { diff --git a/server/src/main/proto/serde/SearchHitsProto.proto b/server/src/main/proto/serde/SearchHitsProto.proto index 30dbb51e2b8e1..78a28da3acb33 100644 --- a/server/src/main/proto/serde/SearchHitsProto.proto +++ b/server/src/main/proto/serde/SearchHitsProto.proto @@ -14,11 +14,11 @@ Object[] collapseValues */ message SearchHitsProto { repeated SearchHitProto hits = 1; - int64 total_hits = 2; + TotalHitsProto total_hits = 2; float max_score = 3; - repeated bytes sort_fields = 4; - string collapse_field = 5; - repeated bytes collapse_values = 6; + string collapse_field = 4; + bytes sort_fields = 5; + bytes collapse_values = 6; } /** @@ -56,6 +56,15 @@ message SearchHitProto { map inner_hits = 15; } +/* +int value; +Relation relation; + */ +message TotalHitsProto { + int64 value = 1; + int64 relation = 2; +} + /* Text field; int offset; From 7f1c0258a1b68857ef59c1c924d3b1fdbd592f75 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 26 Aug 2024 16:52:01 -0700 Subject: [PATCH 25/61] Refactor to inheritance based model Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 345 +++++------ .../org/opensearch/search/SearchHits.java | 122 ++-- .../search/fetch/FetchSearchResult.java | 53 +- .../serde/FetchSearchResultSerDe.java | 89 +++ .../serde/FetchSearchResultsSerDe.java | 62 -- .../transport/serde/SearchHitSerDe.java | 580 +++++------------- .../transport/serde/SearchHitsSerDe.java | 178 +++--- .../org/opensearch/transport/serde/SerDe.java | 215 ++++++- .../main/proto/serde/SearchHitsProto.proto | 11 +- 9 files changed, 744 insertions(+), 911 deletions(-) create mode 100644 server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java delete mode 100644 server/src/main/java/org/opensearch/transport/serde/FetchSearchResultsSerDe.java diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 1286120fffe3a..10cbc00411408 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -34,9 +34,9 @@ import org.apache.lucene.search.Explanation; import org.opensearch.OpenSearchParseException; +import org.opensearch.Version; import org.opensearch.action.OriginalIndices; import org.opensearch.common.Nullable; -import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.annotation.PublicApi; import org.opensearch.common.document.DocumentField; import org.opensearch.common.xcontent.XContentHelper; @@ -65,7 +65,6 @@ import org.opensearch.index.mapper.SourceFieldMapper; import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.rest.action.search.RestSearchAction; -import org.opensearch.transport.serde.SearchHitSerDe; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.search.lookup.SourceLookup; import org.opensearch.transport.RemoteClusterAware; @@ -79,8 +78,13 @@ 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; @@ -94,46 +98,68 @@ * @opensearch.api */ @PublicApi(since = "1.0.0") -public final class SearchHit implements Writeable, ToXContentObject, Iterable { +public class SearchHit implements Writeable, ToXContentObject, Iterable { - private final transient int docId; + protected transient int docId; private static final float DEFAULT_SCORE = Float.NaN; - private float score = DEFAULT_SCORE; + protected float score = DEFAULT_SCORE; - private final Text id; + protected Text id; - private final NestedIdentity nestedIdentity; + protected NestedIdentity nestedIdentity; - private long version = -1; - private long seqNo = SequenceNumbers.UNASSIGNED_SEQ_NO; - private long primaryTerm = SequenceNumbers.UNASSIGNED_PRIMARY_TERM; + protected long version = -1; + protected long seqNo = SequenceNumbers.UNASSIGNED_SEQ_NO; + protected long primaryTerm = SequenceNumbers.UNASSIGNED_PRIMARY_TERM; - private BytesReference source; + protected BytesReference source; - private Map documentFields; - private final Map metaFields; + protected Map documentFields; + protected Map metaFields; - private Map highlightFields = null; + protected Map highlightFields = null; - private SearchSortValues sortValues = SearchSortValues.EMPTY; + protected SearchSortValues sortValues = SearchSortValues.EMPTY; - private Map matchedQueries = new HashMap<>(); + protected Map matchedQueries = new HashMap<>(); - private Explanation explanation; + protected Explanation explanation; @Nullable - private SearchShardTarget shard; + protected SearchShardTarget shard; // These two fields normally get set when setting the shard target, so they hold the same values as the target thus don't get // serialized over the wire. When parsing hits back from xcontent though, in most of the cases (whenever explanation is disabled) // we can't rebuild the shard target object so we need to set these manually for users retrieval. - private transient String index; - private transient String clusterAlias; + protected transient String index; + protected transient String clusterAlias; private Map sourceAsMap; - private Map innerHits; + protected Map innerHits; + + public SearchHit(SearchHit hit) { + this.docId = hit.docId; + this.id = hit.id; + this.nestedIdentity = hit.nestedIdentity; + this.version = hit.version; + this.seqNo = hit.seqNo; + this.primaryTerm = hit.primaryTerm; + this.source = hit.source; + this.documentFields = hit.documentFields; + this.metaFields = hit.metaFields; + this.highlightFields = hit.highlightFields; + this.sortValues = hit.sortValues; + this.matchedQueries = hit.matchedQueries; + this.explanation = hit.explanation; + this.shard = hit.shard; + this.index = hit.index; + this.clusterAlias = hit.clusterAlias; + this.innerHits = hit.innerHits; + this.score = hit.score; + this.sourceAsMap = hit.sourceAsMap; + } // used only in tests public SearchHit(int docId) { @@ -162,187 +188,130 @@ 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 documentFields, - Map metaFields, - Map highlightFields, - Map matchedQueries, - Map innerHits, - String index, - String clusterAlias - ) { - this.docId = docId; - this.score = score; - this.seqNo = seqNo; - this.version = version; - this.primaryTerm = primaryTerm; - this.id = id; - this.source = source; - this.shard = shardTarget; - this.explanation = explanation; - this.sortValues = sortValues; - this.nestedIdentity = nestedIdentity; - this.documentFields = documentFields; - this.metaFields = metaFields; - this.highlightFields = highlightFields; - this.matchedQueries = matchedQueries; - this.innerHits = innerHits; - this.index = index; - this.clusterAlias = clusterAlias; - } - - public SearchHit(SearchHit hit) throws IOException { - this.docId = hit.docId; - this.score = hit.score; - this.seqNo = hit.seqNo; - this.version = hit.version; - this.primaryTerm = hit.primaryTerm; - this.id = hit.id; - this.source = hit.source; - this.shard = hit.shard; - this.explanation = hit.explanation; - this.sortValues = hit.sortValues; - this.nestedIdentity = hit.nestedIdentity; - this.documentFields = hit.documentFields; - this.metaFields = hit.metaFields; - this.highlightFields = hit.highlightFields; - this.matchedQueries = hit.matchedQueries; - this.innerHits = hit.innerHits; - this.sourceAsMap = hit.sourceAsMap; - this.index = hit.index; - this.clusterAlias = hit.clusterAlias; - } - - /** - * Preserving this constructor for compatibility. - * Going forward deserialize with dedicated SearchHitSerDe. - */ public SearchHit(StreamInput in) throws IOException { - this(new SearchHitSerDe().deserialize(in)); - } - - /** - * Internal access for serialization interface. - * @opensearch.api - */ - @ExperimentalApi - public interface SerializationAccess { - float getScore(); - - Text getId(); - - NestedIdentity getNestedIdentity(); - - long getVersion(); - - long getSeqNo(); - - long getPrimaryTerm(); - - BytesReference getSource(); - - Explanation getExplanation(); - - Map getDocumentFields(); - - Map getMetaFields(); - - Map getHighlightedFields(); - - SearchSortValues getSortValues(); - - Map getMatchedQueries(); - - SearchShardTarget getShard(); - - Map 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; + docId = -1; + score = in.readFloat(); + id = in.readOptionalText(); + if (in.getVersion().before(Version.V_2_0_0)) { + in.readOptionalText(); + } + nestedIdentity = in.readOptionalWriteable(NestedIdentity::new); + version = in.readLong(); + seqNo = in.readZLong(); + primaryTerm = in.readVLong(); + source = in.readBytesReference(); + if (source.length() == 0) { + source = null; + } + if (in.readBoolean()) { + explanation = readExplanation(in); + } + documentFields = in.readMap(StreamInput::readString, DocumentField::new); + metaFields = in.readMap(StreamInput::readString, DocumentField::new); + + int size = in.readVInt(); + if (size == 0) { + highlightFields = emptyMap(); + } else if (size == 1) { + HighlightField field = new HighlightField(in); + highlightFields = singletonMap(field.name(), field); + } else { + Map highlightFields = new HashMap<>(); + for (int i = 0; i < size; i++) { + HighlightField field = new HighlightField(in); + highlightFields.put(field.name(), field); } + this.highlightFields = unmodifiableMap(highlightFields); + } - public BytesReference getSource() { - return source; + sortValues = new SearchSortValues(in); + + size = in.readVInt(); + if (in.getVersion().onOrAfter(Version.V_2_13_0)) { + if (size > 0) { + Map tempMap = in.readMap(StreamInput::readString, StreamInput::readFloat); + matchedQueries = tempMap.entrySet() + .stream() + .sorted(Map.Entry.comparingByKey()) + .collect( + Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new) + ); } - - public Explanation getExplanation() { - return explanation; + } else { + matchedQueries = new LinkedHashMap<>(size); + for (int i = 0; i < size; i++) { + matchedQueries.put(in.readString(), Float.NaN); } - - public Map getDocumentFields() { - return documentFields; + } + // we call the setter here because that also sets the local index parameter + shard(in.readOptionalWriteable(SearchShardTarget::new)); + size = in.readVInt(); + if (size > 0) { + innerHits = new HashMap<>(size); + for (int i = 0; i < size; i++) { + String key = in.readString(); + SearchHits value = new SearchHits(in); + innerHits.put(key, value); } + } else { + innerHits = null; + } + } - public Map getMetaFields() { - return metaFields; - } + protected SearchHit() {} - public Map getHighlightedFields() { - return highlightFields; - } + protected static final Text SINGLE_MAPPING_TYPE = new Text(MapperService.SINGLE_MAPPING_NAME); - public SearchSortValues getSortValues() { - return sortValues; + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeFloat(score); + out.writeOptionalText(id); + if (out.getVersion().before(Version.V_2_0_0)) { + out.writeOptionalText(SINGLE_MAPPING_TYPE); + } + out.writeOptionalWriteable(nestedIdentity); + out.writeLong(version); + out.writeZLong(seqNo); + out.writeVLong(primaryTerm); + out.writeBytesReference(source); + if (explanation == null) { + out.writeBoolean(false); + } else { + out.writeBoolean(true); + writeExplanation(out, explanation); + } + out.writeMap(documentFields, StreamOutput::writeString, (stream, documentField) -> documentField.writeTo(stream)); + out.writeMap(metaFields, StreamOutput::writeString, (stream, documentField) -> documentField.writeTo(stream)); + if (highlightFields == null) { + out.writeVInt(0); + } else { + out.writeVInt(highlightFields.size()); + for (HighlightField highlightField : highlightFields.values()) { + highlightField.writeTo(out); } + } + sortValues.writeTo(out); - public Map getMatchedQueries() { - return matchedQueries; + out.writeVInt(matchedQueries.size()); + if (out.getVersion().onOrAfter(Version.V_2_13_0)) { + if (!matchedQueries.isEmpty()) { + out.writeMap(matchedQueries, StreamOutput::writeString, StreamOutput::writeFloat); } - - public SearchShardTarget getShard() { - return shard; + } else { + for (String matchedFilter : matchedQueries.keySet()) { + out.writeString(matchedFilter); } - - public Map getInnerHits() { - return innerHits; + } + out.writeOptionalWriteable(shard); + if (innerHits == null) { + out.writeVInt(0); + } else { + out.writeVInt(innerHits.size()); + for (Map.Entry entry : innerHits.entrySet()) { + out.writeString(entry.getKey()); + entry.getValue().writeTo(out); } - }; - } - - public static final Text SINGLE_MAPPING_TYPE = new Text(MapperService.SINGLE_MAPPING_NAME); - - /** - * Preserving for compatibility. - * Going forward serialize with dedicated SearchHitSerDe. - */ - @Override - public void writeTo(StreamOutput out) throws IOException { - SearchHitSerDe serDe = new SearchHitSerDe(); - serDe.serialize(this, out); + } } public int docId() { diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index 4802ecfa5344b..6b385d566116f 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -36,8 +36,8 @@ import org.apache.lucene.search.TotalHits; import org.apache.lucene.search.TotalHits.Relation; import org.opensearch.common.Nullable; -import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.annotation.PublicApi; +import org.opensearch.common.lucene.Lucene; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; @@ -45,7 +45,6 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.rest.action.search.RestSearchAction; -import org.opensearch.transport.serde.SearchHitsSerDe; import java.io.IOException; import java.util.ArrayList; @@ -62,7 +61,7 @@ * @opensearch.api */ @PublicApi(since = "1.0.0") -public final class SearchHits implements Writeable, ToXContentFragment, Iterable { +public class SearchHits implements Writeable, ToXContentFragment, Iterable { public static SearchHits empty() { return empty(true); } @@ -73,15 +72,24 @@ public static SearchHits empty(boolean withTotalHits) { public static final SearchHit[] EMPTY = new SearchHit[0]; - private final SearchHit[] hits; - private final TotalHits totalHits; - private final float maxScore; + protected SearchHit[] hits; + protected TotalHits totalHits; + protected float maxScore; @Nullable - private final SortField[] sortFields; + protected SortField[] sortFields; @Nullable - private final String collapseField; + protected String collapseField; @Nullable - private final Object[] collapseValues; + protected Object[] collapseValues; + + public SearchHits(SearchHits sHits) { + this.hits = sHits.hits; + this.totalHits = sHits.totalHits; + this.maxScore = sHits.maxScore; + this.sortFields = sHits.sortFields; + this.collapseField = sHits.collapseField; + this.collapseValues = sHits.collapseValues; + } public SearchHits(SearchHit[] hits, @Nullable TotalHits totalHits, float maxScore) { this(hits, totalHits, maxScore, null, null, null); @@ -103,73 +111,47 @@ public SearchHits( this.collapseValues = collapseValues; } - public SearchHits(SearchHits SrchHits) { - this(SrchHits.hits, SrchHits.totalHits, SrchHits.maxScore, SrchHits.sortFields, SrchHits.collapseField, SrchHits.collapseValues); - } - - /** - * Internal access for serialization interface. - * @opensearch.api - */ - @ExperimentalApi - public interface SerializationAccess { - TotalHits getTotalHits(); - - float getMaxScore(); - - SearchHit[] getHits(); - - SortField[] getSortFields(); - - String getCollapseField(); - - Object[] getCollapseValues(); - } - - public SearchHits.SerializationAccess getSerAccess() { - return new SearchHits.SerializationAccess() { - public TotalHits getTotalHits() { - return totalHits; - } - - public float getMaxScore() { - return maxScore; - } - - public SearchHit[] getHits() { - return hits; - } - - public SortField[] getSortFields() { - return sortFields; - } - - public String getCollapseField() { - return collapseField; - } - - public Object[] getCollapseValues() { - return collapseValues; + public SearchHits(StreamInput in) throws IOException { + if (in.readBoolean()) { + totalHits = Lucene.readTotalHits(in); + } else { + // track_total_hits is false + totalHits = null; + } + maxScore = in.readFloat(); + int size = in.readVInt(); + if (size == 0) { + hits = EMPTY; + } else { + hits = new SearchHit[size]; + for (int i = 0; i < hits.length; i++) { + hits[i] = new SearchHit(in); } - }; + } + sortFields = in.readOptionalArray(Lucene::readSortField, SortField[]::new); + collapseField = in.readOptionalString(); + collapseValues = in.readOptionalArray(Lucene::readSortValue, Object[]::new); } - /** - * Preserving for compatibility. - * Going forward serialize with dedicated SearchHitsSerDe. - */ - public SearchHits(StreamInput in) throws IOException { - this(new SearchHitsSerDe().deserialize(in)); - } + protected SearchHits () {} - /** - * Preserving for compatibility. - * Going forward deserialize with dedicated SearchHitsSerDe. - */ @Override public void writeTo(StreamOutput out) throws IOException { - SearchHitsSerDe serDe = new SearchHitsSerDe(); - serDe.serialize(this, out); + final boolean hasTotalHits = totalHits != null; + out.writeBoolean(hasTotalHits); + if (hasTotalHits) { + Lucene.writeTotalHits(out, totalHits); + } + out.writeFloat(maxScore); + out.writeVInt(hits.length); + if (hits.length > 0) { + for (SearchHit hit : hits) { + hit.writeTo(out); + } + } + out.writeOptionalArray(Lucene::writeSortField, sortFields); + out.writeOptionalString(collapseField); + out.writeOptionalArray(Lucene::writeSortValue, collapseValues); } /** diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index dc2a2aa7caaea..643792b17558c 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -32,7 +32,6 @@ package org.opensearch.search.fetch; -import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.annotation.PublicApi; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; @@ -40,7 +39,6 @@ import org.opensearch.search.SearchHits; import org.opensearch.search.SearchPhaseResult; import org.opensearch.search.SearchShardTarget; -import org.opensearch.transport.serde.FetchSearchResultsSerDe; import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.search.query.QuerySearchResult; @@ -54,28 +52,16 @@ @PublicApi(since = "1.0.0") public class FetchSearchResult extends SearchPhaseResult { - private SearchHits hits; + protected SearchHits hits; // client side counter private transient int counter; public FetchSearchResult() {} - /** - * Preserving for compatibility. - * Going forward deserialize with dedicated FetchSearchResultsSerDe. - */ public FetchSearchResult(StreamInput in) throws IOException { - this(new FetchSearchResultsSerDe().deserialize(in)); - } - - public FetchSearchResult(FetchSearchResult result) { - this.contextId = result.contextId; - this.hits = result.hits; - } - - public FetchSearchResult(ShardSearchContextId id, SearchHits hits) throws IOException { - this.contextId = id; - this.hits = hits; + super(in); + contextId = new ShardSearchContextId(in); + hits = new SearchHits(in); } public FetchSearchResult(ShardSearchContextId id, SearchShardTarget shardTarget) { @@ -83,29 +69,6 @@ public FetchSearchResult(ShardSearchContextId id, SearchShardTarget shardTarget) setSearchShardTarget(shardTarget); } - /** - * Internal access for serialization interface. - * @opensearch.api - */ - @ExperimentalApi - public interface SerializationAccess { - ShardSearchContextId getShardSearchContextId(); - - SearchHits getHits(); - } - - public SerializationAccess getSerAccess() { - return new SerializationAccess() { - public ShardSearchContextId getShardSearchContextId() { - return contextId; - } - - public SearchHits getHits() { - return hits; - } - }; - } - @Override public QuerySearchResult queryResult() { return null; @@ -141,13 +104,9 @@ public int counterGetAndIncrement() { return counter++; } - /** - * Preserving for compatibility. - * Going forward serialize with dedicated FetchSearchResultsSerDe. - */ @Override public void writeTo(StreamOutput out) throws IOException { - FetchSearchResultsSerDe serDe = new FetchSearchResultsSerDe(); - serDe.serialize(this, out); + contextId.writeTo(out); + hits.writeTo(out); } } diff --git a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java new file mode 100644 index 0000000000000..383e86635a27e --- /dev/null +++ b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java @@ -0,0 +1,89 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.transport.serde; + +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.search.fetch.FetchSearchResult; +import org.opensearch.search.internal.ShardSearchContextId; +import org.opensearch.serde.proto.SearchHitsTransportProto; + +import java.io.IOException; + +/** + * Serialization/Deserialization implementations for SearchHit. + * @opensearch.internal + */ +public class FetchSearchResultSerDe extends FetchSearchResult implements SerDe.nativeSerializer, SerDe.protobufSerializer { + SerDe.Strategy strategy = SerDe.Strategy.NATIVE; + + public FetchSearchResultSerDe(SerDe.Strategy strategy, StreamInput in) throws IOException { + this.strategy = strategy; + switch (this.strategy) { + case NATIVE: + fromNativeStream(in); + case PROTOBUF: + fromProtobufStream(in); + } + } + + public FetchSearchResultSerDe(StreamInput in) throws IOException { + fromNativeStream(in); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + switch (this.strategy) { + case NATIVE: + toNativeStream(out); + case PROTOBUF: + toProtobufStream(out); + } + } + +// @Override +// public void toProtobufStream(StreamOutput out) throws IOException { +// toProto().writeTo(out); +// } + +// @Override +// public void fromProtobufStream(StreamInput in) throws IOException { +// FetchSearchResultProto proto = SearchHitsTransportProto.SearchHitsProto.parseFrom(in); +// fromProto(proto); +// } + + @Override + public void toNativeStream(StreamOutput out) throws IOException { + super.writeTo(out); + } + + @Override + public void fromNativeStream(StreamInput in) throws IOException { + this.hits = new SearchHitsSerDe(SerDe.Strategy.NATIVE, in); + this.contextId = new ShardSearchContextId(in); + } + + @Override + public void toProtobufStream(StreamOutput out) throws IOException { + // IMPL + } + + @Override + public void fromProtobufStream(StreamInput in) throws IOException { + // IMPL + } + +// SearchHitsTransportProto.SearchHitsProto toProto() { +// +// } +// +// void fromProto(SearchHitsTransportProto.SearchHitsProto searchHits) { +// +// } +} diff --git a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultsSerDe.java deleted file mode 100644 index 2b175dd68a06a..0000000000000 --- a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultsSerDe.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.transport.serde; - -import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.search.SearchHits; -import org.opensearch.search.fetch.FetchSearchResult; -import org.opensearch.search.internal.ShardSearchContextId; - -import java.io.IOException; - -/** - * Serialization/Deserialization implementations for SearchHit. - * @opensearch.internal - */ -public class FetchSearchResultsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { - SearchHitsSerDe searchHitsSerDe; - - public FetchSearchResultsSerDe () { - this.searchHitsSerDe = new SearchHitsSerDe(); - } - - @Override - public FetchSearchResult deserialize(StreamInput in) { - try { - return fromStream(in); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); - } - } - - @Override - public void serialize(FetchSearchResult object, StreamOutput out) throws SerDe.SerializationException { - try { - toStream(object, out); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); - } - } - - private FetchSearchResult fromStream(StreamInput in) throws IOException { - ShardSearchContextId contextId = new ShardSearchContextId(in); - SearchHits hits = searchHitsSerDe.deserialize(in); - return new FetchSearchResult(contextId, hits); - } - - private void toStream(FetchSearchResult object, StreamOutput out) throws IOException { - FetchSearchResult.SerializationAccess serI = object.getSerAccess(); - ShardSearchContextId contextId = serI.getShardSearchContextId(); - SearchHits hits = serI.getHits(); - - contextId.writeTo(out); - searchHitsSerDe.serialize(hits, out); - } -} diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java index 9d4a21bbe80c6..087b2ef1f9f3e 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java @@ -9,40 +9,23 @@ package org.opensearch.transport.serde; import com.google.protobuf.ByteString; -import org.apache.lucene.search.Explanation; import org.opensearch.Version; import org.opensearch.common.document.DocumentField; -import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.common.lucene.Lucene; -import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; 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.core.index.Index; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; import org.opensearch.search.SearchShardTarget; import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitsProto; import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitProto; import org.opensearch.serde.proto.SearchHitsTransportProto.NestedIdentityProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.DocumentFieldProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.HighlightFieldProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchSortValuesProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchShardTargetProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.ExplanationProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.ShardIdProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.IndexProto; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -50,370 +33,83 @@ 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.search.SearchHit.SINGLE_MAPPING_TYPE; +import static org.opensearch.transport.serde.SerDe.documentFieldFromProto; +import static org.opensearch.transport.serde.SerDe.documentFieldToProto; +import static org.opensearch.transport.serde.SerDe.explanationFromProto; +import static org.opensearch.transport.serde.SerDe.explanationToProto; +import static org.opensearch.transport.serde.SerDe.highlightFieldFromProto; +import static org.opensearch.transport.serde.SerDe.highlightFieldToProto; +import static org.opensearch.transport.serde.SerDe.searchShardTargetFromProto; +import static org.opensearch.transport.serde.SerDe.searchShardTargetToProto; +import static org.opensearch.transport.serde.SerDe.searchSortValuesFromProto; +import static org.opensearch.transport.serde.SerDe.searchSortValuesToProto; /** * Serialization/Deserialization implementations for SearchHit. * @opensearch.internal */ -public class SearchHitSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { - SearchHitsSerDe searchHitsSerDe = new SearchHitsSerDe(); +public class SearchHitSerDe extends SearchHit implements SerDe.nativeSerializer, SerDe.protobufSerializer { + SerDe.Strategy strategy = SerDe.Strategy.NATIVE; - @Override - public SearchHit deserialize(StreamInput in) { - try { - return fromStream(in); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); - } - } - - @Override - public void serialize(SearchHit object, StreamOutput out) throws SerDe.SerializationException { - try { - toStream(object, out); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); - } - } - - SearchHitProto toProto(SearchHit searchHit) { - SearchHit.SerializationAccess serI = searchHit.getSerAccess(); - - SearchHitProto.Builder builder = SearchHitProto.newBuilder() - .setScore(serI.getScore()) - .setId(serI.getId().string()) - .setVersion(serI.getVersion()) - .setSeqNo(serI.getSeqNo()) - .setPrimaryTerm(serI.getPrimaryTerm()); - - if (serI.getNestedIdentity() != null) { - builder.setNestedIdentity(nestedIdentityToProto(serI.getNestedIdentity())); - } - - if (serI.getSource() != null) { - builder.setSource(ByteString.copyFrom(serI.getSource().toBytesRef().bytes)); - } - - if (serI.getExplanation() != null) { - builder.setExplanation(explanationToProto(serI.getExplanation())); - } - - serI.getDocumentFields().forEach((key, value) -> - builder.putDocumentFields(key, documentFieldToProto(value)) - ); - - serI.getMetaFields().forEach((key, value) -> - builder.putMetaFields(key, documentFieldToProto(value)) - ); - - serI.getHighlightedFields().forEach((key, value) -> - builder.putHighlightFields(key, highlightFieldToProto(value)) - ); - - if (serI.getSortValues() != null) { - builder.setSortValues(searchSortValuesToProto(serI.getSortValues())); - } - - serI.getMatchedQueries().forEach(builder::putMatchedQueries); - - if (serI.getShard() != null) { - builder.setShard(searchShardTargetToProto(serI.getShard())); - } - - if (serI.getInnerHits() != null) { - serI.getInnerHits().forEach((key, value) -> - builder.putInnerHits(key, searchHitsSerDe.toProto(value)) - ); - } - - return builder.build(); - } - - SearchHit fromProto(SearchHitProto proto) throws SerDe.SerializationException { - int docId = -1; - float score = proto.getScore(); - long seqNo = proto.getSeqNo(); - long version = proto.getVersion(); - long primaryTerm = proto.getPrimaryTerm(); - Text id = new Text(proto.getId()); - BytesReference source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); - SearchShardTarget shard = searchShardTargetFromProto(proto.getShard()); - Explanation explanation = explanationFromProto(proto.getExplanation()); - SearchSortValues sortValues = searchSortValuesFromProto(proto.getSortValues()); - SearchHit.NestedIdentity nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); - - HashMap documentFields = new HashMap<>(); - proto.getDocumentFieldsMap().forEach((key, value) -> - documentFields.put(key, documentFieldFromProto(value)) - ); - - HashMap metaFields = new HashMap<>(); - proto.getMetaFieldsMap().forEach((key, value) -> - metaFields.put(key, documentFieldFromProto(value)) - ); - - HashMap highlightFields = new HashMap<>(); - proto.getHighlightFieldsMap().forEach((key, value) -> - highlightFields.put(key, highlightFieldFromProto(value)) - ); - - Map matchedQueries = proto.getMatchedQueriesMap(); - - HashMap innerHits = new HashMap<>(); - proto.getInnerHitsMap().forEach((key, value) -> - innerHits.put(key, this.searchHitsSerDe.fromProto(value)) - ); - - String index = shard.getIndex(); - String clusterAlias = shard.getClusterAlias(); - - return new SearchHit( - docId, - score, - seqNo, - version, - primaryTerm, - id, - source, - shard, - explanation, - sortValues, - nestedIdentity, - documentFields, - metaFields, - highlightFields, - matchedQueries, - innerHits, - index, - clusterAlias - ); + public SearchHitSerDe(SearchHit hit, SerDe.Strategy strategy) { + super(hit); + this.strategy = strategy; } - static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { - NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() - .setField(nestedIdentity.getField().string()) - .setOffset(nestedIdentity.getOffset()); - - if (nestedIdentity.getChild() != null) { - builder.setChild(nestedIdentityToProto(nestedIdentity.getChild())); + public SearchHitSerDe(SerDe.Strategy strategy, StreamInput in) throws IOException { + this.strategy = strategy; + switch (this.strategy) { + case NATIVE: + fromNativeStream(in); + case PROTOBUF: + fromProtobufStream(in); } - - return builder.build(); } - static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityProto proto) { - String field = proto.getField(); - int offset = proto.getOffset(); - - SearchHit.NestedIdentity child = null; - if (proto.hasChild()) { - child = nestedIdentityFromProto(proto.getChild()); - } - - return new SearchHit.NestedIdentity(field, offset, child); + public SearchHitSerDe(StreamInput in) throws IOException { + fromNativeStream(in); } - // TODO: Lucene definitions should maybe be serialized as generic bytes arrays. - static ExplanationProto explanationToProto(Explanation explanation) { - ExplanationProto.Builder builder = ExplanationProto.newBuilder() - .setMatch(explanation.isMatch()) - .setValue(explanation.getValue().longValue()) - .setDescription(explanation.getDescription()); - - for (Explanation detail : explanation.getDetails()) { - builder.addDetails(explanationToProto(detail)); - } - - return builder.build(); - } - - static Explanation explanationFromProto(ExplanationProto proto) { - long value = proto.getValue(); - String description = proto.getDescription(); - Collection details = new ArrayList<>(); - - for (ExplanationProto det : proto.getDetailsList()) { - details.add(explanationFromProto(det)); - } - - if (proto.getMatch()) { - return Explanation.match(value, description, details); - } - - return Explanation.noMatch(description, details); - } - - // Is there a reason to open a new stream for each object? - // Seems simpler to write a single stream. - static DocumentFieldProto documentFieldToProto(DocumentField field) { - DocumentFieldProto.Builder builder = DocumentFieldProto.newBuilder().setName(field.getName()); - - try (BytesStreamOutput docsOut = new BytesStreamOutput()) { - docsOut.writeCollection(field.getValues(), StreamOutput::writeGenericValue); - builder.addValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); - } catch (IOException e){ - builder.addValues(ByteString.EMPTY); - } - - return builder.build(); - } - - static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws SerDe.SerializationException { - String name = proto.getName(); - List values = new ArrayList<>(0); - - if (proto.getValuesCount() > 0) { - BytesReference valuesBytes = new BytesArray(proto.getValues(0).toByteArray()); - try (StreamInput in = valuesBytes.streamInput()) { - Object readValue = in.readGenericValue(); - values.add(readValue); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize DocumentField values from proto object", e); - } - } - - return new DocumentField(name, values); + public SearchHitSerDe(SearchHitProto proto) throws IOException { + fromProto(proto); } - static HighlightFieldProto highlightFieldToProto(HighlightField field) { - HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder() - .setName(field.getName()); - - for (Text frag : field.getFragments()) { - builder.addFragments(frag.string()); - } - - return builder.build(); - } - - static HighlightField highlightFieldFromProto(HighlightFieldProto proto) { - String name = proto.getName(); - Text[] fragments = new Text[proto.getFragmentsCount()]; - - for (int i = 0; i < proto.getFragmentsCount(); i++) { - fragments[i] = new Text(proto.getFragments(i)); - } - - return new HighlightField(name, fragments); - } - - // See above comment for documentFieldToProto. - static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { - SearchSortValuesProto.Builder builder = SearchSortValuesProto.newBuilder(); - - try (BytesStreamOutput formOut = new BytesStreamOutput()) { - formOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); - builder.addFormattedSortValues(ByteString.copyFrom(formOut.bytes().toBytesRef().bytes)); - } catch (IOException e){ - builder.addFormattedSortValues(ByteString.EMPTY); - } - - try (BytesStreamOutput rawOut = new BytesStreamOutput()) { - rawOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); - builder.addRawSortValues(ByteString.copyFrom(rawOut.bytes().toBytesRef().bytes)); - } catch (IOException e){ - builder.addRawSortValues(ByteString.EMPTY); - } - - return builder.build(); - } - - static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws SerDe.SerializationException { - Object[] formattedSortValues = null; - Object[] rawSortValues = null; - - if (proto.getFormattedSortValuesCount() > 0) { - BytesReference formattedBytes = new BytesArray(proto.getFormattedSortValues(0).toByteArray()); - try (StreamInput formattedIn = formattedBytes.streamInput()) { - formattedSortValues = formattedIn.readArray(Lucene::readSortValue, Object[]::new); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize SearchSortValues from proto object", e); - } - } - - if (proto.getRawSortValuesCount() > 0) { - BytesReference rawBytes = new BytesArray(proto.getRawSortValues(0).toByteArray()); - try (StreamInput rawIn = rawBytes.streamInput()) { - rawSortValues = rawIn.readArray(Lucene::readSortValue, Object[]::new); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize SearchSortValues from proto object", e); - } + @Override + public void writeTo(StreamOutput out) throws IOException { + switch (this.strategy) { + case NATIVE: + toNativeStream(out); + case PROTOBUF: + toProtobufStream(out); } - - return new SearchSortValues(formattedSortValues, rawSortValues); - } - - static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { - return SearchShardTargetProto.newBuilder() - .setNodeId(shardTarget.getNodeId()) - .setShardId(shardIdToProto(shardTarget.getShardId())) - .setClusterAlias(shardTarget.getClusterAlias()) - .build(); - } - - public static SearchShardTarget searchShardTargetFromProto(SearchShardTargetProto proto) { - String nodeId = proto.getNodeId(); - ShardId shardId = shardIdFromProto(proto.getShardId()); - String clusterAlias = proto.getClusterAlias(); - return new SearchShardTarget(nodeId, shardId, clusterAlias); } - static ShardIdProto shardIdToProto(ShardId shardId) { - return ShardIdProto.newBuilder() - .setIndex(indexToProto(shardId.getIndex())) - .setShardId(shardId.id()) - .setHashCode(shardId.hashCode()) - .build(); - } - - public static ShardId shardIdFromProto(ShardIdProto proto) { - Index index = indexFromProto(proto.getIndex()); - int shardId = proto.getShardId(); - return new ShardId(index, shardId); + @Override + public void toProtobufStream(StreamOutput out) throws IOException { + toProto().writeTo(out); } - static IndexProto indexToProto(Index index) { - return IndexProto.newBuilder() - .setName(index.getName()) - .setUuid(index.getUUID()) - .build(); + @Override + public void fromProtobufStream(StreamInput in) throws IOException { + SearchHitProto proto = SearchHitProto.parseFrom(in); + fromProto(proto); } - public static Index indexFromProto(IndexProto proto) { - String name = proto.getName(); - String uuid = proto.getUuid(); - return new Index(name, uuid); + @Override + public void toNativeStream(StreamOutput out) throws IOException { + super.writeTo(out); } - private SearchHit fromStream(StreamInput in) throws IOException { - int docId; - float score; - long seqNo; - long version; - long primaryTerm; - Text id; - BytesReference source; - SearchShardTarget shard; - Explanation explanation = null; - SearchSortValues sortValues; - SearchHit.NestedIdentity nestedIdentity; - Map documentFields; - Map metaFields; - Map highlightFields; - Map matchedQueries = Map.of(); - Map innerHits; - String index = null; - String clusterAlias = null; - + @Override + public void fromNativeStream(StreamInput in) throws IOException { docId = -1; score = in.readFloat(); id = in.readOptionalText(); if (in.getVersion().before(Version.V_2_0_0)) { in.readOptionalText(); } - nestedIdentity = in.readOptionalWriteable(SearchHit.NestedIdentity::new); + + nestedIdentity = in.readOptionalWriteable(NestedIdentity::new); version = in.readLong(); seqNo = in.readZLong(); primaryTerm = in.readVLong(); @@ -472,100 +168,118 @@ private SearchHit fromStream(StreamInput in) throws IOException { innerHits = new HashMap<>(size); for (int i = 0; i < size; i++) { String key = in.readString(); - SearchHits value = new SearchHits(in); + SearchHits value = new SearchHitsSerDe(strategy, in); innerHits.put(key, value); } } else { innerHits = null; } + } - return new SearchHit( - docId, - score, - seqNo, - version, - primaryTerm, - id, - source, - shard, - explanation, - sortValues, - nestedIdentity, - documentFields, - metaFields, - highlightFields, - matchedQueries, - innerHits, - index, - clusterAlias + SearchHitProto toProto() { + SearchHitProto.Builder builder = SearchHitProto.newBuilder() + .setScore(score) + .setId(id.string()) + .setVersion(version) + .setSeqNo(seqNo) + .setPrimaryTerm(primaryTerm); + + builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); + builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); + builder.setExplanation(explanationToProto(explanation)); + builder.setSortValues(searchSortValuesToProto(sortValues)); + + documentFields.forEach((key, value) -> + builder.putDocumentFields(key, documentFieldToProto(value)) ); - } - private void toStream(SearchHit object, StreamOutput out) throws IOException { - SearchHit.SerializationAccess serI = object.getSerAccess(); - float score = serI.getScore(); - long seqNo = serI.getSeqNo(); - long version = serI.getVersion(); - long primaryTerm = serI.getPrimaryTerm(); - Text id = serI.getId(); - BytesReference source = serI.getSource(); - SearchShardTarget shard = serI.getShard(); - Explanation explanation = serI.getExplanation(); - SearchSortValues sortValues = serI.getSortValues(); - SearchHit.NestedIdentity nestedIdentity = serI.getNestedIdentity(); - Map documentFields = serI.getDocumentFields(); - Map metaFields = serI.getMetaFields(); - Map highlightFields = serI.getHighlightedFields(); - Map matchedQueries = serI.getMatchedQueries(); - Map innerHits = serI.getInnerHits(); - - out.writeFloat(score); - out.writeOptionalText(id); - if (out.getVersion().before(Version.V_2_0_0)) { - out.writeOptionalText(SINGLE_MAPPING_TYPE); - } - out.writeOptionalWriteable(nestedIdentity); - out.writeLong(version); - out.writeZLong(seqNo); - out.writeVLong(primaryTerm); - out.writeBytesReference(source); - if (explanation == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - writeExplanation(out, explanation); - } - out.writeMap(documentFields, StreamOutput::writeString, (stream, documentField) -> documentField.writeTo(stream)); - out.writeMap(metaFields, StreamOutput::writeString, (stream, documentField) -> documentField.writeTo(stream)); - if (highlightFields == null) { - out.writeVInt(0); - } else { - out.writeVInt(highlightFields.size()); - for (HighlightField highlightField : highlightFields.values()) { - highlightField.writeTo(out); - } + metaFields.forEach((key, value) -> + builder.putMetaFields(key, documentFieldToProto(value)) + ); + + highlightFields.forEach((key, value) -> + builder.putHighlightFields(key, highlightFieldToProto(value)) + ); + + matchedQueries.forEach(builder::putMatchedQueries); + + // shard is optional + if (shard != null) { + builder.setShard(searchShardTargetToProto(shard)); } - sortValues.writeTo(out); - out.writeVInt(matchedQueries.size()); - if (out.getVersion().onOrAfter(Version.V_2_13_0)) { - if (!matchedQueries.isEmpty()) { - out.writeMap(matchedQueries, StreamOutput::writeString, StreamOutput::writeFloat); - } - } else { - for (String matchedFilter : matchedQueries.keySet()) { - out.writeString(matchedFilter); + innerHits.forEach((key, value) -> + builder.putInnerHits(key, new SearchHitsSerDe(value, strategy).toProto()) + ); + + return builder.build(); + } + + void fromProto(SearchHitProto proto) throws SerDe.SerializationException { + docId = -1; + score = proto.getScore(); + seqNo = proto.getSeqNo(); + version = proto.getVersion(); + primaryTerm = proto.getPrimaryTerm(); + id = new Text(proto.getId()); + source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); + explanation = explanationFromProto(proto.getExplanation()); + sortValues = searchSortValuesFromProto(proto.getSortValues()); + nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); + matchedQueries = proto.getMatchedQueriesMap(); + + documentFields = new HashMap<>(); + proto.getDocumentFieldsMap().forEach((key, value) -> + documentFields.put(key, documentFieldFromProto(value)) + ); + + metaFields = new HashMap<>(); + proto.getMetaFieldsMap().forEach((key, value) -> + metaFields.put(key, documentFieldFromProto(value)) + ); + + highlightFields = new HashMap<>(); + proto.getHighlightFieldsMap().forEach((key, value) -> + highlightFields.put(key, highlightFieldFromProto(value)) + ); + + innerHits = new HashMap<>(); + proto.getInnerHitsMap().forEach((key, value) -> + { + try { + innerHits.put(key, new SearchHitsSerDe(value)); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize innerHits from proto: " + key,e); + } } + ); + + shard = searchShardTargetFromProto(proto.getShard()); + index = shard.getIndex(); + clusterAlias = shard.getClusterAlias(); + } + + static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { + NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() + .setField(nestedIdentity.getField().string()) + .setOffset(nestedIdentity.getOffset()); + + if (nestedIdentity.getChild() != null) { + builder.setChild(nestedIdentityToProto(nestedIdentity.getChild())); } - out.writeOptionalWriteable(shard); - if (innerHits == null) { - out.writeVInt(0); - } else { - out.writeVInt(innerHits.size()); - for (Map.Entry entry : innerHits.entrySet()) { - out.writeString(entry.getKey()); - entry.getValue().writeTo(out); - } + + return builder.build(); + } + + static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityProto proto) { + String field = proto.getField(); + int offset = proto.getOffset(); + + SearchHit.NestedIdentity child = null; + if (proto.hasChild()) { + child = nestedIdentityFromProto(proto.getChild()); } + + return new SearchHit.NestedIdentity(field, offset, child); } } diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java index b22fd0804288e..1fc4a63722501 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java @@ -23,62 +23,109 @@ import java.io.IOException; -import static org.opensearch.search.SearchHits.EMPTY; - /** * Serialization/Deserialization implementations for SearchHits. * @opensearch.internal */ -public class SearchHitsSerDe implements SerDe.StreamSerializer, SerDe.StreamDeserializer { - SearchHitSerDe searchHitSerDe; +public class SearchHitsSerDe extends SearchHits implements SerDe.nativeSerializer, SerDe.protobufSerializer { + SerDe.Strategy strategy = SerDe.Strategy.NATIVE; + + public SearchHitsSerDe(SearchHits hits, SerDe.Strategy strategy) { + super(hits); + this.strategy = strategy; + } - public SearchHitsSerDe () { - this.searchHitSerDe = new SearchHitSerDe(); + public SearchHitsSerDe(SerDe.Strategy strategy, StreamInput in) throws IOException { + this.strategy = strategy; + switch (this.strategy) { + case NATIVE: + fromNativeStream(in); + case PROTOBUF: + fromProtobufStream(in); + } + } + + public SearchHitsSerDe(StreamInput in) throws IOException { + fromNativeStream(in); + } + + public SearchHitsSerDe(SearchHitsProto proto) throws IOException { + fromProto(proto); } @Override - public SearchHits deserialize(StreamInput in) { - try { - return fromStream(in); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize FetchSearchResult", e); + public void writeTo(StreamOutput out) throws IOException { + switch (this.strategy) { + case NATIVE: + toNativeStream(out); + case PROTOBUF: + toProtobufStream(out); } } @Override - public void serialize(SearchHits object, StreamOutput out) throws SerDe.SerializationException { - try { - toStream(object, out); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to serialize FetchSearchResult", e); + public void toProtobufStream(StreamOutput out) throws IOException { + toProto().writeTo(out); + } + + @Override + public void fromProtobufStream(StreamInput in) throws IOException { + SearchHitsProto proto = SearchHitsProto.parseFrom(in); + fromProto(proto); + } + + @Override + public void toNativeStream(StreamOutput out) throws IOException { + super.writeTo(out); + } + + @Override + public void fromNativeStream(StreamInput in) throws IOException { + if (in.readBoolean()) { + this.totalHits = Lucene.readTotalHits(in); + } else { + // track_total_hits is false + this.totalHits = null; } + this.maxScore = in.readFloat(); + int size = in.readVInt(); + if (size == 0) { + hits = EMPTY; + } else { + hits = new SearchHit[size]; + for (int i = 0; i < hits.length; i++) { + hits[i] = new SearchHitSerDe(SerDe.Strategy.NATIVE, in); + } + } + this.sortFields = in.readOptionalArray(Lucene::readSortField, SortField[]::new); + this.collapseField = in.readOptionalString(); + this.collapseValues = in.readOptionalArray(Lucene::readSortValue, Object[]::new); } - SearchHitsProto toProto(SearchHits searchHits) throws SerDe.SerializationException{ - SearchHits.SerializationAccess serI = searchHits.getSerAccess(); + SearchHitsProto toProto() { SearchHitsProto.Builder builder = SearchHitsProto.newBuilder() - .setMaxScore(serI.getMaxScore()) - .setCollapseField(serI.getCollapseField()); + .setMaxScore(maxScore) + .setCollapseField(collapseField); - for (SearchHit hit : serI.getHits()) { - builder.addHits(searchHitSerDe.toProto(hit)); + for (SearchHit hit : hits) { + builder.addHits(new SearchHitSerDe(hit, strategy).toProto()); } - TotalHits totHits = serI.getTotalHits(); + TotalHits totHits = totalHits; TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder() .setRelation(totHits.relation.ordinal()) .setValue(totHits.value); builder.setTotalHits(totHitsBuilder); try (BytesStreamOutput sortOut = new BytesStreamOutput()) { - sortOut.writeOptionalArray(Lucene::writeSortField, serI.getSortFields()); + sortOut.writeOptionalArray(Lucene::writeSortField, sortFields); builder.setSortFields(ByteString.copyFrom(sortOut.bytes().toBytesRef().bytes)); } catch (IOException e){ throw new SerDe.SerializationException("Failed to serialize SearchHits to proto", e); } try (BytesStreamOutput collapseOut = new BytesStreamOutput()) { - collapseOut.writeOptionalArray(Lucene::writeSortField, serI.getSortFields()); + collapseOut.writeOptionalArray(Lucene::writeSortValue, collapseValues); builder.setCollapseValues(ByteString.copyFrom(collapseOut.bytes().toBytesRef().bytes)); } catch (IOException e){ throw new SerDe.SerializationException("Failed to serialize SearchHits to proto", e); @@ -87,94 +134,37 @@ SearchHitsProto toProto(SearchHits searchHits) throws SerDe.SerializationExcepti return builder.build(); } - SearchHits fromProto(SearchHitsProto proto) throws SerDe.SerializationException { - float maxScore = proto.getMaxScore(); - String collapseField = proto.getCollapseField(); + void fromProto(SearchHitsProto proto) throws SerDe.SerializationException { + maxScore = proto.getMaxScore(); + collapseField = proto.getCollapseField(); - TotalHitsProto totalHits = proto.getTotalHits(); - long rel = totalHits.getRelation(); - long val = totalHits.getValue(); + TotalHitsProto totHitsProto = proto.getTotalHits(); + long rel = totHitsProto.getRelation(); + long val = totHitsProto.getValue(); if (rel < 0 || rel >= TotalHits.Relation.values().length) { throw new SerDe.SerializationException("Failed to deserialize TotalHits from proto"); } - TotalHits totHits = new TotalHits(val, TotalHits.Relation.values()[(int) rel]); + totalHits = new TotalHits(val, TotalHits.Relation.values()[(int) rel]); - SortField[] sortFields = null; try (StreamInput sortBytesInput = new BytesArray(proto.getSortFields().toByteArray()).streamInput()) { sortFields = sortBytesInput.readOptionalArray(Lucene::readSortField, SortField[]::new); } catch (IOException e) { throw new SerDe.SerializationException("Failed to deserialize SearchHits from proto", e); } - Object[] collapseValues = null; try (StreamInput collapseBytesInput = new BytesArray(proto.getCollapseValues().toByteArray()).streamInput()) { collapseValues = collapseBytesInput.readOptionalArray(Lucene::readSortValue, Object[]::new); } catch (IOException e) { throw new SerDe.SerializationException("Failed to deserialize SearchHits from proto", e); } - SearchHit[] hits = new SearchHit[proto.getHitsCount()]; + hits = new SearchHit[proto.getHitsCount()]; for(int i = 0; i < hits.length; i++) { - hits[i] = searchHitSerDe.fromProto(proto.getHits(i)); - } - - return new SearchHits(hits, totHits, maxScore, sortFields, collapseField, collapseValues); - } - - private SearchHits fromStream(StreamInput in) throws IOException { - SearchHit[] hits; - TotalHits totalHits; - float maxScore; - SortField[] sortFields; - String collapseField; - Object[] collapseValues; - - if (in.readBoolean()) { - totalHits = Lucene.readTotalHits(in); - } else { - // track_total_hits is false - totalHits = null; - } - maxScore = in.readFloat(); - int size = in.readVInt(); - if (size == 0) { - hits = EMPTY; - } else { - hits = new SearchHit[size]; - for (int i = 0; i < hits.length; i++) { - hits[i] = searchHitSerDe.deserialize(in); - } - } - sortFields = in.readOptionalArray(Lucene::readSortField, SortField[]::new); - collapseField = in.readOptionalString(); - collapseValues = in.readOptionalArray(Lucene::readSortValue, Object[]::new); - - return new SearchHits(hits, totalHits, maxScore, sortFields, collapseField, collapseValues); - } - - private void toStream(SearchHits object, StreamOutput out) throws IOException { - SearchHits.SerializationAccess serI = object.getSerAccess(); - SearchHit[] hits = serI.getHits(); - TotalHits totalHits = serI.getTotalHits(); - float maxScore = serI.getMaxScore(); - SortField[] sortFields = serI.getSortFields(); - String collapseField = serI.getCollapseField(); - Object[] collapseValues = serI.getCollapseValues(); - - final boolean hasTotalHits = totalHits != null; - out.writeBoolean(hasTotalHits); - if (hasTotalHits) { - Lucene.writeTotalHits(out, totalHits); - } - out.writeFloat(maxScore); - out.writeVInt(hits.length); - if (hits.length > 0) { - for (SearchHit hit : hits) { - searchHitSerDe.serialize(hit, out); + try { + hits[i] = new SearchHitSerDe(proto.getHits(i)); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize SearchHits from proto", e); } } - out.writeOptionalArray(Lucene::writeSortField, sortFields); - out.writeOptionalString(collapseField); - out.writeOptionalArray(Lucene::writeSortValue, collapseValues); } } diff --git a/server/src/main/java/org/opensearch/transport/serde/SerDe.java b/server/src/main/java/org/opensearch/transport/serde/SerDe.java index ad2270bf1c558..286dae6e83323 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SerDe.java @@ -9,22 +9,44 @@ package org.opensearch.transport.serde; import com.google.protobuf.ByteString; +import org.apache.lucene.search.Explanation; +import org.opensearch.common.document.DocumentField; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.common.lucene.Lucene; +import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.core.xcontent.XContentParser; +import org.opensearch.core.common.text.Text; +import org.opensearch.core.index.Index; +import org.opensearch.core.index.shard.ShardId; +import org.opensearch.search.SearchShardTarget; +import org.opensearch.search.SearchSortValues; +import org.opensearch.search.fetch.subphase.highlight.HighlightField; +import org.opensearch.serde.proto.SearchHitsTransportProto.DocumentFieldProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.HighlightFieldProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchSortValuesProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchShardTargetProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.ExplanationProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.ShardIdProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.IndexProto; -import java.awt.image.WritableRaster; import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; /** - * Base class for supported serialization/deserialization implementations. + * SerDe interfaces and protobuf SerDe implementations for some "primitive" types. * @opensearch.internal */ public class SerDe { + public enum Strategy { + PROTOBUF, + NATIVE; + } + /** * Serialization/Deserialization exception. * @opensearch.internal @@ -33,29 +55,190 @@ public static class SerializationException extends RuntimeException { public SerializationException(String message) { super(message); } - public SerializationException(String message, Throwable cause) { super(message, cause); } + } + + interface nativeSerializer { + void toNativeStream(StreamOutput out) throws IOException; + void fromNativeStream(StreamInput in) throws IOException; + } + + interface protobufSerializer { + void toProtobufStream(StreamOutput out) throws IOException; + void fromProtobufStream(StreamInput in) throws IOException; + } + + // TODO: Lucene definitions should maybe be serialized as generic bytes arrays. + static ExplanationProto explanationToProto(Explanation explanation) { + ExplanationProto.Builder builder = ExplanationProto.newBuilder() + .setMatch(explanation.isMatch()) + .setValue(explanation.getValue().longValue()) + .setDescription(explanation.getDescription()); + + for (Explanation detail : explanation.getDetails()) { + builder.addDetails(explanationToProto(detail)); + } + + return builder.build(); + } + + static Explanation explanationFromProto(ExplanationProto proto) { + long value = proto.getValue(); + String description = proto.getDescription(); + Collection details = new ArrayList<>(); + + for (ExplanationProto det : proto.getDetailsList()) { + details.add(explanationFromProto(det)); + } + + if (proto.getMatch()) { + return Explanation.match(value, description, details); + } + + return Explanation.noMatch(description, details); + } + + // Is there a reason to open a new stream for each object? + // Seems simpler to write a single stream. + static DocumentFieldProto documentFieldToProto(DocumentField field) { + DocumentFieldProto.Builder builder = DocumentFieldProto.newBuilder().setName(field.getName()); + + try (BytesStreamOutput docsOut = new BytesStreamOutput()) { + docsOut.writeCollection(field.getValues(), StreamOutput::writeGenericValue); + builder.addValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); + } catch (IOException e){ + builder.addValues(ByteString.EMPTY); + } + + return builder.build(); + } - public SerializationException(Throwable cause) { - super(cause); + static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws SerDe.SerializationException { + String name = proto.getName(); + List values = new ArrayList<>(0); + + if (proto.getValuesCount() > 0) { + BytesReference valuesBytes = new BytesArray(proto.getValues(0).toByteArray()); + try (StreamInput in = valuesBytes.streamInput()) { + Object readValue = in.readGenericValue(); + values.add(readValue); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize DocumentField values from proto object", e); + } } + + return new DocumentField(name, values); + } + + static HighlightFieldProto highlightFieldToProto(HighlightField field) { + HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder() + .setName(field.getName()); + + for (Text frag : field.getFragments()) { + builder.addFragments(frag.string()); + } + + return builder.build(); + } + + static HighlightField highlightFieldFromProto(HighlightFieldProto proto) { + String name = proto.getName(); + Text[] fragments = new Text[proto.getFragmentsCount()]; + + for (int i = 0; i < proto.getFragmentsCount(); i++) { + fragments[i] = new Text(proto.getFragments(i)); + } + + return new HighlightField(name, fragments); + } + + // See above comment for documentFieldToProto. + static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { + SearchSortValuesProto.Builder builder = SearchSortValuesProto.newBuilder(); + + try (BytesStreamOutput formOut = new BytesStreamOutput()) { + formOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); + builder.addFormattedSortValues(ByteString.copyFrom(formOut.bytes().toBytesRef().bytes)); + } catch (IOException e){ + builder.addFormattedSortValues(ByteString.EMPTY); + } + + try (BytesStreamOutput rawOut = new BytesStreamOutput()) { + rawOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); + builder.addRawSortValues(ByteString.copyFrom(rawOut.bytes().toBytesRef().bytes)); + } catch (IOException e){ + builder.addRawSortValues(ByteString.EMPTY); + } + + return builder.build(); + } + + static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws SerDe.SerializationException { + Object[] formattedSortValues = null; + Object[] rawSortValues = null; + + if (proto.getFormattedSortValuesCount() > 0) { + BytesReference formattedBytes = new BytesArray(proto.getFormattedSortValues(0).toByteArray()); + try (StreamInput formattedIn = formattedBytes.streamInput()) { + formattedSortValues = formattedIn.readArray(Lucene::readSortValue, Object[]::new); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize SearchSortValues from proto object", e); + } + } + + if (proto.getRawSortValuesCount() > 0) { + BytesReference rawBytes = new BytesArray(proto.getRawSortValues(0).toByteArray()); + try (StreamInput rawIn = rawBytes.streamInput()) { + rawSortValues = rawIn.readArray(Lucene::readSortValue, Object[]::new); + } catch (IOException e) { + throw new SerDe.SerializationException("Failed to deserialize SearchSortValues from proto object", e); + } + } + + return new SearchSortValues(formattedSortValues, rawSortValues); + } + + static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { + return SearchShardTargetProto.newBuilder() + .setNodeId(shardTarget.getNodeId()) + .setShardId(shardIdToProto(shardTarget.getShardId())) + .setClusterAlias(shardTarget.getClusterAlias()) + .build(); + } + + public static SearchShardTarget searchShardTargetFromProto(SearchShardTargetProto proto) { + String nodeId = proto.getNodeId(); + ShardId shardId = shardIdFromProto(proto.getShardId()); + String clusterAlias = proto.getClusterAlias(); + return new SearchShardTarget(nodeId, shardId, clusterAlias); } - interface XContentSerializer { - public XContentBuilder serialize(T object) throws SerializationException; + static ShardIdProto shardIdToProto(ShardId shardId) { + return ShardIdProto.newBuilder() + .setIndex(indexToProto(shardId.getIndex())) + .setShardId(shardId.id()) + .setHashCode(shardId.hashCode()) + .build(); } - interface XContentDeserializer { - public V deserialize(XContentParser parser) throws SerializationException; + public static ShardId shardIdFromProto(ShardIdProto proto) { + Index index = indexFromProto(proto.getIndex()); + int shardId = proto.getShardId(); + return new ShardId(index, shardId); } - interface StreamSerializer { - public void serialize(T object, StreamOutput out) throws SerializationException; + static IndexProto indexToProto(Index index) { + return IndexProto.newBuilder() + .setName(index.getName()) + .setUuid(index.getUUID()) + .build(); } - interface StreamDeserializer { - public V deserialize(StreamInput in) throws SerializationException; + public static Index indexFromProto(IndexProto proto) { + String name = proto.getName(); + String uuid = proto.getUuid(); + return new Index(name, uuid); } } diff --git a/server/src/main/proto/serde/SearchHitsProto.proto b/server/src/main/proto/serde/SearchHitsProto.proto index 78a28da3acb33..c4425cb6e708f 100644 --- a/server/src/main/proto/serde/SearchHitsProto.proto +++ b/server/src/main/proto/serde/SearchHitsProto.proto @@ -4,6 +4,15 @@ package org.opensearch.serde.proto; option java_outer_classname = "SearchHitsTransportProto"; +/* +SearchHits hits; +int counter; + */ +message FetchSearchResultProto { + SearchHitsProto hits = 1; + int64 counter = 2; +} + /* SearchHit[] hits TotalHits totalHits @@ -52,7 +61,7 @@ message SearchHitProto { map highlight_fields = 11; SearchSortValuesProto sort_values = 12; map matched_queries = 13; - SearchShardTargetProto shard = 14; + optional SearchShardTargetProto shard = 14; map inner_hits = 15; } From 76171a8d7d813b4ece6e2aaa30676e1de0c77520 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 26 Aug 2024 17:11:51 -0700 Subject: [PATCH 26/61] Break SerDe switch Signed-off-by: Finn Carroll --- .../search/fetch/FetchSearchResult.java | 2 +- .../serde/FetchSearchResultSerDe.java | 50 ++++++++++--------- .../transport/serde/SearchHitSerDe.java | 16 +++--- .../transport/serde/SearchHitsSerDe.java | 10 +++- 4 files changed, 45 insertions(+), 33 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index 643792b17558c..b64638972ed49 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -54,7 +54,7 @@ public class FetchSearchResult extends SearchPhaseResult { protected SearchHits hits; // client side counter - private transient int counter; + protected transient int counter; public FetchSearchResult() {} diff --git a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java index 383e86635a27e..d230d1eeb4f87 100644 --- a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java @@ -12,7 +12,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.search.fetch.FetchSearchResult; import org.opensearch.search.internal.ShardSearchContextId; -import org.opensearch.serde.proto.SearchHitsTransportProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.FetchSearchResultProto; import java.io.IOException; @@ -28,8 +28,12 @@ public FetchSearchResultSerDe(SerDe.Strategy strategy, StreamInput in) throws IO switch (this.strategy) { case NATIVE: fromNativeStream(in); + break; case PROTOBUF: fromProtobufStream(in); + break; + default: + throw new AssertionError("This code should not be reachable"); } } @@ -42,21 +46,26 @@ public void writeTo(StreamOutput out) throws IOException { switch (this.strategy) { case NATIVE: toNativeStream(out); + break; case PROTOBUF: toProtobufStream(out); + break; + default: + throw new AssertionError("This code should not be reachable"); } } -// @Override -// public void toProtobufStream(StreamOutput out) throws IOException { -// toProto().writeTo(out); -// } + @Override + public void toProtobufStream(StreamOutput out) throws IOException { + toProto().writeTo(out); + } -// @Override -// public void fromProtobufStream(StreamInput in) throws IOException { -// FetchSearchResultProto proto = SearchHitsTransportProto.SearchHitsProto.parseFrom(in); -// fromProto(proto); -// } + + @Override + public void fromProtobufStream(StreamInput in) throws IOException { + FetchSearchResultProto proto = FetchSearchResultProto.parseFrom(in); + fromProto(proto); + } @Override public void toNativeStream(StreamOutput out) throws IOException { @@ -69,21 +78,14 @@ public void fromNativeStream(StreamInput in) throws IOException { this.contextId = new ShardSearchContextId(in); } - @Override - public void toProtobufStream(StreamOutput out) throws IOException { - // IMPL + FetchSearchResultProto toProto() { + FetchSearchResultProto.Builder builder = FetchSearchResultProto.newBuilder() + .setHits(new SearchHitsSerDe(hits, strategy).toProto()) + .setCounter(this.counter); + return builder.build(); } - @Override - public void fromProtobufStream(StreamInput in) throws IOException { - // IMPL + void fromProto(FetchSearchResultProto proto) { + hits = new SearchHitsSerDe(proto.getHits()); } - -// SearchHitsTransportProto.SearchHitsProto toProto() { -// -// } -// -// void fromProto(SearchHitsTransportProto.SearchHitsProto searchHits) { -// -// } } diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java index 087b2ef1f9f3e..a9b9a53800b71 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java @@ -61,8 +61,12 @@ public SearchHitSerDe(SerDe.Strategy strategy, StreamInput in) throws IOExceptio switch (this.strategy) { case NATIVE: fromNativeStream(in); + break; case PROTOBUF: fromProtobufStream(in); + break; + default: + throw new AssertionError("This code should not be reachable"); } } @@ -79,8 +83,12 @@ public void writeTo(StreamOutput out) throws IOException { switch (this.strategy) { case NATIVE: toNativeStream(out); + break; case PROTOBUF: toProtobufStream(out); + break; + default: + throw new AssertionError("This code should not be reachable"); } } @@ -245,13 +253,7 @@ void fromProto(SearchHitProto proto) throws SerDe.SerializationException { innerHits = new HashMap<>(); proto.getInnerHitsMap().forEach((key, value) -> - { - try { - innerHits.put(key, new SearchHitsSerDe(value)); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize innerHits from proto: " + key,e); - } - } + innerHits.put(key, new SearchHitsSerDe(value)) ); shard = searchShardTargetFromProto(proto.getShard()); diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java index 1fc4a63722501..d9e49c4771799 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java @@ -40,8 +40,12 @@ public SearchHitsSerDe(SerDe.Strategy strategy, StreamInput in) throws IOExcepti switch (this.strategy) { case NATIVE: fromNativeStream(in); + break; case PROTOBUF: fromProtobufStream(in); + break; + default: + throw new AssertionError("This code should not be reachable"); } } @@ -49,7 +53,7 @@ public SearchHitsSerDe(StreamInput in) throws IOException { fromNativeStream(in); } - public SearchHitsSerDe(SearchHitsProto proto) throws IOException { + public SearchHitsSerDe(SearchHitsProto proto) { fromProto(proto); } @@ -58,8 +62,12 @@ public void writeTo(StreamOutput out) throws IOException { switch (this.strategy) { case NATIVE: toNativeStream(out); + break; case PROTOBUF: toProtobufStream(out); + break; + default: + throw new AssertionError("This code should not be reachable"); } } From db708017ab7228727c6a8fef33c13bcffc753bd0 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 26 Aug 2024 17:30:22 -0700 Subject: [PATCH 27/61] Add generated protobuf to runAnt accepted licenses Signed-off-by: Finn Carroll --- .../org/opensearch/gradle/precommit/LicenseHeadersTask.groovy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy index b8d0ed2b9c43c..f6c8da1191c5d 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy @@ -149,6 +149,8 @@ class LicenseHeadersTask extends AntTask { licenseFamilyName: "Generated") { // parsers generated by antlr pattern(substring: "ANTLR GENERATED CODE") + // Protobuf + pattern(substring: "Generated by the protocol buffer compiler") } // Vendored Code From 2f4903a86771f874ea0707b03d60274b0269b037 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 26 Aug 2024 17:30:36 -0700 Subject: [PATCH 28/61] Spotless apply Signed-off-by: Finn Carroll --- .../org/opensearch/search/SearchHits.java | 2 +- .../serde/FetchSearchResultSerDe.java | 1 - .../transport/serde/SearchHitSerDe.java | 34 +++++-------------- .../transport/serde/SearchHitsSerDe.java | 14 +++----- .../org/opensearch/transport/serde/SerDe.java | 23 ++++++------- 5 files changed, 26 insertions(+), 48 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index 6b385d566116f..69584e4c1076d 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -133,7 +133,7 @@ public SearchHits(StreamInput in) throws IOException { collapseValues = in.readOptionalArray(Lucene::readSortValue, Object[]::new); } - protected SearchHits () {} + protected SearchHits() {} @Override public void writeTo(StreamOutput out) throws IOException { diff --git a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java index d230d1eeb4f87..f48d334ad3a2c 100644 --- a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java @@ -60,7 +60,6 @@ public void toProtobufStream(StreamOutput out) throws IOException { toProto().writeTo(out); } - @Override public void fromProtobufStream(StreamInput in) throws IOException { FetchSearchResultProto proto = FetchSearchResultProto.parseFrom(in); diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java index a9b9a53800b71..256622a4a033b 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java @@ -20,8 +20,8 @@ import org.opensearch.search.SearchShardTarget; import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitProto; import org.opensearch.serde.proto.SearchHitsTransportProto.NestedIdentityProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitProto; import java.io.IOException; import java.util.HashMap; @@ -197,17 +197,11 @@ SearchHitProto toProto() { builder.setExplanation(explanationToProto(explanation)); builder.setSortValues(searchSortValuesToProto(sortValues)); - documentFields.forEach((key, value) -> - builder.putDocumentFields(key, documentFieldToProto(value)) - ); + documentFields.forEach((key, value) -> builder.putDocumentFields(key, documentFieldToProto(value))); - metaFields.forEach((key, value) -> - builder.putMetaFields(key, documentFieldToProto(value)) - ); + metaFields.forEach((key, value) -> builder.putMetaFields(key, documentFieldToProto(value))); - highlightFields.forEach((key, value) -> - builder.putHighlightFields(key, highlightFieldToProto(value)) - ); + highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); matchedQueries.forEach(builder::putMatchedQueries); @@ -216,9 +210,7 @@ SearchHitProto toProto() { builder.setShard(searchShardTargetToProto(shard)); } - innerHits.forEach((key, value) -> - builder.putInnerHits(key, new SearchHitsSerDe(value, strategy).toProto()) - ); + innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsSerDe(value, strategy).toProto())); return builder.build(); } @@ -237,24 +229,16 @@ void fromProto(SearchHitProto proto) throws SerDe.SerializationException { matchedQueries = proto.getMatchedQueriesMap(); documentFields = new HashMap<>(); - proto.getDocumentFieldsMap().forEach((key, value) -> - documentFields.put(key, documentFieldFromProto(value)) - ); + proto.getDocumentFieldsMap().forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); metaFields = new HashMap<>(); - proto.getMetaFieldsMap().forEach((key, value) -> - metaFields.put(key, documentFieldFromProto(value)) - ); + proto.getMetaFieldsMap().forEach((key, value) -> metaFields.put(key, documentFieldFromProto(value))); highlightFields = new HashMap<>(); - proto.getHighlightFieldsMap().forEach((key, value) -> - highlightFields.put(key, highlightFieldFromProto(value)) - ); + proto.getHighlightFieldsMap().forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); innerHits = new HashMap<>(); - proto.getInnerHitsMap().forEach((key, value) -> - innerHits.put(key, new SearchHitsSerDe(value)) - ); + proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsSerDe(value))); shard = searchShardTargetFromProto(proto.getShard()); index = shard.getIndex(); diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java index d9e49c4771799..9433d5446e271 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java @@ -111,31 +111,27 @@ public void fromNativeStream(StreamInput in) throws IOException { } SearchHitsProto toProto() { - SearchHitsProto.Builder builder = SearchHitsProto.newBuilder() - .setMaxScore(maxScore) - .setCollapseField(collapseField); + SearchHitsProto.Builder builder = SearchHitsProto.newBuilder().setMaxScore(maxScore).setCollapseField(collapseField); for (SearchHit hit : hits) { builder.addHits(new SearchHitSerDe(hit, strategy).toProto()); } TotalHits totHits = totalHits; - TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder() - .setRelation(totHits.relation.ordinal()) - .setValue(totHits.value); + TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder().setRelation(totHits.relation.ordinal()).setValue(totHits.value); builder.setTotalHits(totHitsBuilder); try (BytesStreamOutput sortOut = new BytesStreamOutput()) { sortOut.writeOptionalArray(Lucene::writeSortField, sortFields); builder.setSortFields(ByteString.copyFrom(sortOut.bytes().toBytesRef().bytes)); - } catch (IOException e){ + } catch (IOException e) { throw new SerDe.SerializationException("Failed to serialize SearchHits to proto", e); } try (BytesStreamOutput collapseOut = new BytesStreamOutput()) { collapseOut.writeOptionalArray(Lucene::writeSortValue, collapseValues); builder.setCollapseValues(ByteString.copyFrom(collapseOut.bytes().toBytesRef().bytes)); - } catch (IOException e){ + } catch (IOException e) { throw new SerDe.SerializationException("Failed to serialize SearchHits to proto", e); } @@ -167,7 +163,7 @@ void fromProto(SearchHitsProto proto) throws SerDe.SerializationException { } hits = new SearchHit[proto.getHitsCount()]; - for(int i = 0; i < hits.length; i++) { + for (int i = 0; i < hits.length; i++) { try { hits[i] = new SearchHitSerDe(proto.getHits(i)); } catch (IOException e) { diff --git a/server/src/main/java/org/opensearch/transport/serde/SerDe.java b/server/src/main/java/org/opensearch/transport/serde/SerDe.java index 286dae6e83323..fac079c6b9a87 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SerDe.java +++ b/server/src/main/java/org/opensearch/transport/serde/SerDe.java @@ -24,12 +24,12 @@ import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.serde.proto.SearchHitsTransportProto.DocumentFieldProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.ExplanationProto; import org.opensearch.serde.proto.SearchHitsTransportProto.HighlightFieldProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchSortValuesProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.IndexProto; import org.opensearch.serde.proto.SearchHitsTransportProto.SearchShardTargetProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.ExplanationProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchSortValuesProto; import org.opensearch.serde.proto.SearchHitsTransportProto.ShardIdProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.IndexProto; import java.io.IOException; import java.util.ArrayList; @@ -55,6 +55,7 @@ public static class SerializationException extends RuntimeException { public SerializationException(String message) { super(message); } + public SerializationException(String message, Throwable cause) { super(message, cause); } @@ -62,11 +63,13 @@ public SerializationException(String message, Throwable cause) { interface nativeSerializer { void toNativeStream(StreamOutput out) throws IOException; + void fromNativeStream(StreamInput in) throws IOException; } interface protobufSerializer { void toProtobufStream(StreamOutput out) throws IOException; + void fromProtobufStream(StreamInput in) throws IOException; } @@ -108,7 +111,7 @@ static DocumentFieldProto documentFieldToProto(DocumentField field) { try (BytesStreamOutput docsOut = new BytesStreamOutput()) { docsOut.writeCollection(field.getValues(), StreamOutput::writeGenericValue); builder.addValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); - } catch (IOException e){ + } catch (IOException e) { builder.addValues(ByteString.EMPTY); } @@ -133,8 +136,7 @@ static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws Ser } static HighlightFieldProto highlightFieldToProto(HighlightField field) { - HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder() - .setName(field.getName()); + HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder().setName(field.getName()); for (Text frag : field.getFragments()) { builder.addFragments(frag.string()); @@ -161,14 +163,14 @@ static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSort try (BytesStreamOutput formOut = new BytesStreamOutput()) { formOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); builder.addFormattedSortValues(ByteString.copyFrom(formOut.bytes().toBytesRef().bytes)); - } catch (IOException e){ + } catch (IOException e) { builder.addFormattedSortValues(ByteString.EMPTY); } try (BytesStreamOutput rawOut = new BytesStreamOutput()) { rawOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); builder.addRawSortValues(ByteString.copyFrom(rawOut.bytes().toBytesRef().bytes)); - } catch (IOException e){ + } catch (IOException e) { builder.addRawSortValues(ByteString.EMPTY); } @@ -230,10 +232,7 @@ public static ShardId shardIdFromProto(ShardIdProto proto) { } static IndexProto indexToProto(Index index) { - return IndexProto.newBuilder() - .setName(index.getName()) - .setUuid(index.getUUID()) - .build(); + return IndexProto.newBuilder().setName(index.getName()).setUuid(index.getUUID()).build(); } public static Index indexFromProto(IndexProto proto) { From 2bee1b5a093997fc0184f610a830884a4d880fc0 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 27 Aug 2024 01:42:41 -0700 Subject: [PATCH 29/61] Restore intellij refactor error Signed-off-by: Finn Carroll --- .../common/logging/OpenSearchJsonLayoutTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qa/logging-config/src/test/java/org/opensearch/common/logging/OpenSearchJsonLayoutTests.java b/qa/logging-config/src/test/java/org/opensearch/common/logging/OpenSearchJsonLayoutTests.java index 9694c0b6da6d4..0a8bd46ac96f3 100644 --- a/qa/logging-config/src/test/java/org/opensearch/common/logging/OpenSearchJsonLayoutTests.java +++ b/qa/logging-config/src/test/java/org/opensearch/common/logging/OpenSearchJsonLayoutTests.java @@ -49,7 +49,7 @@ public void testEmptyType() { public void testLayout() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("serde") + .setType("server") .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); @@ -68,7 +68,7 @@ public void testLayout() { public void testWithMaxMessageLengthLayout() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("serde") + .setType("server") .setMaxMessageLength(42) .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); @@ -88,7 +88,7 @@ public void testWithMaxMessageLengthLayout() { public void testWithUnrestrictedMaxMessageLengthLayout() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("serde") + .setType("server") .setMaxMessageLength(0) .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); @@ -108,7 +108,7 @@ public void testWithUnrestrictedMaxMessageLengthLayout() { public void testLayoutWithAdditionalFields() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("serde") + .setType("server") .setOpenSearchMessageFields("x-opaque-id,someOtherField") .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); @@ -130,7 +130,7 @@ public void testLayoutWithAdditionalFields() { public void testLayoutWithAdditionalFieldOverride() { OpenSearchJsonLayout server = OpenSearchJsonLayout.newBuilder() - .setType("serde") + .setType("server") .setOpenSearchMessageFields("message") .build(); String conversionPattern = server.getPatternLayout().getConversionPattern(); From 6ef20c8c9e888e00fa43c9bb8b261f0d32ae0897 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 27 Aug 2024 13:30:20 -0700 Subject: [PATCH 30/61] Remove strategy wrapper. Just implement protobuf in new object, leave previous object for native serde. Signed-off-by: Finn Carroll --- .../protobuf/FetchSearchResultProtobuf.java | 51 ++++ .../ProtoSerDeHelpers.java} | 31 +- .../transport/protobuf/SearchHitProtobuf.java | 147 ++++++++++ .../SearchHitsProtobuf.java} | 92 ++---- .../{serde => protobuf}/package-info.java | 2 +- .../serde/FetchSearchResultSerDe.java | 90 ------ .../transport/serde/SearchHitSerDe.java | 271 ------------------ .../search/SearchHitsProtobufTests.java | 217 ++++++++++++++ 8 files changed, 439 insertions(+), 462 deletions(-) create mode 100644 server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java rename server/src/main/java/org/opensearch/transport/{serde/SerDe.java => protobuf/ProtoSerDeHelpers.java} (90%) create mode 100644 server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java rename server/src/main/java/org/opensearch/transport/{serde/SearchHitsSerDe.java => protobuf/SearchHitsProtobuf.java} (51%) rename server/src/main/java/org/opensearch/transport/{serde => protobuf}/package-info.java (86%) delete mode 100644 server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java delete mode 100644 server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java create mode 100644 server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java diff --git a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java new file mode 100644 index 0000000000000..2f790a86aca32 --- /dev/null +++ b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java @@ -0,0 +1,51 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.transport.protobuf; + +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.search.fetch.FetchSearchResult; +import org.opensearch.serde.proto.SearchHitsTransportProto.FetchSearchResultProto; + +import java.io.IOException; + +/** + * FetchSearchResult child which implements serde operations as protobuf. + * @opensearch.internal + */ +public class FetchSearchResultProtobuf extends FetchSearchResult { + public FetchSearchResultProtobuf(StreamInput in) throws IOException { + fromProtobufStream(in); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + toProtobufStream(out); + } + + public void toProtobufStream(StreamOutput out) throws IOException { + toProto().writeTo(out); + } + + public void fromProtobufStream(StreamInput in) throws IOException { + FetchSearchResultProto proto = FetchSearchResultProto.parseFrom(in); + fromProto(proto); + } + + FetchSearchResultProto toProto() { + FetchSearchResultProto.Builder builder = FetchSearchResultProto.newBuilder() + .setHits(new SearchHitsProtobuf(hits).toProto()) + .setCounter(this.counter); + return builder.build(); + } + + void fromProto(FetchSearchResultProto proto) { + hits = new SearchHitsProtobuf(proto.getHits()); + } +} diff --git a/server/src/main/java/org/opensearch/transport/serde/SerDe.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java similarity index 90% rename from server/src/main/java/org/opensearch/transport/serde/SerDe.java rename to server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index fac079c6b9a87..436676a661109 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SerDe.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.transport.serde; +package org.opensearch.transport.protobuf; import com.google.protobuf.ByteString; import org.apache.lucene.search.Explanation; @@ -40,12 +40,7 @@ * SerDe interfaces and protobuf SerDe implementations for some "primitive" types. * @opensearch.internal */ -public class SerDe { - - public enum Strategy { - PROTOBUF, - NATIVE; - } +public class ProtoSerDeHelpers { /** * Serialization/Deserialization exception. @@ -61,18 +56,6 @@ public SerializationException(String message, Throwable cause) { } } - interface nativeSerializer { - void toNativeStream(StreamOutput out) throws IOException; - - void fromNativeStream(StreamInput in) throws IOException; - } - - interface protobufSerializer { - void toProtobufStream(StreamOutput out) throws IOException; - - void fromProtobufStream(StreamInput in) throws IOException; - } - // TODO: Lucene definitions should maybe be serialized as generic bytes arrays. static ExplanationProto explanationToProto(Explanation explanation) { ExplanationProto.Builder builder = ExplanationProto.newBuilder() @@ -118,7 +101,7 @@ static DocumentFieldProto documentFieldToProto(DocumentField field) { return builder.build(); } - static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws SerDe.SerializationException { + static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws ProtoSerDeHelpers.SerializationException { String name = proto.getName(); List values = new ArrayList<>(0); @@ -128,7 +111,7 @@ static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws Ser Object readValue = in.readGenericValue(); values.add(readValue); } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize DocumentField values from proto object", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize DocumentField values from proto object", e); } } @@ -177,7 +160,7 @@ static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSort return builder.build(); } - static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws SerDe.SerializationException { + static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws ProtoSerDeHelpers.SerializationException { Object[] formattedSortValues = null; Object[] rawSortValues = null; @@ -186,7 +169,7 @@ static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) t try (StreamInput formattedIn = formattedBytes.streamInput()) { formattedSortValues = formattedIn.readArray(Lucene::readSortValue, Object[]::new); } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize SearchSortValues from proto object", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchSortValues from proto object", e); } } @@ -195,7 +178,7 @@ static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) t try (StreamInput rawIn = rawBytes.streamInput()) { rawSortValues = rawIn.readArray(Lucene::readSortValue, Object[]::new); } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize SearchSortValues from proto object", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchSortValues from proto object", e); } } diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java new file mode 100644 index 0000000000000..d21f84edff686 --- /dev/null +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -0,0 +1,147 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.transport.protobuf; + +import com.google.protobuf.ByteString; +import org.opensearch.core.common.bytes.BytesReference; +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.serde.proto.SearchHitsTransportProto.NestedIdentityProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitProto; + +import java.io.IOException; +import java.util.HashMap; + +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.explanationFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.explanationToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.highlightFieldFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.highlightFieldToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesToProto; + +/** + * Serialization/Deserialization implementations for SearchHit. + * @opensearch.internal + */ +public class SearchHitProtobuf extends SearchHit { + public SearchHitProtobuf(SearchHit hit) { + super(hit); + } + + public SearchHitProtobuf(StreamInput in) throws IOException { + fromProtobufStream(in); + } + + public SearchHitProtobuf(SearchHitProto proto) { fromProto(proto); } + + @Override + public void writeTo(StreamOutput out) throws IOException { + toProtobufStream(out); + } + + public void toProtobufStream(StreamOutput out) throws IOException { + toProto().writeTo(out); + } + + public void fromProtobufStream(StreamInput in) throws IOException { + SearchHitProto proto = SearchHitProto.parseFrom(in); + fromProto(proto); + } + + SearchHitProto toProto() { + SearchHitProto.Builder builder = SearchHitProto.newBuilder() + .setScore(score) + .setId(id.string()) + .setVersion(version) + .setSeqNo(seqNo) + .setPrimaryTerm(primaryTerm); + + builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); + builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); + builder.setExplanation(explanationToProto(explanation)); + builder.setSortValues(searchSortValuesToProto(sortValues)); + + documentFields.forEach((key, value) -> builder.putDocumentFields(key, documentFieldToProto(value))); + + metaFields.forEach((key, value) -> builder.putMetaFields(key, documentFieldToProto(value))); + + highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); + + matchedQueries.forEach(builder::putMatchedQueries); + + // shard is optional + if (shard != null) { + builder.setShard(searchShardTargetToProto(shard)); + } + + innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsProtobuf(value).toProto())); + + return builder.build(); + } + + void fromProto(SearchHitProto proto) { + docId = -1; + score = proto.getScore(); + seqNo = proto.getSeqNo(); + version = proto.getVersion(); + primaryTerm = proto.getPrimaryTerm(); + id = new Text(proto.getId()); + source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); + explanation = explanationFromProto(proto.getExplanation()); + sortValues = searchSortValuesFromProto(proto.getSortValues()); + nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); + matchedQueries = proto.getMatchedQueriesMap(); + + documentFields = new HashMap<>(); + proto.getDocumentFieldsMap().forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); + + metaFields = new HashMap<>(); + proto.getMetaFieldsMap().forEach((key, value) -> metaFields.put(key, documentFieldFromProto(value))); + + highlightFields = new HashMap<>(); + proto.getHighlightFieldsMap().forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); + + innerHits = new HashMap<>(); + proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); + + shard = searchShardTargetFromProto(proto.getShard()); + index = shard.getIndex(); + clusterAlias = shard.getClusterAlias(); + } + + static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { + NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() + .setField(nestedIdentity.getField().string()) + .setOffset(nestedIdentity.getOffset()); + + if (nestedIdentity.getChild() != null) { + builder.setChild(nestedIdentityToProto(nestedIdentity.getChild())); + } + + return builder.build(); + } + + static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityProto proto) { + String field = proto.getField(); + int offset = proto.getOffset(); + + SearchHit.NestedIdentity child = null; + if (proto.hasChild()) { + child = nestedIdentityFromProto(proto.getChild()); + } + + return new SearchHit.NestedIdentity(field, offset, child); + } +} diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java similarity index 51% rename from server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java rename to server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index 9433d5446e271..c862bbc0fbdec 100644 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitsSerDe.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.transport.serde; +package org.opensearch.transport.protobuf; import com.google.protobuf.ByteString; import org.apache.lucene.search.SortField; @@ -24,97 +24,41 @@ import java.io.IOException; /** - * Serialization/Deserialization implementations for SearchHits. + * SearchHits child which implements serde operations as protobuf. * @opensearch.internal */ -public class SearchHitsSerDe extends SearchHits implements SerDe.nativeSerializer, SerDe.protobufSerializer { - SerDe.Strategy strategy = SerDe.Strategy.NATIVE; - - public SearchHitsSerDe(SearchHits hits, SerDe.Strategy strategy) { +public class SearchHitsProtobuf extends SearchHits { + public SearchHitsProtobuf(SearchHits hits) { super(hits); - this.strategy = strategy; - } - - public SearchHitsSerDe(SerDe.Strategy strategy, StreamInput in) throws IOException { - this.strategy = strategy; - switch (this.strategy) { - case NATIVE: - fromNativeStream(in); - break; - case PROTOBUF: - fromProtobufStream(in); - break; - default: - throw new AssertionError("This code should not be reachable"); - } } - public SearchHitsSerDe(StreamInput in) throws IOException { - fromNativeStream(in); + public SearchHitsProtobuf(StreamInput in) throws IOException { + fromProtobufStream(in); } - public SearchHitsSerDe(SearchHitsProto proto) { + public SearchHitsProtobuf(SearchHitsProto proto) { fromProto(proto); } @Override public void writeTo(StreamOutput out) throws IOException { - switch (this.strategy) { - case NATIVE: - toNativeStream(out); - break; - case PROTOBUF: - toProtobufStream(out); - break; - default: - throw new AssertionError("This code should not be reachable"); - } + toProtobufStream(out); } - @Override public void toProtobufStream(StreamOutput out) throws IOException { toProto().writeTo(out); } - @Override public void fromProtobufStream(StreamInput in) throws IOException { SearchHitsProto proto = SearchHitsProto.parseFrom(in); fromProto(proto); } - @Override - public void toNativeStream(StreamOutput out) throws IOException { - super.writeTo(out); - } - - @Override - public void fromNativeStream(StreamInput in) throws IOException { - if (in.readBoolean()) { - this.totalHits = Lucene.readTotalHits(in); - } else { - // track_total_hits is false - this.totalHits = null; - } - this.maxScore = in.readFloat(); - int size = in.readVInt(); - if (size == 0) { - hits = EMPTY; - } else { - hits = new SearchHit[size]; - for (int i = 0; i < hits.length; i++) { - hits[i] = new SearchHitSerDe(SerDe.Strategy.NATIVE, in); - } - } - this.sortFields = in.readOptionalArray(Lucene::readSortField, SortField[]::new); - this.collapseField = in.readOptionalString(); - this.collapseValues = in.readOptionalArray(Lucene::readSortValue, Object[]::new); - } - SearchHitsProto toProto() { SearchHitsProto.Builder builder = SearchHitsProto.newBuilder().setMaxScore(maxScore).setCollapseField(collapseField); for (SearchHit hit : hits) { - builder.addHits(new SearchHitSerDe(hit, strategy).toProto()); + builder.addHits(new SearchHitProtobuf(hit).toProto()); } TotalHits totHits = totalHits; @@ -125,20 +69,20 @@ SearchHitsProto toProto() { sortOut.writeOptionalArray(Lucene::writeSortField, sortFields); builder.setSortFields(ByteString.copyFrom(sortOut.bytes().toBytesRef().bytes)); } catch (IOException e) { - throw new SerDe.SerializationException("Failed to serialize SearchHits to proto", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to serialize SearchHits to proto", e); } try (BytesStreamOutput collapseOut = new BytesStreamOutput()) { collapseOut.writeOptionalArray(Lucene::writeSortValue, collapseValues); builder.setCollapseValues(ByteString.copyFrom(collapseOut.bytes().toBytesRef().bytes)); } catch (IOException e) { - throw new SerDe.SerializationException("Failed to serialize SearchHits to proto", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to serialize SearchHits to proto", e); } return builder.build(); } - void fromProto(SearchHitsProto proto) throws SerDe.SerializationException { + void fromProto(SearchHitsProto proto) throws ProtoSerDeHelpers.SerializationException { maxScore = proto.getMaxScore(); collapseField = proto.getCollapseField(); @@ -146,29 +90,25 @@ void fromProto(SearchHitsProto proto) throws SerDe.SerializationException { long rel = totHitsProto.getRelation(); long val = totHitsProto.getValue(); if (rel < 0 || rel >= TotalHits.Relation.values().length) { - throw new SerDe.SerializationException("Failed to deserialize TotalHits from proto"); + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize TotalHits from proto"); } totalHits = new TotalHits(val, TotalHits.Relation.values()[(int) rel]); try (StreamInput sortBytesInput = new BytesArray(proto.getSortFields().toByteArray()).streamInput()) { sortFields = sortBytesInput.readOptionalArray(Lucene::readSortField, SortField[]::new); } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize SearchHits from proto", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchHits from proto", e); } try (StreamInput collapseBytesInput = new BytesArray(proto.getCollapseValues().toByteArray()).streamInput()) { collapseValues = collapseBytesInput.readOptionalArray(Lucene::readSortValue, Object[]::new); } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize SearchHits from proto", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchHits from proto", e); } hits = new SearchHit[proto.getHitsCount()]; for (int i = 0; i < hits.length; i++) { - try { - hits[i] = new SearchHitSerDe(proto.getHits(i)); - } catch (IOException e) { - throw new SerDe.SerializationException("Failed to deserialize SearchHits from proto", e); - } + hits[i] = new SearchHitProtobuf(proto.getHits(i)); } } } diff --git a/server/src/main/java/org/opensearch/transport/serde/package-info.java b/server/src/main/java/org/opensearch/transport/protobuf/package-info.java similarity index 86% rename from server/src/main/java/org/opensearch/transport/serde/package-info.java rename to server/src/main/java/org/opensearch/transport/protobuf/package-info.java index fa144e7d4dcfd..16d52127e37e6 100644 --- a/server/src/main/java/org/opensearch/transport/serde/package-info.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/package-info.java @@ -7,4 +7,4 @@ */ /** Serialization/Deserialization implementations for the fetch package. */ -package org.opensearch.transport.serde; +package org.opensearch.transport.protobuf; diff --git a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java b/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java deleted file mode 100644 index f48d334ad3a2c..0000000000000 --- a/server/src/main/java/org/opensearch/transport/serde/FetchSearchResultSerDe.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.transport.serde; - -import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.search.fetch.FetchSearchResult; -import org.opensearch.search.internal.ShardSearchContextId; -import org.opensearch.serde.proto.SearchHitsTransportProto.FetchSearchResultProto; - -import java.io.IOException; - -/** - * Serialization/Deserialization implementations for SearchHit. - * @opensearch.internal - */ -public class FetchSearchResultSerDe extends FetchSearchResult implements SerDe.nativeSerializer, SerDe.protobufSerializer { - SerDe.Strategy strategy = SerDe.Strategy.NATIVE; - - public FetchSearchResultSerDe(SerDe.Strategy strategy, StreamInput in) throws IOException { - this.strategy = strategy; - switch (this.strategy) { - case NATIVE: - fromNativeStream(in); - break; - case PROTOBUF: - fromProtobufStream(in); - break; - default: - throw new AssertionError("This code should not be reachable"); - } - } - - public FetchSearchResultSerDe(StreamInput in) throws IOException { - fromNativeStream(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - switch (this.strategy) { - case NATIVE: - toNativeStream(out); - break; - case PROTOBUF: - toProtobufStream(out); - break; - default: - throw new AssertionError("This code should not be reachable"); - } - } - - @Override - public void toProtobufStream(StreamOutput out) throws IOException { - toProto().writeTo(out); - } - - @Override - public void fromProtobufStream(StreamInput in) throws IOException { - FetchSearchResultProto proto = FetchSearchResultProto.parseFrom(in); - fromProto(proto); - } - - @Override - public void toNativeStream(StreamOutput out) throws IOException { - super.writeTo(out); - } - - @Override - public void fromNativeStream(StreamInput in) throws IOException { - this.hits = new SearchHitsSerDe(SerDe.Strategy.NATIVE, in); - this.contextId = new ShardSearchContextId(in); - } - - FetchSearchResultProto toProto() { - FetchSearchResultProto.Builder builder = FetchSearchResultProto.newBuilder() - .setHits(new SearchHitsSerDe(hits, strategy).toProto()) - .setCounter(this.counter); - return builder.build(); - } - - void fromProto(FetchSearchResultProto proto) { - hits = new SearchHitsSerDe(proto.getHits()); - } -} diff --git a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java b/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java deleted file mode 100644 index 256622a4a033b..0000000000000 --- a/server/src/main/java/org/opensearch/transport/serde/SearchHitSerDe.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.transport.serde; - -import com.google.protobuf.ByteString; -import org.opensearch.Version; -import org.opensearch.common.document.DocumentField; -import org.opensearch.core.common.bytes.BytesReference; -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; -import org.opensearch.search.fetch.subphase.highlight.HighlightField; -import org.opensearch.serde.proto.SearchHitsTransportProto.NestedIdentityProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitProto; - -import java.io.IOException; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -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.transport.serde.SerDe.documentFieldFromProto; -import static org.opensearch.transport.serde.SerDe.documentFieldToProto; -import static org.opensearch.transport.serde.SerDe.explanationFromProto; -import static org.opensearch.transport.serde.SerDe.explanationToProto; -import static org.opensearch.transport.serde.SerDe.highlightFieldFromProto; -import static org.opensearch.transport.serde.SerDe.highlightFieldToProto; -import static org.opensearch.transport.serde.SerDe.searchShardTargetFromProto; -import static org.opensearch.transport.serde.SerDe.searchShardTargetToProto; -import static org.opensearch.transport.serde.SerDe.searchSortValuesFromProto; -import static org.opensearch.transport.serde.SerDe.searchSortValuesToProto; - -/** - * Serialization/Deserialization implementations for SearchHit. - * @opensearch.internal - */ -public class SearchHitSerDe extends SearchHit implements SerDe.nativeSerializer, SerDe.protobufSerializer { - SerDe.Strategy strategy = SerDe.Strategy.NATIVE; - - public SearchHitSerDe(SearchHit hit, SerDe.Strategy strategy) { - super(hit); - this.strategy = strategy; - } - - public SearchHitSerDe(SerDe.Strategy strategy, StreamInput in) throws IOException { - this.strategy = strategy; - switch (this.strategy) { - case NATIVE: - fromNativeStream(in); - break; - case PROTOBUF: - fromProtobufStream(in); - break; - default: - throw new AssertionError("This code should not be reachable"); - } - } - - public SearchHitSerDe(StreamInput in) throws IOException { - fromNativeStream(in); - } - - public SearchHitSerDe(SearchHitProto proto) throws IOException { - fromProto(proto); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - switch (this.strategy) { - case NATIVE: - toNativeStream(out); - break; - case PROTOBUF: - toProtobufStream(out); - break; - default: - throw new AssertionError("This code should not be reachable"); - } - } - - @Override - public void toProtobufStream(StreamOutput out) throws IOException { - toProto().writeTo(out); - } - - @Override - public void fromProtobufStream(StreamInput in) throws IOException { - SearchHitProto proto = SearchHitProto.parseFrom(in); - fromProto(proto); - } - - @Override - public void toNativeStream(StreamOutput out) throws IOException { - super.writeTo(out); - } - - @Override - public void fromNativeStream(StreamInput in) throws IOException { - docId = -1; - score = in.readFloat(); - id = in.readOptionalText(); - if (in.getVersion().before(Version.V_2_0_0)) { - in.readOptionalText(); - } - - nestedIdentity = in.readOptionalWriteable(NestedIdentity::new); - version = in.readLong(); - seqNo = in.readZLong(); - primaryTerm = in.readVLong(); - source = in.readBytesReference(); - if (source.length() == 0) { - source = null; - } - if (in.readBoolean()) { - explanation = readExplanation(in); - } - documentFields = in.readMap(StreamInput::readString, DocumentField::new); - metaFields = in.readMap(StreamInput::readString, DocumentField::new); - - int size = in.readVInt(); - if (size == 0) { - highlightFields = emptyMap(); - } else if (size == 1) { - HighlightField field = new HighlightField(in); - highlightFields = singletonMap(field.name(), field); - } else { - Map hlFields = new HashMap<>(); - for (int i = 0; i < size; i++) { - HighlightField field = new HighlightField(in); - hlFields.put(field.name(), field); - } - highlightFields = unmodifiableMap(hlFields); - } - - sortValues = new SearchSortValues(in); - - size = in.readVInt(); - if (in.getVersion().onOrAfter(Version.V_2_13_0)) { - if (size > 0) { - Map tempMap = in.readMap(StreamInput::readString, StreamInput::readFloat); - matchedQueries = tempMap.entrySet() - .stream() - .sorted(Map.Entry.comparingByKey()) - .collect( - Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new) - ); - } - } else { - matchedQueries = new LinkedHashMap<>(size); - for (int i = 0; i < size; i++) { - matchedQueries.put(in.readString(), Float.NaN); - } - } - shard = in.readOptionalWriteable(SearchShardTarget::new); - if (shard != null) { - index = shard.getIndex(); - clusterAlias = shard.getClusterAlias(); - } - - size = in.readVInt(); - if (size > 0) { - innerHits = new HashMap<>(size); - for (int i = 0; i < size; i++) { - String key = in.readString(); - SearchHits value = new SearchHitsSerDe(strategy, in); - innerHits.put(key, value); - } - } else { - innerHits = null; - } - } - - SearchHitProto toProto() { - SearchHitProto.Builder builder = SearchHitProto.newBuilder() - .setScore(score) - .setId(id.string()) - .setVersion(version) - .setSeqNo(seqNo) - .setPrimaryTerm(primaryTerm); - - builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); - builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); - builder.setExplanation(explanationToProto(explanation)); - builder.setSortValues(searchSortValuesToProto(sortValues)); - - documentFields.forEach((key, value) -> builder.putDocumentFields(key, documentFieldToProto(value))); - - metaFields.forEach((key, value) -> builder.putMetaFields(key, documentFieldToProto(value))); - - highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); - - matchedQueries.forEach(builder::putMatchedQueries); - - // shard is optional - if (shard != null) { - builder.setShard(searchShardTargetToProto(shard)); - } - - innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsSerDe(value, strategy).toProto())); - - return builder.build(); - } - - void fromProto(SearchHitProto proto) throws SerDe.SerializationException { - docId = -1; - score = proto.getScore(); - seqNo = proto.getSeqNo(); - version = proto.getVersion(); - primaryTerm = proto.getPrimaryTerm(); - id = new Text(proto.getId()); - source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); - explanation = explanationFromProto(proto.getExplanation()); - sortValues = searchSortValuesFromProto(proto.getSortValues()); - nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); - matchedQueries = proto.getMatchedQueriesMap(); - - documentFields = new HashMap<>(); - proto.getDocumentFieldsMap().forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); - - metaFields = new HashMap<>(); - proto.getMetaFieldsMap().forEach((key, value) -> metaFields.put(key, documentFieldFromProto(value))); - - highlightFields = new HashMap<>(); - proto.getHighlightFieldsMap().forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); - - innerHits = new HashMap<>(); - proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsSerDe(value))); - - shard = searchShardTargetFromProto(proto.getShard()); - index = shard.getIndex(); - clusterAlias = shard.getClusterAlias(); - } - - static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { - NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() - .setField(nestedIdentity.getField().string()) - .setOffset(nestedIdentity.getOffset()); - - if (nestedIdentity.getChild() != null) { - builder.setChild(nestedIdentityToProto(nestedIdentity.getChild())); - } - - return builder.build(); - } - - static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityProto proto) { - String field = proto.getField(); - int offset = proto.getOffset(); - - SearchHit.NestedIdentity child = null; - if (proto.hasChild()) { - child = nestedIdentityFromProto(proto.getChild()); - } - - return new SearchHit.NestedIdentity(field, offset, child); - } -} diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java new file mode 100644 index 0000000000000..0fba91828fac3 --- /dev/null +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -0,0 +1,217 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.search; + +import org.apache.lucene.search.SortField; +import org.apache.lucene.search.TotalHits; +import org.apache.lucene.tests.util.TestUtil; +import org.opensearch.action.OriginalIndices; +import org.opensearch.common.lucene.LuceneTests; +import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.index.Index; +import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.ToXContent; +import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentParser; +import org.opensearch.test.AbstractSerializingTestCase; +import org.opensearch.test.AbstractWireSerializingTestCase; +import org.opensearch.transport.protobuf.SearchHitsProtobuf; + +import java.io.IOException; +import java.util.Collections; +import java.util.function.Predicate; + +public class SearchHitsProtobufTests extends AbstractWireSerializingTestCase { + + @Override + protected Writeable.Reader instanceReader() { + return SearchHitsProtobuf::new; + } + + @Override + protected SearchHitsProtobuf createTestInstance() { + // This instance is used to test the transport serialization so it's fine + // to produce shard targets (withShardTarget is true) since they are serialized + // in this layer. + return createTestItem(randomFrom(XContentType.values()), true, true); + } + + public static SearchHitsProtobuf createTestItem(boolean withOptionalInnerHits, boolean withShardTarget) { + return createTestItem(randomFrom(XContentType.values()), withOptionalInnerHits, withShardTarget); + } + + private static SearchHit[] createSearchHitArray( + int size, + final MediaType mediaType, + boolean withOptionalInnerHits, + boolean transportSerialization + ) { + SearchHit[] hits = new SearchHit[size]; + for (int i = 0; i < hits.length; i++) { + hits[i] = SearchHitTests.createTestItem(mediaType, withOptionalInnerHits, transportSerialization); + } + return hits; + } + + private static TotalHits randomTotalHits(TotalHits.Relation relation) { + long totalHits = TestUtil.nextLong(random(), 0, Long.MAX_VALUE); + return new TotalHits(totalHits, relation); + } + + public static SearchHitsProtobuf createTestItem(final MediaType mediaType, boolean withOptionalInnerHits, boolean transportSerialization) { + return createTestItem(mediaType, withOptionalInnerHits, transportSerialization, randomFrom(TotalHits.Relation.values())); + } + + private static SearchHitsProtobuf createTestItem( + final MediaType mediaType, + boolean withOptionalInnerHits, + boolean transportSerialization, + TotalHits.Relation totalHitsRelation + ) { + int searchHits = randomIntBetween(0, 5); + SearchHit[] hits = createSearchHitArray(searchHits, mediaType, withOptionalInnerHits, transportSerialization); + TotalHits totalHits = frequently() ? randomTotalHits(totalHitsRelation) : null; + float maxScore = frequently() ? randomFloat() : Float.NaN; + SortField[] sortFields = null; + String collapseField = null; + Object[] collapseValues = null; + if (transportSerialization) { + sortFields = randomBoolean() ? createSortFields(randomIntBetween(1, 5)) : null; + collapseField = randomAlphaOfLengthBetween(5, 10); + collapseValues = randomBoolean() ? createCollapseValues(randomIntBetween(1, 10)) : null; + } + return new SearchHitsProtobuf(new SearchHits(hits, totalHits, maxScore, sortFields, collapseField, collapseValues)); + } + + private static SortField[] createSortFields(int size) { + SortField[] sortFields = new SortField[size]; + for (int i = 0; i < sortFields.length; i++) { + // sort fields are simplified before serialization, we write directly the simplified version + // otherwise equality comparisons become complicated + sortFields[i] = LuceneTests.randomSortField().v2(); + } + return sortFields; + } + + private static Object[] createCollapseValues(int size) { + Object[] collapseValues = new Object[size]; + for (int i = 0; i < collapseValues.length; i++) { + collapseValues[i] = LuceneTests.randomSortValue(); + } + return collapseValues; + } + + @Override + protected SearchHitsProtobuf mutateInstance(SearchHitsProtobuf instance) { + return new SearchHitsProtobuf(mutate(instance)); + } + + protected SearchHits mutate(SearchHits instance) { + switch (randomIntBetween(0, 5)) { + case 0: + return new SearchHits( + createSearchHitArray(instance.getHits().length + 1, randomFrom(XContentType.values()), false, randomBoolean()), + instance.getTotalHits(), + instance.getMaxScore() + ); + case 1: + final TotalHits totalHits; + if (instance.getTotalHits() == null) { + totalHits = randomTotalHits(randomFrom(TotalHits.Relation.values())); + } else { + totalHits = null; + } + return new SearchHits(instance.getHits(), totalHits, instance.getMaxScore()); + case 2: + final float maxScore; + if (Float.isNaN(instance.getMaxScore())) { + maxScore = randomFloat(); + } else { + maxScore = Float.NaN; + } + return new SearchHits(instance.getHits(), instance.getTotalHits(), maxScore); + case 3: + SortField[] sortFields; + if (instance.getSortFields() == null) { + sortFields = createSortFields(randomIntBetween(1, 5)); + } else { + sortFields = randomBoolean() ? createSortFields(instance.getSortFields().length + 1) : null; + } + return new SearchHits( + instance.getHits(), + instance.getTotalHits(), + instance.getMaxScore(), + sortFields, + instance.getCollapseField(), + instance.getCollapseValues() + ); + case 4: + String collapseField; + if (instance.getCollapseField() == null) { + collapseField = randomAlphaOfLengthBetween(5, 10); + } else { + collapseField = randomBoolean() ? instance.getCollapseField() + randomAlphaOfLengthBetween(2, 5) : null; + } + return new SearchHits( + instance.getHits(), + instance.getTotalHits(), + instance.getMaxScore(), + instance.getSortFields(), + collapseField, + instance.getCollapseValues() + ); + case 5: + Object[] collapseValues; + if (instance.getCollapseValues() == null) { + collapseValues = createCollapseValues(randomIntBetween(1, 5)); + } else { + collapseValues = randomBoolean() ? createCollapseValues(instance.getCollapseValues().length + 1) : null; + } + return new SearchHits( + instance.getHits(), + instance.getTotalHits(), + instance.getMaxScore(), + instance.getSortFields(), + instance.getCollapseField(), + collapseValues + ); + default: + throw new UnsupportedOperationException(); + } + } +} From b7291e1af8b9aacb225b2770b2131320fa06f541 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 27 Aug 2024 17:29:52 -0700 Subject: [PATCH 31/61] Passing unit tests for primitive proto objects Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHit.java | 1 + .../opensearch/search/SearchShardTarget.java | 2 + .../subphase/highlight/HighlightField.java | 2 + .../transport/protobuf/ProtoSerDeHelpers.java | 173 ++++++++++++------ .../main/proto/serde/SearchHitsProto.proto | 39 ++-- 5 files changed, 140 insertions(+), 77 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index 10cbc00411408..c9aed75ee78be 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -107,6 +107,7 @@ public class SearchHit implements Writeable, ToXContentObject, Iterable details = new ArrayList<>(); + Number val = null; + switch (proto.getValueCase()) { + case INT_VALUE: + val = proto.getIntValue(); + break; + case LONG_VALUE: + val = proto.getLongValue(); + break; + case FLOAT_VALUE: + val = proto.getFloatValue(); + break; + case DOUBLE_VALUE: + val = proto.getDoubleValue(); + break; + default: + throw new SerializationException("Unknown numeric type: Explanation.value"); + } + for (ExplanationProto det : proto.getDetailsList()) { details.add(explanationFromProto(det)); } if (proto.getMatch()) { - return Explanation.match(value, description, details); + return Explanation.match(val, description, details); } return Explanation.noMatch(description, details); } - // Is there a reason to open a new stream for each object? - // Seems simpler to write a single stream. - static DocumentFieldProto documentFieldToProto(DocumentField field) { + // TODO: Can we write all objects to a single stream? + public static DocumentFieldProto documentFieldToProto(DocumentField field) { DocumentFieldProto.Builder builder = DocumentFieldProto.newBuilder().setName(field.getName()); - try (BytesStreamOutput docsOut = new BytesStreamOutput()) { - docsOut.writeCollection(field.getValues(), StreamOutput::writeGenericValue); - builder.addValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); - } catch (IOException e) { - builder.addValues(ByteString.EMPTY); + for (Object value : field.getValues()) { + try (BytesStreamOutput docsOut = new BytesStreamOutput()) { + docsOut.writeGenericValue(value); + builder.addValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); + } catch (IOException e) { + builder.addValues(ByteString.EMPTY); + } } return builder.build(); } - static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws ProtoSerDeHelpers.SerializationException { + public static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws ProtoSerDeHelpers.SerializationException { String name = proto.getName(); - List values = new ArrayList<>(0); + ArrayList values = new ArrayList<>(); - if (proto.getValuesCount() > 0) { - BytesReference valuesBytes = new BytesArray(proto.getValues(0).toByteArray()); + for (int i = 0; i < proto.getValuesCount(); i++) { + BytesReference valuesBytes = new BytesArray(proto.getValues(i).toByteArray()); try (StreamInput in = valuesBytes.streamInput()) { - Object readValue = in.readGenericValue(); - values.add(readValue); + values.add(in.readGenericValue()); } catch (IOException e) { throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize DocumentField values from proto object", e); } @@ -118,89 +150,110 @@ static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws Pro return new DocumentField(name, values); } - static HighlightFieldProto highlightFieldToProto(HighlightField field) { - HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder().setName(field.getName()); + public static HighlightFieldProto highlightFieldToProto(HighlightField field) { + HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder() + .setName(field.getName()) + .setFragsNull(true); - for (Text frag : field.getFragments()) { - builder.addFragments(frag.string()); + if (field.getFragments() != null) { + builder.setFragsNull(false); + for (Text frag : field.getFragments()) { + builder.addFragments(frag.string()); + } } return builder.build(); } - static HighlightField highlightFieldFromProto(HighlightFieldProto proto) { + public static HighlightField highlightFieldFromProto(HighlightFieldProto proto) { String name = proto.getName(); - Text[] fragments = new Text[proto.getFragmentsCount()]; + Text[] fragments = null; - for (int i = 0; i < proto.getFragmentsCount(); i++) { - fragments[i] = new Text(proto.getFragments(i)); + if (!proto.getFragsNull()) { + fragments = new Text[proto.getFragmentsCount()]; + for (int i = 0; i < proto.getFragmentsCount(); i++) { + fragments[i] = new Text(proto.getFragments(i)); + } } return new HighlightField(name, fragments); } - // See above comment for documentFieldToProto. - static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { + // TODO: Can we write all objects to a single stream? + public static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { SearchSortValuesProto.Builder builder = SearchSortValuesProto.newBuilder(); - try (BytesStreamOutput formOut = new BytesStreamOutput()) { - formOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); - builder.addFormattedSortValues(ByteString.copyFrom(formOut.bytes().toBytesRef().bytes)); - } catch (IOException e) { - builder.addFormattedSortValues(ByteString.EMPTY); + for (Object value : searchSortValues.getFormattedSortValues()) { + try (BytesStreamOutput docsOut = new BytesStreamOutput()) { + writeSortValue(docsOut, value); + builder.addFormattedSortValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); + } catch (IOException e) { + builder.addFormattedSortValues(ByteString.EMPTY); + } } - try (BytesStreamOutput rawOut = new BytesStreamOutput()) { - rawOut.writeArray(Lucene::writeSortValue, searchSortValues.getFormattedSortValues()); - builder.addRawSortValues(ByteString.copyFrom(rawOut.bytes().toBytesRef().bytes)); - } catch (IOException e) { - builder.addRawSortValues(ByteString.EMPTY); + for (Object value : searchSortValues.getRawSortValues()) { + try (BytesStreamOutput docsOut = new BytesStreamOutput()) { + writeSortValue(docsOut, value); + builder.addRawSortValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); + } catch (IOException e) { + builder.addRawSortValues(ByteString.EMPTY); + } } return builder.build(); } - static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws ProtoSerDeHelpers.SerializationException { - Object[] formattedSortValues = null; - Object[] rawSortValues = null; + public static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws ProtoSerDeHelpers.SerializationException { + Object[] formattedSortValues = new Object[proto.getFormattedSortValuesCount()]; + Object[] rawSortValues = new Object[proto.getRawSortValuesCount()]; - if (proto.getFormattedSortValuesCount() > 0) { - BytesReference formattedBytes = new BytesArray(proto.getFormattedSortValues(0).toByteArray()); - try (StreamInput formattedIn = formattedBytes.streamInput()) { - formattedSortValues = formattedIn.readArray(Lucene::readSortValue, Object[]::new); + for (int i = 0; i < formattedSortValues.length; i++) { + BytesReference valuesBytes = new BytesArray(proto.getFormattedSortValues(i).toByteArray()); + try (StreamInput in = valuesBytes.streamInput()) { + formattedSortValues[i] = readSortValue(in); } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchSortValues from proto object", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchSortValues from protobuf", e); } } - if (proto.getRawSortValuesCount() > 0) { - BytesReference rawBytes = new BytesArray(proto.getRawSortValues(0).toByteArray()); - try (StreamInput rawIn = rawBytes.streamInput()) { - rawSortValues = rawIn.readArray(Lucene::readSortValue, Object[]::new); + for (int i = 0; i < rawSortValues.length; i++) { + BytesReference valuesBytes = new BytesArray(proto.getRawSortValues(i).toByteArray()); + try (StreamInput in = valuesBytes.streamInput()) { + rawSortValues[i] = readSortValue(in); } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchSortValues from proto object", e); + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchSortValues from protobuf", e); } } return new SearchSortValues(formattedSortValues, rawSortValues); } - static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { - return SearchShardTargetProto.newBuilder() + public static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { + SearchShardTargetProto.Builder builder = SearchShardTargetProto.newBuilder() .setNodeId(shardTarget.getNodeId()) - .setShardId(shardIdToProto(shardTarget.getShardId())) - .setClusterAlias(shardTarget.getClusterAlias()) - .build(); + .setShardId(shardIdToProto(shardTarget.getShardId())); + + if (shardTarget.getClusterAlias() != null) { + builder.setClusterAlias(shardTarget.getClusterAlias()); + } + + return builder.build(); } public static SearchShardTarget searchShardTargetFromProto(SearchShardTargetProto proto) { String nodeId = proto.getNodeId(); ShardId shardId = shardIdFromProto(proto.getShardId()); - String clusterAlias = proto.getClusterAlias(); + + String clusterAlias = null; + if (proto.hasClusterAlias()) { + clusterAlias = proto.getClusterAlias(); + } + return new SearchShardTarget(nodeId, shardId, clusterAlias); } - static ShardIdProto shardIdToProto(ShardId shardId) { + public static ShardIdProto shardIdToProto(ShardId shardId) { return ShardIdProto.newBuilder() .setIndex(indexToProto(shardId.getIndex())) .setShardId(shardId.id()) @@ -214,7 +267,7 @@ public static ShardId shardIdFromProto(ShardIdProto proto) { return new ShardId(index, shardId); } - static IndexProto indexToProto(Index index) { + public static IndexProto indexToProto(Index index) { return IndexProto.newBuilder().setName(index.getName()).setUuid(index.getUUID()).build(); } diff --git a/server/src/main/proto/serde/SearchHitsProto.proto b/server/src/main/proto/serde/SearchHitsProto.proto index c4425cb6e708f..e34564ed55988 100644 --- a/server/src/main/proto/serde/SearchHitsProto.proto +++ b/server/src/main/proto/serde/SearchHitsProto.proto @@ -50,19 +50,19 @@ Map innerHits message SearchHitProto { float score = 1; string id = 2; - NestedIdentityProto nested_identity = 3; - int64 version = 4; - int64 seq_no = 5; - int64 primary_term = 6; - bytes source = 7; - ExplanationProto explanation = 8; - map document_fields = 9; - map meta_fields = 10; - map highlight_fields = 11; + int64 version = 3; + int64 seq_no = 4; + int64 primary_term = 5; + bytes source = 6; + map document_fields = 7; + map meta_fields = 8; + map highlight_fields = 9; + map matched_queries = 10; + map inner_hits = 11; SearchSortValuesProto sort_values = 12; - map matched_queries = 13; + optional NestedIdentityProto nested_identity = 13; optional SearchShardTargetProto shard = 14; - map inner_hits = 15; + optional ExplanationProto explanation = 15; } /* @@ -100,7 +100,8 @@ Text[] fragments */ message HighlightFieldProto { string name = 1; - repeated string fragments = 2; + bool frags_null = 2; // fragments can be null OR empty unfortunately + repeated string fragments = 3; } /* @@ -120,10 +121,14 @@ List details */ message ExplanationProto { bool match = 1; - // value used as long - int64 value = 2; - string description = 3; - repeated ExplanationProto details = 4; + oneof value { + int32 int_value = 2; + int64 long_value = 3; + float float_value = 4; + double double_value = 5; + } + string description = 6; + repeated ExplanationProto details = 7; } /* @@ -134,7 +139,7 @@ String clusterAlias message SearchShardTargetProto { string node_id = 1; ShardIdProto shard_id = 2; - string cluster_alias = 3; + optional string cluster_alias = 3; } /* From 881f0476457057b8a436a511e4b829b85facb0c0 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 27 Aug 2024 17:30:22 -0700 Subject: [PATCH 32/61] Bugfix nullable objects Signed-off-by: Finn Carroll --- .../transport/protobuf/SearchHitProtobuf.java | 20 +++- ...bufSearchHitsHelperSerializationTests.java | 97 +++++++++++++++++++ 2 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index d21f84edff686..2400df3ceffca 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -68,25 +68,35 @@ SearchHitProto toProto() { .setSeqNo(seqNo) .setPrimaryTerm(primaryTerm); - builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); + if (nestedIdentity != null) { + builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); + } + builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); - builder.setExplanation(explanationToProto(explanation)); + + if (explanation != null) { + builder.setExplanation(explanationToProto(explanation)); + } + builder.setSortValues(searchSortValuesToProto(sortValues)); documentFields.forEach((key, value) -> builder.putDocumentFields(key, documentFieldToProto(value))); metaFields.forEach((key, value) -> builder.putMetaFields(key, documentFieldToProto(value))); - highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); + if (highlightFields != null) { + highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); + } matchedQueries.forEach(builder::putMatchedQueries); - // shard is optional if (shard != null) { builder.setShard(searchShardTargetToProto(shard)); } - innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsProtobuf(value).toProto())); + if (innerHits != null) { + innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsProtobuf(value).toProto())); + } return builder.build(); } diff --git a/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java b/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java new file mode 100644 index 0000000000000..4e5412c2477e8 --- /dev/null +++ b/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java @@ -0,0 +1,97 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search; + +import org.apache.lucene.search.Explanation; +import org.opensearch.action.OriginalIndices; +import org.opensearch.common.document.DocumentField; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.index.Index; +import org.opensearch.core.index.shard.ShardId; +import org.opensearch.search.fetch.subphase.highlight.HighlightField; +import org.opensearch.search.fetch.subphase.highlight.HighlightFieldTests; +import org.opensearch.serde.proto.SearchHitsTransportProto; +import org.opensearch.test.OpenSearchTestCase; + +import static org.opensearch.index.get.DocumentFieldTests.randomDocumentField; +import static org.opensearch.search.SearchHitTests.createExplanation; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.explanationFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.explanationToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.highlightFieldFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.highlightFieldToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.indexFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.indexToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.shardIdFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.shardIdToProto; + +public class ProtobufSearchHitsHelperSerializationTests extends OpenSearchTestCase { + + public void testProtoExplanationSerDe() { + Explanation orig = createExplanation(randomIntBetween(0, 5)); + SearchHitsTransportProto.ExplanationProto proto = explanationToProto(orig); + Explanation cpy = explanationFromProto(proto); + assertEquals(orig, cpy); + } + + public void testProtoDocumentFieldSerDe() { + DocumentField orig = randomDocumentField(randomFrom(XContentType.values()), randomBoolean(), fieldName -> false).v1(); + SearchHitsTransportProto.DocumentFieldProto proto = documentFieldToProto(orig); + DocumentField cpy = documentFieldFromProto(proto); + assertEquals(orig, cpy); + } + + public void testProtoHighlightFieldSerDe() { + HighlightField orig = HighlightFieldTests.createTestItem(); + SearchHitsTransportProto.HighlightFieldProto proto = highlightFieldToProto(orig); + HighlightField cpy = highlightFieldFromProto(proto); + assertEquals(orig, cpy); + } + + public void testProtoSearchSortValuesSerDe() { + SearchSortValues orig = SearchSortValuesTests.createTestItem(randomFrom(XContentType.values()), true); + SearchHitsTransportProto.SearchSortValuesProto proto = searchSortValuesToProto(orig); + SearchSortValues cpy = searchSortValuesFromProto(proto); + assertEquals(orig, cpy); + } + + public void testProtoSearchShardTargetSerDe() { + String index = randomAlphaOfLengthBetween(5, 10); + String clusterAlias = randomBoolean() ? null : randomAlphaOfLengthBetween(5, 10); + SearchShardTarget orig = new SearchShardTarget( + randomAlphaOfLengthBetween(5, 10), + new ShardId(new Index(index, randomAlphaOfLengthBetween(5, 10)), randomInt()), + clusterAlias, + OriginalIndices.NONE + ); + + SearchHitsTransportProto.SearchShardTargetProto proto = searchShardTargetToProto(orig); + SearchShardTarget cpy = searchShardTargetFromProto(proto); + assertEquals(orig, cpy); + } + + public void testProtoShardIdSerDe() { + ShardId orig = new ShardId(new Index(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)), randomInt()); + SearchHitsTransportProto.ShardIdProto proto = shardIdToProto(orig); + ShardId cpy = shardIdFromProto(proto); + assertEquals(orig, cpy); + } + + public void testProtoIndexSerDe() { + Index orig = new Index(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)); + SearchHitsTransportProto.IndexProto proto = indexToProto(orig); + Index cpy = indexFromProto(proto); + assertEquals(orig, cpy); + } +} From a6f0b90dd4afde9931cc53d8ce9c1fcd91353056 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 27 Aug 2024 20:59:59 -0700 Subject: [PATCH 33/61] Handle null explanation Signed-off-by: Finn Carroll --- .../org/opensearch/transport/protobuf/ProtoSerDeHelpers.java | 2 +- .../org/opensearch/transport/protobuf/SearchHitProtobuf.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index 701d11caabeac..b8880f5b66f34 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -104,7 +104,7 @@ public static Explanation explanationFromProto(ExplanationProto proto) { val = proto.getDoubleValue(); break; default: - throw new SerializationException("Unknown numeric type: Explanation.value"); + // No value, leave null } for (ExplanationProto det : proto.getDetailsList()) { diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index 2400df3ceffca..2fdb0ec556d59 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -72,7 +72,9 @@ SearchHitProto toProto() { builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); } - builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); + if (source != null) { + builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); + } if (explanation != null) { builder.setExplanation(explanationToProto(explanation)); From daa6dddf09cd11e1f3c4b751dd4ff34e42d9e16b Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 28 Aug 2024 00:23:53 -0700 Subject: [PATCH 34/61] Handle null totHits Signed-off-by: Finn Carroll --- .../protobuf/SearchHitsProtobuf.java | 7 ++-- .../search/SearchHitsProtobufTests.java | 36 +++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index c862bbc0fbdec..cffffb4136b52 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -61,9 +61,10 @@ SearchHitsProto toProto() { builder.addHits(new SearchHitProtobuf(hit).toProto()); } - TotalHits totHits = totalHits; - TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder().setRelation(totHits.relation.ordinal()).setValue(totHits.value); - builder.setTotalHits(totHitsBuilder); + if (totalHits != null) { + TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder().setRelation(totalHits.relation.ordinal()).setValue(totalHits.value); + builder.setTotalHits(totHitsBuilder); + } try (BytesStreamOutput sortOut = new BytesStreamOutput()) { sortOut.writeOptionalArray(Lucene::writeSortField, sortFields); diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java index 0fba91828fac3..02801a24a6126 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -75,24 +75,6 @@ public static SearchHitsProtobuf createTestItem(boolean withOptionalInnerHits, b return createTestItem(randomFrom(XContentType.values()), withOptionalInnerHits, withShardTarget); } - private static SearchHit[] createSearchHitArray( - int size, - final MediaType mediaType, - boolean withOptionalInnerHits, - boolean transportSerialization - ) { - SearchHit[] hits = new SearchHit[size]; - for (int i = 0; i < hits.length; i++) { - hits[i] = SearchHitTests.createTestItem(mediaType, withOptionalInnerHits, transportSerialization); - } - return hits; - } - - private static TotalHits randomTotalHits(TotalHits.Relation relation) { - long totalHits = TestUtil.nextLong(random(), 0, Long.MAX_VALUE); - return new TotalHits(totalHits, relation); - } - public static SearchHitsProtobuf createTestItem(final MediaType mediaType, boolean withOptionalInnerHits, boolean transportSerialization) { return createTestItem(mediaType, withOptionalInnerHits, transportSerialization, randomFrom(TotalHits.Relation.values())); } @@ -118,6 +100,24 @@ private static SearchHitsProtobuf createTestItem( return new SearchHitsProtobuf(new SearchHits(hits, totalHits, maxScore, sortFields, collapseField, collapseValues)); } + private static SearchHit[] createSearchHitArray( + int size, + final MediaType mediaType, + boolean withOptionalInnerHits, + boolean transportSerialization + ) { + SearchHit[] hits = new SearchHit[size]; + for (int i = 0; i < hits.length; i++) { + hits[i] = SearchHitTests.createTestItem(mediaType, withOptionalInnerHits, transportSerialization); + } + return hits; + } + + private static TotalHits randomTotalHits(TotalHits.Relation relation) { + long totalHits = TestUtil.nextLong(random(), 0, Long.MAX_VALUE); + return new TotalHits(totalHits, relation); + } + private static SortField[] createSortFields(int size) { SortField[] sortFields = new SortField[size]; for (int i = 0; i < sortFields.length; i++) { From 7ebe02063080f415e4768d9982fe26db376359c2 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 28 Aug 2024 13:15:13 -0700 Subject: [PATCH 35/61] Explicitely set optional values to null Signed-off-by: Finn Carroll --- .../transport/protobuf/SearchHitProtobuf.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index 2fdb0ec556d59..385fda9137c32 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -110,12 +110,37 @@ void fromProto(SearchHitProto proto) { version = proto.getVersion(); primaryTerm = proto.getPrimaryTerm(); id = new Text(proto.getId()); - source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); - explanation = explanationFromProto(proto.getExplanation()); sortValues = searchSortValuesFromProto(proto.getSortValues()); - nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); matchedQueries = proto.getMatchedQueriesMap(); + if (proto.hasNestedIdentity()) { + nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); + } else { + nestedIdentity = null; + } + + if (proto.hasSource()) { + source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); + } else { + source = null; + } + + if (proto.hasExplanation()) { + explanation = explanationFromProto(proto.getExplanation()); + } else { + explanation = null; + } + + if (proto.hasShard()) { + shard = searchShardTargetFromProto(proto.getShard()); + index = shard.getIndex(); + clusterAlias = shard.getClusterAlias(); + } else { + shard = null; + index = null; + clusterAlias = null; + } + documentFields = new HashMap<>(); proto.getDocumentFieldsMap().forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); @@ -127,10 +152,6 @@ void fromProto(SearchHitProto proto) { innerHits = new HashMap<>(); proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); - - shard = searchShardTargetFromProto(proto.getShard()); - index = shard.getIndex(); - clusterAlias = shard.getClusterAlias(); } static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { From c3efe2afa4940a273916413b0d42024c421f0183 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 28 Aug 2024 13:19:12 -0700 Subject: [PATCH 36/61] SearchHit/SearchHits equals() check for instance of class - Not exact match Signed-off-by: Finn Carroll --- server/src/main/java/org/opensearch/search/SearchHit.java | 2 +- server/src/main/java/org/opensearch/search/SearchHits.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index c9aed75ee78be..d47a59307aa6c 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -1018,7 +1018,7 @@ private void buildExplanation(XContentBuilder builder, Explanation explanation) @Override public boolean equals(Object obj) { - if (obj == null || getClass() != obj.getClass()) { + if (!(obj instanceof SearchHit)) { return false; } SearchHit other = (SearchHit) obj; diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index 69584e4c1076d..dffbea2f17b2f 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -299,7 +299,7 @@ public static SearchHits fromXContent(XContentParser parser) throws IOException @Override public boolean equals(Object obj) { - if (obj == null || getClass() != obj.getClass()) { + if (!(obj instanceof SearchHits)) { return false; } SearchHits other = (SearchHits) obj; From ea8c46f279be459d71b0f28f5cf90183f18f3c03 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 28 Aug 2024 13:40:45 -0700 Subject: [PATCH 37/61] SearchHitProto fromProto maps never null, only empty Signed-off-by: Finn Carroll --- .../transport/protobuf/SearchHitProtobuf.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index 385fda9137c32..5cd219f0d48de 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -14,11 +14,14 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.text.Text; import org.opensearch.search.SearchHit; +import org.opensearch.serde.proto.SearchHitsTransportProto; import org.opensearch.serde.proto.SearchHitsTransportProto.NestedIdentityProto; import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitProto; +import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitsProto; import java.io.IOException; import java.util.HashMap; +import java.util.Map; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldToProto; @@ -141,17 +144,29 @@ void fromProto(SearchHitProto proto) { clusterAlias = null; } + Map innerHitsProto = proto.getInnerHitsMap(); + if (!innerHitsProto.isEmpty()) { + innerHits = new HashMap<>(); + innerHitsProto.forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); + } + documentFields = new HashMap<>(); - proto.getDocumentFieldsMap().forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); + Map documentFieldProtoMap = proto.getDocumentFieldsMap(); + if (!documentFieldProtoMap.isEmpty()) { + documentFieldProtoMap.forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); + } metaFields = new HashMap<>(); - proto.getMetaFieldsMap().forEach((key, value) -> metaFields.put(key, documentFieldFromProto(value))); + Map metaFieldProtoMap = proto.getMetaFieldsMap(); + if (!metaFieldProtoMap.isEmpty()) { + metaFieldProtoMap.forEach((key, value) -> metaFields.put(key, documentFieldFromProto(value))); + } highlightFields = new HashMap<>(); - proto.getHighlightFieldsMap().forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); - - innerHits = new HashMap<>(); - proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); + Map highlightFieldProtoMap = proto.getHighlightFieldsMap(); + if (!highlightFieldProtoMap.isEmpty()) { + highlightFieldProtoMap.forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); + } } static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { From 21f8b9edc48ec64674cd8237f514a01777edfdfa Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 28 Aug 2024 13:50:31 -0700 Subject: [PATCH 38/61] totalHits to optional Signed-off-by: Finn Carroll --- .../transport/protobuf/SearchHitsProtobuf.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index cffffb4136b52..d677c1de62eb4 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -87,13 +87,16 @@ void fromProto(SearchHitsProto proto) throws ProtoSerDeHelpers.SerializationExce maxScore = proto.getMaxScore(); collapseField = proto.getCollapseField(); - TotalHitsProto totHitsProto = proto.getTotalHits(); - long rel = totHitsProto.getRelation(); - long val = totHitsProto.getValue(); - if (rel < 0 || rel >= TotalHits.Relation.values().length) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize TotalHits from proto"); + if (proto.hasTotalHits()) { + long rel = proto.getTotalHits().getRelation(); + long val = proto.getTotalHits().getValue(); + if (rel < 0 || rel >= TotalHits.Relation.values().length) { + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize TotalHits from proto"); + } + totalHits = new TotalHits(val, TotalHits.Relation.values()[(int) rel]); + } else { + totalHits = null; } - totalHits = new TotalHits(val, TotalHits.Relation.values()[(int) rel]); try (StreamInput sortBytesInput = new BytesArray(proto.getSortFields().toByteArray()).streamInput()) { sortFields = sortBytesInput.readOptionalArray(Lucene::readSortField, SortField[]::new); From f86acfe2e560e1ba538681f8ecbead9fff3657cc Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 28 Aug 2024 13:51:43 -0700 Subject: [PATCH 39/61] totalHits to nullable Signed-off-by: Finn Carroll --- server/src/main/java/org/opensearch/search/SearchHits.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/SearchHits.java b/server/src/main/java/org/opensearch/search/SearchHits.java index dffbea2f17b2f..58b12fd9cd628 100644 --- a/server/src/main/java/org/opensearch/search/SearchHits.java +++ b/server/src/main/java/org/opensearch/search/SearchHits.java @@ -73,9 +73,10 @@ public static SearchHits empty(boolean withTotalHits) { public static final SearchHit[] EMPTY = new SearchHit[0]; protected SearchHit[] hits; - protected TotalHits totalHits; protected float maxScore; @Nullable + protected TotalHits totalHits; + @Nullable protected SortField[] sortFields; @Nullable protected String collapseField; From 6e57629db575a98a03abc4c5aca27ec7ce91a0d8 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 28 Aug 2024 13:52:52 -0700 Subject: [PATCH 40/61] Update SearchHits proto def w/ optional fields Signed-off-by: Finn Carroll --- server/src/main/proto/serde/SearchHitsProto.proto | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/main/proto/serde/SearchHitsProto.proto b/server/src/main/proto/serde/SearchHitsProto.proto index e34564ed55988..9a5055e685c2e 100644 --- a/server/src/main/proto/serde/SearchHitsProto.proto +++ b/server/src/main/proto/serde/SearchHitsProto.proto @@ -22,12 +22,12 @@ String collapseField Object[] collapseValues */ message SearchHitsProto { - repeated SearchHitProto hits = 1; - TotalHitsProto total_hits = 2; - float max_score = 3; - string collapse_field = 4; - bytes sort_fields = 5; - bytes collapse_values = 6; + float max_score = 1; + string collapse_field = 2; + bytes sort_fields = 3; + bytes collapse_values = 4; + optional TotalHitsProto total_hits = 5; + repeated SearchHitProto hits = 6; } /** @@ -53,7 +53,7 @@ message SearchHitProto { int64 version = 3; int64 seq_no = 4; int64 primary_term = 5; - bytes source = 6; + optional bytes source = 6; map document_fields = 7; map meta_fields = 8; map highlight_fields = 9; From 4a3a463879e4bf43666145d89a65181e8c064b5c Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 28 Aug 2024 14:00:09 -0700 Subject: [PATCH 41/61] Spotless apply Signed-off-by: Finn Carroll --- .../transport/protobuf/ProtoSerDeHelpers.java | 7 +------ .../transport/protobuf/SearchHitProtobuf.java | 4 +++- .../protobuf/SearchHitsProtobuf.java | 4 +++- .../search/SearchHitsProtobufTests.java | 20 +++++-------------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index b8880f5b66f34..dd2db1320924d 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -12,11 +12,9 @@ import org.apache.lucene.search.Explanation; import org.opensearch.common.document.DocumentField; import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.common.lucene.Lucene; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; 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.core.index.Index; import org.opensearch.core.index.shard.ShardId; @@ -34,7 +32,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.List; import static org.opensearch.common.lucene.Lucene.readSortValue; import static org.opensearch.common.lucene.Lucene.writeSortValue; @@ -151,9 +148,7 @@ public static DocumentField documentFieldFromProto(DocumentFieldProto proto) thr } public static HighlightFieldProto highlightFieldToProto(HighlightField field) { - HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder() - .setName(field.getName()) - .setFragsNull(true); + HighlightFieldProto.Builder builder = HighlightFieldProto.newBuilder().setName(field.getName()).setFragsNull(true); if (field.getFragments() != null) { builder.setFragsNull(false); diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index 5cd219f0d48de..69ee7e3ef1237 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -47,7 +47,9 @@ public SearchHitProtobuf(StreamInput in) throws IOException { fromProtobufStream(in); } - public SearchHitProtobuf(SearchHitProto proto) { fromProto(proto); } + public SearchHitProtobuf(SearchHitProto proto) { + fromProto(proto); + } @Override public void writeTo(StreamOutput out) throws IOException { diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index d677c1de62eb4..b46181f3e55b4 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -62,7 +62,9 @@ SearchHitsProto toProto() { } if (totalHits != null) { - TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder().setRelation(totalHits.relation.ordinal()).setValue(totalHits.value); + TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder() + .setRelation(totalHits.relation.ordinal()) + .setValue(totalHits.value); builder.setTotalHits(totHitsBuilder); } diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java index 02801a24a6126..14b84069c555a 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -35,27 +35,13 @@ import org.apache.lucene.search.SortField; import org.apache.lucene.search.TotalHits; import org.apache.lucene.tests.util.TestUtil; -import org.opensearch.action.OriginalIndices; import org.opensearch.common.lucene.LuceneTests; -import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.common.xcontent.json.JsonXContent; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.core.index.Index; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.core.xcontent.MediaType; -import org.opensearch.core.xcontent.ToXContent; -import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.test.AbstractSerializingTestCase; import org.opensearch.test.AbstractWireSerializingTestCase; import org.opensearch.transport.protobuf.SearchHitsProtobuf; -import java.io.IOException; -import java.util.Collections; -import java.util.function.Predicate; - public class SearchHitsProtobufTests extends AbstractWireSerializingTestCase { @Override @@ -75,7 +61,11 @@ public static SearchHitsProtobuf createTestItem(boolean withOptionalInnerHits, b return createTestItem(randomFrom(XContentType.values()), withOptionalInnerHits, withShardTarget); } - public static SearchHitsProtobuf createTestItem(final MediaType mediaType, boolean withOptionalInnerHits, boolean transportSerialization) { + public static SearchHitsProtobuf createTestItem( + final MediaType mediaType, + boolean withOptionalInnerHits, + boolean transportSerialization + ) { return createTestItem(mediaType, withOptionalInnerHits, transportSerialization, randomFrom(TotalHits.Relation.values())); } From e4c227799fe4152667b780825a2761536c478b16 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 29 Aug 2024 12:28:01 -0700 Subject: [PATCH 42/61] Collapse field to optional Signed-off-by: Finn Carroll --- .../opensearch/transport/protobuf/SearchHitsProtobuf.java | 6 +++++- server/src/main/proto/serde/SearchHitsProto.proto | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index b46181f3e55b4..76518a345a6c7 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -55,12 +55,16 @@ public void fromProtobufStream(StreamInput in) throws IOException { } SearchHitsProto toProto() { - SearchHitsProto.Builder builder = SearchHitsProto.newBuilder().setMaxScore(maxScore).setCollapseField(collapseField); + SearchHitsProto.Builder builder = SearchHitsProto.newBuilder().setMaxScore(maxScore); for (SearchHit hit : hits) { builder.addHits(new SearchHitProtobuf(hit).toProto()); } + if (collapseField != null) { + builder.setCollapseField(collapseField); + } + if (totalHits != null) { TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder() .setRelation(totalHits.relation.ordinal()) diff --git a/server/src/main/proto/serde/SearchHitsProto.proto b/server/src/main/proto/serde/SearchHitsProto.proto index 9a5055e685c2e..92fdef26732b1 100644 --- a/server/src/main/proto/serde/SearchHitsProto.proto +++ b/server/src/main/proto/serde/SearchHitsProto.proto @@ -23,7 +23,7 @@ Object[] collapseValues */ message SearchHitsProto { float max_score = 1; - string collapse_field = 2; + optional string collapse_field = 2; bytes sort_fields = 3; bytes collapse_values = 4; optional TotalHitsProto total_hits = 5; From 9a2838b1e7a2086fa251d34294a50b1391fe7d8f Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Fri, 30 Aug 2024 13:11:15 -0700 Subject: [PATCH 43/61] Seperate proto defs a bit Signed-off-by: Finn Carroll --- .../protobuf/FetchSearchResultProtobuf.java | 2 +- .../transport/protobuf/ProtoSerDeHelpers.java | 14 +-- .../transport/protobuf/SearchHitProtobuf.java | 15 ++-- .../protobuf/SearchHitsProtobuf.java | 4 +- .../main/proto/search/FetchSearchResult.proto | 12 +++ .../SearchHits.proto} | 89 ++----------------- ...bufSearchHitsHelperSerializationTests.java | 23 +++-- 7 files changed, 52 insertions(+), 107 deletions(-) create mode 100644 server/src/main/proto/search/FetchSearchResult.proto rename server/src/main/proto/{serde/SearchHitsProto.proto => search/SearchHits.proto} (61%) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java index 2f790a86aca32..723322b3102ef 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java @@ -11,7 +11,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.search.fetch.FetchSearchResult; -import org.opensearch.serde.proto.SearchHitsTransportProto.FetchSearchResultProto; +import org.opensearch.proto.search.FetchSearchResultProtoDef.FetchSearchResultProto; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index dd2db1320924d..7380f660a23f9 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -21,13 +21,13 @@ import org.opensearch.search.SearchShardTarget; import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; -import org.opensearch.serde.proto.SearchHitsTransportProto.DocumentFieldProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.ExplanationProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.HighlightFieldProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.IndexProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchShardTargetProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchSortValuesProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.ShardIdProto; +import org.opensearch.proto.search.SearchHitsProtoDef.DocumentFieldProto; +import org.opensearch.proto.search.SearchHitsProtoDef.ExplanationProto; +import org.opensearch.proto.search.SearchHitsProtoDef.HighlightFieldProto; +import org.opensearch.proto.search.SearchHitsProtoDef.IndexProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SearchShardTargetProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SearchSortValuesProto; +import org.opensearch.proto.search.SearchHitsProtoDef.ShardIdProto; import java.io.IOException; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index 69ee7e3ef1237..d2c0dc1af8173 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -14,10 +14,11 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.text.Text; import org.opensearch.search.SearchHit; -import org.opensearch.serde.proto.SearchHitsTransportProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.NestedIdentityProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitsProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitsProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitProto; +import org.opensearch.proto.search.SearchHitsProtoDef.NestedIdentityProto; +import org.opensearch.proto.search.SearchHitsProtoDef.DocumentFieldProto; +import org.opensearch.proto.search.SearchHitsProtoDef.HighlightFieldProto; import java.io.IOException; import java.util.HashMap; @@ -153,19 +154,19 @@ void fromProto(SearchHitProto proto) { } documentFields = new HashMap<>(); - Map documentFieldProtoMap = proto.getDocumentFieldsMap(); + Map documentFieldProtoMap = proto.getDocumentFieldsMap(); if (!documentFieldProtoMap.isEmpty()) { documentFieldProtoMap.forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); } metaFields = new HashMap<>(); - Map metaFieldProtoMap = proto.getMetaFieldsMap(); + Map metaFieldProtoMap = proto.getMetaFieldsMap(); if (!metaFieldProtoMap.isEmpty()) { metaFieldProtoMap.forEach((key, value) -> metaFields.put(key, documentFieldFromProto(value))); } highlightFields = new HashMap<>(); - Map highlightFieldProtoMap = proto.getHighlightFieldsMap(); + Map highlightFieldProtoMap = proto.getHighlightFieldsMap(); if (!highlightFieldProtoMap.isEmpty()) { highlightFieldProtoMap.forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); } diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index 76518a345a6c7..e5ca21fdf6dd6 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -18,8 +18,8 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; -import org.opensearch.serde.proto.SearchHitsTransportProto.SearchHitsProto; -import org.opensearch.serde.proto.SearchHitsTransportProto.TotalHitsProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitsProto; +import org.opensearch.proto.search.SearchHitsProtoDef.TotalHitsProto; import java.io.IOException; diff --git a/server/src/main/proto/search/FetchSearchResult.proto b/server/src/main/proto/search/FetchSearchResult.proto new file mode 100644 index 0000000000000..db1e37ce66cb6 --- /dev/null +++ b/server/src/main/proto/search/FetchSearchResult.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package org.opensearch.proto.search; + +import "search/SearchHits.proto"; + +option java_outer_classname = "FetchSearchResultProtoDef"; + +message FetchSearchResultProto { + SearchHitsProto hits = 1; + int64 counter = 2; +} diff --git a/server/src/main/proto/serde/SearchHitsProto.proto b/server/src/main/proto/search/SearchHits.proto similarity index 61% rename from server/src/main/proto/serde/SearchHitsProto.proto rename to server/src/main/proto/search/SearchHits.proto index 92fdef26732b1..801706bd9990d 100644 --- a/server/src/main/proto/serde/SearchHitsProto.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -1,26 +1,9 @@ syntax = "proto3"; -package org.opensearch.serde.proto; +package org.opensearch.proto.search; -option java_outer_classname = "SearchHitsTransportProto"; +option java_outer_classname = "SearchHitsProtoDef"; -/* -SearchHits hits; -int counter; - */ -message FetchSearchResultProto { - SearchHitsProto hits = 1; - int64 counter = 2; -} - -/* -SearchHit[] hits -TotalHits totalHits -float maxScore -SortField[] sortFields -String collapseField -Object[] collapseValues - */ message SearchHitsProto { float max_score = 1; optional string collapse_field = 2; @@ -30,23 +13,11 @@ message SearchHitsProto { repeated SearchHitProto hits = 6; } -/** -float score -Text id -NestedIdentity nestedIdentity -long version -long seqNo -long primaryTerm -BytesReference source -Explanation explanation -Map documentFields -Map metaFields -Map highlightedFields -SearchSortValues sortValues -Map matchedQueries -SearchShardTarget shard -Map innerHits -*/ +message TotalHitsProto { + int64 value = 1; + int64 relation = 2; +} + message SearchHitProto { float score = 1; string id = 2; @@ -65,60 +36,28 @@ message SearchHitProto { optional ExplanationProto explanation = 15; } -/* -int value; -Relation relation; - */ -message TotalHitsProto { - int64 value = 1; - int64 relation = 2; -} - -/* -Text field; -int offset; -NestedIdentity child; - */ message NestedIdentityProto { string field = 1; int32 offset = 2; NestedIdentityProto child = 3; } -/* -String name -List values - */ message DocumentFieldProto { string name = 1; repeated bytes values = 2; } -/* -String name -Text[] fragments - */ message HighlightFieldProto { string name = 1; bool frags_null = 2; // fragments can be null OR empty unfortunately repeated string fragments = 3; } -/* -Object[] formattedSortValues -Object[] rawSortValues - */ message SearchSortValuesProto { repeated bytes formatted_sort_values = 1; repeated bytes raw_sort_values = 2; } -/* -boolean match -Number value -String description -List details - */ message ExplanationProto { bool match = 1; oneof value { @@ -131,32 +70,18 @@ message ExplanationProto { repeated ExplanationProto details = 7; } -/* -Text nodeId -ShardId shardId -String clusterAlias - */ message SearchShardTargetProto { string node_id = 1; ShardIdProto shard_id = 2; optional string cluster_alias = 3; } -/* -Index index -int shardId -int hashCode - */ message ShardIdProto { IndexProto index = 1; int32 shard_id = 2; int32 hash_code = 3; } -/* -String name -String uuid - */ message IndexProto { string name = 1; string uuid = 2; diff --git a/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java b/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java index 4e5412c2477e8..6dee773cae708 100644 --- a/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java +++ b/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java @@ -16,9 +16,16 @@ import org.opensearch.core.index.shard.ShardId; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.search.fetch.subphase.highlight.HighlightFieldTests; -import org.opensearch.serde.proto.SearchHitsTransportProto; import org.opensearch.test.OpenSearchTestCase; +import org.opensearch.proto.search.SearchHitsProtoDef.DocumentFieldProto; +import org.opensearch.proto.search.SearchHitsProtoDef.ExplanationProto; +import org.opensearch.proto.search.SearchHitsProtoDef.HighlightFieldProto; +import org.opensearch.proto.search.SearchHitsProtoDef.IndexProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SearchShardTargetProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SearchSortValuesProto; +import org.opensearch.proto.search.SearchHitsProtoDef.ShardIdProto; + import static org.opensearch.index.get.DocumentFieldTests.randomDocumentField; import static org.opensearch.search.SearchHitTests.createExplanation; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldFromProto; @@ -40,28 +47,28 @@ public class ProtobufSearchHitsHelperSerializationTests extends OpenSearchTestCa public void testProtoExplanationSerDe() { Explanation orig = createExplanation(randomIntBetween(0, 5)); - SearchHitsTransportProto.ExplanationProto proto = explanationToProto(orig); + ExplanationProto proto = explanationToProto(orig); Explanation cpy = explanationFromProto(proto); assertEquals(orig, cpy); } public void testProtoDocumentFieldSerDe() { DocumentField orig = randomDocumentField(randomFrom(XContentType.values()), randomBoolean(), fieldName -> false).v1(); - SearchHitsTransportProto.DocumentFieldProto proto = documentFieldToProto(orig); + DocumentFieldProto proto = documentFieldToProto(orig); DocumentField cpy = documentFieldFromProto(proto); assertEquals(orig, cpy); } public void testProtoHighlightFieldSerDe() { HighlightField orig = HighlightFieldTests.createTestItem(); - SearchHitsTransportProto.HighlightFieldProto proto = highlightFieldToProto(orig); + HighlightFieldProto proto = highlightFieldToProto(orig); HighlightField cpy = highlightFieldFromProto(proto); assertEquals(orig, cpy); } public void testProtoSearchSortValuesSerDe() { SearchSortValues orig = SearchSortValuesTests.createTestItem(randomFrom(XContentType.values()), true); - SearchHitsTransportProto.SearchSortValuesProto proto = searchSortValuesToProto(orig); + SearchSortValuesProto proto = searchSortValuesToProto(orig); SearchSortValues cpy = searchSortValuesFromProto(proto); assertEquals(orig, cpy); } @@ -76,21 +83,21 @@ public void testProtoSearchShardTargetSerDe() { OriginalIndices.NONE ); - SearchHitsTransportProto.SearchShardTargetProto proto = searchShardTargetToProto(orig); + SearchShardTargetProto proto = searchShardTargetToProto(orig); SearchShardTarget cpy = searchShardTargetFromProto(proto); assertEquals(orig, cpy); } public void testProtoShardIdSerDe() { ShardId orig = new ShardId(new Index(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)), randomInt()); - SearchHitsTransportProto.ShardIdProto proto = shardIdToProto(orig); + ShardIdProto proto = shardIdToProto(orig); ShardId cpy = shardIdFromProto(proto); assertEquals(orig, cpy); } public void testProtoIndexSerDe() { Index orig = new Index(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)); - SearchHitsTransportProto.IndexProto proto = indexToProto(orig); + IndexProto proto = indexToProto(orig); Index cpy = indexFromProto(proto); assertEquals(orig, cpy); } From bdf5084582f2702d33d5f2c8888e2a567b451cda Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 9 Sep 2024 09:47:00 -0700 Subject: [PATCH 44/61] SearchHit id to optional - Sort values to proto Signed-off-by: Finn Carroll --- .../transport/protobuf/ProtoSerDeHelpers.java | 121 +++++++++++++----- .../transport/protobuf/SearchHitProtobuf.java | 12 +- .../protobuf/SearchHitsProtobuf.java | 11 +- server/src/main/proto/search/SearchHits.proto | 69 +++++++--- 4 files changed, 160 insertions(+), 53 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index 7380f660a23f9..0d4967f592a89 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -10,6 +10,8 @@ import com.google.protobuf.ByteString; import org.apache.lucene.search.Explanation; +import org.apache.lucene.search.SortField; +import org.apache.lucene.util.BytesRef; import org.opensearch.common.document.DocumentField; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.bytes.BytesArray; @@ -18,6 +20,7 @@ import org.opensearch.core.common.text.Text; import org.opensearch.core.index.Index; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.proto.search.SearchHitsProtoDef; import org.opensearch.search.SearchShardTarget; import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; @@ -28,14 +31,14 @@ import org.opensearch.proto.search.SearchHitsProtoDef.SearchShardTargetProto; import org.opensearch.proto.search.SearchHitsProtoDef.SearchSortValuesProto; import org.opensearch.proto.search.SearchHitsProtoDef.ShardIdProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SortValueProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SortFieldProto; import java.io.IOException; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; -import static org.opensearch.common.lucene.Lucene.readSortValue; -import static org.opensearch.common.lucene.Lucene.writeSortValue; - /** * SerDe interfaces and protobuf SerDe implementations for some "primitive" types. * @opensearch.internal @@ -56,7 +59,6 @@ public SerializationException(String message, Throwable cause) { } } - // TODO: Lucene definitions should maybe be serialized as generic bytes arrays. public static ExplanationProto explanationToProto(Explanation explanation) { ExplanationProto.Builder builder = ExplanationProto.newBuilder() .setMatch(explanation.isMatch()) @@ -174,26 +176,15 @@ public static HighlightField highlightFieldFromProto(HighlightFieldProto proto) return new HighlightField(name, fragments); } - // TODO: Can we write all objects to a single stream? public static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { SearchSortValuesProto.Builder builder = SearchSortValuesProto.newBuilder(); for (Object value : searchSortValues.getFormattedSortValues()) { - try (BytesStreamOutput docsOut = new BytesStreamOutput()) { - writeSortValue(docsOut, value); - builder.addFormattedSortValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); - } catch (IOException e) { - builder.addFormattedSortValues(ByteString.EMPTY); - } + builder.addFormattedSortValues(SortValueToProto(value)); } for (Object value : searchSortValues.getRawSortValues()) { - try (BytesStreamOutput docsOut = new BytesStreamOutput()) { - writeSortValue(docsOut, value); - builder.addRawSortValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); - } catch (IOException e) { - builder.addRawSortValues(ByteString.EMPTY); - } + builder.addRawSortValues(SortValueToProto(value)); } return builder.build(); @@ -204,26 +195,98 @@ public static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto p Object[] rawSortValues = new Object[proto.getRawSortValuesCount()]; for (int i = 0; i < formattedSortValues.length; i++) { - BytesReference valuesBytes = new BytesArray(proto.getFormattedSortValues(i).toByteArray()); - try (StreamInput in = valuesBytes.streamInput()) { - formattedSortValues[i] = readSortValue(in); - } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchSortValues from protobuf", e); - } + SortValueProto sortProto = proto.getFormattedSortValues(i); + formattedSortValues[i] = SortValueFromProto(sortProto); } for (int i = 0; i < rawSortValues.length; i++) { - BytesReference valuesBytes = new BytesArray(proto.getRawSortValues(i).toByteArray()); - try (StreamInput in = valuesBytes.streamInput()) { - rawSortValues[i] = readSortValue(in); - } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchSortValues from protobuf", e); - } + SortValueProto sortProto = proto.getRawSortValues(i); + rawSortValues[i] = SortValueFromProto(sortProto); } return new SearchSortValues(formattedSortValues, rawSortValues); } + public static SortValueProto SortValueToProto(Object sortValue) throws ProtoSerDeHelpers.SerializationException { + SortValueProto.Builder builder = SortValueProto.newBuilder(); + + if (sortValue.getClass().equals(String.class)) { + builder.setStringValue((String) sortValue); + } else if (sortValue.getClass().equals(Integer.class)) { + builder.setIntValue((Integer) sortValue); + } else if (sortValue.getClass().equals(Long.class)) { + builder.setLongValue((Long) sortValue); + } else if (sortValue.getClass().equals(Float.class)) { + builder.setFloatValue((Float) sortValue); + } else if (sortValue.getClass().equals(Double.class)) { + builder.setDoubleValue((Double) sortValue); + } else if (sortValue.getClass().equals(Byte.class)) { + builder.setByteValue((Byte) sortValue); + } else if (sortValue.getClass().equals(Short.class)) { + builder.setShortValue((Short) sortValue); + } else if (sortValue.getClass().equals(Boolean.class)) { + builder.setBoolValue((Boolean) sortValue); + } else if (sortValue.getClass().equals(BytesRef.class)) { + builder.setBytesValue(ByteString.copyFrom( + ((BytesRef) sortValue).bytes, + ((BytesRef) sortValue).offset, + ((BytesRef) sortValue).length)); + } else if (sortValue.getClass().equals(BigInteger.class)) { + builder.setBigIntegerValue(sortValue.toString()); + } else { + throw new ProtoSerDeHelpers.SerializationException("Unexpected sortValue: " + sortValue.toString()); + } + + return builder.build(); + } + + public static Object SortValueFromProto(SortValueProto proto) throws ProtoSerDeHelpers.SerializationException { + switch (proto.getValueCase()) { + case STRING_VALUE: + return proto.getStringValue(); + case INT_VALUE: + return proto.getIntValue(); + case LONG_VALUE: + return proto.getLongValue(); + case FLOAT_VALUE: + return proto.getFloatValue(); + case DOUBLE_VALUE: + return proto.getDoubleValue(); + case BYTE_VALUE: + return (byte) proto.getByteValue(); + case SHORT_VALUE: + return (short) proto.getShortValue(); + case BOOL_VALUE: + return proto.getBoolValue(); + case BYTES_VALUE: + ByteString byteString = proto.getBytesValue(); + return new BytesRef(byteString.toByteArray()); + case BIG_INTEGER_VALUE: + return new BigInteger(proto.getBigIntegerValue()); + case VALUE_NOT_SET: + return null; + default: + throw new ProtoSerDeHelpers.SerializationException("Unexpected value case: " + proto.getValueCase()); + } + } + + public static SortFieldProto sortFieldToProto(SortField sortField) { + SortFieldProto.Builder builder = SortFieldProto.newBuilder() + .setId(sortField.get) + .setReverse() + .setType(); + + builder.setField(); + + return builder.build(); + } + + public static SortField sortFieldFromProto(SortFieldProto proto) { + + + return builder.build(); + } + public static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { SearchShardTargetProto.Builder builder = SearchShardTargetProto.newBuilder() .setNodeId(shardTarget.getNodeId()) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index d2c0dc1af8173..c75921ad6da22 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -69,11 +69,14 @@ public void fromProtobufStream(StreamInput in) throws IOException { SearchHitProto toProto() { SearchHitProto.Builder builder = SearchHitProto.newBuilder() .setScore(score) - .setId(id.string()) .setVersion(version) .setSeqNo(seqNo) .setPrimaryTerm(primaryTerm); + if (id != null) { + builder.setId(id.string()); + } + if (nestedIdentity != null) { builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); } @@ -115,10 +118,15 @@ void fromProto(SearchHitProto proto) { seqNo = proto.getSeqNo(); version = proto.getVersion(); primaryTerm = proto.getPrimaryTerm(); - id = new Text(proto.getId()); sortValues = searchSortValuesFromProto(proto.getSortValues()); matchedQueries = proto.getMatchedQueriesMap(); + if (proto.hasId()) { + id = new Text(proto.getId()); + } else { + id = null; + } + if (proto.hasNestedIdentity()) { nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); } else { diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index e5ca21fdf6dd6..da68efee2ca97 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -23,6 +23,8 @@ import java.io.IOException; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.SortValueToProto; + /** * SearchHits child which implements serde operations as protobuf. * @opensearch.internal @@ -79,11 +81,10 @@ SearchHitsProto toProto() { throw new ProtoSerDeHelpers.SerializationException("Failed to serialize SearchHits to proto", e); } - try (BytesStreamOutput collapseOut = new BytesStreamOutput()) { - collapseOut.writeOptionalArray(Lucene::writeSortValue, collapseValues); - builder.setCollapseValues(ByteString.copyFrom(collapseOut.bytes().toBytesRef().bytes)); - } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to serialize SearchHits to proto", e); + if (collapseValues != null) { + for (Object col : collapseValues) { + builder.addCollapseValues(SortValueToProto(col)); + } } return builder.build(); diff --git a/server/src/main/proto/search/SearchHits.proto b/server/src/main/proto/search/SearchHits.proto index 801706bd9990d..b3e808f997567 100644 --- a/server/src/main/proto/search/SearchHits.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -7,9 +7,9 @@ option java_outer_classname = "SearchHitsProtoDef"; message SearchHitsProto { float max_score = 1; optional string collapse_field = 2; - bytes sort_fields = 3; - bytes collapse_values = 4; optional TotalHitsProto total_hits = 5; + repeated SortValueProto collapse_values = 4; + repeated SortFieldProto sort_fields = 3; repeated SearchHitProto hits = 6; } @@ -18,19 +18,54 @@ message TotalHitsProto { int64 relation = 2; } +message SortValueProto { + oneof value { + string string_value = 1; + int32 int_value = 2; + int64 long_value = 3; + float float_value = 4; + double double_value = 5; + int32 byte_value = 6; + int32 short_value = 7; + bool bool_value = 8; + bytes bytes_value = 9; // BytesRef + string big_integer_value = 10; + } +} + +message SortFieldProto { + int32 missing_value = 1; + bool reverse = 2; + SortType type = 3; + optional string field = 4; +} + +enum SortType { + SCORE = 0; + DOC = 1; + STRING = 2; + INT = 3; + FLOAT = 4; + LONG = 5; + DOUBLE = 6; + CUSTOM = 7; + STRING_VAL = 8; + REWRITEABLE = 9; +} + message SearchHitProto { float score = 1; - string id = 2; - int64 version = 3; - int64 seq_no = 4; - int64 primary_term = 5; - optional bytes source = 6; - map document_fields = 7; - map meta_fields = 8; - map highlight_fields = 9; - map matched_queries = 10; - map inner_hits = 11; - SearchSortValuesProto sort_values = 12; + int64 version = 2; + int64 seq_no = 3; + int64 primary_term = 4; + optional bytes source = 5; // JSON payload - Move to map? + map document_fields = 6; + map meta_fields = 7; + map highlight_fields = 8; + map matched_queries = 9; + map inner_hits = 10; + SearchSortValuesProto sort_values = 11; + optional string id = 12; optional NestedIdentityProto nested_identity = 13; optional SearchShardTargetProto shard = 14; optional ExplanationProto explanation = 15; @@ -44,18 +79,18 @@ message NestedIdentityProto { message DocumentFieldProto { string name = 1; - repeated bytes values = 2; + repeated bytes values = 2; // List values - Can we limit this to specific types? } message HighlightFieldProto { string name = 1; - bool frags_null = 2; // fragments can be null OR empty unfortunately + bool frags_null = 2; // fragments can be null OR empty repeated string fragments = 3; } message SearchSortValuesProto { - repeated bytes formatted_sort_values = 1; - repeated bytes raw_sort_values = 2; + repeated SortValueProto formatted_sort_values = 1; + repeated SortValueProto raw_sort_values = 2; } message ExplanationProto { From 406bfbc9da5f6a85632ec257797a0a2443089afe Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 9 Sep 2024 12:11:01 -0700 Subject: [PATCH 45/61] Decompose SearchHits sortFields to protobuf Signed-off-by: Finn Carroll --- .../transport/protobuf/ProtoSerDeHelpers.java | 98 +++++++++++++++---- .../protobuf/SearchHitsProtobuf.java | 4 + server/src/main/proto/search/SearchHits.proto | 21 +++- 3 files changed, 101 insertions(+), 22 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index 0d4967f592a89..1a107fc0f60e1 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -20,7 +20,6 @@ import org.opensearch.core.common.text.Text; import org.opensearch.core.index.Index; import org.opensearch.core.index.shard.ShardId; -import org.opensearch.proto.search.SearchHitsProtoDef; import org.opensearch.search.SearchShardTarget; import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; @@ -33,6 +32,9 @@ import org.opensearch.proto.search.SearchHitsProtoDef.ShardIdProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortValueProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortFieldProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SortTypeProto; +import org.opensearch.proto.search.SearchHitsProtoDef.GenericObjectProto; +import org.opensearch.proto.search.SearchHitsProtoDef.MissingValueProto; import java.io.IOException; import java.math.BigInteger; @@ -59,6 +61,33 @@ public SerializationException(String message, Throwable cause) { } } + public static GenericObjectProto genericObjectToProto(Object obj) { + GenericObjectProto.Builder builder = GenericObjectProto.newBuilder(); + + try (BytesStreamOutput docsOut = new BytesStreamOutput()) { + docsOut.writeGenericValue(obj); + builder.setValue(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); + } catch (IOException e) { + builder.setValue(ByteString.EMPTY); + } + + return builder.build(); + } + + public static Object genericObjectFromProto(GenericObjectProto proto) { + Object obj; + BytesReference valuesBytes = new BytesArray(proto.getValue().toByteArray()); + + try (StreamInput in = valuesBytes.streamInput()) { + obj = in.readGenericValue(); + } catch (IOException e) { + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize DocumentField values from proto object", e); + } + + return obj; + } + + public static ExplanationProto explanationToProto(Explanation explanation) { ExplanationProto.Builder builder = ExplanationProto.newBuilder() .setMatch(explanation.isMatch()) @@ -117,17 +146,11 @@ public static Explanation explanationFromProto(ExplanationProto proto) { return Explanation.noMatch(description, details); } - // TODO: Can we write all objects to a single stream? public static DocumentFieldProto documentFieldToProto(DocumentField field) { DocumentFieldProto.Builder builder = DocumentFieldProto.newBuilder().setName(field.getName()); for (Object value : field.getValues()) { - try (BytesStreamOutput docsOut = new BytesStreamOutput()) { - docsOut.writeGenericValue(value); - builder.addValues(ByteString.copyFrom(docsOut.bytes().toBytesRef().bytes)); - } catch (IOException e) { - builder.addValues(ByteString.EMPTY); - } + builder.addValues(genericObjectToProto(value)); } return builder.build(); @@ -138,12 +161,8 @@ public static DocumentField documentFieldFromProto(DocumentFieldProto proto) thr ArrayList values = new ArrayList<>(); for (int i = 0; i < proto.getValuesCount(); i++) { - BytesReference valuesBytes = new BytesArray(proto.getValues(i).toByteArray()); - try (StreamInput in = valuesBytes.streamInput()) { - values.add(in.readGenericValue()); - } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize DocumentField values from proto object", e); - } + GenericObjectProto v = proto.getValues(i); + values.add(genericObjectFromProto(v)); } return new DocumentField(name, values); @@ -272,21 +291,64 @@ public static Object SortValueFromProto(SortValueProto proto) throws ProtoSerDeH public static SortFieldProto sortFieldToProto(SortField sortField) { SortFieldProto.Builder builder = SortFieldProto.newBuilder() - .setId(sortField.get) - .setReverse() - .setType(); + .setMissingValue(missingValueToProto(sortField.getMissingValue())) + .setType(sortTypeToProto(sortField.getType())) + .setReverse(sortField.getReverse()); - builder.setField(); + if (sortField.getField() != null) { + builder.setField(sortField.getField()); + } return builder.build(); } public static SortField sortFieldFromProto(SortFieldProto proto) { + SortField sortField = new SortField( + proto.getField(), + sortTypeFromProto(proto.getType()), + proto.getReverse()); + + if (proto.hasMissingValue()) { + sortField.setMissingValue(missingValueFromProto(proto.getMissingValue())); + } + + return sortField; + } + + public static SortTypeProto sortTypeToProto(SortField.Type sortType) { + return SortTypeProto.forNumber(sortType.ordinal()); + } + + public static SortField.Type sortTypeFromProto(SortTypeProto proto) { + return SortField.Type.values()[proto.getNumber()]; + } + + public static MissingValueProto missingValueToProto(Object missingValue) { + MissingValueProto.Builder builder = MissingValueProto.newBuilder(); + if (missingValue == SortField.STRING_FIRST) { + builder.setIntVal(1); + } else if (missingValue == SortField.STRING_LAST) { + builder.setIntVal(2); + } else { + builder.setObjVal(genericObjectToProto(missingValue)); + } return builder.build(); } + public static Object missingValueFromProto(MissingValueProto proto) { + switch (proto.getValueCase()) { + case INT_VAL: + if (proto.getIntVal() == 1) { return SortField.STRING_FIRST; } + if (proto.getIntVal() == 2) { return SortField.STRING_LAST; } + case OBJ_VAL: + return genericObjectFromProto(proto.getObjVal()); + default: + throw new ProtoSerDeHelpers.SerializationException("Unexpected value case: " + proto.getValueCase()); + } + } + public static SearchShardTargetProto searchShardTargetToProto(SearchShardTarget shardTarget) { SearchShardTargetProto.Builder builder = SearchShardTargetProto.newBuilder() .setNodeId(shardTarget.getNodeId()) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index da68efee2ca97..9f6c0243a3e34 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -74,6 +74,10 @@ SearchHitsProto toProto() { builder.setTotalHits(totHitsBuilder); } + if (sortFields != null) { + builder.setSortFields(sortFields); + } + try (BytesStreamOutput sortOut = new BytesStreamOutput()) { sortOut.writeOptionalArray(Lucene::writeSortField, sortFields); builder.setSortFields(ByteString.copyFrom(sortOut.bytes().toBytesRef().bytes)); diff --git a/server/src/main/proto/search/SearchHits.proto b/server/src/main/proto/search/SearchHits.proto index b3e808f997567..6e2cb8a745c21 100644 --- a/server/src/main/proto/search/SearchHits.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -4,6 +4,12 @@ package org.opensearch.proto.search; option java_outer_classname = "SearchHitsProtoDef"; +// Generic java Object +// Ideally we are able to remove all usages of this message type +message GenericObjectProto { + bytes value = 1; +} + message SearchHitsProto { float max_score = 1; optional string collapse_field = 2; @@ -34,13 +40,20 @@ message SortValueProto { } message SortFieldProto { - int32 missing_value = 1; + MissingValueProto missing_value = 1; bool reverse = 2; - SortType type = 3; + SortTypeProto type = 3; optional string field = 4; } -enum SortType { +message MissingValueProto { + oneof value { + int32 int_val = 1; + GenericObjectProto obj_val = 2; + } +} + +enum SortTypeProto { SCORE = 0; DOC = 1; STRING = 2; @@ -79,7 +92,7 @@ message NestedIdentityProto { message DocumentFieldProto { string name = 1; - repeated bytes values = 2; // List values - Can we limit this to specific types? + repeated GenericObjectProto values = 2; } message HighlightFieldProto { From 49c27665f88474dfe420e38dc0dc4ce56006d73c Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 10 Sep 2024 20:10:38 -0700 Subject: [PATCH 46/61] SortValues to proto Signed-off-by: Finn Carroll --- .../transport/protobuf/ProtoSerDeHelpers.java | 12 +++--- .../protobuf/SearchHitsProtobuf.java | 40 +++++++++---------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index 1a107fc0f60e1..ccd1f9f11b805 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -199,11 +199,11 @@ public static SearchSortValuesProto searchSortValuesToProto(SearchSortValues sea SearchSortValuesProto.Builder builder = SearchSortValuesProto.newBuilder(); for (Object value : searchSortValues.getFormattedSortValues()) { - builder.addFormattedSortValues(SortValueToProto(value)); + builder.addFormattedSortValues(sortValueToProto(value)); } for (Object value : searchSortValues.getRawSortValues()) { - builder.addRawSortValues(SortValueToProto(value)); + builder.addRawSortValues(sortValueToProto(value)); } return builder.build(); @@ -215,18 +215,18 @@ public static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto p for (int i = 0; i < formattedSortValues.length; i++) { SortValueProto sortProto = proto.getFormattedSortValues(i); - formattedSortValues[i] = SortValueFromProto(sortProto); + formattedSortValues[i] = sortValueFromProto(sortProto); } for (int i = 0; i < rawSortValues.length; i++) { SortValueProto sortProto = proto.getRawSortValues(i); - rawSortValues[i] = SortValueFromProto(sortProto); + rawSortValues[i] = sortValueFromProto(sortProto); } return new SearchSortValues(formattedSortValues, rawSortValues); } - public static SortValueProto SortValueToProto(Object sortValue) throws ProtoSerDeHelpers.SerializationException { + public static SortValueProto sortValueToProto(Object sortValue) throws ProtoSerDeHelpers.SerializationException { SortValueProto.Builder builder = SortValueProto.newBuilder(); if (sortValue.getClass().equals(String.class)) { @@ -259,7 +259,7 @@ public static SortValueProto SortValueToProto(Object sortValue) throws ProtoSerD return builder.build(); } - public static Object SortValueFromProto(SortValueProto proto) throws ProtoSerDeHelpers.SerializationException { + public static Object sortValueFromProto(SortValueProto proto) throws ProtoSerDeHelpers.SerializationException { switch (proto.getValueCase()) { case STRING_VALUE: return proto.getStringValue(); diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index 9f6c0243a3e34..aebe07879a540 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -8,22 +8,23 @@ package org.opensearch.transport.protobuf; -import com.google.protobuf.ByteString; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TotalHits; -import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.common.lucene.Lucene; -import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitsProto; import org.opensearch.proto.search.SearchHitsProtoDef.TotalHitsProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SortFieldProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SortValueProto; import java.io.IOException; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.SortValueToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldFromProto; /** * SearchHits child which implements serde operations as protobuf. @@ -75,19 +76,14 @@ SearchHitsProto toProto() { } if (sortFields != null) { - builder.setSortFields(sortFields); - } - - try (BytesStreamOutput sortOut = new BytesStreamOutput()) { - sortOut.writeOptionalArray(Lucene::writeSortField, sortFields); - builder.setSortFields(ByteString.copyFrom(sortOut.bytes().toBytesRef().bytes)); - } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to serialize SearchHits to proto", e); + for (SortField field : sortFields) { + builder.addSortFields(sortFieldToProto(field)); + } } if (collapseValues != null) { for (Object col : collapseValues) { - builder.addCollapseValues(SortValueToProto(col)); + builder.addCollapseValues(sortValueToProto(col)); } } @@ -109,16 +105,16 @@ void fromProto(SearchHitsProto proto) throws ProtoSerDeHelpers.SerializationExce totalHits = null; } - try (StreamInput sortBytesInput = new BytesArray(proto.getSortFields().toByteArray()).streamInput()) { - sortFields = sortBytesInput.readOptionalArray(Lucene::readSortField, SortField[]::new); - } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchHits from proto", e); + sortFields = new SortField[proto.getSortFieldsCount()]; + for (int i = 0; i < proto.getSortFieldsCount(); i++) { + SortFieldProto field = proto.getSortFields(i); + sortFields[i] = sortFieldFromProto(field); } - try (StreamInput collapseBytesInput = new BytesArray(proto.getCollapseValues().toByteArray()).streamInput()) { - collapseValues = collapseBytesInput.readOptionalArray(Lucene::readSortValue, Object[]::new); - } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize SearchHits from proto", e); + collapseValues = new Object[proto.getCollapseValuesCount()]; + for (int i = 0; i < proto.getCollapseValuesCount(); i++) { + SortValueProto val = proto.getCollapseValues(i); + collapseValues[i] = sortValueFromProto(val); } hits = new SearchHit[proto.getHitsCount()]; From ff2e8bf2c64fcd95fffe05dd81162fcc0d13b3ca Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 11 Sep 2024 09:54:33 -0700 Subject: [PATCH 47/61] SortValues can be null - Different from optional Signed-off-by: Finn Carroll --- .../transport/protobuf/ProtoSerDeHelpers.java | 10 ++++++---- server/src/main/proto/search/SearchHits.proto | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index ccd1f9f11b805..ce2f368489aaa 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -229,7 +229,9 @@ public static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto p public static SortValueProto sortValueToProto(Object sortValue) throws ProtoSerDeHelpers.SerializationException { SortValueProto.Builder builder = SortValueProto.newBuilder(); - if (sortValue.getClass().equals(String.class)) { + if (sortValue == null) { + builder.setIsNull(true); + } else if (sortValue.getClass().equals(String.class)) { builder.setStringValue((String) sortValue); } else if (sortValue.getClass().equals(Integer.class)) { builder.setIntValue((Integer) sortValue); @@ -282,11 +284,11 @@ public static Object sortValueFromProto(SortValueProto proto) throws ProtoSerDeH return new BytesRef(byteString.toByteArray()); case BIG_INTEGER_VALUE: return new BigInteger(proto.getBigIntegerValue()); - case VALUE_NOT_SET: + case IS_NULL: return null; - default: - throw new ProtoSerDeHelpers.SerializationException("Unexpected value case: " + proto.getValueCase()); } + + throw new ProtoSerDeHelpers.SerializationException("Unexpected value case: " + proto.getValueCase()); } public static SortFieldProto sortFieldToProto(SortField sortField) { diff --git a/server/src/main/proto/search/SearchHits.proto b/server/src/main/proto/search/SearchHits.proto index 6e2cb8a745c21..89d884c01091e 100644 --- a/server/src/main/proto/search/SearchHits.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -36,6 +36,7 @@ message SortValueProto { bool bool_value = 8; bytes bytes_value = 9; // BytesRef string big_integer_value = 10; + bool is_null = 11; } } From 61676fa2f2a3e3abfaacbeba8026c6d3f310071a Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 11 Sep 2024 09:55:30 -0700 Subject: [PATCH 48/61] SortValues comment Signed-off-by: Finn Carroll --- server/src/main/proto/search/SearchHits.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/proto/search/SearchHits.proto b/server/src/main/proto/search/SearchHits.proto index 89d884c01091e..17b00775fddd3 100644 --- a/server/src/main/proto/search/SearchHits.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -36,7 +36,7 @@ message SortValueProto { bool bool_value = 8; bytes bytes_value = 9; // BytesRef string big_integer_value = 10; - bool is_null = 11; + bool is_null = 11; // Can be explicitly null } } From 47f076d49fefeb6e6647b303706c72f77b21e9a8 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 17 Sep 2024 18:19:06 -0700 Subject: [PATCH 49/61] Refactor SearchHitsProto tests Signed-off-by: Finn Carroll --- .../transport/protobuf/ProtoSerDeHelpers.java | 12 +- server/src/main/proto/search/SearchHits.proto | 8 +- ...bufSearchHitsHelperSerializationTests.java | 14 ++ .../search/SearchHitsProtobufTests.java | 180 +++--------------- .../opensearch/search/SearchHitsTests.java | 8 +- 5 files changed, 63 insertions(+), 159 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index ce2f368489aaa..8ee51342ba77d 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -293,10 +293,13 @@ public static Object sortValueFromProto(SortValueProto proto) throws ProtoSerDeH public static SortFieldProto sortFieldToProto(SortField sortField) { SortFieldProto.Builder builder = SortFieldProto.newBuilder() - .setMissingValue(missingValueToProto(sortField.getMissingValue())) .setType(sortTypeToProto(sortField.getType())) .setReverse(sortField.getReverse()); + if (sortField.getMissingValue() != null) { + builder.setMissingValue(missingValueToProto(sortField.getMissingValue())); + } + if (sortField.getField() != null) { builder.setField(sortField.getField()); } @@ -305,8 +308,13 @@ public static SortFieldProto sortFieldToProto(SortField sortField) { } public static SortField sortFieldFromProto(SortFieldProto proto) { + String field = null; + if (proto.hasField()) { + field = proto.getField(); + } + SortField sortField = new SortField( - proto.getField(), + field, sortTypeFromProto(proto.getType()), proto.getReverse()); diff --git a/server/src/main/proto/search/SearchHits.proto b/server/src/main/proto/search/SearchHits.proto index 17b00775fddd3..a0ee458ff37d1 100644 --- a/server/src/main/proto/search/SearchHits.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -41,10 +41,10 @@ message SortValueProto { } message SortFieldProto { - MissingValueProto missing_value = 1; - bool reverse = 2; - SortTypeProto type = 3; - optional string field = 4; + bool reverse = 1; + SortTypeProto type = 2; + optional string field = 3; + optional MissingValueProto missing_value = 4; } message MissingValueProto { diff --git a/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java b/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java index 6dee773cae708..fa915efdde9ca 100644 --- a/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java +++ b/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java @@ -50,6 +50,8 @@ public void testProtoExplanationSerDe() { ExplanationProto proto = explanationToProto(orig); Explanation cpy = explanationFromProto(proto); assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } public void testProtoDocumentFieldSerDe() { @@ -57,6 +59,8 @@ public void testProtoDocumentFieldSerDe() { DocumentFieldProto proto = documentFieldToProto(orig); DocumentField cpy = documentFieldFromProto(proto); assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } public void testProtoHighlightFieldSerDe() { @@ -64,6 +68,8 @@ public void testProtoHighlightFieldSerDe() { HighlightFieldProto proto = highlightFieldToProto(orig); HighlightField cpy = highlightFieldFromProto(proto); assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } public void testProtoSearchSortValuesSerDe() { @@ -71,6 +77,8 @@ public void testProtoSearchSortValuesSerDe() { SearchSortValuesProto proto = searchSortValuesToProto(orig); SearchSortValues cpy = searchSortValuesFromProto(proto); assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } public void testProtoSearchShardTargetSerDe() { @@ -86,6 +94,8 @@ public void testProtoSearchShardTargetSerDe() { SearchShardTargetProto proto = searchShardTargetToProto(orig); SearchShardTarget cpy = searchShardTargetFromProto(proto); assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } public void testProtoShardIdSerDe() { @@ -93,6 +103,8 @@ public void testProtoShardIdSerDe() { ShardIdProto proto = shardIdToProto(orig); ShardId cpy = shardIdFromProto(proto); assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } public void testProtoIndexSerDe() { @@ -100,5 +112,7 @@ public void testProtoIndexSerDe() { IndexProto proto = indexToProto(orig); Index cpy = indexFromProto(proto); assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } } diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java index 14b84069c555a..dece273cae409 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -33,175 +33,53 @@ package org.opensearch.search; import org.apache.lucene.search.SortField; -import org.apache.lucene.search.TotalHits; -import org.apache.lucene.tests.util.TestUtil; -import org.opensearch.common.lucene.LuceneTests; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.core.xcontent.MediaType; +import org.opensearch.proto.search.SearchHitsProtoDef; import org.opensearch.test.AbstractWireSerializingTestCase; import org.opensearch.transport.protobuf.SearchHitsProtobuf; -public class SearchHitsProtobufTests extends AbstractWireSerializingTestCase { +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldToProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueToProto; - @Override - protected Writeable.Reader instanceReader() { - return SearchHitsProtobuf::new; - } - - @Override - protected SearchHitsProtobuf createTestInstance() { - // This instance is used to test the transport serialization so it's fine - // to produce shard targets (withShardTarget is true) since they are serialized - // in this layer. - return createTestItem(randomFrom(XContentType.values()), true, true); - } - - public static SearchHitsProtobuf createTestItem(boolean withOptionalInnerHits, boolean withShardTarget) { - return createTestItem(randomFrom(XContentType.values()), withOptionalInnerHits, withShardTarget); - } - - public static SearchHitsProtobuf createTestItem( - final MediaType mediaType, - boolean withOptionalInnerHits, - boolean transportSerialization - ) { - return createTestItem(mediaType, withOptionalInnerHits, transportSerialization, randomFrom(TotalHits.Relation.values())); - } +public class SearchHitsProtobufTests extends AbstractWireSerializingTestCase { - private static SearchHitsProtobuf createTestItem( - final MediaType mediaType, - boolean withOptionalInnerHits, - boolean transportSerialization, - TotalHits.Relation totalHitsRelation - ) { - int searchHits = randomIntBetween(0, 5); - SearchHit[] hits = createSearchHitArray(searchHits, mediaType, withOptionalInnerHits, transportSerialization); - TotalHits totalHits = frequently() ? randomTotalHits(totalHitsRelation) : null; - float maxScore = frequently() ? randomFloat() : Float.NaN; - SortField[] sortFields = null; - String collapseField = null; - Object[] collapseValues = null; - if (transportSerialization) { - sortFields = randomBoolean() ? createSortFields(randomIntBetween(1, 5)) : null; - collapseField = randomAlphaOfLengthBetween(5, 10); - collapseValues = randomBoolean() ? createCollapseValues(randomIntBetween(1, 10)) : null; + public void testSortFieldProtoSerialization () { + SortField[] fields = SearchHitsTests.createSortFields(randomIntBetween(1, 5)); + for (SortField orig : fields) { + SearchHitsProtoDef.SortFieldProto proto = sortFieldToProto(orig); + SortField cpy = sortFieldFromProto(proto); + assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } - return new SearchHitsProtobuf(new SearchHits(hits, totalHits, maxScore, sortFields, collapseField, collapseValues)); } - private static SearchHit[] createSearchHitArray( - int size, - final MediaType mediaType, - boolean withOptionalInnerHits, - boolean transportSerialization - ) { - SearchHit[] hits = new SearchHit[size]; - for (int i = 0; i < hits.length; i++) { - hits[i] = SearchHitTests.createTestItem(mediaType, withOptionalInnerHits, transportSerialization); + public void testSortValueProtoSerialization () { + Object[] values = SearchHitsTests.createCollapseValues(randomIntBetween(1, 10)); + for (Object orig : values) { + SearchHitsProtoDef.SortValueProto proto = sortValueToProto(orig); + Object cpy = sortValueFromProto(proto); + assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); } - return hits; - } - - private static TotalHits randomTotalHits(TotalHits.Relation relation) { - long totalHits = TestUtil.nextLong(random(), 0, Long.MAX_VALUE); - return new TotalHits(totalHits, relation); } - private static SortField[] createSortFields(int size) { - SortField[] sortFields = new SortField[size]; - for (int i = 0; i < sortFields.length; i++) { - // sort fields are simplified before serialization, we write directly the simplified version - // otherwise equality comparisons become complicated - sortFields[i] = LuceneTests.randomSortField().v2(); - } - return sortFields; + @Override + protected Writeable.Reader instanceReader() { + return SearchHitsProtobuf::new; } - private static Object[] createCollapseValues(int size) { - Object[] collapseValues = new Object[size]; - for (int i = 0; i < collapseValues.length; i++) { - collapseValues[i] = LuceneTests.randomSortValue(); - } - return collapseValues; + @Override + protected SearchHitsProtobuf createTestInstance() { + return new SearchHitsProtobuf(SearchHitsTests.createTestItem(randomFrom(XContentType.values()), true, true)); } @Override protected SearchHitsProtobuf mutateInstance(SearchHitsProtobuf instance) { - return new SearchHitsProtobuf(mutate(instance)); - } - - protected SearchHits mutate(SearchHits instance) { - switch (randomIntBetween(0, 5)) { - case 0: - return new SearchHits( - createSearchHitArray(instance.getHits().length + 1, randomFrom(XContentType.values()), false, randomBoolean()), - instance.getTotalHits(), - instance.getMaxScore() - ); - case 1: - final TotalHits totalHits; - if (instance.getTotalHits() == null) { - totalHits = randomTotalHits(randomFrom(TotalHits.Relation.values())); - } else { - totalHits = null; - } - return new SearchHits(instance.getHits(), totalHits, instance.getMaxScore()); - case 2: - final float maxScore; - if (Float.isNaN(instance.getMaxScore())) { - maxScore = randomFloat(); - } else { - maxScore = Float.NaN; - } - return new SearchHits(instance.getHits(), instance.getTotalHits(), maxScore); - case 3: - SortField[] sortFields; - if (instance.getSortFields() == null) { - sortFields = createSortFields(randomIntBetween(1, 5)); - } else { - sortFields = randomBoolean() ? createSortFields(instance.getSortFields().length + 1) : null; - } - return new SearchHits( - instance.getHits(), - instance.getTotalHits(), - instance.getMaxScore(), - sortFields, - instance.getCollapseField(), - instance.getCollapseValues() - ); - case 4: - String collapseField; - if (instance.getCollapseField() == null) { - collapseField = randomAlphaOfLengthBetween(5, 10); - } else { - collapseField = randomBoolean() ? instance.getCollapseField() + randomAlphaOfLengthBetween(2, 5) : null; - } - return new SearchHits( - instance.getHits(), - instance.getTotalHits(), - instance.getMaxScore(), - instance.getSortFields(), - collapseField, - instance.getCollapseValues() - ); - case 5: - Object[] collapseValues; - if (instance.getCollapseValues() == null) { - collapseValues = createCollapseValues(randomIntBetween(1, 5)); - } else { - collapseValues = randomBoolean() ? createCollapseValues(instance.getCollapseValues().length + 1) : null; - } - return new SearchHits( - instance.getHits(), - instance.getTotalHits(), - instance.getMaxScore(), - instance.getSortFields(), - instance.getCollapseField(), - collapseValues - ); - default: - throw new UnsupportedOperationException(); - } + return new SearchHitsProtobuf(SearchHitsTests.mutate(instance)); } } diff --git a/server/src/test/java/org/opensearch/search/SearchHitsTests.java b/server/src/test/java/org/opensearch/search/SearchHitsTests.java index fd3ba35a4d3bb..cf00ba768da7c 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsTests.java @@ -103,7 +103,7 @@ private static SearchHits createTestItem( return new SearchHits(hits, totalHits, maxScore, sortFields, collapseField, collapseValues); } - private static SortField[] createSortFields(int size) { + public static SortField[] createSortFields(int size) { SortField[] sortFields = new SortField[size]; for (int i = 0; i < sortFields.length; i++) { // sort fields are simplified before serialization, we write directly the simplified version @@ -113,7 +113,7 @@ private static SortField[] createSortFields(int size) { return sortFields; } - private static Object[] createCollapseValues(int size) { + public static Object[] createCollapseValues(int size) { Object[] collapseValues = new Object[size]; for (int i = 0; i < collapseValues.length; i++) { collapseValues[i] = LuceneTests.randomSortValue(); @@ -123,6 +123,10 @@ private static Object[] createCollapseValues(int size) { @Override protected SearchHits mutateInstance(SearchHits instance) { + return mutate(instance); + } + + public static SearchHits mutate(SearchHits instance) { switch (randomIntBetween(0, 5)) { case 0: return new SearchHits( From 8bb96c0c3494cbe944920fef3956f264c39f7d83 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 17 Sep 2024 18:25:34 -0700 Subject: [PATCH 50/61] No assert not equals for potentially primitive types Signed-off-by: Finn Carroll --- .../test/java/org/opensearch/search/SearchHitsProtobufTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java index dece273cae409..027f30b77d8ee 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -64,7 +64,6 @@ public void testSortValueProtoSerialization () { Object cpy = sortValueFromProto(proto); assertEquals(orig, cpy); assertEquals(orig.hashCode(), cpy.hashCode()); - assertNotSame(orig, cpy); } } From d7612de89dad7341944ed47e6803ed12d8f9d5b2 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 17 Sep 2024 18:40:10 -0700 Subject: [PATCH 51/61] Collapse+Sort arrays to optional Signed-off-by: Finn Carroll --- .../protobuf/SearchHitsProtobuf.java | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index aebe07879a540..a2d696d087cab 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -92,7 +92,13 @@ SearchHitsProto toProto() { void fromProto(SearchHitsProto proto) throws ProtoSerDeHelpers.SerializationException { maxScore = proto.getMaxScore(); - collapseField = proto.getCollapseField(); + + hits = new SearchHit[proto.getHitsCount()]; + for (int i = 0; i < hits.length; i++) { + hits[i] = new SearchHitProtobuf(proto.getHits(i)); + } + + collapseField = proto.hasCollapseField()? proto.getCollapseField() : null; if (proto.hasTotalHits()) { long rel = proto.getTotalHits().getRelation(); @@ -105,21 +111,25 @@ void fromProto(SearchHitsProto proto) throws ProtoSerDeHelpers.SerializationExce totalHits = null; } - sortFields = new SortField[proto.getSortFieldsCount()]; - for (int i = 0; i < proto.getSortFieldsCount(); i++) { - SortFieldProto field = proto.getSortFields(i); - sortFields[i] = sortFieldFromProto(field); + if (proto.getSortFieldsCount() > 0) { + sortFields = new SortField[proto.getSortFieldsCount()]; + for (int i = 0; i < proto.getSortFieldsCount(); i++) { + SortFieldProto field = proto.getSortFields(i); + sortFields[i] = sortFieldFromProto(field); + } + } else { + sortFields = null; } - collapseValues = new Object[proto.getCollapseValuesCount()]; - for (int i = 0; i < proto.getCollapseValuesCount(); i++) { - SortValueProto val = proto.getCollapseValues(i); - collapseValues[i] = sortValueFromProto(val); + if (proto.getCollapseValuesCount() > 0) { + collapseValues = new Object[proto.getCollapseValuesCount()]; + for (int i = 0; i < proto.getCollapseValuesCount(); i++) { + SortValueProto val = proto.getCollapseValues(i); + collapseValues[i] = sortValueFromProto(val); + } + } else { + collapseValues = null; } - hits = new SearchHit[proto.getHitsCount()]; - for (int i = 0; i < hits.length; i++) { - hits[i] = new SearchHitProtobuf(proto.getHits(i)); - } } } From b20bddf85760e2602670a5a5169591208e453ef0 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 18 Sep 2024 12:15:28 -0700 Subject: [PATCH 52/61] Add SearchHitProtobufTests Signed-off-by: Finn Carroll --- .../transport/protobuf/SearchHitProtobuf.java | 4 +- .../protobuf/SearchHitsProtobuf.java | 1 - ...Tests.java => SearchHitProtobufTests.java} | 102 ++++++++++-------- .../search/SearchHitsProtobufTests.java | 2 +- 4 files changed, 61 insertions(+), 48 deletions(-) rename server/src/test/java/org/opensearch/search/{ProtobufSearchHitsHelperSerializationTests.java => SearchHitProtobufTests.java} (57%) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index c75921ad6da22..ebbbbb23691e1 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -180,7 +180,7 @@ void fromProto(SearchHitProto proto) { } } - static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { + public static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { NestedIdentityProto.Builder builder = NestedIdentityProto.newBuilder() .setField(nestedIdentity.getField().string()) .setOffset(nestedIdentity.getOffset()); @@ -192,7 +192,7 @@ static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nested return builder.build(); } - static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityProto proto) { + public static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityProto proto) { String field = proto.getField(); int offset = proto.getOffset(); diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index a2d696d087cab..842bf4f050def 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -130,6 +130,5 @@ void fromProto(SearchHitsProto proto) throws ProtoSerDeHelpers.SerializationExce } else { collapseValues = null; } - } } diff --git a/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java b/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java similarity index 57% rename from server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java rename to server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java index fa915efdde9ca..dfb96020d730e 100644 --- a/server/src/test/java/org/opensearch/search/ProtobufSearchHitsHelperSerializationTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java @@ -6,25 +6,44 @@ * compatible open source license. */ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + package org.opensearch.search; import org.apache.lucene.search.Explanation; import org.opensearch.action.OriginalIndices; import org.opensearch.common.document.DocumentField; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.index.Index; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.proto.search.SearchHitsProtoDef; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.search.fetch.subphase.highlight.HighlightFieldTests; -import org.opensearch.test.OpenSearchTestCase; - -import org.opensearch.proto.search.SearchHitsProtoDef.DocumentFieldProto; -import org.opensearch.proto.search.SearchHitsProtoDef.ExplanationProto; -import org.opensearch.proto.search.SearchHitsProtoDef.HighlightFieldProto; -import org.opensearch.proto.search.SearchHitsProtoDef.IndexProto; -import org.opensearch.proto.search.SearchHitsProtoDef.SearchShardTargetProto; -import org.opensearch.proto.search.SearchHitsProtoDef.SearchSortValuesProto; -import org.opensearch.proto.search.SearchHitsProtoDef.ShardIdProto; +import org.opensearch.test.AbstractWireSerializingTestCase; +import org.opensearch.transport.protobuf.SearchHitProtobuf; import static org.opensearch.index.get.DocumentFieldTests.randomDocumentField; import static org.opensearch.search.SearchHitTests.createExplanation; @@ -34,54 +53,49 @@ import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.explanationToProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.highlightFieldFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.highlightFieldToProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.indexFromProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.indexToProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetToProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesToProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.shardIdFromProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.shardIdToProto; - -public class ProtobufSearchHitsHelperSerializationTests extends OpenSearchTestCase { - - public void testProtoExplanationSerDe() { - Explanation orig = createExplanation(randomIntBetween(0, 5)); - ExplanationProto proto = explanationToProto(orig); - Explanation cpy = explanationFromProto(proto); - assertEquals(orig, cpy); - assertEquals(orig.hashCode(), cpy.hashCode()); - assertNotSame(orig, cpy); - } - public void testProtoDocumentFieldSerDe() { +public class SearchHitProtobufTests extends AbstractWireSerializingTestCase { + public void testDocumentFieldProtoSerialization () { DocumentField orig = randomDocumentField(randomFrom(XContentType.values()), randomBoolean(), fieldName -> false).v1(); - DocumentFieldProto proto = documentFieldToProto(orig); + SearchHitsProtoDef.DocumentFieldProto proto = documentFieldToProto(orig); DocumentField cpy = documentFieldFromProto(proto); assertEquals(orig, cpy); assertEquals(orig.hashCode(), cpy.hashCode()); assertNotSame(orig, cpy); } - public void testProtoHighlightFieldSerDe() { + public void testHighlightFieldProtoSerialization () { HighlightField orig = HighlightFieldTests.createTestItem(); - HighlightFieldProto proto = highlightFieldToProto(orig); + SearchHitsProtoDef.HighlightFieldProto proto = highlightFieldToProto(orig); HighlightField cpy = highlightFieldFromProto(proto); assertEquals(orig, cpy); assertEquals(orig.hashCode(), cpy.hashCode()); assertNotSame(orig, cpy); } - public void testProtoSearchSortValuesSerDe() { + public void testSearchSortValuesProtoSerialization () { SearchSortValues orig = SearchSortValuesTests.createTestItem(randomFrom(XContentType.values()), true); - SearchSortValuesProto proto = searchSortValuesToProto(orig); + SearchHitsProtoDef.SearchSortValuesProto proto = searchSortValuesToProto(orig); SearchSortValues cpy = searchSortValuesFromProto(proto); assertEquals(orig, cpy); assertEquals(orig.hashCode(), cpy.hashCode()); assertNotSame(orig, cpy); } - public void testProtoSearchShardTargetSerDe() { + public void testNestedIdentityProtoSerialization () { + SearchHit.NestedIdentity orig = NestedIdentityTests.createTestItem(randomIntBetween(0, 2)); + SearchHitsProtoDef.NestedIdentityProto proto = SearchHitProtobuf.nestedIdentityToProto(orig); + SearchHit.NestedIdentity cpy = SearchHitProtobuf.nestedIdentityFromProto(proto); + assertEquals(orig, cpy); + assertEquals(orig.hashCode(), cpy.hashCode()); + assertNotSame(orig, cpy); + } + + public void testSearchShardTargetProtoSerialization () { String index = randomAlphaOfLengthBetween(5, 10); String clusterAlias = randomBoolean() ? null : randomAlphaOfLengthBetween(5, 10); SearchShardTarget orig = new SearchShardTarget( @@ -90,29 +104,29 @@ public void testProtoSearchShardTargetSerDe() { clusterAlias, OriginalIndices.NONE ); - - SearchShardTargetProto proto = searchShardTargetToProto(orig); + SearchHitsProtoDef.SearchShardTargetProto proto = searchShardTargetToProto(orig); SearchShardTarget cpy = searchShardTargetFromProto(proto); assertEquals(orig, cpy); assertEquals(orig.hashCode(), cpy.hashCode()); assertNotSame(orig, cpy); } - public void testProtoShardIdSerDe() { - ShardId orig = new ShardId(new Index(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)), randomInt()); - ShardIdProto proto = shardIdToProto(orig); - ShardId cpy = shardIdFromProto(proto); + public void testExplanationProtoSerialization () { + Explanation orig = createExplanation(randomIntBetween(0, 5)); + SearchHitsProtoDef.ExplanationProto proto = explanationToProto(orig); + Explanation cpy = explanationFromProto(proto); assertEquals(orig, cpy); assertEquals(orig.hashCode(), cpy.hashCode()); assertNotSame(orig, cpy); } - public void testProtoIndexSerDe() { - Index orig = new Index(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)); - IndexProto proto = indexToProto(orig); - Index cpy = indexFromProto(proto); - assertEquals(orig, cpy); - assertEquals(orig.hashCode(), cpy.hashCode()); - assertNotSame(orig, cpy); + @Override + protected Writeable.Reader instanceReader() { + return SearchHitProtobuf::new; + } + + @Override + protected SearchHitProtobuf createTestInstance() { + return new SearchHitProtobuf(SearchHitTests.createTestItem(randomFrom(XContentType.values()), randomBoolean(), randomBoolean())); } } diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java index 027f30b77d8ee..74794f727d5a0 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -45,7 +45,6 @@ import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueToProto; public class SearchHitsProtobufTests extends AbstractWireSerializingTestCase { - public void testSortFieldProtoSerialization () { SortField[] fields = SearchHitsTests.createSortFields(randomIntBetween(1, 5)); for (SortField orig : fields) { @@ -64,6 +63,7 @@ public void testSortValueProtoSerialization () { Object cpy = sortValueFromProto(proto); assertEquals(orig, cpy); assertEquals(orig.hashCode(), cpy.hashCode()); + // No assertNotSame, object could be primitive type } } From 512c574e8bd4568fc87a28ec59dc96bc50d3f691 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 18 Sep 2024 13:43:28 -0700 Subject: [PATCH 53/61] Mark SearchHit members as nullable where applicable Signed-off-by: Finn Carroll --- server/src/main/java/org/opensearch/search/SearchHit.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index d47a59307aa6c..bcab575022add 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -105,6 +105,7 @@ public class SearchHit implements Writeable, ToXContentObject, Iterable documentFields; protected Map metaFields; + @Nullable protected Map highlightFields = null; protected SearchSortValues sortValues = SearchSortValues.EMPTY; protected Map matchedQueries = new HashMap<>(); + @Nullable protected Explanation explanation; @Nullable @@ -138,6 +142,7 @@ public class SearchHit implements Writeable, ToXContentObject, Iterable sourceAsMap; + @Nullable protected Map innerHits; public SearchHit(SearchHit hit) { From 961f035786cb9eea7ac90dd1a81df7ad57f84f83 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 18 Sep 2024 14:58:59 -0700 Subject: [PATCH 54/61] Decompose toProto/fromProto Signed-off-by: Finn Carroll --- .../transport/protobuf/SearchHitProtobuf.java | 106 +++++------------- .../protobuf/SearchHitsProtobuf.java | 51 +++++---- server/src/main/proto/search/SearchHits.proto | 6 +- 3 files changed, 54 insertions(+), 109 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index ebbbbb23691e1..751210f0a0f48 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -14,15 +14,11 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.text.Text; import org.opensearch.search.SearchHit; -import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitsProto; import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitProto; import org.opensearch.proto.search.SearchHitsProtoDef.NestedIdentityProto; -import org.opensearch.proto.search.SearchHitsProtoDef.DocumentFieldProto; -import org.opensearch.proto.search.SearchHitsProtoDef.HighlightFieldProto; import java.io.IOException; import java.util.HashMap; -import java.util.Map; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldToProto; @@ -71,43 +67,21 @@ SearchHitProto toProto() { .setScore(score) .setVersion(version) .setSeqNo(seqNo) - .setPrimaryTerm(primaryTerm); - - if (id != null) { - builder.setId(id.string()); - } - - if (nestedIdentity != null) { - builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); - } - - if (source != null) { - builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); - } - - if (explanation != null) { - builder.setExplanation(explanationToProto(explanation)); - } - - builder.setSortValues(searchSortValuesToProto(sortValues)); + .setPrimaryTerm(primaryTerm) + .setSortValues(searchSortValuesToProto(sortValues)); documentFields.forEach((key, value) -> builder.putDocumentFields(key, documentFieldToProto(value))); - metaFields.forEach((key, value) -> builder.putMetaFields(key, documentFieldToProto(value))); - - if (highlightFields != null) { - highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); - } - matchedQueries.forEach(builder::putMatchedQueries); - if (shard != null) { - builder.setShard(searchShardTargetToProto(shard)); - } + if (highlightFields != null) { highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); } + if (innerHits != null) { innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsProtobuf(value).toProto())); } - if (innerHits != null) { - innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsProtobuf(value).toProto())); - } + if (source != null) { builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); } + if (id != null) { builder.setId(id.string()); } + if (nestedIdentity != null) { builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); } + if (shard != null) { builder.setShard(searchShardTargetToProto(shard)); } + if (explanation != null) { builder.setExplanation(explanationToProto(explanation)); } return builder.build(); } @@ -115,35 +89,29 @@ SearchHitProto toProto() { void fromProto(SearchHitProto proto) { docId = -1; score = proto.getScore(); - seqNo = proto.getSeqNo(); version = proto.getVersion(); + seqNo = proto.getSeqNo(); primaryTerm = proto.getPrimaryTerm(); sortValues = searchSortValuesFromProto(proto.getSortValues()); - matchedQueries = proto.getMatchedQueriesMap(); - if (proto.hasId()) { - id = new Text(proto.getId()); - } else { - id = null; - } + documentFields = new HashMap<>(); + proto.getDocumentFieldsMap().forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); - if (proto.hasNestedIdentity()) { - nestedIdentity = nestedIdentityFromProto(proto.getNestedIdentity()); - } else { - nestedIdentity = null; - } + metaFields = new HashMap<>(); + proto.getMetaFieldsMap().forEach((key, value) -> metaFields.put(key, documentFieldFromProto(value))); - if (proto.hasSource()) { - source = BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()); - } else { - source = null; - } + matchedQueries = proto.getMatchedQueriesMap(); - if (proto.hasExplanation()) { - explanation = explanationFromProto(proto.getExplanation()); - } else { - explanation = null; - } + highlightFields = new HashMap<>(); + proto.getHighlightFieldsMap().forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); + + innerHits = new HashMap<>(); + proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); + + source = proto.hasSource()? BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()) : null; + id = proto.hasId()? new Text(proto.getId()) : null; + nestedIdentity = proto.hasNestedIdentity()? nestedIdentityFromProto(proto.getNestedIdentity()) : null; + explanation = proto.hasExplanation()? explanationFromProto(proto.getExplanation()) : null; if (proto.hasShard()) { shard = searchShardTargetFromProto(proto.getShard()); @@ -154,30 +122,6 @@ void fromProto(SearchHitProto proto) { index = null; clusterAlias = null; } - - Map innerHitsProto = proto.getInnerHitsMap(); - if (!innerHitsProto.isEmpty()) { - innerHits = new HashMap<>(); - innerHitsProto.forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); - } - - documentFields = new HashMap<>(); - Map documentFieldProtoMap = proto.getDocumentFieldsMap(); - if (!documentFieldProtoMap.isEmpty()) { - documentFieldProtoMap.forEach((key, value) -> documentFields.put(key, documentFieldFromProto(value))); - } - - metaFields = new HashMap<>(); - Map metaFieldProtoMap = proto.getMetaFieldsMap(); - if (!metaFieldProtoMap.isEmpty()) { - metaFieldProtoMap.forEach((key, value) -> metaFields.put(key, documentFieldFromProto(value))); - } - - highlightFields = new HashMap<>(); - Map highlightFieldProtoMap = proto.getHighlightFieldsMap(); - if (!highlightFieldProtoMap.isEmpty()) { - highlightFieldProtoMap.forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); - } } public static NestedIdentityProto nestedIdentityToProto(SearchHit.NestedIdentity nestedIdentity) { diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index 842bf4f050def..99bec9b3c1526 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -18,8 +18,10 @@ import org.opensearch.proto.search.SearchHitsProtoDef.TotalHitsProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortFieldProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortValueProto; +import org.opensearch.transport.TransportSerializationException; import java.io.IOException; +import java.util.List; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueToProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueFromProto; @@ -90,7 +92,7 @@ SearchHitsProto toProto() { return builder.build(); } - void fromProto(SearchHitsProto proto) throws ProtoSerDeHelpers.SerializationException { + void fromProto(SearchHitsProto proto) throws TransportSerializationException { maxScore = proto.getMaxScore(); hits = new SearchHit[proto.getHitsCount()]; @@ -99,36 +101,33 @@ void fromProto(SearchHitsProto proto) throws ProtoSerDeHelpers.SerializationExce } collapseField = proto.hasCollapseField()? proto.getCollapseField() : null; + totalHits = proto.hasTotalHits()? totalHitsFromProto(proto.getTotalHits()) : null; + sortFields = proto.getSortFieldsCount() > 0? sortFieldsFromProto(proto.getSortFieldsList()) : null; + collapseValues = proto.getCollapseValuesCount() > 0? collapseValuesFromProto(proto.getCollapseValuesList()) : null; + } - if (proto.hasTotalHits()) { - long rel = proto.getTotalHits().getRelation(); - long val = proto.getTotalHits().getValue(); - if (rel < 0 || rel >= TotalHits.Relation.values().length) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize TotalHits from proto"); - } - totalHits = new TotalHits(val, TotalHits.Relation.values()[(int) rel]); - } else { - totalHits = null; + private TotalHits totalHitsFromProto(TotalHitsProto proto) { + long rel = proto.getRelation(); + long val = proto.getValue(); + if (rel < 0 || rel >= TotalHits.Relation.values().length) { + throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize TotalHits from proto"); } + return new TotalHits(val, TotalHits.Relation.values()[(int) rel]); + } - if (proto.getSortFieldsCount() > 0) { - sortFields = new SortField[proto.getSortFieldsCount()]; - for (int i = 0; i < proto.getSortFieldsCount(); i++) { - SortFieldProto field = proto.getSortFields(i); - sortFields[i] = sortFieldFromProto(field); - } - } else { - sortFields = null; + private SortField[] sortFieldsFromProto(List protoList) { + SortField[] fields = new SortField[protoList.size()]; + for (int i = 0; i < protoList.size(); i++) { + fields[i] = sortFieldFromProto(protoList.get(i)); } + return fields; + } - if (proto.getCollapseValuesCount() > 0) { - collapseValues = new Object[proto.getCollapseValuesCount()]; - for (int i = 0; i < proto.getCollapseValuesCount(); i++) { - SortValueProto val = proto.getCollapseValues(i); - collapseValues[i] = sortValueFromProto(val); - } - } else { - collapseValues = null; + private Object[] collapseValuesFromProto(List protoList) { + Object[] vals = new Object[protoList.size()]; + for (int i = 0; i < protoList.size(); i++) { + vals[i] = sortValueFromProto(protoList.get(i)); } + return vals; } } diff --git a/server/src/main/proto/search/SearchHits.proto b/server/src/main/proto/search/SearchHits.proto index a0ee458ff37d1..5ff1633bf68ee 100644 --- a/server/src/main/proto/search/SearchHits.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -72,13 +72,15 @@ message SearchHitProto { int64 version = 2; int64 seq_no = 3; int64 primary_term = 4; - optional bytes source = 5; // JSON payload - Move to map? + SearchSortValuesProto sort_values = 5; + map document_fields = 6; map meta_fields = 7; map highlight_fields = 8; map matched_queries = 9; map inner_hits = 10; - SearchSortValuesProto sort_values = 11; + + optional bytes source = 5; // JSON payload - Move to map? optional string id = 12; optional NestedIdentityProto nested_identity = 13; optional SearchShardTargetProto shard = 14; From 69450efbd662aa6434a93989f4f723a1f822f8ca Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 18 Sep 2024 15:31:21 -0700 Subject: [PATCH 55/61] Fix innerHits nullable map Signed-off-by: Finn Carroll --- .../opensearch/transport/protobuf/SearchHitProtobuf.java | 9 +++++++-- server/src/main/proto/search/SearchHits.proto | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index 751210f0a0f48..f2194c95db724 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -105,8 +105,13 @@ void fromProto(SearchHitProto proto) { highlightFields = new HashMap<>(); proto.getHighlightFieldsMap().forEach((key, value) -> highlightFields.put(key, highlightFieldFromProto(value))); - innerHits = new HashMap<>(); - proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); + // innerHits is nullable + if (proto.getInnerHitsCount() < 1) { + innerHits = null; + } else { + innerHits = new HashMap<>(); + proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); + } source = proto.hasSource()? BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()) : null; id = proto.hasId()? new Text(proto.getId()) : null; diff --git a/server/src/main/proto/search/SearchHits.proto b/server/src/main/proto/search/SearchHits.proto index 5ff1633bf68ee..80ab07e28b4e1 100644 --- a/server/src/main/proto/search/SearchHits.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -73,14 +73,12 @@ message SearchHitProto { int64 seq_no = 3; int64 primary_term = 4; SearchSortValuesProto sort_values = 5; - map document_fields = 6; map meta_fields = 7; map highlight_fields = 8; map matched_queries = 9; map inner_hits = 10; - - optional bytes source = 5; // JSON payload - Move to map? + optional bytes source = 11; // JSON payload - Move to map? optional string id = 12; optional NestedIdentityProto nested_identity = 13; optional SearchShardTargetProto shard = 14; From faac1ae08344eb919eee031665e03f77c3354888 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 18 Sep 2024 15:38:34 -0700 Subject: [PATCH 56/61] Fix SortValue test when null Signed-off-by: Finn Carroll --- .../java/org/opensearch/search/SearchHitsProtobufTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java index 74794f727d5a0..ebc4532181a1e 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -61,9 +61,11 @@ public void testSortValueProtoSerialization () { for (Object orig : values) { SearchHitsProtoDef.SortValueProto proto = sortValueToProto(orig); Object cpy = sortValueFromProto(proto); + assertEquals(orig, cpy); - assertEquals(orig.hashCode(), cpy.hashCode()); - // No assertNotSame, object could be primitive type + if (orig != null && cpy != null) { + assertEquals(orig.hashCode(), cpy.hashCode()); + } } } From 47da14ae97c7a33e08fc9842a3d97ec42bf36635 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 18 Sep 2024 16:03:06 -0700 Subject: [PATCH 57/61] Move serde helpers into specific class definitions Signed-off-by: Finn Carroll --- .../TransportSerializationException.java | 4 + .../transport/protobuf/ProtoSerDeHelpers.java | 129 +----------------- .../transport/protobuf/SearchHitProtobuf.java | 103 +++++++++++++- .../protobuf/SearchHitsProtobuf.java | 6 +- .../search/SearchHitProtobufTests.java | 4 +- .../search/SearchHitsProtobufTests.java | 4 +- 6 files changed, 119 insertions(+), 131 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/TransportSerializationException.java b/server/src/main/java/org/opensearch/transport/TransportSerializationException.java index 1a5f9cec28ea1..e87d9879b6ab2 100644 --- a/server/src/main/java/org/opensearch/transport/TransportSerializationException.java +++ b/server/src/main/java/org/opensearch/transport/TransportSerializationException.java @@ -47,6 +47,10 @@ public TransportSerializationException(StreamInput in) throws IOException { super(in); } + public TransportSerializationException(String msg) { + super(msg); + } + public TransportSerializationException(String msg, Throwable cause) { super(msg, cause); } diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index 8ee51342ba77d..147804a2be738 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -11,7 +11,6 @@ import com.google.protobuf.ByteString; import org.apache.lucene.search.Explanation; import org.apache.lucene.search.SortField; -import org.apache.lucene.util.BytesRef; import org.opensearch.common.document.DocumentField; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.bytes.BytesArray; @@ -21,46 +20,28 @@ import org.opensearch.core.index.Index; import org.opensearch.core.index.shard.ShardId; import org.opensearch.search.SearchShardTarget; -import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.proto.search.SearchHitsProtoDef.DocumentFieldProto; import org.opensearch.proto.search.SearchHitsProtoDef.ExplanationProto; import org.opensearch.proto.search.SearchHitsProtoDef.HighlightFieldProto; import org.opensearch.proto.search.SearchHitsProtoDef.IndexProto; import org.opensearch.proto.search.SearchHitsProtoDef.SearchShardTargetProto; -import org.opensearch.proto.search.SearchHitsProtoDef.SearchSortValuesProto; import org.opensearch.proto.search.SearchHitsProtoDef.ShardIdProto; -import org.opensearch.proto.search.SearchHitsProtoDef.SortValueProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortFieldProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortTypeProto; import org.opensearch.proto.search.SearchHitsProtoDef.GenericObjectProto; import org.opensearch.proto.search.SearchHitsProtoDef.MissingValueProto; +import org.opensearch.transport.TransportSerializationException; import java.io.IOException; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; /** - * SerDe interfaces and protobuf SerDe implementations for some "primitive" types. + * Serialization helpers for common objects shared across multiple protobuf types. * @opensearch.internal */ public class ProtoSerDeHelpers { - - /** - * Serialization/Deserialization exception. - * @opensearch.internal - */ - public static class SerializationException extends RuntimeException { - public SerializationException(String message) { - super(message); - } - - public SerializationException(String message, Throwable cause) { - super(message, cause); - } - } - public static GenericObjectProto genericObjectToProto(Object obj) { GenericObjectProto.Builder builder = GenericObjectProto.newBuilder(); @@ -81,13 +62,12 @@ public static Object genericObjectFromProto(GenericObjectProto proto) { try (StreamInput in = valuesBytes.streamInput()) { obj = in.readGenericValue(); } catch (IOException e) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize DocumentField values from proto object", e); + throw new TransportSerializationException("Failed to deserialize DocumentField values from proto object", e); } return obj; } - public static ExplanationProto explanationToProto(Explanation explanation) { ExplanationProto.Builder builder = ExplanationProto.newBuilder() .setMatch(explanation.isMatch()) @@ -103,7 +83,7 @@ public static ExplanationProto explanationToProto(Explanation explanation) { } else if (num instanceof Float) { builder.setFloatValue(num.floatValue()); } else { - throw new SerializationException("Unknown numeric type [" + num + "]"); + throw new TransportSerializationException("Unknown numeric type [" + num + "]"); } for (Explanation detail : explanation.getDetails()) { @@ -140,6 +120,7 @@ public static Explanation explanationFromProto(ExplanationProto proto) { } if (proto.getMatch()) { + assert val != null; return Explanation.match(val, description, details); } @@ -156,7 +137,7 @@ public static DocumentFieldProto documentFieldToProto(DocumentField field) { return builder.build(); } - public static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws ProtoSerDeHelpers.SerializationException { + public static DocumentField documentFieldFromProto(DocumentFieldProto proto) throws TransportSerializationException { String name = proto.getName(); ArrayList values = new ArrayList<>(); @@ -195,102 +176,6 @@ public static HighlightField highlightFieldFromProto(HighlightFieldProto proto) return new HighlightField(name, fragments); } - public static SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { - SearchSortValuesProto.Builder builder = SearchSortValuesProto.newBuilder(); - - for (Object value : searchSortValues.getFormattedSortValues()) { - builder.addFormattedSortValues(sortValueToProto(value)); - } - - for (Object value : searchSortValues.getRawSortValues()) { - builder.addRawSortValues(sortValueToProto(value)); - } - - return builder.build(); - } - - public static SearchSortValues searchSortValuesFromProto(SearchSortValuesProto proto) throws ProtoSerDeHelpers.SerializationException { - Object[] formattedSortValues = new Object[proto.getFormattedSortValuesCount()]; - Object[] rawSortValues = new Object[proto.getRawSortValuesCount()]; - - for (int i = 0; i < formattedSortValues.length; i++) { - SortValueProto sortProto = proto.getFormattedSortValues(i); - formattedSortValues[i] = sortValueFromProto(sortProto); - } - - for (int i = 0; i < rawSortValues.length; i++) { - SortValueProto sortProto = proto.getRawSortValues(i); - rawSortValues[i] = sortValueFromProto(sortProto); - } - - return new SearchSortValues(formattedSortValues, rawSortValues); - } - - public static SortValueProto sortValueToProto(Object sortValue) throws ProtoSerDeHelpers.SerializationException { - SortValueProto.Builder builder = SortValueProto.newBuilder(); - - if (sortValue == null) { - builder.setIsNull(true); - } else if (sortValue.getClass().equals(String.class)) { - builder.setStringValue((String) sortValue); - } else if (sortValue.getClass().equals(Integer.class)) { - builder.setIntValue((Integer) sortValue); - } else if (sortValue.getClass().equals(Long.class)) { - builder.setLongValue((Long) sortValue); - } else if (sortValue.getClass().equals(Float.class)) { - builder.setFloatValue((Float) sortValue); - } else if (sortValue.getClass().equals(Double.class)) { - builder.setDoubleValue((Double) sortValue); - } else if (sortValue.getClass().equals(Byte.class)) { - builder.setByteValue((Byte) sortValue); - } else if (sortValue.getClass().equals(Short.class)) { - builder.setShortValue((Short) sortValue); - } else if (sortValue.getClass().equals(Boolean.class)) { - builder.setBoolValue((Boolean) sortValue); - } else if (sortValue.getClass().equals(BytesRef.class)) { - builder.setBytesValue(ByteString.copyFrom( - ((BytesRef) sortValue).bytes, - ((BytesRef) sortValue).offset, - ((BytesRef) sortValue).length)); - } else if (sortValue.getClass().equals(BigInteger.class)) { - builder.setBigIntegerValue(sortValue.toString()); - } else { - throw new ProtoSerDeHelpers.SerializationException("Unexpected sortValue: " + sortValue.toString()); - } - - return builder.build(); - } - - public static Object sortValueFromProto(SortValueProto proto) throws ProtoSerDeHelpers.SerializationException { - switch (proto.getValueCase()) { - case STRING_VALUE: - return proto.getStringValue(); - case INT_VALUE: - return proto.getIntValue(); - case LONG_VALUE: - return proto.getLongValue(); - case FLOAT_VALUE: - return proto.getFloatValue(); - case DOUBLE_VALUE: - return proto.getDoubleValue(); - case BYTE_VALUE: - return (byte) proto.getByteValue(); - case SHORT_VALUE: - return (short) proto.getShortValue(); - case BOOL_VALUE: - return proto.getBoolValue(); - case BYTES_VALUE: - ByteString byteString = proto.getBytesValue(); - return new BytesRef(byteString.toByteArray()); - case BIG_INTEGER_VALUE: - return new BigInteger(proto.getBigIntegerValue()); - case IS_NULL: - return null; - } - - throw new ProtoSerDeHelpers.SerializationException("Unexpected value case: " + proto.getValueCase()); - } - public static SortFieldProto sortFieldToProto(SortField sortField) { SortFieldProto.Builder builder = SortFieldProto.newBuilder() .setType(sortTypeToProto(sortField.getType())) @@ -355,7 +240,7 @@ public static Object missingValueFromProto(MissingValueProto proto) { case OBJ_VAL: return genericObjectFromProto(proto.getObjVal()); default: - throw new ProtoSerDeHelpers.SerializationException("Unexpected value case: " + proto.getValueCase()); + throw new TransportSerializationException("Unexpected value case: " + proto.getValueCase()); } } diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index f2194c95db724..b3fa973a17e47 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -9,15 +9,20 @@ package org.opensearch.transport.protobuf; import com.google.protobuf.ByteString; +import org.apache.lucene.util.BytesRef; import org.opensearch.core.common.bytes.BytesReference; 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.proto.search.SearchHitsProtoDef; import org.opensearch.search.SearchHit; import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitProto; import org.opensearch.proto.search.SearchHitsProtoDef.NestedIdentityProto; +import org.opensearch.search.SearchSortValues; +import org.opensearch.transport.TransportSerializationException; import java.io.IOException; +import java.math.BigInteger; import java.util.HashMap; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.documentFieldFromProto; @@ -28,8 +33,6 @@ import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.highlightFieldToProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetToProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesFromProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesToProto; /** * Serialization/Deserialization implementations for SearchHit. @@ -152,4 +155,100 @@ public static SearchHit.NestedIdentity nestedIdentityFromProto(NestedIdentityPro return new SearchHit.NestedIdentity(field, offset, child); } + + public static SearchHitsProtoDef.SearchSortValuesProto searchSortValuesToProto(SearchSortValues searchSortValues) { + SearchHitsProtoDef.SearchSortValuesProto.Builder builder = SearchHitsProtoDef.SearchSortValuesProto.newBuilder(); + + for (Object value : searchSortValues.getFormattedSortValues()) { + builder.addFormattedSortValues(sortValueToProto(value)); + } + + for (Object value : searchSortValues.getRawSortValues()) { + builder.addRawSortValues(sortValueToProto(value)); + } + + return builder.build(); + } + + public static SearchSortValues searchSortValuesFromProto(SearchHitsProtoDef.SearchSortValuesProto proto) throws TransportSerializationException { + Object[] formattedSortValues = new Object[proto.getFormattedSortValuesCount()]; + Object[] rawSortValues = new Object[proto.getRawSortValuesCount()]; + + for (int i = 0; i < formattedSortValues.length; i++) { + SearchHitsProtoDef.SortValueProto sortProto = proto.getFormattedSortValues(i); + formattedSortValues[i] = sortValueFromProto(sortProto); + } + + for (int i = 0; i < rawSortValues.length; i++) { + SearchHitsProtoDef.SortValueProto sortProto = proto.getRawSortValues(i); + rawSortValues[i] = sortValueFromProto(sortProto); + } + + return new SearchSortValues(formattedSortValues, rawSortValues); + } + + public static SearchHitsProtoDef.SortValueProto sortValueToProto(Object sortValue) throws TransportSerializationException { + SearchHitsProtoDef.SortValueProto.Builder builder = SearchHitsProtoDef.SortValueProto.newBuilder(); + + if (sortValue == null) { + builder.setIsNull(true); + } else if (sortValue.getClass().equals(String.class)) { + builder.setStringValue((String) sortValue); + } else if (sortValue.getClass().equals(Integer.class)) { + builder.setIntValue((Integer) sortValue); + } else if (sortValue.getClass().equals(Long.class)) { + builder.setLongValue((Long) sortValue); + } else if (sortValue.getClass().equals(Float.class)) { + builder.setFloatValue((Float) sortValue); + } else if (sortValue.getClass().equals(Double.class)) { + builder.setDoubleValue((Double) sortValue); + } else if (sortValue.getClass().equals(Byte.class)) { + builder.setByteValue((Byte) sortValue); + } else if (sortValue.getClass().equals(Short.class)) { + builder.setShortValue((Short) sortValue); + } else if (sortValue.getClass().equals(Boolean.class)) { + builder.setBoolValue((Boolean) sortValue); + } else if (sortValue.getClass().equals(BytesRef.class)) { + builder.setBytesValue(ByteString.copyFrom( + ((BytesRef) sortValue).bytes, + ((BytesRef) sortValue).offset, + ((BytesRef) sortValue).length)); + } else if (sortValue.getClass().equals(BigInteger.class)) { + builder.setBigIntegerValue(sortValue.toString()); + } else { + throw new TransportSerializationException("Unexpected sortValue: " + sortValue); + } + + return builder.build(); + } + + public static Object sortValueFromProto(SearchHitsProtoDef.SortValueProto proto) throws TransportSerializationException { + switch (proto.getValueCase()) { + case STRING_VALUE: + return proto.getStringValue(); + case INT_VALUE: + return proto.getIntValue(); + case LONG_VALUE: + return proto.getLongValue(); + case FLOAT_VALUE: + return proto.getFloatValue(); + case DOUBLE_VALUE: + return proto.getDoubleValue(); + case BYTE_VALUE: + return (byte) proto.getByteValue(); + case SHORT_VALUE: + return (short) proto.getShortValue(); + case BOOL_VALUE: + return proto.getBoolValue(); + case BYTES_VALUE: + ByteString byteString = proto.getBytesValue(); + return new BytesRef(byteString.toByteArray()); + case BIG_INTEGER_VALUE: + return new BigInteger(proto.getBigIntegerValue()); + case IS_NULL: + return null; + } + + throw new TransportSerializationException("Unexpected value case: " + proto.getValueCase()); + } } diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index 99bec9b3c1526..ef5f7a4997de8 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -23,10 +23,10 @@ import java.io.IOException; import java.util.List; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueToProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldToProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldFromProto; +import static org.opensearch.transport.protobuf.SearchHitProtobuf.sortValueFromProto; +import static org.opensearch.transport.protobuf.SearchHitProtobuf.sortValueToProto; /** * SearchHits child which implements serde operations as protobuf. @@ -110,7 +110,7 @@ private TotalHits totalHitsFromProto(TotalHitsProto proto) { long rel = proto.getRelation(); long val = proto.getValue(); if (rel < 0 || rel >= TotalHits.Relation.values().length) { - throw new ProtoSerDeHelpers.SerializationException("Failed to deserialize TotalHits from proto"); + throw new TransportSerializationException("Failed to deserialize TotalHits from proto"); } return new TotalHits(val, TotalHits.Relation.values()[(int) rel]); } diff --git a/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java index dfb96020d730e..4b4a5169ce243 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java @@ -55,8 +55,8 @@ import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.highlightFieldToProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetToProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesFromProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchSortValuesToProto; +import static org.opensearch.transport.protobuf.SearchHitProtobuf.searchSortValuesFromProto; +import static org.opensearch.transport.protobuf.SearchHitProtobuf.searchSortValuesToProto; public class SearchHitProtobufTests extends AbstractWireSerializingTestCase { public void testDocumentFieldProtoSerialization () { diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java index ebc4532181a1e..e6789ab459e78 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -41,8 +41,8 @@ import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldFromProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldToProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueFromProto; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortValueToProto; +import static org.opensearch.transport.protobuf.SearchHitProtobuf.sortValueFromProto; +import static org.opensearch.transport.protobuf.SearchHitProtobuf.sortValueToProto; public class SearchHitsProtobufTests extends AbstractWireSerializingTestCase { public void testSortFieldProtoSerialization () { From 0255df3526192481a8deaa0b900977d8097fbd7b Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 18 Sep 2024 16:16:59 -0700 Subject: [PATCH 58/61] Fix possible switch fall through Signed-off-by: Finn Carroll --- .../transport/protobuf/FetchSearchResultProtobuf.java | 2 +- .../org/opensearch/transport/protobuf/ProtoSerDeHelpers.java | 1 + .../org/opensearch/transport/protobuf/SearchHitProtobuf.java | 2 +- .../org/opensearch/transport/protobuf/SearchHitsProtobuf.java | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java index 723322b3102ef..f5533a5dceac7 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java @@ -16,7 +16,7 @@ import java.io.IOException; /** - * FetchSearchResult child which implements serde operations as protobuf. + * FetchSearchResult which leverages protobuf for transport layer serialization. * @opensearch.internal */ public class FetchSearchResultProtobuf extends FetchSearchResult { diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index 147804a2be738..b5c7088fa9374 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -237,6 +237,7 @@ public static Object missingValueFromProto(MissingValueProto proto) { case INT_VAL: if (proto.getIntVal() == 1) { return SortField.STRING_FIRST; } if (proto.getIntVal() == 2) { return SortField.STRING_LAST; } + throw new TransportSerializationException("Unexpected sortField missingValue (INT_VAL): " + proto.getIntVal()); case OBJ_VAL: return genericObjectFromProto(proto.getObjVal()); default: diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index b3fa973a17e47..d77b450331d28 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -35,7 +35,7 @@ import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.searchShardTargetToProto; /** - * Serialization/Deserialization implementations for SearchHit. + * SearchHit which leverages protobuf for transport layer serialization. * @opensearch.internal */ public class SearchHitProtobuf extends SearchHit { diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index ef5f7a4997de8..499c8799fa184 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -29,7 +29,7 @@ import static org.opensearch.transport.protobuf.SearchHitProtobuf.sortValueToProto; /** - * SearchHits child which implements serde operations as protobuf. + * SearchHits which leverages protobuf for transport layer serialization. * @opensearch.internal */ public class SearchHitsProtobuf extends SearchHits { From 402172276132a26e9f65b6afb4804912c7a1994f Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 18 Sep 2024 16:18:39 -0700 Subject: [PATCH 59/61] Spotless apply Signed-off-by: Finn Carroll --- .../protobuf/FetchSearchResultProtobuf.java | 2 +- .../transport/protobuf/ProtoSerDeHelpers.java | 21 ++++---- .../transport/protobuf/SearchHitProtobuf.java | 50 ++++++++++++------- .../protobuf/SearchHitsProtobuf.java | 16 +++--- .../search/SearchHitProtobufTests.java | 12 ++--- .../search/SearchHitsProtobufTests.java | 4 +- 6 files changed, 60 insertions(+), 45 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java index f5533a5dceac7..a2b57b0dc6997 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java @@ -10,8 +10,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.search.fetch.FetchSearchResult; import org.opensearch.proto.search.FetchSearchResultProtoDef.FetchSearchResultProto; +import org.opensearch.search.fetch.FetchSearchResult; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java index b5c7088fa9374..dca3b3693ba2a 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/ProtoSerDeHelpers.java @@ -19,18 +19,18 @@ import org.opensearch.core.common.text.Text; import org.opensearch.core.index.Index; import org.opensearch.core.index.shard.ShardId; -import org.opensearch.search.SearchShardTarget; -import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.proto.search.SearchHitsProtoDef.DocumentFieldProto; import org.opensearch.proto.search.SearchHitsProtoDef.ExplanationProto; +import org.opensearch.proto.search.SearchHitsProtoDef.GenericObjectProto; import org.opensearch.proto.search.SearchHitsProtoDef.HighlightFieldProto; import org.opensearch.proto.search.SearchHitsProtoDef.IndexProto; +import org.opensearch.proto.search.SearchHitsProtoDef.MissingValueProto; import org.opensearch.proto.search.SearchHitsProtoDef.SearchShardTargetProto; import org.opensearch.proto.search.SearchHitsProtoDef.ShardIdProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortFieldProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortTypeProto; -import org.opensearch.proto.search.SearchHitsProtoDef.GenericObjectProto; -import org.opensearch.proto.search.SearchHitsProtoDef.MissingValueProto; +import org.opensearch.search.SearchShardTarget; +import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.transport.TransportSerializationException; import java.io.IOException; @@ -198,10 +198,7 @@ public static SortField sortFieldFromProto(SortFieldProto proto) { field = proto.getField(); } - SortField sortField = new SortField( - field, - sortTypeFromProto(proto.getType()), - proto.getReverse()); + SortField sortField = new SortField(field, sortTypeFromProto(proto.getType()), proto.getReverse()); if (proto.hasMissingValue()) { sortField.setMissingValue(missingValueFromProto(proto.getMissingValue())); @@ -235,8 +232,12 @@ public static MissingValueProto missingValueToProto(Object missingValue) { public static Object missingValueFromProto(MissingValueProto proto) { switch (proto.getValueCase()) { case INT_VAL: - if (proto.getIntVal() == 1) { return SortField.STRING_FIRST; } - if (proto.getIntVal() == 2) { return SortField.STRING_LAST; } + if (proto.getIntVal() == 1) { + return SortField.STRING_FIRST; + } + if (proto.getIntVal() == 2) { + return SortField.STRING_LAST; + } throw new TransportSerializationException("Unexpected sortField missingValue (INT_VAL): " + proto.getIntVal()); case OBJ_VAL: return genericObjectFromProto(proto.getObjVal()); diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java index d77b450331d28..5e4253b6db83e 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitProtobuf.java @@ -15,9 +15,9 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.text.Text; import org.opensearch.proto.search.SearchHitsProtoDef; -import org.opensearch.search.SearchHit; -import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitProto; import org.opensearch.proto.search.SearchHitsProtoDef.NestedIdentityProto; +import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitProto; +import org.opensearch.search.SearchHit; import org.opensearch.search.SearchSortValues; import org.opensearch.transport.TransportSerializationException; @@ -77,14 +77,28 @@ SearchHitProto toProto() { metaFields.forEach((key, value) -> builder.putMetaFields(key, documentFieldToProto(value))); matchedQueries.forEach(builder::putMatchedQueries); - if (highlightFields != null) { highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); } - if (innerHits != null) { innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsProtobuf(value).toProto())); } + if (highlightFields != null) { + highlightFields.forEach((key, value) -> builder.putHighlightFields(key, highlightFieldToProto(value))); + } + if (innerHits != null) { + innerHits.forEach((key, value) -> builder.putInnerHits(key, new SearchHitsProtobuf(value).toProto())); + } - if (source != null) { builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); } - if (id != null) { builder.setId(id.string()); } - if (nestedIdentity != null) { builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); } - if (shard != null) { builder.setShard(searchShardTargetToProto(shard)); } - if (explanation != null) { builder.setExplanation(explanationToProto(explanation)); } + if (source != null) { + builder.setSource(ByteString.copyFrom(source.toBytesRef().bytes)); + } + if (id != null) { + builder.setId(id.string()); + } + if (nestedIdentity != null) { + builder.setNestedIdentity(nestedIdentityToProto(nestedIdentity)); + } + if (shard != null) { + builder.setShard(searchShardTargetToProto(shard)); + } + if (explanation != null) { + builder.setExplanation(explanationToProto(explanation)); + } return builder.build(); } @@ -116,10 +130,10 @@ void fromProto(SearchHitProto proto) { proto.getInnerHitsMap().forEach((key, value) -> innerHits.put(key, new SearchHitsProtobuf(value))); } - source = proto.hasSource()? BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()) : null; - id = proto.hasId()? new Text(proto.getId()) : null; - nestedIdentity = proto.hasNestedIdentity()? nestedIdentityFromProto(proto.getNestedIdentity()) : null; - explanation = proto.hasExplanation()? explanationFromProto(proto.getExplanation()) : null; + source = proto.hasSource() ? BytesReference.fromByteBuffer(proto.getSource().asReadOnlyByteBuffer()) : null; + id = proto.hasId() ? new Text(proto.getId()) : null; + nestedIdentity = proto.hasNestedIdentity() ? nestedIdentityFromProto(proto.getNestedIdentity()) : null; + explanation = proto.hasExplanation() ? explanationFromProto(proto.getExplanation()) : null; if (proto.hasShard()) { shard = searchShardTargetFromProto(proto.getShard()); @@ -170,7 +184,8 @@ public static SearchHitsProtoDef.SearchSortValuesProto searchSortValuesToProto(S return builder.build(); } - public static SearchSortValues searchSortValuesFromProto(SearchHitsProtoDef.SearchSortValuesProto proto) throws TransportSerializationException { + public static SearchSortValues searchSortValuesFromProto(SearchHitsProtoDef.SearchSortValuesProto proto) + throws TransportSerializationException { Object[] formattedSortValues = new Object[proto.getFormattedSortValuesCount()]; Object[] rawSortValues = new Object[proto.getRawSortValuesCount()]; @@ -209,10 +224,9 @@ public static SearchHitsProtoDef.SortValueProto sortValueToProto(Object sortValu } else if (sortValue.getClass().equals(Boolean.class)) { builder.setBoolValue((Boolean) sortValue); } else if (sortValue.getClass().equals(BytesRef.class)) { - builder.setBytesValue(ByteString.copyFrom( - ((BytesRef) sortValue).bytes, - ((BytesRef) sortValue).offset, - ((BytesRef) sortValue).length)); + builder.setBytesValue( + ByteString.copyFrom(((BytesRef) sortValue).bytes, ((BytesRef) sortValue).offset, ((BytesRef) sortValue).length) + ); } else if (sortValue.getClass().equals(BigInteger.class)) { builder.setBigIntegerValue(sortValue.toString()); } else { diff --git a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java index 499c8799fa184..413801c732922 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/SearchHitsProtobuf.java @@ -12,19 +12,19 @@ import org.apache.lucene.search.TotalHits; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.search.SearchHit; -import org.opensearch.search.SearchHits; import org.opensearch.proto.search.SearchHitsProtoDef.SearchHitsProto; -import org.opensearch.proto.search.SearchHitsProtoDef.TotalHitsProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortFieldProto; import org.opensearch.proto.search.SearchHitsProtoDef.SortValueProto; +import org.opensearch.proto.search.SearchHitsProtoDef.TotalHitsProto; +import org.opensearch.search.SearchHit; +import org.opensearch.search.SearchHits; import org.opensearch.transport.TransportSerializationException; import java.io.IOException; import java.util.List; -import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldToProto; import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldFromProto; +import static org.opensearch.transport.protobuf.ProtoSerDeHelpers.sortFieldToProto; import static org.opensearch.transport.protobuf.SearchHitProtobuf.sortValueFromProto; import static org.opensearch.transport.protobuf.SearchHitProtobuf.sortValueToProto; @@ -100,10 +100,10 @@ void fromProto(SearchHitsProto proto) throws TransportSerializationException { hits[i] = new SearchHitProtobuf(proto.getHits(i)); } - collapseField = proto.hasCollapseField()? proto.getCollapseField() : null; - totalHits = proto.hasTotalHits()? totalHitsFromProto(proto.getTotalHits()) : null; - sortFields = proto.getSortFieldsCount() > 0? sortFieldsFromProto(proto.getSortFieldsList()) : null; - collapseValues = proto.getCollapseValuesCount() > 0? collapseValuesFromProto(proto.getCollapseValuesList()) : null; + collapseField = proto.hasCollapseField() ? proto.getCollapseField() : null; + totalHits = proto.hasTotalHits() ? totalHitsFromProto(proto.getTotalHits()) : null; + sortFields = proto.getSortFieldsCount() > 0 ? sortFieldsFromProto(proto.getSortFieldsList()) : null; + collapseValues = proto.getCollapseValuesCount() > 0 ? collapseValuesFromProto(proto.getCollapseValuesList()) : null; } private TotalHits totalHitsFromProto(TotalHitsProto proto) { diff --git a/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java index 4b4a5169ce243..9d043efcdc4ea 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitProtobufTests.java @@ -59,7 +59,7 @@ import static org.opensearch.transport.protobuf.SearchHitProtobuf.searchSortValuesToProto; public class SearchHitProtobufTests extends AbstractWireSerializingTestCase { - public void testDocumentFieldProtoSerialization () { + public void testDocumentFieldProtoSerialization() { DocumentField orig = randomDocumentField(randomFrom(XContentType.values()), randomBoolean(), fieldName -> false).v1(); SearchHitsProtoDef.DocumentFieldProto proto = documentFieldToProto(orig); DocumentField cpy = documentFieldFromProto(proto); @@ -68,7 +68,7 @@ public void testDocumentFieldProtoSerialization () { assertNotSame(orig, cpy); } - public void testHighlightFieldProtoSerialization () { + public void testHighlightFieldProtoSerialization() { HighlightField orig = HighlightFieldTests.createTestItem(); SearchHitsProtoDef.HighlightFieldProto proto = highlightFieldToProto(orig); HighlightField cpy = highlightFieldFromProto(proto); @@ -77,7 +77,7 @@ public void testHighlightFieldProtoSerialization () { assertNotSame(orig, cpy); } - public void testSearchSortValuesProtoSerialization () { + public void testSearchSortValuesProtoSerialization() { SearchSortValues orig = SearchSortValuesTests.createTestItem(randomFrom(XContentType.values()), true); SearchHitsProtoDef.SearchSortValuesProto proto = searchSortValuesToProto(orig); SearchSortValues cpy = searchSortValuesFromProto(proto); @@ -86,7 +86,7 @@ public void testSearchSortValuesProtoSerialization () { assertNotSame(orig, cpy); } - public void testNestedIdentityProtoSerialization () { + public void testNestedIdentityProtoSerialization() { SearchHit.NestedIdentity orig = NestedIdentityTests.createTestItem(randomIntBetween(0, 2)); SearchHitsProtoDef.NestedIdentityProto proto = SearchHitProtobuf.nestedIdentityToProto(orig); SearchHit.NestedIdentity cpy = SearchHitProtobuf.nestedIdentityFromProto(proto); @@ -95,7 +95,7 @@ public void testNestedIdentityProtoSerialization () { assertNotSame(orig, cpy); } - public void testSearchShardTargetProtoSerialization () { + public void testSearchShardTargetProtoSerialization() { String index = randomAlphaOfLengthBetween(5, 10); String clusterAlias = randomBoolean() ? null : randomAlphaOfLengthBetween(5, 10); SearchShardTarget orig = new SearchShardTarget( @@ -111,7 +111,7 @@ public void testSearchShardTargetProtoSerialization () { assertNotSame(orig, cpy); } - public void testExplanationProtoSerialization () { + public void testExplanationProtoSerialization() { Explanation orig = createExplanation(randomIntBetween(0, 5)); SearchHitsProtoDef.ExplanationProto proto = explanationToProto(orig); Explanation cpy = explanationFromProto(proto); diff --git a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java index e6789ab459e78..b2f52e87aadd2 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsProtobufTests.java @@ -45,7 +45,7 @@ import static org.opensearch.transport.protobuf.SearchHitProtobuf.sortValueToProto; public class SearchHitsProtobufTests extends AbstractWireSerializingTestCase { - public void testSortFieldProtoSerialization () { + public void testSortFieldProtoSerialization() { SortField[] fields = SearchHitsTests.createSortFields(randomIntBetween(1, 5)); for (SortField orig : fields) { SearchHitsProtoDef.SortFieldProto proto = sortFieldToProto(orig); @@ -56,7 +56,7 @@ public void testSortFieldProtoSerialization () { } } - public void testSortValueProtoSerialization () { + public void testSortValueProtoSerialization() { Object[] values = SearchHitsTests.createCollapseValues(randomIntBetween(1, 10)); for (Object orig : values) { SearchHitsProtoDef.SortValueProto proto = sortValueToProto(orig); From 7f4e887ed61cb85315c85c6ad8e65266020d3bad Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 23 Sep 2024 13:06:04 -0700 Subject: [PATCH 60/61] Proto folder should mirror project structure Signed-off-by: Finn Carroll --- server/src/main/proto/search/SearchHits.proto | 6 +++--- .../main/proto/search/{ => fetch}/FetchSearchResult.proto | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename server/src/main/proto/search/{ => fetch}/FetchSearchResult.proto (65%) diff --git a/server/src/main/proto/search/SearchHits.proto b/server/src/main/proto/search/SearchHits.proto index 80ab07e28b4e1..9bfcb9849b873 100644 --- a/server/src/main/proto/search/SearchHits.proto +++ b/server/src/main/proto/search/SearchHits.proto @@ -34,9 +34,9 @@ message SortValueProto { int32 byte_value = 6; int32 short_value = 7; bool bool_value = 8; - bytes bytes_value = 9; // BytesRef + bytes bytes_value = 9; string big_integer_value = 10; - bool is_null = 11; // Can be explicitly null + bool is_null = 11; } } @@ -78,7 +78,7 @@ message SearchHitProto { map highlight_fields = 8; map matched_queries = 9; map inner_hits = 10; - optional bytes source = 11; // JSON payload - Move to map? + optional bytes source = 11; // compressible map optional string id = 12; optional NestedIdentityProto nested_identity = 13; optional SearchShardTargetProto shard = 14; diff --git a/server/src/main/proto/search/FetchSearchResult.proto b/server/src/main/proto/search/fetch/FetchSearchResult.proto similarity index 65% rename from server/src/main/proto/search/FetchSearchResult.proto rename to server/src/main/proto/search/fetch/FetchSearchResult.proto index db1e37ce66cb6..5c2c71b1528b7 100644 --- a/server/src/main/proto/search/FetchSearchResult.proto +++ b/server/src/main/proto/search/fetch/FetchSearchResult.proto @@ -1,12 +1,12 @@ syntax = "proto3"; -package org.opensearch.proto.search; +package org.opensearch.proto.fetch; import "search/SearchHits.proto"; option java_outer_classname = "FetchSearchResultProtoDef"; message FetchSearchResultProto { - SearchHitsProto hits = 1; + org.opensearch.proto.search.SearchHitsProto hits = 1; int64 counter = 2; } From 9c79d902c3724a52b20da449b7a58afeee84e159 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 23 Sep 2024 13:21:43 -0700 Subject: [PATCH 61/61] Fix import Signed-off-by: Finn Carroll --- .../transport/protobuf/FetchSearchResultProtobuf.java | 2 +- server/src/main/proto/search/fetch/FetchSearchResult.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java index a2b57b0dc6997..81350e22fbc8c 100644 --- a/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java +++ b/server/src/main/java/org/opensearch/transport/protobuf/FetchSearchResultProtobuf.java @@ -10,8 +10,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.proto.search.FetchSearchResultProtoDef.FetchSearchResultProto; import org.opensearch.search.fetch.FetchSearchResult; +import org.opensearch.proto.search.fetch.FetchSearchResultProtoDef.FetchSearchResultProto; import java.io.IOException; diff --git a/server/src/main/proto/search/fetch/FetchSearchResult.proto b/server/src/main/proto/search/fetch/FetchSearchResult.proto index 5c2c71b1528b7..e04e041167ed0 100644 --- a/server/src/main/proto/search/fetch/FetchSearchResult.proto +++ b/server/src/main/proto/search/fetch/FetchSearchResult.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package org.opensearch.proto.fetch; +package org.opensearch.proto.search.fetch; import "search/SearchHits.proto";