From 117572c7b8d71992af4416b4b33e3647936c6ce3 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Tue, 26 Mar 2024 18:25:47 +0000 Subject: [PATCH] Fixing precommit Signed-off-by: Vacha Shah --- .../core/common/io/stream/BytesWriteable.java | 5 ----- .../common/document/DocumentField.java | 13 ------------- .../DocumentFieldProtobufSerializer.java | 18 +++++++++++++----- .../serializer/DocumentFieldSerializer.java | 8 +++----- .../document/serializer/package-info.java | 10 ++++++++++ .../HighlightFieldProtobufSerializer.java | 10 ++++------ .../serializer/HighlightFieldSerializer.java | 13 +++++-------- .../highlight/serializer/package-info.java | 10 ++++++++++ .../NestedIdentityProtobufSerializer.java | 8 +++----- .../serializer/NestedIdentitySerializer.java | 8 +++----- .../SearchHitProtobufSerializer.java | 13 +++++++------ .../search/serializer/SearchHitSerializer.java | 8 +++----- .../SearchHitsProtobufSerializer.java | 8 +++----- .../serializer/SearchHitsSerializer.java | 8 +++----- .../SearchSortValuesProtobufSerializer.java | 8 +++----- .../serializer/SearchSortValuesSerializer.java | 8 +++----- .../search/serializer/package-info.java | 10 ++++++++++ .../transport/ProtobufMessageHandler.java | 5 ----- .../proto/server/NodeToNodeMessageProto.proto | 3 --- .../server/search/FetchSearchResultProto.proto | 3 --- .../search/QueryFetchSearchResultProto.proto | 3 --- .../server/search/QuerySearchResultProto.proto | 3 --- .../search/ShardSearchRequestProto.proto | 3 --- 23 files changed, 83 insertions(+), 103 deletions(-) create mode 100644 server/src/main/java/org/opensearch/common/document/serializer/package-info.java create mode 100644 server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/package-info.java create mode 100644 server/src/main/java/org/opensearch/search/serializer/package-info.java diff --git a/libs/core/src/main/java/org/opensearch/core/common/io/stream/BytesWriteable.java b/libs/core/src/main/java/org/opensearch/core/common/io/stream/BytesWriteable.java index 001af4e672b1d..8b4f9a6aaf6ef 100644 --- a/libs/core/src/main/java/org/opensearch/core/common/io/stream/BytesWriteable.java +++ b/libs/core/src/main/java/org/opensearch/core/common/io/stream/BytesWriteable.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.core.common.io.stream; import org.opensearch.common.annotation.ExperimentalApi; diff --git a/server/src/main/java/org/opensearch/common/document/DocumentField.java b/server/src/main/java/org/opensearch/common/document/DocumentField.java index 383648e175dc0..5cdc2bba8be16 100644 --- a/server/src/main/java/org/opensearch/common/document/DocumentField.java +++ b/server/src/main/java/org/opensearch/common/document/DocumentField.java @@ -33,7 +33,6 @@ package org.opensearch.common.document; import org.opensearch.common.annotation.PublicApi; -import org.opensearch.common.document.serializer.DocumentFieldProtobufSerializer; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; @@ -42,7 +41,6 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.get.GetResult; import org.opensearch.search.SearchHit; -import org.opensearch.server.proto.FetchSearchResultProto; import java.io.IOException; import java.util.ArrayList; @@ -66,7 +64,6 @@ public class DocumentField implements Writeable, ToXContentFragment, Iterable values; - private FetchSearchResultProto.SearchHit.DocumentField documentField; public DocumentField(StreamInput in) throws IOException { name = in.readString(); @@ -78,16 +75,6 @@ public DocumentField(String name, List values) { this.values = Objects.requireNonNull(values, "values must not be null"); } - public static FetchSearchResultProto.SearchHit.DocumentField convertDocumentFieldToProto(DocumentField documentField) { - FetchSearchResultProto.SearchHit.DocumentField.Builder builder = FetchSearchResultProto.SearchHit.DocumentField.newBuilder(); - builder.setName(documentField.getName()); - for (Object value : documentField.getValues()) { - FetchSearchResultProto.DocumentFieldValue.Builder valueBuilder = FetchSearchResultProto.DocumentFieldValue.newBuilder(); - builder.addValues(DocumentFieldProtobufSerializer.convertDocumentFieldValueToProto(value, valueBuilder)); - } - return builder.build(); - } - /** * The name of the field. */ diff --git a/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldProtobufSerializer.java b/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldProtobufSerializer.java index 614837ce7c9d3..e606773d07826 100644 --- a/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldProtobufSerializer.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.common.document.serializer; import com.google.protobuf.ByteString; @@ -33,6 +28,9 @@ import java.util.List; import java.util.Map; +/** + * Serializer for {@link DocumentField} to/from protobuf. + */ public class DocumentFieldProtobufSerializer implements DocumentFieldSerializer { private FetchSearchResultProto.SearchHit.DocumentField documentField; @@ -132,4 +130,14 @@ public static DocumentFieldValue.Builder convertDocumentFieldValueToProto(Object return valueBuilder; } + public static FetchSearchResultProto.SearchHit.DocumentField convertDocumentFieldToProto(DocumentField documentField) { + FetchSearchResultProto.SearchHit.DocumentField.Builder builder = FetchSearchResultProto.SearchHit.DocumentField.newBuilder(); + builder.setName(documentField.getName()); + for (Object value : documentField.getValues()) { + FetchSearchResultProto.DocumentFieldValue.Builder valueBuilder = FetchSearchResultProto.DocumentFieldValue.newBuilder(); + builder.addValues(DocumentFieldProtobufSerializer.convertDocumentFieldValueToProto(value, valueBuilder)); + } + return builder.build(); + } + } diff --git a/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldSerializer.java b/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldSerializer.java index 04d0b5a81bcf6..48916c4b87b51 100644 --- a/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldSerializer.java +++ b/server/src/main/java/org/opensearch/common/document/serializer/DocumentFieldSerializer.java @@ -6,17 +6,15 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.common.document.serializer; import org.opensearch.common.document.DocumentField; import java.io.IOException; +/** + * Serializer for {@link DocumentField} which can be implemented for different types of serialization. + */ public interface DocumentFieldSerializer { DocumentField createDocumentField(T inputStream) throws IOException; diff --git a/server/src/main/java/org/opensearch/common/document/serializer/package-info.java b/server/src/main/java/org/opensearch/common/document/serializer/package-info.java new file mode 100644 index 0000000000000..e8419ac59bb03 --- /dev/null +++ b/server/src/main/java/org/opensearch/common/document/serializer/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. + */ + +/** Serializer package for documents. */ +package org.opensearch.common.document.serializer; 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/HighlightFieldProtobufSerializer.java index dbf9ac5ac48ee..74557d5618ce0 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/HighlightFieldProtobufSerializer.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.fetch.subphase.highlight.serializer; import org.opensearch.core.common.text.Text; @@ -22,7 +17,10 @@ import java.util.ArrayList; import java.util.List; -public class HighlightFieldProtobufSerializer implements HighlightFieldSerializer { +/** + * Serializer for {@link HighlightField} to/from protobuf. + */ +public class HighlightFieldProtobufSerializer implements HighlightFieldSerializer { @Override public HighlightField createHighLightField(InputStream inputStream) throws IOException { 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/HighlightFieldSerializer.java index d62016969885d..21a6afdac565f 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/HighlightFieldSerializer.java @@ -6,19 +6,16 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.fetch.subphase.highlight.serializer; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import java.io.IOException; -import java.io.InputStream; -public interface HighlightFieldSerializer { +/** + * Serializer for {@link HighlightField} which can be implemented for different types of serialization. + */ +public interface HighlightFieldSerializer { - HighlightField createHighLightField(InputStream inputStream) throws IOException; + HighlightField createHighLightField(T inputStream) throws IOException; } diff --git a/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/package-info.java b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/package-info.java new file mode 100644 index 0000000000000..dc08282a8954f --- /dev/null +++ b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/serializer/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. + */ + +/** Serializer package for highlights. */ +package org.opensearch.search.fetch.subphase.highlight.serializer; diff --git a/server/src/main/java/org/opensearch/search/serializer/NestedIdentityProtobufSerializer.java b/server/src/main/java/org/opensearch/search/serializer/NestedIdentityProtobufSerializer.java index fc6902193af84..0e1081c9cc8d8 100644 --- a/server/src/main/java/org/opensearch/search/serializer/NestedIdentityProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/NestedIdentityProtobufSerializer.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.serializer; import org.opensearch.search.SearchHit.NestedIdentity; @@ -20,6 +15,9 @@ import java.io.IOException; import java.io.InputStream; +/** + * Serializer for {@link NestedIdentity} to/from protobuf. + */ public class NestedIdentityProtobufSerializer implements NestedIdentitySerializer { @Override diff --git a/server/src/main/java/org/opensearch/search/serializer/NestedIdentitySerializer.java b/server/src/main/java/org/opensearch/search/serializer/NestedIdentitySerializer.java index 7631fc61b28c7..5ee30337bb4b6 100644 --- a/server/src/main/java/org/opensearch/search/serializer/NestedIdentitySerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/NestedIdentitySerializer.java @@ -6,17 +6,15 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.serializer; import org.opensearch.search.SearchHit.NestedIdentity; import java.io.IOException; +/** + * Serializer for {@link NestedIdentity} which can be implemented for different types of serialization. + */ public interface NestedIdentitySerializer { public NestedIdentity createNestedIdentity(T inputStream) throws IOException, Exception; diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchHitProtobufSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchHitProtobufSerializer.java index 78e2f76e6a8d1..e06e31bee249f 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchHitProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchHitProtobufSerializer.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.serializer; import com.google.protobuf.ByteString; @@ -40,6 +35,9 @@ import java.util.Map; import java.util.stream.Collectors; +/** + * Serializer for {@link SearchHit} to/from protobuf. + */ public class SearchHitProtobufSerializer implements SearchHitSerializer { private FetchSearchResultProto.SearchHit searchHitProto; @@ -171,7 +169,10 @@ public static FetchSearchResultProto.SearchHit convertHitToProto(SearchHit hit) searchHitBuilder.setSource(ByteString.copyFrom(hit.getSourceRef().toBytesRef().bytes)); } for (Map.Entry entry : hit.getFields().entrySet()) { - searchHitBuilder.putDocumentFields(entry.getKey(), DocumentField.convertDocumentFieldToProto(entry.getValue())); + searchHitBuilder.putDocumentFields( + entry.getKey(), + DocumentFieldProtobufSerializer.convertDocumentFieldToProto(entry.getValue()) + ); } return searchHitBuilder.build(); } diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchHitSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchHitSerializer.java index 0f66eeb9d03da..217266f720079 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchHitSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchHitSerializer.java @@ -6,17 +6,15 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.serializer; import org.opensearch.search.SearchHit; import java.io.IOException; +/** + * Serializer for {@link SearchHit} which can be implemented for different types of serialization. + */ public interface SearchHitSerializer { SearchHit createSearchHit(T inputStream) throws IOException; diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchHitsProtobufSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchHitsProtobufSerializer.java index b61fc194200b5..d32043d9caa49 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchHitsProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchHitsProtobufSerializer.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.serializer; import com.google.protobuf.ByteString; @@ -31,6 +26,9 @@ import java.util.ArrayList; import java.util.List; +/** + * Serializer for {@link SearchHits} to/from protobuf. + */ public class SearchHitsProtobufSerializer implements SearchHitsSerializer { private FetchSearchResultProto.SearchHits searchHitsProto; diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchHitsSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchHitsSerializer.java index f61af18682627..f09e369aaeee1 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchHitsSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchHitsSerializer.java @@ -6,17 +6,15 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.serializer; import org.opensearch.search.SearchHits; import java.io.IOException; +/** + * Serializer for {@link SearchHits} which can be implemented for different types of serialization. + */ public interface SearchHitsSerializer { SearchHits createSearchHits(T inputStream) throws IOException; diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesProtobufSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesProtobufSerializer.java index dec522ba4a7ef..007e951cbf10a 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesProtobufSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesProtobufSerializer.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.serializer; import org.opensearch.search.SearchSortValues; @@ -19,6 +14,9 @@ import java.io.IOException; import java.io.InputStream; +/** + * Serializer for {@link SearchSortValues} to/from protobuf. + */ public class SearchSortValuesProtobufSerializer implements SearchSortValuesSerializer { @Override diff --git a/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesSerializer.java b/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesSerializer.java index 6a9a23700635d..31feb206eb74d 100644 --- a/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesSerializer.java +++ b/server/src/main/java/org/opensearch/search/serializer/SearchSortValuesSerializer.java @@ -6,17 +6,15 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.search.serializer; import org.opensearch.search.SearchSortValues; import java.io.IOException; +/** + * Serializer for {@link SearchSortValues} which can be implemented for different types of serialization. + */ public interface SearchSortValuesSerializer { SearchSortValues createSearchSortValues(T inputStream) throws IOException; diff --git a/server/src/main/java/org/opensearch/search/serializer/package-info.java b/server/src/main/java/org/opensearch/search/serializer/package-info.java new file mode 100644 index 0000000000000..25a4d1935016e --- /dev/null +++ b/server/src/main/java/org/opensearch/search/serializer/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. + */ + +/** Serializer package for search. */ +package org.opensearch.search.serializer; diff --git a/server/src/main/java/org/opensearch/transport/ProtobufMessageHandler.java b/server/src/main/java/org/opensearch/transport/ProtobufMessageHandler.java index d3262f4d3e5c4..3aa8be4d094e2 100644 --- a/server/src/main/java/org/opensearch/transport/ProtobufMessageHandler.java +++ b/server/src/main/java/org/opensearch/transport/ProtobufMessageHandler.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.transport; import org.apache.logging.log4j.LogManager; diff --git a/server/src/main/proto/server/NodeToNodeMessageProto.proto b/server/src/main/proto/server/NodeToNodeMessageProto.proto index e0d46bac94216..e83143202dce7 100644 --- a/server/src/main/proto/server/NodeToNodeMessageProto.proto +++ b/server/src/main/proto/server/NodeToNodeMessageProto.proto @@ -4,9 +4,6 @@ * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. */ syntax = "proto3"; diff --git a/server/src/main/proto/server/search/FetchSearchResultProto.proto b/server/src/main/proto/server/search/FetchSearchResultProto.proto index 88f306d31a173..f0f4f495ad179 100644 --- a/server/src/main/proto/server/search/FetchSearchResultProto.proto +++ b/server/src/main/proto/server/search/FetchSearchResultProto.proto @@ -4,9 +4,6 @@ * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. */ syntax = "proto3"; diff --git a/server/src/main/proto/server/search/QueryFetchSearchResultProto.proto b/server/src/main/proto/server/search/QueryFetchSearchResultProto.proto index 08d7d9941022c..deac135c0e3d0 100644 --- a/server/src/main/proto/server/search/QueryFetchSearchResultProto.proto +++ b/server/src/main/proto/server/search/QueryFetchSearchResultProto.proto @@ -4,9 +4,6 @@ * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. */ syntax = "proto3"; diff --git a/server/src/main/proto/server/search/QuerySearchResultProto.proto b/server/src/main/proto/server/search/QuerySearchResultProto.proto index 32ed57d4d9063..e4fc82207042c 100644 --- a/server/src/main/proto/server/search/QuerySearchResultProto.proto +++ b/server/src/main/proto/server/search/QuerySearchResultProto.proto @@ -4,9 +4,6 @@ * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. */ syntax = "proto3"; diff --git a/server/src/main/proto/server/search/ShardSearchRequestProto.proto b/server/src/main/proto/server/search/ShardSearchRequestProto.proto index 0975a96d77167..114e9154ee5d9 100644 --- a/server/src/main/proto/server/search/ShardSearchRequestProto.proto +++ b/server/src/main/proto/server/search/ShardSearchRequestProto.proto @@ -4,9 +4,6 @@ * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. */ syntax = "proto3";