Refine search
@Override public Page getOutput() { if (state != State.HAS_OUTPUT) { return null; } // project results into output blocks List<Type> types = aggregates.stream().map(Aggregator::getType).collect(toImmutableList()); // output page will only be constructed once, // so a new PageBuilder is constructed (instead of using PageBuilder.reset) PageBuilder pageBuilder = new PageBuilder(1, types); pageBuilder.declarePosition(); for (int i = 0; i < aggregates.size(); i++) { Aggregator aggregator = aggregates.get(i); BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(i); aggregator.evaluate(blockBuilder); } state = State.FINISHED; return pageBuilder.build(); } }
private void evaluateAndFlushGroup(Page page, int position) { pageBuilder.declarePosition(); for (int i = 0; i < groupByTypes.size(); i++) { Block block = page.getBlock(groupByChannels[i]); Type type = groupByTypes.get(i); type.appendTo(block, position, pageBuilder.getBlockBuilder(i)); } int offset = groupByTypes.size(); for (int i = 0; i < aggregates.size(); i++) { aggregates.get(i).evaluate(pageBuilder.getBlockBuilder(offset + i)); } if (pageBuilder.isFull()) { outputPages.add(pageBuilder.build()); pageBuilder.reset(); } aggregates = setupAggregates(step, accumulatorFactories); }
private Page createFragmentsPage() { Collection<Slice> fragments = getFutureValue(finishFuture); committed = true; updateWrittenBytes(); // output page will only be constructed once, // so a new PageBuilder is constructed (instead of using PageBuilder.reset) PageBuilder page = new PageBuilder(fragments.size() + 1, ImmutableList.of(types.get(ROW_COUNT_CHANNEL), types.get(FRAGMENT_CHANNEL))); BlockBuilder rowsBuilder = page.getBlockBuilder(0); BlockBuilder fragmentBuilder = page.getBlockBuilder(1); // write row count page.declarePosition(); BIGINT.writeLong(rowsBuilder, rowCount); fragmentBuilder.appendNull(); // write fragments for (Slice fragment : fragments) { page.declarePosition(); rowsBuilder.appendNull(); VARBINARY.writeSlice(fragmentBuilder, fragment); } return page.build(); }
@Override public Page getNextPage() { verify(pageBuilder.isEmpty()); count = 0; for (int i = 0; i < ROWS_PER_REQUEST; i++) { if (!cursor.hasNext()) { finished = true; break; } currentDoc = cursor.next(); count++; pageBuilder.declarePosition(); for (int column = 0; column < columnTypes.size(); column++) { BlockBuilder output = pageBuilder.getBlockBuilder(column); appendTo(columnTypes.get(column), currentDoc.get(columnNames.get(column)), output); } } Page page = pageBuilder.build(); pageBuilder.reset(); return page; }
output.declarePosition(); int channel = 0; return null; return output.build();
@Override public Page getOutput() { if (finished) { return null; } finished = true; OptionalLong rowsDeletedCount = metadata.metadataDelete(session, tableHandle, tableLayout); // output page will only be constructed once, // so a new PageBuilder is constructed (instead of using PageBuilder.reset) PageBuilder page = new PageBuilder(1, TYPES); BlockBuilder rowsBuilder = page.getBlockBuilder(0); page.declarePosition(); if (rowsDeletedCount.isPresent()) { BIGINT.writeLong(rowsBuilder, rowsDeletedCount.getAsLong()); } else { rowsBuilder.appendNull(); } return page.build(); } }
pageBuilder.declarePosition(); for (int i = 0; i < columns.size(); i++) { if (columns.get(i) == AtopColumn.HOST_IP) { Page page = pageBuilder.build(); pageBuilder.reset();
break; pageBuilder.declarePosition(); page = pageBuilder.build(); pageBuilder.reset();
@Override public Page getOutput() { if ((state != State.FINISHING) || !finishFuture.isDone()) { return null; } state = State.FINISHED; Collection<Slice> fragments = getFutureValue(finishFuture); // output page will only be constructed once, // so a new PageBuilder is constructed (instead of using PageBuilder.reset) PageBuilder page = new PageBuilder(fragments.size() + 1, TYPES); BlockBuilder rowsBuilder = page.getBlockBuilder(0); BlockBuilder fragmentBuilder = page.getBlockBuilder(1); // write row count page.declarePosition(); BIGINT.writeLong(rowsBuilder, rowCount); fragmentBuilder.appendNull(); // write fragments for (Slice fragment : fragments) { page.declarePosition(); rowsBuilder.appendNull(); VARBINARY.writeSlice(fragmentBuilder, fragment); } return page.build(); }
private Page getSelectedRows() { verify(selectedRowPageBuilder.isPresent()); int rowNumberChannel = types.size() - 1; PageBuilder pageBuilder = selectedRowPageBuilder.get(); verify(pageBuilder.isEmpty()); for (int currentPosition = 0; currentPosition < inputPage.getPositionCount(); currentPosition++) { long partitionId = getPartitionId(currentPosition); long rowCount = partitionRowCount.get(partitionId); if (rowCount == maxRowsPerPartition.get()) { continue; } pageBuilder.declarePosition(); for (int i = 0; i < outputChannels.length; i++) { int channel = outputChannels[i]; Type type = types.get(i); type.appendTo(inputPage.getBlock(channel), currentPosition, pageBuilder.getBlockBuilder(i)); } BIGINT.writeLong(pageBuilder.getBlockBuilder(rowNumberChannel), rowCount + 1); partitionRowCount.set(partitionId, rowCount + 1); } if (pageBuilder.isEmpty()) { return null; } Page page = pageBuilder.build(); pageBuilder.reset(); return page; }
private static List<Page> createBigintPages(int positionCount, int groupCount, int channelCount, boolean hashEnabled) { List<Type> types = Collections.nCopies(channelCount, BIGINT); ImmutableList.Builder<Page> pages = ImmutableList.builder(); if (hashEnabled) { types = ImmutableList.copyOf(Iterables.concat(types, ImmutableList.of(BIGINT))); } PageBuilder pageBuilder = new PageBuilder(types); for (int position = 0; position < positionCount; position++) { int rand = ThreadLocalRandom.current().nextInt(groupCount); pageBuilder.declarePosition(); for (int numChannel = 0; numChannel < channelCount; numChannel++) { BIGINT.writeLong(pageBuilder.getBlockBuilder(numChannel), rand); } if (hashEnabled) { BIGINT.writeLong(pageBuilder.getBlockBuilder(channelCount), BigintOperators.hashCode(rand)); } if (pageBuilder.isFull()) { pages.add(pageBuilder.build()); pageBuilder.reset(); } } pages.add(pageBuilder.build()); return pages.build(); }
private static List<Page> createVarcharPages(int positionCount, int groupCount, int channelCount, boolean hashEnabled) { List<Type> types = Collections.nCopies(channelCount, VARCHAR); ImmutableList.Builder<Page> pages = ImmutableList.builder(); if (hashEnabled) { types = ImmutableList.copyOf(Iterables.concat(types, ImmutableList.of(BIGINT))); } PageBuilder pageBuilder = new PageBuilder(types); for (int position = 0; position < positionCount; position++) { int rand = ThreadLocalRandom.current().nextInt(groupCount); Slice value = Slices.wrappedBuffer(ByteBuffer.allocate(4).putInt(rand)); pageBuilder.declarePosition(); for (int channel = 0; channel < channelCount; channel++) { VARCHAR.writeSlice(pageBuilder.getBlockBuilder(channel), value); } if (hashEnabled) { BIGINT.writeLong(pageBuilder.getBlockBuilder(channelCount), VarcharOperators.hashCode(value)); } if (pageBuilder.isFull()) { pages.add(pageBuilder.build()); pageBuilder.reset(); } } pages.add(pageBuilder.build()); return pages.build(); }
private WorkProcessor<Page> buildResult(IntIterator groupIds) { final PageBuilder pageBuilder = new PageBuilder(buildTypes()); return WorkProcessor.create(() -> { if (!groupIds.hasNext()) { return ProcessState.finished(); } pageBuilder.reset(); List<Type> types = groupByHash.getTypes(); while (!pageBuilder.isFull() && groupIds.hasNext()) { int groupId = groupIds.nextInt(); groupByHash.appendValuesTo(groupId, pageBuilder, 0); pageBuilder.declarePosition(); for (int i = 0; i < aggregators.size(); i++) { Aggregator aggregator = aggregators.get(i); BlockBuilder output = pageBuilder.getBlockBuilder(types.size() + i); aggregator.evaluate(groupId, output); } } return ProcessState.ofResult(pageBuilder.build()); }); }
PageBuilder pageBuilder = new PageBuilder(node.getRows().size(), outputTypes); for (List<Expression> row : node.getRows()) { pageBuilder.declarePosition(); Map<NodeRef<Expression>, Type> expressionTypes = getExpressionTypes( context.getSession(), OperatorFactory operatorFactory = new ValuesOperatorFactory(context.getNextOperatorId(), node.getId(), ImmutableList.of(pageBuilder.build())); return new PhysicalOperation(operatorFactory, makeLayout(node), context, UNGROUPED_EXECUTION);
private static List<Page> createOutputPages(List<Type> types, List<Page> inputPages, long[] sortedAddresses) { PageBuilder pageBuilder = new PageBuilder(types); pageBuilder.reset(); for (long address : sortedAddresses) { int index = sorter.decodePageIndex(address); int position = sorter.decodePositionIndex(address); Page page = inputPages.get(index); for (int i = 0; i < types.size(); i++) { Type type = types.get(i); type.appendTo(page.getBlock(i), position, pageBuilder.getBlockBuilder(i)); } pageBuilder.declarePosition(); } return ImmutableList.of(pageBuilder.build()); } }
@Benchmark @OperationsPerInvocation(POSITIONS) public Object bigintGroupByHash(SingleChannelBenchmarkData data) { GroupByHash groupByHash = new BigintGroupByHash(0, data.getHashEnabled(), EXPECTED_SIZE, NOOP); data.getPages().forEach(p -> groupByHash.addPage(p).process()); ImmutableList.Builder<Page> pages = ImmutableList.builder(); PageBuilder pageBuilder = new PageBuilder(groupByHash.getTypes()); for (int groupId = 0; groupId < groupByHash.getGroupCount(); groupId++) { pageBuilder.declarePosition(); groupByHash.appendValuesTo(groupId, pageBuilder, 0); if (pageBuilder.isFull()) { pages.add(pageBuilder.build()); pageBuilder.reset(); } } pages.add(pageBuilder.build()); return pageBuilder.build(); }
page.declarePosition(); BIGINT.writeLong(page.getBlockBuilder(0), rowCount); return page.build();
int position = indexKeysRecordCursor.getPosition(); if (lookupSource.getJoinPosition(position, page, page) < 0) { missingKeysPageBuilder.declarePosition(); for (int i = 0; i < page.getChannelCount(); i++) { Block block = page.getBlock(i); Page missingKeysPage = missingKeysPageBuilder.build(); if (!missingKeysPageBuilder.isEmpty()) { missingKeysPageBuilder.reset();
private static Page makeInput(int numberOfBuckets) { PageBuilder builder = new PageBuilder(ImmutableList.of(BIGINT, REAL, DOUBLE)); for (int i = 0; i < 100; i++) { builder.declarePosition(); BIGINT.writeLong(builder.getBlockBuilder(0), numberOfBuckets); REAL.writeLong(builder.getBlockBuilder(1), i); // value DOUBLE.writeDouble(builder.getBlockBuilder(2), 1); // weight } return builder.build(); } }
private static Page makeInput(int numberOfBuckets) { PageBuilder builder = new PageBuilder(ImmutableList.of(BIGINT, DOUBLE, DOUBLE)); for (int i = 0; i < 100; i++) { builder.declarePosition(); BIGINT.writeLong(builder.getBlockBuilder(0), numberOfBuckets); DOUBLE.writeDouble(builder.getBlockBuilder(1), i); // value DOUBLE.writeDouble(builder.getBlockBuilder(2), 1); // weight } return builder.build(); } }