Skip to content

Commit

Permalink
json handler, filesystem client and columnarbatch impls
Browse files Browse the repository at this point in the history
  • Loading branch information
vkorukanti committed Sep 19, 2024
1 parent 29a0770 commit d388182
Show file tree
Hide file tree
Showing 7 changed files with 747 additions and 57 deletions.
26 changes: 26 additions & 0 deletions core/trino-spi/src/main/java/io/trino/spi/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,32 @@ public Page appendColumn(Block block)
return wrapBlocksWithoutCopy(positionCount, newBlocks);
}

public Page insertColumnAt(int ordinal, Block block)
{
requireNonNull(block, "block is null");
if (ordinal < 0 || ordinal > blocks.length) {
throw new IllegalArgumentException("Invalid ordinal: " + ordinal);
}
if (positionCount != block.getPositionCount()) {
throw new IllegalArgumentException("Block does not have same position count");
}
Block[] newBlocks = Arrays.copyOf(blocks, blocks.length + 1);
System.arraycopy(blocks, ordinal, newBlocks, ordinal + 1, blocks.length - ordinal);
newBlocks[ordinal] = block;
return wrapBlocksWithoutCopy(positionCount, newBlocks);
}

public Page deleteColumnAt(int ordinal)
{
if (ordinal < 0 || ordinal >= blocks.length) {
throw new IllegalArgumentException("Invalid ordinal: " + ordinal);
}
Block[] newBlocks = new Block[blocks.length - 1];
System.arraycopy(blocks, 0, newBlocks, 0, ordinal);
System.arraycopy(blocks, ordinal + 1, newBlocks, ordinal, blocks.length - ordinal - 1);
return wrapBlocksWithoutCopy(positionCount, newBlocks);
}

public void compact()
{
if (getRetainedSizeInBytes() <= getSizeInBytes()) {
Expand Down
Loading

0 comments on commit d388182

Please sign in to comment.