Skip to content

Commit

Permalink
Fixing precommit
Browse files Browse the repository at this point in the history
Signed-off-by: Vacha Shah <[email protected]>
  • Loading branch information
VachaShah committed Apr 9, 2024
1 parent b7ee789 commit 117572c
Show file tree
Hide file tree
Showing 23 changed files with 83 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -66,7 +64,6 @@ public class DocumentField implements Writeable, ToXContentFragment, Iterable<Ob

private final String name;
private final List<Object> values;
private FetchSearchResultProto.SearchHit.DocumentField documentField;

public DocumentField(StreamInput in) throws IOException {
name = in.readString();
Expand All @@ -78,16 +75,6 @@ public DocumentField(String name, List<Object> 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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +28,9 @@
import java.util.List;
import java.util.Map;

/**
* Serializer for {@link DocumentField} to/from protobuf.
*/
public class DocumentFieldProtobufSerializer implements DocumentFieldSerializer<InputStream> {

private FetchSearchResultProto.SearchHit.DocumentField documentField;
Expand Down Expand Up @@ -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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {

DocumentField createDocumentField(T inputStream) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<InputStream> {

@Override
public HighlightField createHighLightField(InputStream inputStream) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {

HighlightField createHighLightField(InputStream inputStream) throws IOException;
HighlightField createHighLightField(T inputStream) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +15,9 @@
import java.io.IOException;
import java.io.InputStream;

/**
* Serializer for {@link NestedIdentity} to/from protobuf.
*/
public class NestedIdentityProtobufSerializer implements NestedIdentitySerializer<InputStream> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {

public NestedIdentity createNestedIdentity(T inputStream) throws IOException, Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<InputStream> {

private FetchSearchResultProto.SearchHit searchHitProto;
Expand Down Expand Up @@ -171,7 +169,10 @@ public static FetchSearchResultProto.SearchHit convertHitToProto(SearchHit hit)
searchHitBuilder.setSource(ByteString.copyFrom(hit.getSourceRef().toBytesRef().bytes));
}
for (Map.Entry<String, DocumentField> entry : hit.getFields().entrySet()) {
searchHitBuilder.putDocumentFields(entry.getKey(), DocumentField.convertDocumentFieldToProto(entry.getValue()));
searchHitBuilder.putDocumentFields(
entry.getKey(),
DocumentFieldProtobufSerializer.convertDocumentFieldToProto(entry.getValue())
);
}
return searchHitBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {

SearchHit createSearchHit(T inputStream) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +26,9 @@
import java.util.ArrayList;
import java.util.List;

/**
* Serializer for {@link SearchHits} to/from protobuf.
*/
public class SearchHitsProtobufSerializer implements SearchHitsSerializer<InputStream> {

private FetchSearchResultProto.SearchHits searchHitsProto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {

SearchHits createSearchHits(T inputStream) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,6 +14,9 @@
import java.io.IOException;
import java.io.InputStream;

/**
* Serializer for {@link SearchSortValues} to/from protobuf.
*/
public class SearchSortValuesProtobufSerializer implements SearchSortValuesSerializer<InputStream> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {

SearchSortValues createSearchSortValues(T inputStream) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions server/src/main/proto/server/NodeToNodeMessageProto.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading

0 comments on commit 117572c

Please sign in to comment.