use of io.trino.spi.block.Block in project trino by trinodb.
the class PagesIndex method appendTo.
public void appendTo(int channel, int position, BlockBuilder output) {
long pageAddress = valueAddresses.getLong(position);
Type type = types.get(channel);
Block block = channels[channel].get(decodeSliceIndex(pageAddress));
int blockPosition = decodePosition(pageAddress);
type.appendTo(block, blockPosition, output);
}
use of io.trino.spi.block.Block in project trino by trinodb.
the class PagesRTreeIndex method findJoinPositions.
/**
* Returns an array of addresses from {@link PagesIndex#valueAddresses} corresponding
* to rows with matching geometries.
* <p>
* The caller is responsible for calling {@link #isJoinPositionEligible(int, int, Page)}
* for each of these addresses to apply additional join filters.
*/
@Override
public int[] findJoinPositions(int probePosition, Page probe, int probeGeometryChannel, Optional<Integer> probePartitionChannel) {
Block probeGeometryBlock = probe.getBlock(probeGeometryChannel);
if (probeGeometryBlock.isNull(probePosition)) {
return EMPTY_ADDRESSES;
}
int probePartition = probePartitionChannel.map(channel -> toIntExact(INTEGER.getLong(probe.getBlock(channel), probePosition))).orElse(-1);
Slice slice = probeGeometryBlock.getSlice(probePosition, 0, probeGeometryBlock.getSliceLength(probePosition));
OGCGeometry probeGeometry = deserialize(slice);
verifyNotNull(probeGeometry);
if (probeGeometry.isEmpty()) {
return EMPTY_ADDRESSES;
}
boolean probeIsPoint = probeGeometry instanceof OGCPoint;
IntArrayList matchingPositions = new IntArrayList();
Envelope envelope = getEnvelope(probeGeometry);
rtree.query(envelope, item -> {
GeometryWithPosition geometryWithPosition = (GeometryWithPosition) item;
OGCGeometry buildGeometry = geometryWithPosition.getGeometry();
if (partitions.isEmpty() || (probePartition == geometryWithPosition.getPartition() && (probeIsPoint || (buildGeometry instanceof OGCPoint) || testReferencePoint(envelope, buildGeometry, probePartition)))) {
if (radiusChannel == -1) {
if (spatialRelationshipTest.apply(buildGeometry, probeGeometry, OptionalDouble.empty())) {
matchingPositions.add(geometryWithPosition.getPosition());
}
} else {
if (spatialRelationshipTest.apply(geometryWithPosition.getGeometry(), probeGeometry, OptionalDouble.of(getRadius(geometryWithPosition.getPosition())))) {
matchingPositions.add(geometryWithPosition.getPosition());
}
}
}
});
return matchingPositions.toIntArray(null);
}
use of io.trino.spi.block.Block in project trino by trinodb.
the class PagesIndex method compact.
public void compact() {
if (eagerCompact || channels.length == 0) {
return;
}
for (int channel = 0; channel < types.size(); channel++) {
ObjectArrayList<Block> blocks = channels[channel];
for (int i = nextBlockToCompact; i < blocks.size(); i++) {
Block block = blocks.get(i);
// Copy the block to compact its size
Block compactedBlock = block.copyRegion(0, block.getPositionCount());
blocks.set(i, compactedBlock);
pagesMemorySize -= block.getRetainedSizeInBytes();
pagesMemorySize += compactedBlock.getRetainedSizeInBytes();
}
}
nextBlockToCompact = channels[0].size();
estimatedSize = calculateEstimatedSize();
}
use of io.trino.spi.block.Block in project trino by trinodb.
the class PagesIndex method getSlice.
public Slice getSlice(int channel, int position) {
long pageAddress = valueAddresses.getLong(position);
Block block = channels[channel].get(decodeSliceIndex(pageAddress));
int blockPosition = decodePosition(pageAddress);
return types.get(channel).getSlice(block, blockPosition);
}
use of io.trino.spi.block.Block in project trino by trinodb.
the class PagesIndex method getBoolean.
public boolean getBoolean(int channel, int position) {
long pageAddress = valueAddresses.getLong(position);
Block block = channels[channel].get(decodeSliceIndex(pageAddress));
int blockPosition = decodePosition(pageAddress);
return types.get(channel).getBoolean(block, blockPosition);
}
Aggregations