Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
405fb99
Add missing casts for NullLiteral
dain Oct 17, 2023
6e3b725
Fix null row id check in update operations
dain Oct 20, 2023
815c8cf
Create correct block type in TestSpatialPartitioningInternalAggregation
dain Oct 17, 2023
30a8519
Create correct block type in TestStatistics
dain Oct 17, 2023
135c479
Skip already coerced blocks in Hive TypeCoercer
dain Oct 20, 2023
6f48233
Fix ORC validation hash assumption that all timestamps are short
dain Oct 17, 2023
e9e93c1
Add ValueBlock interface
dain Jul 14, 2023
1656578
Add Block getUnderlyingValueBlock and getUnderlyingValuePosition
dain Jul 14, 2023
5d425d4
Change RLE value to ValueBlock
dain Jul 14, 2023
c2e61e3
Change Block getSingleValueBlock to return ValueBlock
dain Jul 14, 2023
eef9e5f
Change dictionary to be a ValueBlock
dain Jul 14, 2023
dcab1e4
Add static block to lookup constant method handles
dain Jul 15, 2023
9c5980d
Add VALUE_BLOCK_POSITION and VALUE_BLOCK_POSITION_NOT_NULL convention
dain Jul 16, 2023
ad2e6e9
Convert Type operators to use ValueBlock
dain Jul 16, 2023
574da62
Convert Array operators to ValueBlock
dain Jul 17, 2023
7a007a9
Require that type operators use ValueBlock convention instead of Block
dain Jul 17, 2023
37c19a9
Convert type tests to use ValueBlock convention
dain Jul 18, 2023
a947a43
Support ValueBlock in function system
dain Jul 18, 2023
604d262
Convert JoinDomainBuilder to ValueBlock
dain Jul 18, 2023
edb4262
Use separate position per input block in aggregation
dain Jul 18, 2023
4fe43ba
Convert aggregation functions to use ValueBlock
dain Jul 19, 2023
ee337ef
Generate specialized loops for dictionary, rle, and masked aggregations
dain Sep 17, 2022
c4d106d
Remove unused equals and hashCode from Accumulo Row and Field
dain Jul 19, 2023
6039756
Remove unnecessary slice equals, hash, and compare methods from Block
dain Jul 19, 2023
31f1fe3
Remove Block writeSliceTo method
dain Jul 19, 2023
9f323c0
Cleanup output appender warnings
dain Jul 19, 2023
b881291
Simplify UnnestingPositionsAppender
dain Jul 19, 2023
70e3ee7
Change PositionsAppender to use ValueBlocks
dain Jul 20, 2023
428717b
Enforce ValueBlock types in PositionsAppender
dain Jul 20, 2023
c01f346
Convert direct block getObject calls to type where type is available
dain Jul 21, 2023
bed30ca
Add direct value readers to ValueBlocks
dain Jul 21, 2023
53b9251
Update CheckpointEntryIterator to use ValueBlocks
dain Jul 21, 2023
30e1b44
Change BlockEncodings to explicitly down cast to block type
dain Jul 21, 2023
382231a
Fix warnings in Types
dain Jul 21, 2023
6312727
Remove non-working implementations of Type getSlice
dain Jul 22, 2023
e872b5c
Convert Types to use direct access methods on ValueBlocks
dain Jul 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.trino.spi.TrinoException;
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.block.ValueBlock;
import io.trino.spi.connector.CatalogHandle;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.function.AggregationImplementation;
Expand Down Expand Up @@ -240,6 +241,11 @@ private static void verifyMethodHandleSignature(BoundSignature boundSignature, S
verifyFunctionSignature(parameterType.equals(Block.class) && methodType.parameterType(parameterIndex + 1).equals(int.class),
"Expected %s argument types to be Block and int".formatted(argumentConvention));
break;
case VALUE_BLOCK_POSITION:
case VALUE_BLOCK_POSITION_NOT_NULL:
verifyFunctionSignature(ValueBlock.class.isAssignableFrom(parameterType) && methodType.parameterType(parameterIndex + 1).equals(int.class),
"Expected %s argument types to be ValueBlock and int".formatted(argumentConvention));
break;
case FLAT:
verifyFunctionSignature(parameterType.equals(byte[].class) &&
methodType.parameterType(parameterIndex + 1).equals(int.class) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public BucketPartitionFunction(BucketFunction bucketFunction, int[] bucketToPart
}

@Override
public int getPartitionCount()
public int partitionCount()
{
return partitionCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public Page transformPage(Page inputPage)
checkArgument(positionCount > 0, "positionCount should be > 0, but is %s", positionCount);

ColumnarRow mergeRow = toColumnarRow(inputPage.getBlock(mergeRowChannel));
checkArgument(!mergeRow.mayHaveNull(), "The mergeRow may not have null rows");
if (mergeRow.mayHaveNull()) {
for (int position = 0; position < positionCount; position++) {
checkArgument(!mergeRow.isNull(position), "The mergeRow may not have null rows");
}
}

// We've verified that the mergeRow block has no null rows, so it's okay to get the field blocks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import io.airlift.units.DataSize;
import io.trino.spi.TrinoException;
import io.trino.spi.block.Block;
import io.trino.spi.block.DictionaryBlock;
import io.trino.spi.block.RunLengthEncodedBlock;
import io.trino.spi.block.ValueBlock;
import io.trino.spi.predicate.Domain;
import io.trino.spi.predicate.ValueSet;
import io.trino.spi.type.Type;
Expand All @@ -32,8 +35,8 @@
import static io.trino.operator.VariableWidthData.EMPTY_CHUNK;
import static io.trino.operator.VariableWidthData.POINTER_SIZE;
import static io.trino.spi.StandardErrorCode.GENERIC_INSUFFICIENT_RESOURCES;
import static io.trino.spi.function.InvocationConvention.InvocationArgumentConvention.BLOCK_POSITION_NOT_NULL;
import static io.trino.spi.function.InvocationConvention.InvocationArgumentConvention.FLAT;
import static io.trino.spi.function.InvocationConvention.InvocationArgumentConvention.VALUE_BLOCK_POSITION_NOT_NULL;
import static io.trino.spi.function.InvocationConvention.InvocationReturnConvention.FAIL_ON_NULL;
import static io.trino.spi.function.InvocationConvention.InvocationReturnConvention.FLAT_RETURN;
import static io.trino.spi.function.InvocationConvention.InvocationReturnConvention.NULLABLE_RETURN;
Expand Down Expand Up @@ -88,8 +91,8 @@ public class JoinDomainBuilder
private int distinctSize;
private int distinctMaxFill;

private Block minValue;
private Block maxValue;
private ValueBlock minValue;
private ValueBlock maxValue;

private boolean collectDistinctValues = true;
private boolean collectMinMax;
Expand All @@ -116,15 +119,15 @@ public JoinDomainBuilder(
MethodHandle readOperator = typeOperators.getReadValueOperator(type, simpleConvention(NULLABLE_RETURN, FLAT));
readOperator = readOperator.asType(readOperator.type().changeReturnType(Object.class));
this.readFlat = readOperator;
this.writeFlat = typeOperators.getReadValueOperator(type, simpleConvention(FLAT_RETURN, BLOCK_POSITION_NOT_NULL));
this.writeFlat = typeOperators.getReadValueOperator(type, simpleConvention(FLAT_RETURN, VALUE_BLOCK_POSITION_NOT_NULL));

this.hashFlat = typeOperators.getHashCodeOperator(type, simpleConvention(FAIL_ON_NULL, FLAT));
this.hashBlock = typeOperators.getHashCodeOperator(type, simpleConvention(FAIL_ON_NULL, BLOCK_POSITION_NOT_NULL));
this.hashBlock = typeOperators.getHashCodeOperator(type, simpleConvention(FAIL_ON_NULL, VALUE_BLOCK_POSITION_NOT_NULL));
this.distinctFlatFlat = typeOperators.getDistinctFromOperator(type, simpleConvention(FAIL_ON_NULL, FLAT, FLAT));
this.distinctFlatBlock = typeOperators.getDistinctFromOperator(type, simpleConvention(FAIL_ON_NULL, FLAT, BLOCK_POSITION_NOT_NULL));
this.distinctFlatBlock = typeOperators.getDistinctFromOperator(type, simpleConvention(FAIL_ON_NULL, FLAT, VALUE_BLOCK_POSITION_NOT_NULL));
if (collectMinMax) {
this.compareFlatFlat = typeOperators.getComparisonUnorderedLastOperator(type, simpleConvention(FAIL_ON_NULL, FLAT, FLAT));
this.compareBlockBlock = typeOperators.getComparisonUnorderedLastOperator(type, simpleConvention(FAIL_ON_NULL, BLOCK_POSITION_NOT_NULL, BLOCK_POSITION_NOT_NULL));
this.compareBlockBlock = typeOperators.getComparisonUnorderedLastOperator(type, simpleConvention(FAIL_ON_NULL, VALUE_BLOCK_POSITION_NOT_NULL, VALUE_BLOCK_POSITION_NOT_NULL));
}
else {
this.compareFlatFlat = null;
Expand Down Expand Up @@ -157,9 +160,24 @@ public boolean isCollecting()

public void add(Block block)
{
block = block.getLoadedBlock();
if (collectDistinctValues) {
for (int position = 0; position < block.getPositionCount(); ++position) {
add(block, position);
if (block instanceof ValueBlock valueBlock) {
for (int position = 0; position < block.getPositionCount(); position++) {
add(valueBlock, position);
}
}
else if (block instanceof RunLengthEncodedBlock rleBlock) {
add(rleBlock.getValue(), 0);
}
else if (block instanceof DictionaryBlock dictionaryBlock) {
ValueBlock dictionary = dictionaryBlock.getDictionary();
for (int i = 0; i < dictionaryBlock.getPositionCount(); i++) {
add(dictionary, dictionaryBlock.getId(i));
}
}
else {
throw new IllegalArgumentException("Unsupported block type: " + block.getClass().getSimpleName());
}

// if the distinct size is too large, fall back to min max, and drop the distinct values
Expand Down Expand Up @@ -207,8 +225,10 @@ else if (collectMinMax) {
int minValuePosition = -1;
int maxValuePosition = -1;

for (int position = 0; position < block.getPositionCount(); ++position) {
if (block.isNull(position)) {
ValueBlock valueBlock = block.getUnderlyingValueBlock();
for (int i = 0; i < block.getPositionCount(); i++) {
int position = block.getUnderlyingValuePosition(i);
if (valueBlock.isNull(position)) {
continue;
}
if (minValuePosition == -1) {
Expand All @@ -217,10 +237,10 @@ else if (collectMinMax) {
maxValuePosition = position;
continue;
}
if (valueCompare(block, position, block, minValuePosition) < 0) {
if (valueCompare(valueBlock, position, valueBlock, minValuePosition) < 0) {
minValuePosition = position;
}
else if (valueCompare(block, position, block, maxValuePosition) > 0) {
else if (valueCompare(valueBlock, position, valueBlock, maxValuePosition) > 0) {
maxValuePosition = position;
}
}
Expand All @@ -231,18 +251,18 @@ else if (valueCompare(block, position, block, maxValuePosition) > 0) {
}

if (minValue == null) {
minValue = block.getSingleValueBlock(minValuePosition);
maxValue = block.getSingleValueBlock(maxValuePosition);
minValue = valueBlock.getSingleValueBlock(minValuePosition);
maxValue = valueBlock.getSingleValueBlock(maxValuePosition);
return;
}
if (valueCompare(block, minValuePosition, minValue, 0) < 0) {
if (valueCompare(valueBlock, minValuePosition, minValue, 0) < 0) {
retainedSizeInBytes -= minValue.getRetainedSizeInBytes();
minValue = block.getSingleValueBlock(minValuePosition);
minValue = valueBlock.getSingleValueBlock(minValuePosition);
retainedSizeInBytes += minValue.getRetainedSizeInBytes();
}
if (valueCompare(block, maxValuePosition, maxValue, 0) > 0) {
if (valueCompare(valueBlock, maxValuePosition, maxValue, 0) > 0) {
retainedSizeInBytes -= maxValue.getRetainedSizeInBytes();
maxValue = block.getSingleValueBlock(maxValuePosition);
maxValue = valueBlock.getSingleValueBlock(maxValuePosition);
retainedSizeInBytes += maxValue.getRetainedSizeInBytes();
}
}
Expand Down Expand Up @@ -289,7 +309,7 @@ public Domain build()
return Domain.all(type);
}

private void add(Block block, int position)
private void add(ValueBlock block, int position)
{
// Inner and right join doesn't match rows with null key column values.
if (block.isNull(position)) {
Expand Down Expand Up @@ -343,7 +363,7 @@ private int matchInVector(byte[] otherValues, VariableWidthData otherVariableWid
return -1;
}

private int matchInVector(Block block, int position, int vectorStartBucket, long repeated, long controlVector)
private int matchInVector(ValueBlock block, int position, int vectorStartBucket, long repeated, long controlVector)
{
long controlMatches = match(controlVector, repeated);
while (controlMatches != 0) {
Expand All @@ -367,7 +387,7 @@ private int findEmptyInVector(long vector, int vectorStartBucket)
return bucket(vectorStartBucket + slot);
}

private void insert(int index, Block block, int position, byte hashPrefix)
private void insert(int index, ValueBlock block, int position, byte hashPrefix)
{
setControl(index, hashPrefix);

Expand Down Expand Up @@ -512,7 +532,7 @@ private Object readValueToObject(int position)
}
}

private Block readValueToBlock(int position)
private ValueBlock readValueToBlock(int position)
{
return writeNativeValue(type, readValueToObject(position));
}
Expand All @@ -538,7 +558,7 @@ private long valueHashCode(byte[] values, int position)
}
}

private long valueHashCode(Block right, int rightPosition)
private long valueHashCode(ValueBlock right, int rightPosition)
{
try {
return (long) hashBlock.invokeExact(right, rightPosition);
Expand All @@ -549,7 +569,7 @@ private long valueHashCode(Block right, int rightPosition)
}
}

private boolean valueNotDistinctFrom(int leftPosition, Block right, int rightPosition)
private boolean valueNotDistinctFrom(int leftPosition, ValueBlock right, int rightPosition)
{
byte[] leftFixedRecordChunk = distinctRecords;
int leftRecordOffset = getRecordOffset(leftPosition);
Expand Down Expand Up @@ -603,7 +623,7 @@ private boolean valueNotDistinctFrom(int leftPosition, byte[] rightValues, Varia
}
}

private int valueCompare(Block left, int leftPosition, Block right, int rightPosition)
private int valueCompare(ValueBlock left, int leftPosition, ValueBlock right, int rightPosition)
{
try {
return (int) (long) compareBlockBlock.invokeExact(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public interface PartitionFunction
{
int getPartitionCount();
int partitionCount();

/**
* @param page the arguments to bucketing function in order (no extra columns)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import com.google.common.primitives.Ints;
import io.trino.operator.VariableWidthData;
import io.trino.spi.TrinoException;
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.block.MapBlockBuilder;
import io.trino.spi.block.ValueBlock;
import io.trino.spi.type.Type;
import jakarta.annotation.Nullable;

Expand Down Expand Up @@ -285,7 +285,7 @@ private void serializeEntry(BlockBuilder keyBuilder, BlockBuilder valueBuilder,
}
}

protected void add(int groupId, Block keyBlock, int keyPosition, Block valueBlock, int valuePosition)
protected void add(int groupId, ValueBlock keyBlock, int keyPosition, ValueBlock valueBlock, int valuePosition)
{
checkArgument(!keyBlock.isNull(keyPosition), "key must not be null");
checkArgument(groupId == 0 || groupRecordIndex != null, "groupId must be zero when grouping is not enabled");
Expand Down Expand Up @@ -322,7 +322,7 @@ protected void add(int groupId, Block keyBlock, int keyPosition, Block valueBloc
}
}

private int matchInVector(int groupId, Block block, int position, int vectorStartBucket, long repeated, long controlVector)
private int matchInVector(int groupId, ValueBlock block, int position, int vectorStartBucket, long repeated, long controlVector)
{
long controlMatches = match(controlVector, repeated);
while (controlMatches != 0) {
Expand All @@ -346,7 +346,7 @@ private int findEmptyInVector(long vector, int vectorStartBucket)
return bucket(vectorStartBucket + slot);
}

private void insert(int index, int groupId, Block keyBlock, int keyPosition, Block valueBlock, int valuePosition, byte hashPrefix)
private void insert(int index, int groupId, ValueBlock keyBlock, int keyPosition, ValueBlock valueBlock, int valuePosition, byte hashPrefix)
{
setControl(index, hashPrefix);

Expand Down Expand Up @@ -499,7 +499,7 @@ private long keyHashCode(int groupId, byte[] records, int index)
}
}

private long keyHashCode(int groupId, Block right, int rightPosition)
private long keyHashCode(int groupId, ValueBlock right, int rightPosition)
{
try {
long valueHash = (long) keyHashBlock.invokeExact(right, rightPosition);
Expand All @@ -511,7 +511,7 @@ private long keyHashCode(int groupId, Block right, int rightPosition)
}
}

private boolean keyNotDistinctFrom(int leftPosition, Block right, int rightPosition, int rightGroupId)
private boolean keyNotDistinctFrom(int leftPosition, ValueBlock right, int rightPosition, int rightGroupId)
{
byte[] leftRecords = getRecords(leftPosition);
int leftRecordOffset = getRecordOffset(leftPosition);
Expand Down
Loading