diff --git a/server/build.gradle b/server/build.gradle index 810e429da359a..f0ce4011ca951 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -350,32 +350,6 @@ tasks.named("dependencyLicenses").configure { } } -tasks.named("missingJavadoc").configure { - /* - * annotate_code in L210 does not add the Generated annotation to nested code generated using protobuf. - * TODO: Add support to missingJavadoc task to ignore all such nested classes. - * https://github.com/opensearch-project/OpenSearch/issues/11913 - */ - dependsOn("generateProto") - javadocMissingIgnore = [ - "org.opensearch.server.proto.QuerySearchResultProto.QuerySearchResult.RescoreDocIds.setIntegerOrBuilder", - "org.opensearch.server.proto.QuerySearchResultProto.QuerySearchResult.RescoreDocIdsOrBuilder", - "org.opensearch.server.proto.QuerySearchResultProto.QuerySearchResult.TopDocs.ScoreDocOrBuilder", - "org.opensearch.server.proto.QuerySearchResultProto.QuerySearchResult.TopDocsOrBuilder", - "org.opensearch.server.proto.QuerySearchResultProto.QuerySearchResult.TopDocsAndMaxScoreOrBuilder", - "org.opensearch.server.proto.FetchSearchResultProto.SearchHit.SearchSortValuesOrBuilder", - "org.opensearch.server.proto.FetchSearchResultProto.SearchHit.HighlightFieldOrBuilder", - "org.opensearch.server.proto.FetchSearchResultProto.SearchHit.DocumentFieldOrBuilder", - "org.opensearch.server.proto.FetchSearchResultProto.SearchHit.NestedIdentityOrBuilder", - "org.opensearch.server.proto.NodeToNodeMessageProto.NodeToNodeMessage.MessageCase", - "org.opensearch.server.proto.NodeToNodeMessageProto.NodeToNodeMessage.ResponseHandlersListOrBuilder", - "org.opensearch.server.proto.NodeToNodeMessageProto.NodeToNodeMessage.HeaderOrBuilder", - "org.opensearch.server.proto.FetchSearchResultProto.SearchHit.Explanation.ExplanationValueCase", - "org.opensearch.server.proto.FetchSearchResultProto.SearchHit.ExplanationOrBuilder", - "org.opensearch.server.proto.ShardSearchRequestProto.OriginalIndices.IndicesOptionsOrBuilder", - ] -} - tasks.named("filepermissions").configure { mustRunAfter("generateProto") } diff --git a/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldSerializer.java b/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldDeserializer.java similarity index 73% rename from server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldSerializer.java rename to server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldDeserializer.java index 48916c4b87b51..fbd00eded893f 100644 --- a/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldSerializer.java +++ b/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldDeserializer.java @@ -13,9 +13,9 @@ import java.io.IOException; /** - * Serializer for {@link DocumentField} which can be implemented for different types of serialization. + * Deserializer for {@link DocumentField} which can be implemented for different types of serde mechanisms. */ -public interface DocumentFieldSerializer { +public interface DocumentFieldDeserializer { DocumentField createDocumentField(T inputStream) throws IOException; diff --git a/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldProtobufSerializer.java b/server/src/main/java/org/opensearch/common/document/serializer/protobuf/DocumentFieldProtobufDeserializer.java similarity index 94% rename from server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldProtobufSerializer.java rename to server/src/main/java/org/opensearch/common/document/serializer/protobuf/DocumentFieldProtobufDeserializer.java index e606773d07826..dd5cc9450bf99 100644 --- a/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/common/document/serializer/protobuf/DocumentFieldProtobufDeserializer.java @@ -6,11 +6,12 @@ * compatible open source license. */ -package org.opensearch.common.document.serializer; +package org.opensearch.common.document.serializer.protobuf; import com.google.protobuf.ByteString; import org.opensearch.OpenSearchException; import org.opensearch.common.document.DocumentField; +import org.opensearch.common.document.serializer.DocumentFieldDeserializer; import org.opensearch.core.common.text.Text; import org.opensearch.server.proto.FetchSearchResultProto; import org.opensearch.server.proto.FetchSearchResultProto.DocumentFieldValue; @@ -29,9 +30,9 @@ import java.util.Map; /** - * Serializer for {@link DocumentField} to/from protobuf. + * Deserializer for {@link DocumentField} to/from protobuf. */ -public class DocumentFieldProtobufSerializer implements DocumentFieldSerializer { +public class DocumentFieldProtobufDeserializer implements DocumentFieldDeserializer { private FetchSearchResultProto.SearchHit.DocumentField documentField; @@ -135,7 +136,7 @@ public static FetchSearchResultProto.SearchHit.DocumentField convertDocumentFiel builder.setName(documentField.getName()); for (Object value : documentField.getValues()) { FetchSearchResultProto.DocumentFieldValue.Builder valueBuilder = FetchSearchResultProto.DocumentFieldValue.newBuilder(); - builder.addValues(DocumentFieldProtobufSerializer.convertDocumentFieldValueToProto(value, valueBuilder)); + builder.addValues(convertDocumentFieldValueToProto(value, valueBuilder)); } return builder.build(); } diff --git a/server/src/main/java/org/opensearch/common/document/serializer/protobuf/package-info.java b/server/src/main/java/org/opensearch/common/document/serializer/protobuf/package-info.java new file mode 100644 index 0000000000000..690bc7642390d --- /dev/null +++ b/server/src/main/java/org/opensearch/common/document/serializer/protobuf/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. + */ + +/** Protobuf Serializer package for documents. */ +package org.opensearch.common.document.serializer.protobuf; diff --git a/server/src/main/java/org/opensearch/search/SearchSortValues.java b/server/src/main/java/org/opensearch/search/SearchSortValues.java index d03cc80b90de3..1957c79c98649 100644 --- a/server/src/main/java/org/opensearch/search/SearchSortValues.java +++ b/server/src/main/java/org/opensearch/search/SearchSortValues.java @@ -68,7 +68,12 @@ public class SearchSortValues implements ToXContentFragment, Writeable { } public SearchSortValues(Object[] sortValues, Object[] rawSortValues) { - this.formattedSortValues = Objects.requireNonNull(sortValues, "sort values must not be empty"); + Objects.requireNonNull(rawSortValues); + Objects.requireNonNull(sortValues); + if (rawSortValues.length != sortValues.length) { + throw new IllegalArgumentException("formattedSortValues and sortValues must hold the same number of items"); + } + this.formattedSortValues = sortValues; this.rawSortValues = rawSortValues; } 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 95d281be137f7..fd5e2b9cdd250 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -42,7 +42,7 @@ import org.opensearch.search.SearchShardTarget; import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.search.query.QuerySearchResult; -import org.opensearch.search.serializer.SearchHitsProtobufSerializer; +import org.opensearch.search.serializer.protobuf.SearchHitsProtobufDeserializer; import org.opensearch.server.proto.FetchSearchResultProto; import org.opensearch.server.proto.ShardSearchRequestProto; @@ -78,7 +78,7 @@ public FetchSearchResult(InputStream in) throws IOException { this.fetchSearchResultProto.getContextId().getSessionId(), this.fetchSearchResultProto.getContextId().getId() ); - SearchHitsProtobufSerializer protobufSerializer = new SearchHitsProtobufSerializer(); + SearchHitsProtobufDeserializer protobufSerializer = new SearchHitsProtobufDeserializer(); hits = protobufSerializer.createSearchHits(new ByteArrayInputStream(this.fetchSearchResultProto.getHits().toByteArray())); } @@ -107,7 +107,7 @@ public void hits(SearchHits hits) { this.hits = hits; if (FeatureFlags.isEnabled(FeatureFlags.PROTOBUF_SETTING) && this.fetchSearchResultProto != null) { this.fetchSearchResultProto = this.fetchSearchResultProto.toBuilder() - .setHits(SearchHitsProtobufSerializer.convertHitsToProto(hits)) + .setHits(SearchHitsProtobufDeserializer.convertHitsToProto(hits)) .build(); } } @@ -123,7 +123,7 @@ public SearchHits hits() { if (FeatureFlags.isEnabled(FeatureFlags.PROTOBUF_SETTING) && this.fetchSearchResultProto != null) { SearchHits hits; try { - SearchHitsProtobufSerializer protobufSerializer = new SearchHitsProtobufSerializer(); + SearchHitsProtobufDeserializer protobufSerializer = new SearchHitsProtobufDeserializer(); hits = protobufSerializer.createSearchHits(new ByteArrayInputStream(this.fetchSearchResultProto.getHits().toByteArray())); return hits; } catch (IOException e) { diff --git a/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldSerializer.java b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldDeserializer.java similarity index 74% rename from server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldSerializer.java rename to server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldDeserializer.java index 21a6afdac565f..8ede74986ff9f 100644 --- a/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldSerializer.java +++ b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldDeserializer.java @@ -13,9 +13,9 @@ import java.io.IOException; /** - * Serializer for {@link HighlightField} which can be implemented for different types of serialization. + * Deserializer for {@link HighlightField} which can be implemented for different types of serde mechanisms. */ -public interface HighlightFieldSerializer { +public interface HighlightFieldDeserializer { HighlightField createHighLightField(T inputStream) throws IOException; } diff --git a/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldProtobufSerializer.java b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/protobuf/HighlightFieldProtobufDeserializer.java similarity index 82% rename from server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldProtobufSerializer.java rename to server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/protobuf/HighlightFieldProtobufDeserializer.java index 74557d5618ce0..d3023a7342f7d 100644 --- a/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/HighlightFieldProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/protobuf/HighlightFieldProtobufDeserializer.java @@ -6,10 +6,11 @@ * compatible open source license. */ -package org.opensearch.search.fetch.subphase.highlight.serializer; +package org.opensearch.search.fetch.subphase.highlight.serializer.protobuf; import org.opensearch.core.common.text.Text; import org.opensearch.search.fetch.subphase.highlight.HighlightField; +import org.opensearch.search.fetch.subphase.highlight.serializer.HighlightFieldDeserializer; import org.opensearch.server.proto.FetchSearchResultProto; import java.io.IOException; @@ -18,9 +19,9 @@ import java.util.List; /** - * Serializer for {@link HighlightField} to/from protobuf. + * Deserializer for {@link HighlightField} to/from protobuf. */ -public class HighlightFieldProtobufSerializer implements HighlightFieldSerializer { +public class HighlightFieldProtobufDeserializer implements HighlightFieldDeserializer { @Override public HighlightField createHighLightField(InputStream inputStream) throws IOException { diff --git a/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/protobuf/package-info.java b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/protobuf/package-info.java new file mode 100644 index 0000000000000..796383b48afda --- /dev/null +++ b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/protobuf/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. + */ + +/** Protobuf Serializer package for highlights. */ +package org.opensearch.search.fetch.subphase.highlight.serializer.protobuf; diff --git a/server/src/main/java/org/opensearch/search/serializer/NestedIdentitySerializer.java b/server/src/main/java/org/opensearch/search/serializer/NestedIdentityDeserializer.java similarity index 69% rename from server/src/main/java/org/opensearch/search/serializer/NestedIdentitySerializer.java rename to server/src/main/java/org/opensearch/search/serializer/NestedIdentityDeserializer.java index 5ee30337bb4b6..f707921b81ca8 100644 --- a/server/src/main/java/org/opensearch/search/serializer/NestedIdentitySerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/NestedIdentityDeserializer.java @@ -13,9 +13,9 @@ import java.io.IOException; /** - * Serializer for {@link NestedIdentity} which can be implemented for different types of serialization. + * Deserializer for {@link NestedIdentity} which can be implemented for different types of serde mechanisms. */ -public interface NestedIdentitySerializer { +public interface NestedIdentityDeserializer { - public NestedIdentity createNestedIdentity(T inputStream) throws IOException, Exception; + public NestedIdentity createNestedIdentity(T inputStream) throws IOException; } diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchHitSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchHitDeserializer.java similarity index 72% rename from server/src/main/java/org/opensearch/search/serializer/SearchHitSerializer.java rename to server/src/main/java/org/opensearch/search/serializer/SearchHitDeserializer.java index 217266f720079..6dbf3a8fd4e05 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchHitSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchHitDeserializer.java @@ -13,9 +13,9 @@ import java.io.IOException; /** - * Serializer for {@link SearchHit} which can be implemented for different types of serialization. + * Deserializer for {@link SearchHit} which can be implemented for different types of serde mechanisms. */ -public interface SearchHitSerializer { +public interface SearchHitDeserializer { SearchHit createSearchHit(T inputStream) throws IOException; diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchHitsSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchHitsDeserializer.java similarity index 72% rename from server/src/main/java/org/opensearch/search/serializer/SearchHitsSerializer.java rename to server/src/main/java/org/opensearch/search/serializer/SearchHitsDeserializer.java index f09e369aaeee1..6457eb1d29ad2 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchHitsSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchHitsDeserializer.java @@ -13,9 +13,9 @@ import java.io.IOException; /** - * Serializer for {@link SearchHits} which can be implemented for different types of serialization. + * Deserializer for {@link SearchHits} which can be implemented for different types of serde mechanisms. */ -public interface SearchHitsSerializer { +public interface SearchHitsDeserializer { SearchHits createSearchHits(T inputStream) throws IOException; diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesDeserializer.java similarity index 71% rename from server/src/main/java/org/opensearch/search/serializer/SearchSortValuesSerializer.java rename to server/src/main/java/org/opensearch/search/serializer/SearchSortValuesDeserializer.java index 31feb206eb74d..2aafe485b9d59 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesDeserializer.java @@ -13,9 +13,9 @@ import java.io.IOException; /** - * Serializer for {@link SearchSortValues} which can be implemented for different types of serialization. + * Deserializer for {@link SearchSortValues} which can be implemented for different types of serde mechanisms. */ -public interface SearchSortValuesSerializer { +public interface SearchSortValuesDeserializer { SearchSortValues createSearchSortValues(T inputStream) throws IOException; diff --git a/server/src/main/java/org/opensearch/search/serializer/NestedIdentityProtobufSerializer.java b/server/src/main/java/org/opensearch/search/serializer/protobuf/NestedIdentityProtobufDeserializer.java similarity index 81% rename from server/src/main/java/org/opensearch/search/serializer/NestedIdentityProtobufSerializer.java rename to server/src/main/java/org/opensearch/search/serializer/protobuf/NestedIdentityProtobufDeserializer.java index 0e1081c9cc8d8..a7e26e8c0d1ae 100644 --- a/server/src/main/java/org/opensearch/search/serializer/NestedIdentityProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/protobuf/NestedIdentityProtobufDeserializer.java @@ -6,9 +6,10 @@ * compatible open source license. */ -package org.opensearch.search.serializer; +package org.opensearch.search.serializer.protobuf; import org.opensearch.search.SearchHit.NestedIdentity; +import org.opensearch.search.serializer.NestedIdentityDeserializer; import org.opensearch.server.proto.FetchSearchResultProto; import java.io.ByteArrayInputStream; @@ -16,9 +17,9 @@ import java.io.InputStream; /** - * Serializer for {@link NestedIdentity} to/from protobuf. + * Deserializer for {@link NestedIdentity} to/from protobuf. */ -public class NestedIdentityProtobufSerializer implements NestedIdentitySerializer { +public class NestedIdentityProtobufDeserializer implements NestedIdentityDeserializer { @Override public NestedIdentity createNestedIdentity(InputStream inputStream) throws IOException { diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchHitProtobufSerializer.java b/server/src/main/java/org/opensearch/search/serializer/protobuf/SearchHitProtobufDeserializer.java similarity index 89% rename from server/src/main/java/org/opensearch/search/serializer/SearchHitProtobufSerializer.java rename to server/src/main/java/org/opensearch/search/serializer/protobuf/SearchHitProtobufDeserializer.java index f135ef4433ca6..29bc523473c5d 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchHitProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/protobuf/SearchHitProtobufDeserializer.java @@ -6,14 +6,14 @@ * compatible open source license. */ -package org.opensearch.search.serializer; +package org.opensearch.search.serializer.protobuf; import com.google.protobuf.ByteString; import org.apache.lucene.search.Explanation; import org.opensearch.OpenSearchParseException; import org.opensearch.action.OriginalIndices; import org.opensearch.common.document.DocumentField; -import org.opensearch.common.document.serializer.DocumentFieldProtobufSerializer; +import org.opensearch.common.document.serializer.protobuf.DocumentFieldProtobufDeserializer; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.index.shard.ShardId; import org.opensearch.search.SearchHit; @@ -22,7 +22,8 @@ import org.opensearch.search.SearchShardTarget; import org.opensearch.search.SearchSortValues; import org.opensearch.search.fetch.subphase.highlight.HighlightField; -import org.opensearch.search.fetch.subphase.highlight.serializer.HighlightFieldProtobufSerializer; +import org.opensearch.search.fetch.subphase.highlight.serializer.protobuf.HighlightFieldProtobufDeserializer; +import org.opensearch.search.serializer.SearchHitDeserializer; import org.opensearch.server.proto.FetchSearchResultProto; import java.io.ByteArrayInputStream; @@ -35,9 +36,9 @@ import java.util.stream.Collectors; /** - * Serializer for {@link SearchHit} to/from protobuf. + * Deserializer for {@link SearchHit} to/from protobuf. */ -public class SearchHitProtobufSerializer implements SearchHitSerializer { +public class SearchHitProtobufDeserializer implements SearchHitDeserializer { private FetchSearchResultProto.SearchHit searchHitProto; @@ -49,7 +50,7 @@ public SearchHit createSearchHit(InputStream inputStream) throws IOException { String id = this.searchHitProto.getId(); NestedIdentity nestedIdentity; if (!this.searchHitProto.hasNestedIdentity() && this.searchHitProto.getNestedIdentity().toByteArray().length > 0) { - NestedIdentityProtobufSerializer protobufSerializer = new NestedIdentityProtobufSerializer(); + NestedIdentityProtobufDeserializer protobufSerializer = new NestedIdentityProtobufDeserializer(); nestedIdentity = protobufSerializer.createNestedIdentity( new ByteArrayInputStream(this.searchHitProto.getNestedIdentity().toByteArray()) ); @@ -64,7 +65,7 @@ public SearchHit createSearchHit(InputStream inputStream) throws IOException { source = null; } Map documentFields = new HashMap<>(); - DocumentFieldProtobufSerializer protobufSerializer = new DocumentFieldProtobufSerializer(); + DocumentFieldProtobufDeserializer protobufSerializer = new DocumentFieldProtobufDeserializer(); this.searchHitProto.getDocumentFieldsMap().forEach((k, v) -> { try { documentFields.put(k, protobufSerializer.createDocumentField(new ByteArrayInputStream(v.toByteArray()))); @@ -81,7 +82,7 @@ public SearchHit createSearchHit(InputStream inputStream) throws IOException { } }); Map highlightFields = new HashMap<>(); - HighlightFieldProtobufSerializer highlightFieldProtobufSerializer = new HighlightFieldProtobufSerializer(); + HighlightFieldProtobufDeserializer highlightFieldProtobufSerializer = new HighlightFieldProtobufDeserializer(); this.searchHitProto.getHighlightFieldsMap().forEach((k, v) -> { try { highlightFields.put(k, highlightFieldProtobufSerializer.createHighLightField(new ByteArrayInputStream(v.toByteArray()))); @@ -89,7 +90,7 @@ public SearchHit createSearchHit(InputStream inputStream) throws IOException { throw new OpenSearchParseException("failed to parse highlight field", e); } }); - SearchSortValuesProtobufSerializer sortValueProtobufSerializer = new SearchSortValuesProtobufSerializer(); + SearchSortValuesProtobufDeserializer sortValueProtobufSerializer = new SearchSortValuesProtobufDeserializer(); SearchSortValues sortValues = sortValueProtobufSerializer.createSearchSortValues( new ByteArrayInputStream(this.searchHitProto.getSortValues().toByteArray()) ); @@ -129,7 +130,7 @@ public SearchHit createSearchHit(InputStream inputStream) throws IOException { innerHits = new HashMap<>(); this.searchHitProto.getInnerHitsMap().forEach((k, v) -> { try { - SearchHitsProtobufSerializer protobufHitsFactory = new SearchHitsProtobufSerializer(); + SearchHitsProtobufDeserializer protobufHitsFactory = new SearchHitsProtobufDeserializer(); innerHits.put(k, protobufHitsFactory.createSearchHits(new ByteArrayInputStream(v.toByteArray()))); } catch (IOException e) { throw new OpenSearchParseException("failed to parse inner hits", e); @@ -170,7 +171,7 @@ public static FetchSearchResultProto.SearchHit convertHitToProto(SearchHit hit) for (Map.Entry entry : hit.getFields().entrySet()) { searchHitBuilder.putDocumentFields( entry.getKey(), - DocumentFieldProtobufSerializer.convertDocumentFieldToProto(entry.getValue()) + DocumentFieldProtobufDeserializer.convertDocumentFieldToProto(entry.getValue()) ); } return searchHitBuilder.build(); diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchHitsProtobufSerializer.java b/server/src/main/java/org/opensearch/search/serializer/protobuf/SearchHitsProtobufDeserializer.java similarity index 94% rename from server/src/main/java/org/opensearch/search/serializer/SearchHitsProtobufSerializer.java rename to server/src/main/java/org/opensearch/search/serializer/protobuf/SearchHitsProtobufDeserializer.java index d32043d9caa49..94ee61aa58621 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchHitsProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/protobuf/SearchHitsProtobufDeserializer.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.search.serializer; +package org.opensearch.search.serializer.protobuf; import com.google.protobuf.ByteString; import org.apache.lucene.search.SortField; @@ -16,6 +16,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; +import org.opensearch.search.serializer.SearchHitsDeserializer; import org.opensearch.server.proto.FetchSearchResultProto; import org.opensearch.server.proto.QuerySearchResultProto; @@ -27,9 +28,9 @@ import java.util.List; /** - * Serializer for {@link SearchHits} to/from protobuf. + * Deserializer for {@link SearchHits} to/from protobuf. */ -public class SearchHitsProtobufSerializer implements SearchHitsSerializer { +public class SearchHitsProtobufDeserializer implements SearchHitsDeserializer { private FetchSearchResultProto.SearchHits searchHitsProto; @@ -37,7 +38,7 @@ public class SearchHitsProtobufSerializer implements SearchHitsSerializer searchHitList = new ArrayList<>(); for (SearchHit hit : hits) { - searchHitList.add(SearchHitProtobufSerializer.convertHitToProto(hit)); + searchHitList.add(SearchHitProtobufDeserializer.convertHitToProto(hit)); } QuerySearchResultProto.TotalHits.Builder totalHitsBuilder = QuerySearchResultProto.TotalHits.newBuilder(); if (hits.getTotalHits() != null) { diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesProtobufSerializer.java b/server/src/main/java/org/opensearch/search/serializer/protobuf/SearchSortValuesProtobufDeserializer.java similarity index 66% rename from server/src/main/java/org/opensearch/search/serializer/SearchSortValuesProtobufSerializer.java rename to server/src/main/java/org/opensearch/search/serializer/protobuf/SearchSortValuesProtobufDeserializer.java index 007e951cbf10a..63ac21a0e2fb9 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/protobuf/SearchSortValuesProtobufDeserializer.java @@ -6,18 +6,19 @@ * compatible open source license. */ -package org.opensearch.search.serializer; +package org.opensearch.search.serializer.protobuf; import org.opensearch.search.SearchSortValues; +import org.opensearch.search.serializer.SearchSortValuesDeserializer; import org.opensearch.server.proto.FetchSearchResultProto; import java.io.IOException; import java.io.InputStream; /** - * Serializer for {@link SearchSortValues} to/from protobuf. + * Deserializer for {@link SearchSortValues} to/from protobuf. */ -public class SearchSortValuesProtobufSerializer implements SearchSortValuesSerializer { +public class SearchSortValuesProtobufDeserializer implements SearchSortValuesDeserializer { @Override public SearchSortValues createSearchSortValues(InputStream inputStream) throws IOException { @@ -26,11 +27,11 @@ public SearchSortValues createSearchSortValues(InputStream inputStream) throws I ); Object[] formattedSortValues = new Object[searchSortValues.getFormattedSortValuesCount()]; for (int i = 0; i < searchSortValues.getFormattedSortValuesCount(); i++) { - formattedSortValues[i] = SearchHitsProtobufSerializer.readSortValueFromProtobuf(searchSortValues.getFormattedSortValues(i)); + formattedSortValues[i] = SearchHitsProtobufDeserializer.readSortValueFromProtobuf(searchSortValues.getFormattedSortValues(i)); } Object[] rawSortValues = new Object[searchSortValues.getRawSortValuesCount()]; for (int i = 0; i < searchSortValues.getRawSortValuesCount(); i++) { - rawSortValues[i] = SearchHitsProtobufSerializer.readSortValueFromProtobuf(searchSortValues.getRawSortValues(i)); + rawSortValues[i] = SearchHitsProtobufDeserializer.readSortValueFromProtobuf(searchSortValues.getRawSortValues(i)); } return new SearchSortValues(formattedSortValues, rawSortValues); } diff --git a/server/src/main/java/org/opensearch/search/serializer/protobuf/package-info.java b/server/src/main/java/org/opensearch/search/serializer/protobuf/package-info.java new file mode 100644 index 0000000000000..6a1a564bf2664 --- /dev/null +++ b/server/src/main/java/org/opensearch/search/serializer/protobuf/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. + */ + +/** Protobuf serializer package for search. */ +package org.opensearch.search.serializer.protobuf;