private long getRawHash(int sliceIndex, int position) { return channelBuilders.get(precomputedHashChannel.getAsInt()).get(sliceIndex).getLong(position, 0); }
@Override protected Page computeNext() { if (pageCounter == channels[0].size()) { return endOfData(); } Block[] blocks = Stream.of(channels) .map(channel -> channel.get(pageCounter)) .toArray(Block[]::new); pageCounter++; return new Page(blocks); } };
public Object getObject(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return types.get(channel).getObject(block, blockPosition); }
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); }
public long getLong(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return types.get(channel).getLong(block, blockPosition); }
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); }
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); }
public double getDouble(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return types.get(channel).getDouble(block, blockPosition); }
/** * Helper method that moves the element at the specified index up * until the heap ordering is established. * * @param index Index of element to sift up. */ private void siftUp(int index) { // Return if already at root node. if (index == 0) { return; } while (index != 0) { int parentIndex = getParentIndex(index); T value = _values.get(index); T parentValue = _values.get(parentIndex); if (compare(parentValue, value) == 1) { swapValues(index, parentIndex); index = parentIndex; } else { // No more sifting up required, break break; } } }
public boolean isNull(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return block.isNull(blockPosition); }
public Block getSingleValueBlock(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return block.getSingleValueBlock(blockPosition); }
@Override public int compareTo(PagesIndex pagesIndex, int leftPosition, int rightPosition) { long leftPageAddress = pagesIndex.getValueAddresses().getLong(leftPosition); int leftBlockIndex = decodeSliceIndex(leftPageAddress); int leftBlockPosition = decodePosition(leftPageAddress); long rightPageAddress = pagesIndex.getValueAddresses().getLong(rightPosition); int rightBlockIndex = decodeSliceIndex(rightPageAddress); int rightBlockPosition = decodePosition(rightPageAddress); for (int i = 0; i < sortChannels.size(); i++) { int sortChannel = sortChannels.get(i); Block leftBlock = pagesIndex.getChannel(sortChannel).get(leftBlockIndex); Block rightBlock = pagesIndex.getChannel(sortChannel).get(rightBlockIndex); SortOrder sortOrder = sortOrders.get(i); int compare = sortOrder.compareBlockValue(sortTypes.get(i), leftBlock, leftBlockPosition, rightBlock, rightBlockPosition); if (compare != 0) { return compare; } } return 0; } }
minIndex = leftChildIndex; } else { // Node has both left and right children, find the minimum of the two. T leftChildValue = _values.get(leftChildIndex); T rightChildValue = _values.get(rightChildIndex); if (compare(_values.get(index), _values.get(minIndex)) == 1) { swapValues(index, minIndex); index = minIndex;
public int buildPage(int position, int[] outputChannels, PageBuilder pageBuilder) { while (!pageBuilder.isFull() && position < positionCount) { long pageAddress = valueAddresses.getLong(position); int blockIndex = decodeSliceIndex(pageAddress); int blockPosition = decodePosition(pageAddress); // append the row pageBuilder.declarePosition(); for (int i = 0; i < outputChannels.length; i++) { int outputChannel = outputChannels[i]; Type type = types.get(outputChannel); Block block = this.channels[outputChannel].get(blockIndex); type.appendTo(block, blockPosition, pageBuilder.getBlockBuilder(i)); } position++; } return position; }
/** * Returns the key+value pair with the max priority (min for minHeap mode) * <ul> * <li> key+value pair is not removed from the priority queue. </li> * <li> Returns null if the priority queue is empty. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @return Key+Value pair */ public IntObjectPair<T> peek() { if (_values.isEmpty()) { return null; } _reusablePair.setIntValue(_indexToKeyMap.get(0)); _reusablePair.setObjectValue(_values.get(0)); return _reusablePair; }
public void compact() { if (eagerCompact) { 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(); }
/** * Returns the value for the specified key. * <ul> * <li> Returns null if the specified key does not exist. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @param key Key for which to return the value * @return Value for the key */ public IntObjectPair get(int key) { if (!_keyToIndexMap.containsKey(key)) { return null; } int index = _keyToIndexMap.get(key); T value = _values.get(index); _reusablePair.setIntValue(index); _reusablePair.setObjectValue(value); return _reusablePair; }
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); }
public double getDouble(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return types.get(channel).getDouble(block, blockPosition); }
public boolean isNull(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return block.isNull(blockPosition); }