public class TierSegmentReader extends Object
Modifier and Type | Class and Description |
---|---|
static class |
TierSegmentReader.NextOffsetAndBatchMetadata |
static class |
TierSegmentReader.RecordsAndNextBatchMetadata |
Constructor and Description |
---|
TierSegmentReader(String logPrefix) |
Modifier and Type | Method and Description |
---|---|
Optional<Long> |
offsetForTimestamp(CancellationContext cancellationContext,
InputStream inputStream,
long targetTimestamp,
int segmentSize)
Read the supplied input stream to find the first offset with a timestamp >= targetTimestamp
|
org.apache.kafka.common.record.RecordBatch |
readBatch(InputStream inputStream,
int segmentSize)
Reads one full batch from an InputStream.
|
TierSegmentReader.RecordsAndNextBatchMetadata |
readRecords(CancellationContext cancellationContext,
Optional<MemoryTracker.MemoryLease> lease,
InputStream inputStream,
int maxBytes,
long targetOffset,
int startBytePosition,
int segmentSize)
Loads records from a given InputStream up to maxBytes.
|
public TierSegmentReader(String logPrefix)
public TierSegmentReader.RecordsAndNextBatchMetadata readRecords(CancellationContext cancellationContext, Optional<MemoryTracker.MemoryLease> lease, InputStream inputStream, int maxBytes, long targetOffset, int startBytePosition, int segmentSize) throws IOException
In the event that maxOffset is hit, this method can return an empty buffer.
Cancellation can be triggered using the CancellationContext, and it's granularity is on the individual record batch level. That's to say, cancellation must wait for the current record batch to be parsed and loaded (or ignored) before taking effect.
IOException
public Optional<Long> offsetForTimestamp(CancellationContext cancellationContext, InputStream inputStream, long targetTimestamp, int segmentSize) throws IOException
cancellationContext
- cancellation context to allow reads of InputStream to be abortedinputStream
- InputStream for the tiered segmenttargetTimestamp
- target timestamp to lookup the offset forsegmentSize
- total size of the segment we are readingIOException
public org.apache.kafka.common.record.RecordBatch readBatch(InputStream inputStream, int segmentSize) throws IOException
Throws EOFException if either the header or full record batch cannot be read. Visible for testing.
IOException