Record Class FormatReadContext
- Record Components:
projectedColumns- columns to read.nullmeans "no projection info available — read every column" (backward compatibility default). An empty list means "the optimizer pruned every column" (e.g.COUNT(*)); format readers may take a fast path that skips type conversion and emits row- count-onlyPages.batchSize- target number of rows per pagerowLimit- maximum total rows to return (FormatReader.NO_LIMITfor unlimited)errorPolicy- how to handle malformed rowsfirstSplit- whether this is the first split for the file (consistent withlastSplit; format-agnostic replacement for the legacyskipFirstLineparameter)lastSplit- whether this is the last split for the file (affects trailing-record handling)recordAligned- whether the split starts at a record boundary (no leading partial record). Whenfalse, line-oriented readers may need to skip a leading partial line (e.g. bzip2 / zstd-indexed macro-splits). Whentrue, the split is known to start exactly on a record boundary (e.g. streaming-parallel chunks sliced on\n). Has no effect on the first split.readSchema- optional planner-resolved positional column layout. When non-null, format readers use it as the authoritative typed schema; whennull, readers fall back to per-file inference. Distinct fromFormatReader.withSchema(java.util.List<org.elasticsearch.xpack.esql.core.expression.Attribute>), which carries the projection. Empty list andnullboth mean "no schema"; the compact constructor collapses empty tonullso readers do one check.splitStartByte- file-global byte offset at which this split begins (i.e.FileSplit.offset()). Text readers add the bytes they consume to this anchor to emit a file-global, split-invariant start byte per record for the_rowPositionchannel (the substrate of_file.record_ref/_id).0for the whole-file (non-split) case and for columnar formats, which derive a file-global row index from their own footer/stripe metadata rather than from a byte anchor.Note: this carries the SAME VALUE as
statsBaseOffsetat every current call site, but they are distinct CONTRACTS, not one quantity:splitStartBytemay be a COMPRESSED coordinate under compressed-offset splits (COMPRESSED_OFFSET_SPLIT_KEY), whereasstatsBaseOffsetis decompressed-stream only. Stripe capture is disabled exactly where the two would diverge, so they must stay separate — a blind unification would mis-address stripes on compressed splits.maxRecordBytes- maximum bytes a single text record may occupy while split/trim code scans for a record boundary.statsBaseOffset- the DECOMPRESSED-stream byte offset of this read's first byte, used by the reader to address records to canonical stripes (ordinal = floor((statsBaseOffset + recordOffsetInRead) / statsStripeSize)). Ignored whenstatsStripeSize <= 0. Same value assplitStartByteat every current call site, but a distinct contract under compressed-offset splits (see its note).statsStripeSize- canonical-stripe grid in bytes for per-stripe stats attribution, or<= 0to disable stripe addressing (the reader then emits no stripe-addressed contributions and the warm short-circuit safe-misses). A pure stats overlay — it never affects how the read is chunked or split.statsFileFinal- whether this read reaches the file's true end (the segmentator's EOF chunk, or the segmented coordinator's trailing segment). Only the file-final read may mark its last stripe complete-on-the-right (atStripeEnd) and terminal (eof); a non-final chunk ends mid-stripe at a chunk boundary, so its trailing stripe is a partial right fragment the next chunk continues. Marking a non-final chunk's trailing stripe complete would silently undercount.statsColumnScope- how much per-stripe statistics the read harvests while it scans (row count only / row count + projected columns / row count + all file columns / nothing). Orthogonal tostatsStripeSize: the grid decides which stripe a record lands in, this decides what is summarised per stripe.nulldefaults toStripeColumnScope.PROJECTED(back-compat for call sites that predate the setting); the compact constructor collapsesnullto that default so readers do one check.informationalWarningSink- optional relay for client-visible lenient-policy warnings (seeSkipWarnings) raised while reading.nullmeans the reader should fall back to emitting warnings directly viaHeaderWarning, which is only correct when the read runs on the request/driver thread. Callers that dispatch reads to a background thread (e.g.AsyncExternalSourceOperatorFactory) must set this to a sink — typicallyAsyncExternalSourceBuffer::recordInformationalWarning, preserving these warnings' pre-existing behavior of never flipping the response'sis_partialflag (seeAsyncExternalSourceBuffer#recordWarningfor the one warning that does) — so the warning is relayed back and re-emitted on the correct thread instead of being silently dropped.
FormatReader.read(org.elasticsearch.xpack.esql.datasources.spi.StorageObject, org.elasticsearch.xpack.esql.datasources.spi.FormatReadContext) or FormatReader.readAsync(org.elasticsearch.xpack.esql.datasources.spi.StorageObject, org.elasticsearch.xpack.esql.datasources.spi.FormatReadContext, java.util.concurrent.Executor, org.elasticsearch.action.ActionListener<org.elasticsearch.compute.operator.CloseableIterator<org.elasticsearch.compute.data.Page>>) call.
Bundles all per-read execution parameters that were previously spread across 12+ method overloads.
Format-specific configuration (delimiter, encoding, etc.) lives on the reader instance via
FormatReader.withConfig(java.util.Map<java.lang.String, java.lang.Object>). Per-query optimizer hints (pushed filters) live on the reader
instance via FormatReader.withPushedFilter(java.lang.Object). This context carries only the parameters
that may vary per file or per split within a single query execution.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionFormatReadContext(List<String> projectedColumns, int batchSize, int rowLimit, ErrorPolicy errorPolicy, boolean firstSplit, boolean lastSplit, boolean recordAligned, List<Attribute> readSchema, long splitStartByte, int maxRecordBytes, long statsBaseOffset, long statsStripeSize, boolean statsFileFinal, StripeColumnScope statsColumnScope, Consumer<String> informationalWarningSink) Creates an instance of aFormatReadContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thebatchSizerecord component.static FormatReadContext.Builderbuilder()final booleanIndicates whether some other object is "equal to" this one.Returns the value of theerrorPolicyrecord component.booleanReturns the value of thefirstSplitrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of theinformationalWarningSinkrecord component.booleanReturns the value of thelastSplitrecord component.intReturns the value of themaxRecordBytesrecord component.static FormatReadContextCreates a minimal context for the common non-split case.Returns the value of theprojectedColumnsrecord component.Returns the value of thereadSchemarecord component.booleanReturns the value of therecordAlignedrecord component.introwLimit()Returns the value of therowLimitrecord component.longReturns the value of thesplitStartByterecord component.longReturns the value of thestatsBaseOffsetrecord component.Returns the value of thestatsColumnScoperecord component.booleanReturns the value of thestatsFileFinalrecord component.longReturns the value of thestatsStripeSizerecord component.final StringtoString()Returns a string representation of this record class.withErrorPolicy(ErrorPolicy policy) Returns a copy with a different error policy.withRowLimit(int limit) Returns a copy with a different row limit.withSplit(boolean first, boolean last) Returns a copy configured for a split-based read.
-
Constructor Details
-
FormatReadContext
public FormatReadContext(List<String> projectedColumns, int batchSize, int rowLimit, ErrorPolicy errorPolicy, boolean firstSplit, boolean lastSplit, boolean recordAligned, @Nullable List<Attribute> readSchema, long splitStartByte, int maxRecordBytes, long statsBaseOffset, long statsStripeSize, boolean statsFileFinal, StripeColumnScope statsColumnScope, @Nullable Consumer<String> informationalWarningSink) Creates an instance of aFormatReadContextrecord class.- Parameters:
projectedColumns- the value for theprojectedColumnsrecord componentbatchSize- the value for thebatchSizerecord componentrowLimit- the value for therowLimitrecord componenterrorPolicy- the value for theerrorPolicyrecord componentfirstSplit- the value for thefirstSplitrecord componentlastSplit- the value for thelastSplitrecord componentrecordAligned- the value for therecordAlignedrecord componentreadSchema- the value for thereadSchemarecord componentsplitStartByte- the value for thesplitStartByterecord componentmaxRecordBytes- the value for themaxRecordBytesrecord componentstatsBaseOffset- the value for thestatsBaseOffsetrecord componentstatsStripeSize- the value for thestatsStripeSizerecord componentstatsFileFinal- the value for thestatsFileFinalrecord componentstatsColumnScope- the value for thestatsColumnScoperecord componentinformationalWarningSink- the value for theinformationalWarningSinkrecord component
-
-
Method Details
-
of
Creates a minimal context for the common non-split case. LeaveserrorPolicyasnullso the reader falls back to its own default — typically the policy resolved from the user'sWITHoptions viaFormatReader.withConfig(java.util.Map<java.lang.String, java.lang.Object>), or theFormatReader.defaultErrorPolicy()when no user options are set. Callers that need to override the policy should usebuilder()orwithErrorPolicy(ErrorPolicy). -
withRowLimit
Returns a copy with a different row limit. -
withErrorPolicy
Returns a copy with a different error policy. -
withSplit
Returns a copy configured for a split-based read. -
builder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
projectedColumns
Returns the value of theprojectedColumnsrecord component.- Returns:
- the value of the
projectedColumnsrecord component
-
batchSize
public int batchSize()Returns the value of thebatchSizerecord component.- Returns:
- the value of the
batchSizerecord component
-
rowLimit
public int rowLimit()Returns the value of therowLimitrecord component.- Returns:
- the value of the
rowLimitrecord component
-
errorPolicy
Returns the value of theerrorPolicyrecord component.- Returns:
- the value of the
errorPolicyrecord component
-
firstSplit
public boolean firstSplit()Returns the value of thefirstSplitrecord component.- Returns:
- the value of the
firstSplitrecord component
-
lastSplit
public boolean lastSplit()Returns the value of thelastSplitrecord component.- Returns:
- the value of the
lastSplitrecord component
-
recordAligned
public boolean recordAligned()Returns the value of therecordAlignedrecord component.- Returns:
- the value of the
recordAlignedrecord component
-
readSchema
Returns the value of thereadSchemarecord component.- Returns:
- the value of the
readSchemarecord component
-
splitStartByte
public long splitStartByte()Returns the value of thesplitStartByterecord component.- Returns:
- the value of the
splitStartByterecord component
-
maxRecordBytes
public int maxRecordBytes()Returns the value of themaxRecordBytesrecord component.- Returns:
- the value of the
maxRecordBytesrecord component
-
statsBaseOffset
public long statsBaseOffset()Returns the value of thestatsBaseOffsetrecord component.- Returns:
- the value of the
statsBaseOffsetrecord component
-
statsStripeSize
public long statsStripeSize()Returns the value of thestatsStripeSizerecord component.- Returns:
- the value of the
statsStripeSizerecord component
-
statsFileFinal
public boolean statsFileFinal()Returns the value of thestatsFileFinalrecord component.- Returns:
- the value of the
statsFileFinalrecord component
-
statsColumnScope
Returns the value of thestatsColumnScoperecord component.- Returns:
- the value of the
statsColumnScoperecord component
-
informationalWarningSink
Returns the value of theinformationalWarningSinkrecord component.- Returns:
- the value of the
informationalWarningSinkrecord component
-