Skip to content

Commit f89c72b

Browse files
committed
add clarifying (hopefully) docs regarding the writerWithOffset
1 parent f1643d2 commit f89c72b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,19 @@ public void maybeFetchRange(
660660
}
661661
}
662662

663+
/**
664+
* Wraps the given {@link RangeMissingHandler} to adjust the position of the data read from the blob store
665+
* (NB: the relativePos parameter in {@link RangeMissingHandler#fillCacheRange(SharedBytes.IO, int, SourceInputStreamFactory, int, int, IntConsumer, ActionListener)})
666+
* relative to the beginning of the region we're reading from.
667+
*
668+
* This is useful so that we can read the input stream we open for reading from the blob store
669+
* from the beginning (i.e. position 0 <b>in the input stream</b>).
670+
*
671+
* For example, if we want to read 2000 bytes the blob store starting at position 1000, the writer here will
672+
* adjust the relative position we read to be 0, the offset being 1000, and the input stream we open to
673+
* read from the blob store will start streaming from position 1000 (but we adjusted the relative read position
674+
* to 0 so we consume the input stream from the beginning).
675+
*/
663676
private RangeMissingHandler writerWithOffset(RangeMissingHandler writer, int writeOffset) {
664677
if (writeOffset == 0) {
665678
// no need to allocate a new capturing lambda if the offset isn't adjusted

0 commit comments

Comments
 (0)