Skip to content

Commit 481c579

Browse files
committed
Add TODO for min/max versioning and remove references of parser
Signed-off-by: Varun Bansal <[email protected]>
1 parent 26e922e commit 481c579

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

server/src/main/java/org/opensearch/common/io/StreamReadWriteHandler.java

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* Interface for reading/writing content streams to/from - {@link T}
1818
* @param <T> The type of content to be read/written to stream
19+
*
20+
* @opensearch.internal
1921
*/
2022
public interface StreamReadWriteHandler<T> {
2123
/**

server/src/main/java/org/opensearch/common/io/VersionedCodecStreamWrapper.java

+15-11
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@
1919
/**
2020
* Manages versioning and checksum for a stream of content.
2121
* @param <T> Type of content to be read/written
22+
*
23+
* @opensearch.internal
2224
*/
2325
public class VersionedCodecStreamWrapper<T> {
24-
// This can be updated to hold a parserFactory and get relevant parsers based on the stream versions
25-
private final StreamReadWriteHandler<T> parser;
26+
// TODO This can be updated to hold a streamReadWriteHandlerFactory and get relevant handler based on the stream versions
27+
private final StreamReadWriteHandler<T> streamReadWriteHandler;
2628
private final int currentVersion;
2729
private final String codec;
2830

2931
/**
30-
* @param parser parser to read/write stream from T
32+
* @param streamReadWriteHandler handler to read/write stream from T
3133
* @param currentVersion latest supported version of the stream
3234
* @param codec: stream codec
3335
*/
34-
public VersionedCodecStreamWrapper(StreamReadWriteHandler<T> parser, int currentVersion, String codec) {
35-
this.parser = parser;
36+
public VersionedCodecStreamWrapper(StreamReadWriteHandler<T> streamReadWriteHandler, int currentVersion, String codec) {
37+
this.streamReadWriteHandler = streamReadWriteHandler;
3638
this.currentVersion = currentVersion;
3739
this.codec = codec;
3840
}
@@ -47,7 +49,7 @@ public VersionedCodecStreamWrapper(StreamReadWriteHandler<T> parser, int current
4749
public T readStream(IndexInput indexInput) throws IOException {
4850
ChecksumIndexInput checksumIndexInput = new BufferedChecksumIndexInput(indexInput);
4951
int readStreamVersion = checkHeader(checksumIndexInput);
50-
T content = getParserForVersion(readStreamVersion).readContent(checksumIndexInput);
52+
T content = getHandlerForVersion(readStreamVersion).readContent(checksumIndexInput);
5153
checkFooter(checksumIndexInput);
5254
return content;
5355
}
@@ -59,7 +61,7 @@ public T readStream(IndexInput indexInput) throws IOException {
5961
*/
6062
public void writeStream(IndexOutput indexOutput, T content) throws IOException {
6163
this.writeHeader(indexOutput);
62-
getParserForVersion(this.currentVersion).writeContent(indexOutput, content);
64+
getHandlerForVersion(this.currentVersion).writeContent(indexOutput, content);
6365
this.writeFooter(indexOutput);
6466
}
6567

@@ -69,6 +71,7 @@ public void writeStream(IndexOutput indexOutput, T content) throws IOException {
6971
* @return header version found in the input stream
7072
*/
7173
private int checkHeader(IndexInput indexInput) throws IOException {
74+
// TODO Once versioning strategy is decided we'll add support for min/max supported versions
7275
return CodecUtil.checkHeader(indexInput, this.codec, this.currentVersion, this.currentVersion);
7376
}
7477

@@ -98,11 +101,12 @@ private void writeFooter(IndexOutput indexOutput) throws IOException {
98101
}
99102

100103
/**
101-
* Returns relevant parser for the version
104+
* Returns relevant handler for the version
102105
* @param version stream content version
103106
*/
104-
private StreamReadWriteHandler<T> getParserForVersion(int version) {
105-
// TODO implement parser factory and pick relevant parser based on version
106-
return this.parser;
107+
private StreamReadWriteHandler<T> getHandlerForVersion(int version) {
108+
// TODO implement factory and pick relevant handler based on version.
109+
// It should also take into account min and max supported versions
110+
return this.streamReadWriteHandler;
107111
}
108112
}

server/src/main/java/org/opensearch/index/store/remote/metadata/RemoteSegmentMetadata.java

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
/**
1818
* Metadata object for Remote Segment
19+
*
20+
* @opensearch.internal
1921
*/
2022
public class RemoteSegmentMetadata {
2123
/**

server/src/main/java/org/opensearch/index/store/remote/metadata/RemoteSegmentMetadataHandler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
import org.opensearch.common.io.StreamReadWriteHandler;
1616

1717
/**
18-
* Parser for {@link RemoteSegmentMetadata}
18+
* Handler for {@link RemoteSegmentMetadata}
19+
*
20+
* @opensearch.internal
1921
*/
2022
public class RemoteSegmentMetadataHandler implements StreamReadWriteHandler<RemoteSegmentMetadata> {
2123
/**

0 commit comments

Comments
 (0)