Skip to content

Commit 1a98708

Browse files
committed
fix floating javadocs, add null checks, restrict public method visiblity, add more javadocs
Signed-off-by: Karen Xu <[email protected]>
1 parent 148f712 commit 1a98708

36 files changed

+207
-139
lines changed

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/common/FetchSourceContextProtoUtils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ private FetchSourceContextProtoUtils() {
3434
* Converts a SourceConfig Protocol Buffer to a FetchSourceContext object.
3535
* Similar to {@link FetchSourceContext#parseFromRestRequest(RestRequest)}
3636
*
37-
* @param request
38-
* @return
37+
* @param request The BulkRequest Protocol Buffer containing source configuration
38+
* @return A FetchSourceContext object based on the request parameters, or null if no source parameters are provided
3939
*/
4040
public static FetchSourceContext parseFromProtoRequest(org.opensearch.protobufs.BulkRequest request) {
4141
Boolean fetchSource = true;
@@ -70,9 +70,11 @@ public static FetchSourceContext parseFromProtoRequest(org.opensearch.protobufs.
7070
}
7171

7272
/**
73+
* Converts a SourceConfig Protocol Buffer to a FetchSourceContext object.
7374
* Similar to {@link FetchSourceContext#parseFromRestRequest(RestRequest)}
74-
* @param request
75-
* @return
75+
*
76+
* @param request The SearchRequest Protocol Buffer containing source configuration
77+
* @return A FetchSourceContext object based on the request parameters, or null if no source parameters are provided
7678
*/
7779
public static FetchSourceContext parseFromProtoRequest(org.opensearch.protobufs.SearchRequest request) {
7880
Boolean fetchSource = null;

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/common/ScriptProtoUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static Script parseFromProtoRequest(org.opensearch.protobufs.Script scrip
5353
* @param defaultLang the default script language to use if not specified
5454
* @return the converted Script object
5555
*/
56-
public static Script parseFromProtoRequest(org.opensearch.protobufs.Script script, String defaultLang) {
56+
private static Script parseFromProtoRequest(org.opensearch.protobufs.Script script, String defaultLang) {
5757
Objects.requireNonNull(defaultLang);
5858

5959
if (script.hasInlineScript()) {

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/document/bulk/ActiveShardCountProtoUtils.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
import org.opensearch.protobufs.WaitForActiveShards;
1414

1515
/**
16-
* Handler for bulk requests in gRPC.
16+
* Utility class for handling active shard count settings in gRPC bulk requests.
17+
* This class provides methods to convert between Protocol Buffer representations
18+
* and OpenSearch ActiveShardCount objects.
1719
*/
1820
public class ActiveShardCountProtoUtils {
1921
// protected final Settings settings;
@@ -27,11 +29,13 @@ protected ActiveShardCountProtoUtils() {
2729

2830
/**
2931
* Sets the active shard count on the bulk request based on the protobuf request.
30-
* Similar to {@link ActiveShardCount#parseString(String)}
32+
* Similar to {@link ActiveShardCount#parseString(String)}, this method interprets
33+
* the wait_for_active_shards parameter from the Protocol Buffer request and applies
34+
* the appropriate ActiveShardCount setting to the OpenSearch bulk request.
3135
*
32-
* @param bulkRequest The bulk request to modify
33-
* @param request The protobuf request containing the active shard count
34-
* @return The modified bulk request
36+
* @param bulkRequest The OpenSearch bulk request to modify
37+
* @param request The Protocol Buffer request containing the active shard count settings
38+
* @return The modified OpenSearch bulk request with updated active shard count settings
3539
*/
3640
public static org.opensearch.action.bulk.BulkRequest getActiveShardCount(
3741
org.opensearch.action.bulk.BulkRequest bulkRequest,

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/search/CollapseBuilderProtoUtils.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
import java.io.IOException;
1515

1616
/**
17-
* Utility class for converting CollapseBuilder Protocol Buffers to objects
18-
*
17+
* Utility class for converting CollapseBuilder Protocol Buffers to OpenSearch objects.
18+
* This class provides methods to transform Protocol Buffer representations of field collapse
19+
* specifications into their corresponding OpenSearch CollapseBuilder implementations for
20+
* search result field collapsing and grouping.
1921
*/
2022
public class CollapseBuilderProtoUtils {
2123

@@ -24,12 +26,17 @@ private CollapseBuilderProtoUtils() {
2426
}
2527

2628
/**
27-
* Similar to {@link CollapseBuilder#fromXContent(XContentParser)}
29+
* Converts a Protocol Buffer FieldCollapse to an OpenSearch CollapseBuilder.
30+
* Similar to {@link CollapseBuilder#fromXContent(XContentParser)}, this method
31+
* parses the Protocol Buffer representation and creates a properly configured
32+
* CollapseBuilder with the appropriate field, max concurrent group searches,
33+
* and inner hits settings.
2834
*
29-
* @param collapseProto
35+
* @param collapseProto The Protocol Buffer FieldCollapse to convert
36+
* @return A configured CollapseBuilder instance
37+
* @throws IOException if there's an error during parsing or conversion
3038
*/
31-
32-
public static CollapseBuilder fromProto(FieldCollapse collapseProto) throws IOException {
39+
protected static CollapseBuilder fromProto(FieldCollapse collapseProto) throws IOException {
3340
CollapseBuilder collapseBuilder = new CollapseBuilder(collapseProto.getField());
3441

3542
if (collapseProto.hasMaxConcurrentGroupSearches()) {
@@ -41,5 +48,4 @@ public static CollapseBuilder fromProto(FieldCollapse collapseProto) throws IOEx
4148

4249
return collapseBuilder;
4350
}
44-
4551
}

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/search/FieldAndFormatProtoUtils.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
import org.opensearch.search.fetch.subphase.FieldAndFormat;
1212

1313
/**
14-
* Utility class for converting SearchSourceBuilder Protocol Buffers to objects
15-
*
14+
* Utility class for converting FieldAndFormat Protocol Buffers to OpenSearch objects.
15+
* This class provides methods to transform Protocol Buffer representations of field and format
16+
* specifications into their corresponding OpenSearch FieldAndFormat implementations for search operations.
1617
*/
1718
public class FieldAndFormatProtoUtils {
1819

@@ -21,12 +22,15 @@ private FieldAndFormatProtoUtils() {
2122
}
2223

2324
/**
24-
* Similar to {@link FieldAndFormat#fromXContent(XContentParser)}
25+
* Converts a Protocol Buffer FieldAndFormat to an OpenSearch FieldAndFormat object.
26+
* Similar to {@link FieldAndFormat#fromXContent(XContentParser)}, this method
27+
* parses the Protocol Buffer representation and creates a properly configured
28+
* FieldAndFormat with the appropriate field name and format settings.
2529
*
26-
* @param fieldAndFormatProto
30+
* @param fieldAndFormatProto The Protocol Buffer FieldAndFormat to convert
31+
* @return A configured FieldAndFormat instance
2732
*/
28-
29-
public static FieldAndFormat fromProto(org.opensearch.protobufs.FieldAndFormat fieldAndFormatProto) {
33+
protected static FieldAndFormat fromProto(org.opensearch.protobufs.FieldAndFormat fieldAndFormatProto) {
3034

3135
// TODO how is this field used?
3236
// fieldAndFormatProto.getIncludeUnmapped();

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/search/HighlightBuilderProtoUtils.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
import org.opensearch.search.fetch.subphase.highlight.HighlightBuilder;
1313

1414
/**
15-
* Utility class for converting Highlight Protocol Buffers to objects
16-
*
15+
* Utility class for converting Highlight Protocol Buffers to OpenSearch objects.
16+
* This class provides methods to transform Protocol Buffer representations of highlights
17+
* into their corresponding OpenSearch HighlightBuilder implementations for search result highlighting.
1718
*/
1819
public class HighlightBuilderProtoUtils {
1920

@@ -22,12 +23,16 @@ private HighlightBuilderProtoUtils() {
2223
}
2324

2425
/**
25-
* Similar to {@link HighlightBuilder#fromXContent(XContentParser)}
26+
* Converts a Protocol Buffer Highlight to an OpenSearch HighlightBuilder.
27+
* Similar to {@link HighlightBuilder#fromXContent(XContentParser)}, this method
28+
* would parse the Protocol Buffer representation and create a properly configured
29+
* HighlightBuilder with the appropriate settings.
2630
*
27-
* @param highlightProto
31+
* @param highlightProto The Protocol Buffer Highlight to convert
32+
* @return A configured HighlightBuilder instance
33+
* @throws UnsupportedOperationException as highlight functionality is not yet implemented
2834
*/
29-
30-
public static HighlightBuilder fromProto(Highlight highlightProto) {
35+
protected static HighlightBuilder fromProto(Highlight highlightProto) {
3136

3237
throw new UnsupportedOperationException("highlight not supported yet");
3338

@@ -36,7 +41,5 @@ public static HighlightBuilder fromProto(Highlight highlightProto) {
3641
// TODO populate highlightBuilder
3742
return highlightBuilder;
3843
*/
39-
4044
}
41-
4245
}

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/search/IndicesOptionsProtoUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private IndicesOptionsProtoUtils() {
3939
* @param defaultSettings the default IndicesOptions to use if not specified in the request
4040
* @return the IndicesOptions based on the request parameters
4141
*/
42-
public static IndicesOptions fromRequest(org.opensearch.protobufs.SearchRequest request, IndicesOptions defaultSettings) {
42+
protected static IndicesOptions fromRequest(org.opensearch.protobufs.SearchRequest request, IndicesOptions defaultSettings) {
4343
return fromProtoParameters(request, defaultSettings);
4444
}
4545

@@ -51,7 +51,7 @@ public static IndicesOptions fromRequest(org.opensearch.protobufs.SearchRequest
5151
* @param defaultSettings the default IndicesOptions to use if not specified in the request
5252
* @return the IndicesOptions based on the request parameters
5353
*/
54-
public static IndicesOptions fromProtoParameters(SearchRequest request, IndicesOptions defaultSettings) {
54+
protected static IndicesOptions fromProtoParameters(SearchRequest request, IndicesOptions defaultSettings) {
5555
if (!(request.getExpandWildcardsCount() > 0)
5656
&& !request.hasIgnoreUnavailable()
5757
&& !request.hasAllowNoIndices()
@@ -87,7 +87,7 @@ public static IndicesOptions fromProtoParameters(SearchRequest request, IndicesO
8787
* @param defaultStates the default WildcardStates to use if the list is empty
8888
* @return an EnumSet of WildcardStates based on the provided wildcardList
8989
*/
90-
public static EnumSet<IndicesOptions.WildcardStates> parseProtoParameter(
90+
protected static EnumSet<IndicesOptions.WildcardStates> parseProtoParameter(
9191
List<SearchRequest.ExpandWildcard> wildcardList,
9292
EnumSet<IndicesOptions.WildcardStates> defaultStates
9393
) {
@@ -110,7 +110,7 @@ public static EnumSet<IndicesOptions.WildcardStates> parseProtoParameter(
110110
* @param states the EnumSet of WildcardStates to update
111111
* @param wildcard the ExpandWildcard value to use for updating the states
112112
*/
113-
public static void updateSetForValue(EnumSet<IndicesOptions.WildcardStates> states, SearchRequest.ExpandWildcard wildcard) {
113+
protected static void updateSetForValue(EnumSet<IndicesOptions.WildcardStates> states, SearchRequest.ExpandWildcard wildcard) {
114114
switch (wildcard) {
115115
case EXPAND_WILDCARD_OPEN:
116116
states.add(OPEN);

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/search/InnerHitsBuilderProtoUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ private InnerHitsBuilderProtoUtils() {
3939
* @param innerHits
4040
* @throws IOException if there's an error during parsing
4141
*/
42-
43-
public static InnerHitBuilder fromProto(List<InnerHits> innerHits) throws IOException {
42+
protected static InnerHitBuilder fromProto(List<InnerHits> innerHits) throws IOException {
4443
InnerHitBuilder innerHitBuilder = new InnerHitBuilder();
4544

4645
for (InnerHits innerHit : innerHits) {

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/search/OperatorProtoUtils.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
package org.opensearch.plugin.transport.grpc.proto.request.search;
1010

11-
import org.apache.logging.log4j.LogManager;
12-
import org.apache.logging.log4j.Logger;
1311
import org.opensearch.index.query.Operator;
1412

1513
/**
@@ -18,11 +16,6 @@
1816
* in search operations.
1917
*/
2018
public class OperatorProtoUtils {
21-
/**
22-
* Logger for the OperatorProtoUtils class.
23-
*/
24-
protected static Logger logger = LogManager.getLogger(OperatorProtoUtils.class);
25-
2619
private OperatorProtoUtils() {
2720
// Utility class, no instances
2821
}
@@ -33,8 +26,7 @@ private OperatorProtoUtils() {
3326
* @param op
3427
* @return
3528
*/
36-
37-
public static Operator fromEnum(org.opensearch.protobufs.SearchRequest.Operator op) {
29+
protected static Operator fromEnum(org.opensearch.protobufs.SearchRequest.Operator op) {
3830
switch (op) {
3931
case OPERATOR_AND:
4032
return Operator.AND;

plugins/transport-grpc/src/main/java/org/opensearch/plugin/transport/grpc/proto/request/search/PointInTimeBuilderProtoUtils.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import static org.opensearch.search.builder.SearchSourceBuilder.POINT_IN_TIME;
1616

1717
/**
18-
* Utility class for converting SearchSourceBuilder Protocol Buffers to objects
19-
*
18+
* Utility class for converting PointInTimeBuilder Protocol Buffers to OpenSearch objects.
19+
* This class provides methods to transform Protocol Buffer representations of point-in-time
20+
* references into their corresponding OpenSearch PointInTimeBuilder implementations for
21+
* search operations with consistent snapshots.
2022
*/
2123
public class PointInTimeBuilderProtoUtils {
2224

@@ -25,12 +27,15 @@ private PointInTimeBuilderProtoUtils() {
2527
}
2628

2729
/**
28-
* Similar to {@link PointInTimeBuilder#fromXContent(XContentParser)}
30+
* Converts a Protocol Buffer PointInTimeReference to an OpenSearch PointInTimeBuilder.
31+
* Similar to {@link PointInTimeBuilder#fromXContent(XContentParser)}, this method
32+
* parses the Protocol Buffer representation and creates a properly configured
33+
* PointInTimeBuilder with the appropriate ID and keep-alive settings.
2934
*
30-
* @param pointInTime
35+
* @param pointInTime The Protocol Buffer PointInTimeReference to convert
36+
* @return A configured PointInTimeBuilder instance
3137
*/
32-
33-
public static PointInTimeBuilder fromProto(PointInTimeReference pointInTime) {
38+
protected static PointInTimeBuilder fromProto(PointInTimeReference pointInTime) {
3439

3540
TimeValue keepAlive = TimeValue.parseTimeValue(pointInTime.getKeepAlive(), null, POINT_IN_TIME.getPreferredName());
3641
return new PointInTimeBuilder(pointInTime.getId()).setKeepAlive(keepAlive);

0 commit comments

Comments
 (0)