public DictionaryBlock(int positionCount, Block dictionary, int[] ids) { this(0, positionCount, dictionary, ids, false, randomDictionaryId()); }
public DictionaryBlock(int positionCount, Block dictionary, int[] ids, boolean dictionaryIsCompacted) { this(0, positionCount, dictionary, ids, dictionaryIsCompacted, randomDictionaryId()); }
@Override public DictionaryId apply(DictionaryBlock block) { return dictionarySourceIds.computeIfAbsent(block.getDictionarySourceId(), ignored -> randomDictionaryId()); }
/** * Create a new block from the current block by keeping the same elements * only with respect to {@code positions} that starts at {@code offset} and has length of {@code length}. * May return a view over the data in this block or may return a copy */ default Block getPositions(int[] positions, int offset, int length) { checkArrayRange(positions, offset, length); return new DictionaryBlock(offset, length, this, positions, false, randomDictionaryId()); }
@Override public Block getLoadedBlock() { Block loadedDictionary = dictionary.getLoadedBlock(); if (loadedDictionary == dictionary) { return this; } return new DictionaryBlock(idsOffset, getPositionCount(), loadedDictionary, ids, false, randomDictionaryId()); }
DictionaryId newDictionaryId = randomDictionaryId(); for (DictionaryBlock dictionaryBlock : blocks) { if (!firstDictionaryBlock.getDictionarySourceId().equals(dictionaryBlock.getDictionarySourceId())) {
private static DictionaryAwarePageProjection createProjection() { return new DictionaryAwarePageProjection( new TestPageProjection(), block -> randomDictionaryId()); }
DictionaryId commonSourceId = randomDictionaryId(); int commonDictionaryUsedPositions = 20; int[] commonDictionaryIds = getDictionaryIds(positionCount, commonDictionaryUsedPositions);
public DictionaryBlock(int positionCount, Block dictionary, int[] ids) { this(0, positionCount, dictionary, ids, false, randomDictionaryId()); }
public DictionaryBlock(int positionCount, Block dictionary, int[] ids, boolean dictionaryIsCompacted) { this(0, positionCount, dictionary, ids, dictionaryIsCompacted, randomDictionaryId()); }
/** * Create a new block from the current block by keeping the same elements * only with respect to {@code positions} that starts at {@code offset} and has length of {@code length}. * May return a view over the data in this block or may return a copy */ default Block getPositions(int[] positions, int offset, int length) { checkArrayRange(positions, offset, length); return new DictionaryBlock(offset, length, this, positions, false, randomDictionaryId()); }
@Override public Block getLoadedBlock() { Block loadedDictionary = dictionary.getLoadedBlock(); if (loadedDictionary == dictionary) { return this; } return new DictionaryBlock(idsOffset, getPositionCount(), loadedDictionary, ids, false, randomDictionaryId()); }
DictionaryId newDictionaryId = randomDictionaryId(); for (DictionaryBlock dictionaryBlock : blocks) { if (!firstDictionaryBlock.getDictionarySourceId().equals(dictionaryBlock.getDictionarySourceId())) {
private Block projectColumnarDictionary(Page inputPage, int[] selectedPositions, ProjectionFunction projection, Map<DictionaryId, DictionaryId> dictionarySourceIds) { int inputChannel = getOnlyElement(projection.getInputChannels()); Block[] blocks = new Block[inputPage.getChannelCount()]; if (inputPage.getBlock(inputChannel) instanceof RunLengthEncodedBlock) { RunLengthEncodedBlock rleBlock = (RunLengthEncodedBlock) inputPage.getBlock(inputChannel); BlockBuilder builder = projection.getType().createBlockBuilder(new BlockBuilderStatus(), 1); blocks[inputChannel] = rleBlock.getValue(); projection.project(0, blocks, builder); return new RunLengthEncodedBlock(builder.build(), selectedPositions.length); } Block outputDictionary = projectDictionary(projection, inputPage); int[] outputIds = filterIds(projection, inputPage, selectedPositions); DictionaryBlock dictionaryBlock = (DictionaryBlock) inputPage.getBlock(inputChannel); DictionaryId sourceId = dictionarySourceIds.get(dictionaryBlock.getDictionarySourceId()); if (sourceId == null) { sourceId = randomDictionaryId(); dictionarySourceIds.put(dictionaryBlock.getDictionarySourceId(), sourceId); } return new DictionaryBlock(selectedPositions.length, outputDictionary, wrappedIntArray(outputIds), false, sourceId); }