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
Constructors -
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()booleanfilter(int... positions) <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()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.toString()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
- 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
-
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
-