8
8
import lombok .Builder ;
9
9
import lombok .Getter ;
10
10
import lombok .Setter ;
11
+ import org .opensearch .Version ;
11
12
import org .opensearch .core .common .io .stream .StreamInput ;
12
13
import org .opensearch .core .common .io .stream .StreamOutput ;
14
+ import org .opensearch .ml .common .CommonValue ;
13
15
import org .opensearch .ml .common .connector .ConnectorAction .ActionType ;
14
16
import org .opensearch .ml .common .annotation .InputDataSet ;
15
17
import org .opensearch .ml .common .dataset .MLInputDataType ;
21
23
@ Getter
22
24
@ InputDataSet (MLInputDataType .REMOTE )
23
25
public class RemoteInferenceInputDataSet extends MLInputDataset {
24
-
26
+ private static final Version MINIMAL_SUPPORTED_VERSION_FOR_CLIENT_CONFIG = CommonValue . VERSION_2_16_0 ;
25
27
@ Setter
26
28
private Map <String , String > parameters ;
27
29
@ Setter
@@ -40,30 +42,36 @@ public RemoteInferenceInputDataSet(Map<String, String> parameters) {
40
42
41
43
public RemoteInferenceInputDataSet (StreamInput streamInput ) throws IOException {
42
44
super (MLInputDataType .REMOTE );
45
+ Version streamInputVersion = streamInput .getVersion ();
43
46
if (streamInput .readBoolean ()) {
44
47
parameters = streamInput .readMap (s -> s .readString (), s -> s .readString ());
45
48
}
46
- if (streamInput .readBoolean ()) {
47
- actionType = streamInput .readEnum (ActionType .class );
48
- } else {
49
- this .actionType = null ;
49
+ if (streamInputVersion .onOrAfter (MINIMAL_SUPPORTED_VERSION_FOR_CLIENT_CONFIG )) {
50
+ if (streamInput .readBoolean ()) {
51
+ actionType = streamInput .readEnum (ActionType .class );
52
+ } else {
53
+ this .actionType = null ;
54
+ }
50
55
}
51
56
}
52
57
53
58
@ Override
54
59
public void writeTo (StreamOutput streamOutput ) throws IOException {
55
60
super .writeTo (streamOutput );
61
+ Version streamOutputVersion = streamOutput .getVersion ();
56
62
if (parameters != null ) {
57
63
streamOutput .writeBoolean (true );
58
64
streamOutput .writeMap (parameters , StreamOutput ::writeString , StreamOutput ::writeString );
59
65
} else {
60
66
streamOutput .writeBoolean (false );
61
67
}
62
- if (actionType != null ) {
63
- streamOutput .writeBoolean (true );
64
- streamOutput .writeEnum (actionType );
65
- } else {
66
- streamOutput .writeBoolean (false );
68
+ if (streamOutputVersion .onOrAfter (MINIMAL_SUPPORTED_VERSION_FOR_CLIENT_CONFIG )) {
69
+ if (actionType != null ) {
70
+ streamOutput .writeBoolean (true );
71
+ streamOutput .writeEnum (actionType );
72
+ } else {
73
+ streamOutput .writeBoolean (false );
74
+ }
67
75
}
68
76
}
69
77
0 commit comments