Package io.delta.kernel.internal.replay
Class ActionsIterator
Object
io.delta.kernel.internal.replay.ActionsIterator
- All Implemented Interfaces:
CloseableIterator<ActionWrapper>,Closeable,AutoCloseable,Iterator<ActionWrapper>
This class takes as input a list of delta files (.json, .checkpoint.parquet) and produces an
iterator of (ColumnarBatch, isFromCheckpoint) tuples, where the schema of the ColumnarBatch
semantically represents actions (or, a subset of action fields) parsed from the Delta Log.
Users must pass in a `deltaReadSchema` to select which actions and sub-fields they want to consume.
Users can also pass in an optional `checkpointReadSchema` if it is different from `deltaReadSchema`.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.delta.kernel.utils.CloseableIterator
CloseableIterator.BreakableFilterResult -
Constructor Summary
ConstructorsConstructorDescriptionActionsIterator(Engine engine, List<FileStatus> files, StructType deltaReadSchema, StructType checkpointReadSchema, Optional<Predicate> checkpointPredicate, Optional<PaginationContext> paginationContextOpt) ActionsIterator(Engine engine, List<FileStatus> files, StructType deltaReadSchema, Optional<Predicate> checkpointPredicate) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()extractSidecarsFromBatch(FileStatus checkpointFileStatus, long checkpointVersion, ColumnarBatch columnarBatch) Reads SidecarFile actions from ColumnarBatch, removing sidecar actions from the ColumnarBatch.booleanhasNext()Returns true if the iteration has more elements.next()Returns the next element in the iteration.booleanpaginatedFilter(DeltaLogFile nextLogFile) Filters a log segment file based on the pagination context.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.delta.kernel.utils.CloseableIterator
breakableFilter, combine, filter, flatMap, map, takeWhile, toInMemoryListMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
ActionsIterator
public ActionsIterator(Engine engine, List<FileStatus> files, StructType deltaReadSchema, Optional<Predicate> checkpointPredicate) -
ActionsIterator
public ActionsIterator(Engine engine, List<FileStatus> files, StructType deltaReadSchema, StructType checkpointReadSchema, Optional<Predicate> checkpointPredicate, Optional<PaginationContext> paginationContextOpt)
-
-
Method Details
-
paginatedFilter
Filters a log segment file based on the pagination context.If this method returns
true, the current file will be kept; otherwise, it will be skipped.- If pagination is not enabled (i.e.,
paginationContextOptis not present), returntrue. - If the pagination context is present but doesn't include a last read log file path,
return
true(indicates reading the first page). - If the file is a JSON log file, return
true— we never skip JSON files as they're needed to build hash sets. - If the file is a V2 checkpoint manifest, return
true— these should never be skipped. - If the file is a checkpoint file and comes after the last log file recorded in the page
token, return
false(skip it).
Note: The
nextLogFileparameter cannot be a sidecar file because sidecar files are not included in the log segment list. Sidecar files are handled separately later, after the V2 manifest file has been read, specifically in theextractSidecarFiles()method.- Parameters:
nextLogFile- the log file to evaluate- Returns:
trueto include the file;falseto skip it
- If pagination is not enabled (i.e.,
-
hasNext
public boolean hasNext()Description copied from interface:CloseableIteratorReturns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)- Specified by:
hasNextin interfaceCloseableIterator<ActionWrapper>- Specified by:
hasNextin interfaceIterator<ActionWrapper>- Returns:
- true if the iteration has more elements
-
next
Description copied from interface:CloseableIteratorReturns the next element in the iteration.- Specified by:
nextin interfaceCloseableIterator<ActionWrapper>- Specified by:
nextin interfaceIterator<ActionWrapper>- Returns:
- a tuple of (ColumnarBatch, isFromCheckpoint), where ColumnarBatch conforms to the
instance
deltaReadSchemaorcheckpointReadSchema(the latter when when isFromCheckpoint=true).
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
extractSidecarsFromBatch
public ColumnarBatch extractSidecarsFromBatch(FileStatus checkpointFileStatus, long checkpointVersion, ColumnarBatch columnarBatch) Reads SidecarFile actions from ColumnarBatch, removing sidecar actions from the ColumnarBatch. Returns a list of SidecarFile actions found.
-