use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.
the class TestIpPrefixType method createTestBlock.
public static Block createTestBlock() {
BlockBuilder blockBuilder = IPPREFIX.createBlockBuilder(null, 1);
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8320/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8321/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8322/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8323/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8324/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8325/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8326/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8327/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8328/48"));
IPPREFIX.writeSlice(blockBuilder, getSliceForPrefix("2001:db8::ff00:42:8329/48"));
return blockBuilder.build();
}
use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.
the class TestJsonType method createTestBlock.
public static Block createTestBlock() {
BlockBuilder blockBuilder = JSON.createBlockBuilder(null, 1);
Slice slice = Slices.utf8Slice("{\"x\":1, \"y\":2}");
JSON.writeSlice(blockBuilder, slice);
return blockBuilder.build();
}
use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.
the class PassthroughQueryPageSource method getNextPage.
@Override
public Page getNextPage() {
if (done) {
return null;
}
done = true;
PageBuilder page = new PageBuilder(1, ImmutableList.of(jsonType));
page.declarePosition();
BlockBuilder column = page.getBlockBuilder(0);
jsonType.writeSlice(column, Slices.utf8Slice(result));
return page.build();
}
use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.
the class NodesSystemTable method pageSource.
@Override
public ConnectorPageSource pageSource(ConnectorTransactionHandle transaction, ConnectorSession session, TupleDomain<Integer> constraint) {
Set<ElasticsearchNode> nodes = client.getNodes();
BlockBuilder nodeId = VARCHAR.createBlockBuilder(null, nodes.size());
BlockBuilder prestoAddress = VARCHAR.createBlockBuilder(null, nodes.size());
BlockBuilder elasticsearchNodeId = VARCHAR.createBlockBuilder(null, nodes.size());
BlockBuilder elasticsearchAddress = VARCHAR.createBlockBuilder(null, nodes.size());
for (ElasticsearchNode node : nodes) {
VARCHAR.writeString(nodeId, currentNode.getNodeIdentifier());
VARCHAR.writeString(prestoAddress, currentNode.getHostAndPort().toString());
VARCHAR.writeString(elasticsearchNodeId, node.getId());
if (node.getAddress().isPresent()) {
VARCHAR.writeString(elasticsearchAddress, node.getAddress().get());
} else {
elasticsearchAddress.appendNull();
}
}
return new FixedPageSource(ImmutableList.of(new Page(nodeId.build(), prestoAddress.build(), elasticsearchNodeId.build(), elasticsearchAddress.build())));
}
use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.
the class ScanQueryPageSource method getNextPage.
@Override
public Page getNextPage() {
long size = 0;
while (size < PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES && iterator.hasNext()) {
SearchHit hit = iterator.next();
Map<String, Object> document = hit.getSourceAsMap();
for (int i = 0; i < decoders.size(); i++) {
String field = columns.get(i).getName();
decoders.get(i).decode(hit, () -> getField(document, field), columnBuilders[i]);
}
if (hit.getSourceRef() != null) {
totalBytes += hit.getSourceRef().length();
}
completedPositions += 1;
size = Arrays.stream(columnBuilders).mapToLong(BlockBuilder::getSizeInBytes).sum();
}
Block[] blocks = new Block[columnBuilders.length];
for (int i = 0; i < columnBuilders.length; i++) {
blocks[i] = columnBuilders[i].build();
columnBuilders[i] = columnBuilders[i].newBlockBuilderLike(null);
}
return new Page(blocks);
}
Aggregations