java.lang.Object
org.elasticsearch.compute.data.Page
- All Implemented Interfaces:
Closeable,AutoCloseable,Writeable,org.elasticsearch.core.Releasable
A page is a column-oriented data abstraction that allows data to be passed between operators in
batches.
A page has a fixed number of positions (or rows), exposed via getPositionCount().
It is further composed of a number of Blocks, which represent the columnar data.
The number of blocks can be retrieved via getBlockCount(), and the respective
blocks can be retrieved via their index getBlock(int).
Pages are immutable and can be passed between threads.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new page with the given positionCount and blocks.Page(StreamInput in) Page(BatchMetadata batchMetadata, Block... blocks) Create a new page with the given blocks and batch metadata.Creates a new page with the given blocks. -
Method Summary
Modifier and TypeMethodDescriptionvoidBefore passing a Page to another Driver, it is necessary to switch the owning block factories of its Blocks to their parents, which are associated with the global circuit breaker.appendBlock(Block block) Creates a new page, appending the given block to the existing blocks in this Page.appendBlocks(Block[] toAdd) Creates a new page, appending the given blocks to the existing blocks in this Page.appendPage(Page toAdd) Creates a new page, appending the blocks of the given block to the existing blocks in this Page.voidclose()static PagecreateBatchMarkerPage(long batchId, int pageIndexInBatch) Creates an empty marker page for batch completion.booleanfilter(boolean mayContainDuplicates, int... positions) Creates a new page that only exposes the positions provided.<B extends Block>
BgetBlock(int blockIndex) Returns the block at the given block index.intReturns the number of blocks in this page.intReturns the number of positions (rows) in this page.inthashCode()booleanCheck if this page is a batch marker (empty page with isLastPageInBatch=true).projectBlocks(int[] blockMapping) Returns a new page with blocks in the containingBlocks shifted around or removed.longvoidRelease all blocks in this page, decrementing any breakers accounting for these blocks.slice(int beginInclusive, int endExclusive) toString()withBatchMetadata(BatchMetadata metadata) Creates a new page with the same blocks but with the given batch metadata.voidwriteTo(StreamOutput out)
-
Constructor Details
-
Page
Creates a new page with the given blocks. Every block has the same number of positions.- Parameters:
blocks- the blocks- Throws:
IllegalArgumentException- if all blocks do not have the same number of positions
-
Page
Creates a new page with the given positionCount and blocks. Assumes that every block has the same number of positions as the positionCount that's passed in - there is no validation of this.- Parameters:
positionCount- the block position countblocks- the blocks
-
Page
Create a new page with the given blocks and batch metadata. -
Page
- Throws:
IOException
-
-
Method Details
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
getBlock
Returns the block at the given block index.- Parameters:
blockIndex- the block index- Returns:
- the block
-
appendBlock
Creates a new page, appending the given block to the existing blocks in this Page.- Parameters:
block- the block to append- Returns:
- a new Page with the block appended
- Throws:
IllegalArgumentException- if the given block does not have the same number of positions as the blocks in this Page
-
appendBlocks
Creates a new page, appending the given blocks to the existing blocks in this Page.- Parameters:
toAdd- the blocks to append- Returns:
- a new Page with the block appended
- Throws:
IllegalArgumentException- if one of the given blocks does not have the same number of positions as the blocks in this Page
-
appendPage
Creates a new page, appending the blocks of the given block to the existing blocks in this Page.- Parameters:
toAdd- the page to append- Returns:
- a new Page
- Throws:
IllegalArgumentException- if any blocks of the given page does not have the same number of positions as the blocks in this Page
-
hashCode
public int hashCode() -
equals
-
toString
-
getPositionCount
public int getPositionCount()Returns the number of positions (rows) in this page.- Returns:
- the number of positions
-
getBlockCount
public int getBlockCount()Returns the number of blocks in this page. Blocks can then be retrieved viagetBlock(int)where channel ranges from 0 togetBlockCount.- Returns:
- the number of blocks in this page
-
batchMetadata
-
withBatchMetadata
Creates a new page with the same blocks but with the given batch metadata. The blocks are shared (ref count incremented) with the original page. -
isBatchMarkerOnly
public boolean isBatchMarkerOnly()Check if this page is a batch marker (empty page with isLastPageInBatch=true). Marker pages are used to signal batch completion for batches that produce no output. -
createBatchMarkerPage
Creates an empty marker page for batch completion. A marker page is an empty page with isLastPageInBatch=true. -
ramBytesUsedByBlocks
public long ramBytesUsedByBlocks() -
releaseBlocks
public void releaseBlocks()Release all blocks in this page, decrementing any breakers accounting for these blocks. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.elasticsearch.core.Releasable
-
allowPassingToDifferentDriver
public void allowPassingToDifferentDriver()Before passing a Page to another Driver, it is necessary to switch the owning block factories of its Blocks to their parents, which are associated with the global circuit breaker. This ensures that when the new driver releases this Page, it returns memory directly to the parent block factory instead of the local block factory. This is important because the local block factory is not thread safe and doesn't support simultaneous access by more than one thread. -
shallowCopy
-
projectBlocks
-
filter
Creates a new page that only exposes the positions provided.- Parameters:
mayContainDuplicates- may the positions array contain duplicate positions?positions- the positions to retain- Returns:
- a filtered page
-
slice
-