use of com.facebook.presto.common.block.LongArrayBlock in project presto by prestodb.
the class TimestampSelectiveStreamReader method getBlockView.
@Override
public BlockLease getBlockView(int[] positions, int positionCount) {
checkArgument(outputPositionCount > 0, "outputPositionCount must be greater than zero");
checkState(outputRequired, "This stream reader doesn't produce output");
checkState(positionCount <= outputPositionCount, "Not enough values");
checkState(!valuesInUse, "BlockLease hasn't been closed yet");
if (allNulls) {
return newLease(new RunLengthEncodedBlock(NULL_BLOCK, positionCount));
}
boolean includeNulls = nullsAllowed && presentStream != null;
if (positionCount != outputPositionCount) {
compactValues(positions, positionCount, includeNulls);
}
return newLease(new LongArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), values));
}
use of com.facebook.presto.common.block.LongArrayBlock in project presto by prestodb.
the class DoubleSelectiveStreamReader method getBlockView.
@Override
public BlockLease getBlockView(int[] positions, int positionCount) {
checkArgument(outputPositionCount > 0, "outputPositionCount must be greater than zero");
checkState(outputRequired, "This stream reader doesn't produce output");
checkState(positionCount <= outputPositionCount, "Not enough values");
checkState(!valuesInUse, "BlockLease hasn't been closed yet");
if (allNulls) {
return newLease(new RunLengthEncodedBlock(NULL_BLOCK, positionCount));
}
boolean includeNulls = nullsAllowed && presentStream != null;
if (positionCount != outputPositionCount) {
compactValues(positions, positionCount, includeNulls);
}
return newLease(new LongArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), values));
}
use of com.facebook.presto.common.block.LongArrayBlock in project presto by prestodb.
the class TestLongArrayBlock method testCompactBlock.
@Test
public void testCompactBlock() {
long[] longArray = { 0L, 0L, 1L, 2L, 3L, 4L };
boolean[] valueIsNull = { false, true, false, false, false, false };
testCompactBlock(new LongArrayBlock(0, Optional.empty(), new long[0]));
testCompactBlock(new LongArrayBlock(longArray.length, Optional.of(valueIsNull), longArray));
testIncompactBlock(new LongArrayBlock(longArray.length - 1, Optional.of(valueIsNull), longArray));
}
use of com.facebook.presto.common.block.LongArrayBlock in project presto by prestodb.
the class TestObjectEncoders method testComplexObjectEncoders.
@Test
public void testComplexObjectEncoders() {
ObjectInspector inspector;
ObjectEncoder encoder;
inspector = ObjectInspectors.create(new ArrayType(BIGINT), typeManager);
encoder = createEncoder(new ArrayType(BIGINT), inspector);
assertTrue(encoder instanceof ObjectEncoders.ListObjectEncoder);
Object arrayObject = encoder.encode(new Long[] { 1L, 2L, 3L });
assertTrue(arrayObject instanceof LongArrayBlock);
assertEquals(((LongArrayBlock) arrayObject).getLong(0), 1L);
assertEquals(((LongArrayBlock) arrayObject).getLong(1), 2L);
assertEquals(((LongArrayBlock) arrayObject).getLong(2), 3L);
inspector = ObjectInspectors.create(new MapType(VARCHAR, BIGINT, methodHandle(TestRowType.class, "throwUnsupportedOperation"), methodHandle(TestRowType.class, "throwUnsupportedOperation")), typeManager);
encoder = createEncoder(new MapType(VARCHAR, BIGINT, methodHandle(TestRowType.class, "throwUnsupportedOperation"), methodHandle(TestRowType.class, "throwUnsupportedOperation")), inspector);
assertTrue(encoder instanceof ObjectEncoders.MapObjectEncoder);
assertTrue(encoder.encode(new HashMap<String, Long>() {
}) instanceof SingleMapBlock);
}
use of com.facebook.presto.common.block.LongArrayBlock in project presto by prestodb.
the class BenchmarkGroupByHash method benchmarkHashPosition.
@Benchmark
@OperationsPerInvocation(POSITIONS)
public List<Page> benchmarkHashPosition(BenchmarkData data) {
InterpretedHashGenerator hashGenerator = new InterpretedHashGenerator(data.getTypes(), data.getChannels());
ImmutableList.Builder<Page> results = ImmutableList.builderWithExpectedSize(data.getPages().size());
for (Page page : data.getPages()) {
long[] hashes = new long[page.getPositionCount()];
for (int position = 0; position < page.getPositionCount(); position++) {
hashes[position] = hashGenerator.hashPosition(position, page);
}
results.add(page.appendColumn(new LongArrayBlock(page.getPositionCount(), Optional.empty(), hashes)));
}
return results.build();
}
Aggregations