Skip to content

Commit 6a30ba5

Browse files
committed
Use 0.8.0 protos and fix search and bulk protos
Signed-off-by: Karen Xu <karenxyr@gmail.com>
1 parent 29ca685 commit 6a30ba5

28 files changed

+190
-247
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55

66
## [Unreleased 3.x]
77
### Added
8-
- Upgrade opensearch-protobufs dependency to 0.7.0 and update transport-grpc module compatibility
8+
* Upgrade opensearch-protobufs dependency to 0.7.0 and update transport-grpc module compatibility ([#19003](https://github.com/opensearch-project/OpenSearch/issues/19003))
9+
* Upgrade opensearch-protobufs dependency to 0.8.0 and update transport-grpc module compatibility ([#19007](https://github.com/opensearch-project/OpenSearch/issues/19007))
10+
911

1012
### Changed
1113

modules/transport-grpc/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ dependencies {
3434
implementation "io.grpc:grpc-stub:${versions.grpc}"
3535
implementation "io.grpc:grpc-util:${versions.grpc}"
3636
implementation "io.perfmark:perfmark-api:0.27.0"
37-
implementation "org.opensearch:protobufs:0.7.0"
37+
implementation "org.opensearch:protobufs:0.8.0-SNAPSHOT"
3838
testImplementation project(':test:framework')
3939
}
4040

41+
repositories {
42+
maven {
43+
url = 'https://central.sonatype.com/repository/maven-snapshots/'
44+
}
45+
}
46+
4147
tasks.named("dependencyLicenses").configure {
4248
mapping from: /grpc-.*/, to: 'grpc'
4349
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public static FetchSourceContext parseFromProtoRequest(org.opensearch.protobufs.
8181
String[] sourceExcludes = null;
8282
String[] sourceIncludes = null;
8383

84-
if (request.hasSource()) {
85-
SourceConfigParam source = request.getSource();
84+
if (request.hasUnderscoreSource()) {
85+
SourceConfigParam source = request.getUnderscoreSource();
8686

8787
if (source.hasBoolValue()) {
8888
fetchSource = source.getBoolValue();
@@ -91,12 +91,12 @@ public static FetchSourceContext parseFromProtoRequest(org.opensearch.protobufs.
9191
}
9292
}
9393

94-
if (request.getSourceIncludesCount() > 0) {
95-
sourceIncludes = request.getSourceIncludesList().toArray(new String[0]);
94+
if (request.getUnderscoreSourceIncludesCount() > 0) {
95+
sourceIncludes = request.getUnderscoreSourceIncludesList().toArray(new String[0]);
9696
}
9797

98-
if (request.getSourceExcludesCount() > 0) {
99-
sourceExcludes = request.getSourceExcludesList().toArray(new String[0]);
98+
if (request.getUnderscoreSourceExcludesCount() > 0) {
99+
sourceExcludes = request.getUnderscoreSourceExcludesList().toArray(new String[0]);
100100
}
101101

102102
if (fetchSource != null || sourceIncludes != null || sourceExcludes != null) {

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/common/OpTypeProtoUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ private OpTypeProtoUtils() {
3232
*/
3333
public static DocWriteRequest.OpType fromProto(OpType opType) {
3434

35-
switch (opType.getOpTypeCase()) {
35+
switch (opType) {
3636
case OP_TYPE_CREATE:
3737
return DocWriteRequest.OpType.CREATE;
3838
case OP_TYPE_INDEX:
3939
return DocWriteRequest.OpType.INDEX;
40-
case OPTYPE_NOT_SET:
40+
case OP_TYPE_UNSPECIFIED:
4141
default:
4242
throw new UnsupportedOperationException("Invalid optype: " + opType);
4343
}

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/common/RefreshProtoUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ private RefreshProtoUtils() {
3030
* @return The corresponding OpenSearch refresh policy string value
3131
*/
3232
public static String getRefreshPolicy(org.opensearch.protobufs.Refresh refresh) {
33-
switch (refresh.getRefreshCase()) {
33+
switch (refresh) {
3434
case REFRESH_TRUE:
3535
return WriteRequest.RefreshPolicy.IMMEDIATE.getValue();
3636
case REFRESH_WAIT_FOR:
3737
return WriteRequest.RefreshPolicy.WAIT_UNTIL.getValue();
3838
case REFRESH_FALSE:
39-
case REFRESH_NOT_SET:
39+
case REFRESH_BOOLEAN:
40+
case REFRESH_UNSPECIFIED:
4041
default:
4142
return WriteRequest.RefreshPolicy.NONE.getValue();
4243
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ public static ActiveShardCount parseProto(WaitForActiveShards waitForActiveShard
3939

4040
switch (waitForActiveShards.getWaitForActiveShardsCase()) {
4141
case WAIT_FOR_ACTIVE_SHARD_OPTIONS:
42-
switch (waitForActiveShards.getWaitForActiveShardOptions().getWaitForActiveShardOptionsCase()) {
42+
switch (waitForActiveShards.getWaitForActiveShardOptions()) {
4343
case WAIT_FOR_ACTIVE_SHARD_OPTIONS_ALL:
4444
return ActiveShardCount.ALL;
45-
case NULL_VALUE:
46-
case WAITFORACTIVESHARDOPTIONS_NOT_SET:
45+
case WAIT_FOR_ACTIVE_SHARD_OPTIONS_NULL:
46+
case WAIT_FOR_ACTIVE_SHARD_OPTIONS_UNSPECIFIED:
4747
default:
4848
return ActiveShardCount.DEFAULT;
4949
}

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestParserProtoUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public static IndexRequest buildIndexRequest(
304304
.routing(routing)
305305
.version(version)
306306
.versionType(versionType)
307-
.create(opType.getOpTypeCase() == OpType.OpTypeCase.OP_TYPE_CREATE)
307+
.create(opType == OpType.OP_TYPE_CREATE)
308308
.setPipeline(pipeline)
309309
.setIfSeqNo(ifSeqNo)
310310
.setIfPrimaryTerm(ifPrimaryTerm)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ protected static IndicesOptions fromProtoParameters(SearchRequest request, Indic
8888
* @return an EnumSet of WildcardStates based on the provided wildcardList
8989
*/
9090
protected static EnumSet<IndicesOptions.WildcardStates> parseProtoParameter(
91-
List<SearchRequest.ExpandWildcard> wildcardList,
91+
List<org.opensearch.protobufs.ExpandWildcard> wildcardList,
9292
EnumSet<IndicesOptions.WildcardStates> defaultStates
9393
) {
9494
if (wildcardList.isEmpty()) {
9595
return defaultStates;
9696
}
9797

9898
EnumSet<IndicesOptions.WildcardStates> states = EnumSet.noneOf(IndicesOptions.WildcardStates.class);
99-
for (SearchRequest.ExpandWildcard wildcard : wildcardList) {
99+
for (org.opensearch.protobufs.ExpandWildcard wildcard : wildcardList) {
100100
updateSetForValue(states, wildcard);
101101
}
102102

@@ -110,7 +110,7 @@ protected 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-
protected static void updateSetForValue(EnumSet<IndicesOptions.WildcardStates> states, SearchRequest.ExpandWildcard wildcard) {
113+
protected static void updateSetForValue(EnumSet<IndicesOptions.WildcardStates> states, org.opensearch.protobufs.ExpandWildcard wildcard) {
114114
switch (wildcard) {
115115
case EXPAND_WILDCARD_OPEN:
116116
states.add(OPEN);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ protected static InnerHitBuilder fromProto(List<InnerHits> innerHits) throws IOE
7979
}
8080
if (innerHit.getFieldsCount() > 0) {
8181
List<FieldAndFormat> fieldAndFormatList = new ArrayList<>();
82-
for (org.opensearch.protobufs.FieldAndFormat fieldAndFormat : innerHit.getFieldsList()) {
83-
fieldAndFormatList.add(FieldAndFormatProtoUtils.fromProto(fieldAndFormat));
82+
for (String fieldName : innerHit.getFieldsList()) {
83+
// Convert string field names to FieldAndFormat objects
84+
fieldAndFormatList.add(new FieldAndFormat(fieldName, null));
8485
}
8586
innerHitBuilder.setFetchFields(fieldAndFormatList);
8687
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private OperatorProtoUtils() {
2626
* @param op
2727
* @return
2828
*/
29-
protected static Operator fromEnum(org.opensearch.protobufs.SearchRequest.Operator op) {
29+
protected static Operator fromEnum(org.opensearch.protobufs.Operator op) {
3030
switch (op) {
3131
case OPERATOR_AND:
3232
return Operator.AND;

0 commit comments

Comments
 (0)