Class CountingInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.elasticsearch.xpack.esql.datasources.cache.CountingInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public final class CountingInputStream extends FilterInputStream
Wraps an InputStream and counts the bytes successfully read. Used by the line-oriented text-format readers to publish a sizeInBytes statistic for stream-only sources (bzip2, zstd-streamed) whose StorageObject.length() throws UnsupportedOperationException.

The count reflects bytes consumed from the underlying stream, including bytes pulled into a downstream buffer (e.g. BufferedReader's 8 KiB block) regardless of whether the reader subsequently propagates them. For a clean whole-file drain this equals the decompressed file size; for partial drains (the cache gate refuses the write in that case) it is an over-estimate.