int getValuePosition() { return valuePositions.get(nodePointer); }
@Override public int nextInt() { return groupIds.get(position++); } };
@Override public int getPartitionCount() { return partitionCounts.get(groupId); }
@Override public int nextInt() { return groupIds.get(position++); } };
int getValuePosition() { return valuePositions.get(nodePointer); }
public final int getEntryCount() { return groupEntryCount.get(getGroupId()); }
public final int getEntryCount() { return groupEntryCount.get(getGroupId()); }
public boolean contains(Block block, int position) { requireNonNull(block, "block must not be null"); checkArgument(position >= 0, "position must be >= 0"); if (block.isNull(position)) { return containsNullElement; } else { return blockPositionByHash.get(getHashPositionOfElement(block, position)) != EMPTY_SLOT; } }
public boolean contains(Block block, int position) { requireNonNull(block, "block must not be null"); checkArgument(position >= 0, "position must be >= 0"); if (block.isNull(position)) { return containsNullElement; } else { return blockPositionByHash.get(getHashPositionOfElement(block, position)) != EMPTY_SLOT; } }
/** * used to iterate over all non-null nodes in the data structure * * @param nodeReader - will be passed every non-null nodePointer */ private void iterateGroupNodes(long groupdId, NodeReader nodeReader) { // while the index can be a long, the value is always an int int currentPointer = (int) headPointers.get(groupdId); checkArgument(currentPointer != NULL, "valid group must have non-null head pointer"); while (currentPointer != NULL) { checkState(currentPointer < nextNodePointer, "error, corrupt pointer; max valid %s, found %s", nextNodePointer, currentPointer); nodeReader.read(currentPointer); currentPointer = nextPointers.get(currentPointer); } }
/** * used to iterate over all non-null nodes in the data structure * * @param nodeReader - will be passed every non-null nodePointer */ private void iterateGroupNodes(long groupdId, NodeReader nodeReader) { // while the index can be a long, the value is always an int int currentPointer = (int) headPointers.get(groupdId); checkArgument(currentPointer != NULL, "valid group must have non-null head pointer"); while (currentPointer != NULL) { checkState(currentPointer < nextNodePointer, "error, corrupt pointer; max valid %s, found %s", nextNodePointer, currentPointer); nodeReader.read(currentPointer); currentPointer = nextPointers.get(currentPointer); } }
@Override public void add(int position, Block block, long count) { int hashPosition = getBucketId(TypeUtils.hashPosition(type, block, position), mask); // look for an empty slot or a slot containing this key while (true) { if (hashPositions.get(hashPosition) == -1) { break; } if (type.equalTo(block, position, values, hashPositions.get(hashPosition))) { counts.add(hashPositions.get(hashPosition), count); return; } // increment position and mask to handle wrap around hashPosition = (hashPosition + 1) & mask; } addNewGroup(hashPosition, position, block, count); }
@Override public void add(int position, Block block, long count) { int hashPosition = getBucketId(TypeUtils.hashPosition(type, block, position), mask); // look for an empty slot or a slot containing this key while (true) { if (hashPositions.get(hashPosition) == -1) { break; } if (type.equalTo(block, position, values, hashPositions.get(hashPosition))) { counts.add(hashPositions.get(hashPosition), count); return; } // increment position and mask to handle wrap around hashPosition = (hashPosition + 1) & mask; } addNewGroup(hashPosition, position, block, count); }
public int putIfAbsent(Block block, int position) { requireNonNull(block, "block must not be null"); if (block.isNull(position)) { containsNullElement = true; return NULL_POSITION; } int blockPosition; long hashPosition = getHashPositionOfElement(block, position); if (blockPositionByHash.get(hashPosition) != EMPTY_SLOT) { blockPosition = blockPositionByHash.get(hashPosition); } else { blockPosition = addNewElement(hashPosition, block, position); } verify(blockPosition != NULL_POSITION); return blockPosition; }
public int putIfAbsent(Block block, int position) { requireNonNull(block, "block must not be null"); if (block.isNull(position)) { containsNullElement = true; return NULL_POSITION; } int blockPosition; long hashPosition = getHashPositionOfElement(block, position); if (blockPositionByHash.get(hashPosition) != EMPTY_SLOT) { blockPosition = blockPositionByHash.get(hashPosition); } else { blockPosition = addNewElement(hashPosition, block, position); } verify(blockPosition != NULL_POSITION); return blockPosition; }
public void forEach(T consumer) { short currentBlockId = headBlockIndex.get(getGroupId()); int currentPosition = headPosition.get(getGroupId()); while (currentBlockId != NULL) { accept(consumer, values.get(currentBlockId), currentPosition); long absoluteCurrentAddress = toAbsolutePosition(currentBlockId, currentPosition); currentBlockId = nextBlockIndex.get(absoluteCurrentAddress); currentPosition = nextPosition.get(absoluteCurrentAddress); } }
public void forEach(T consumer) { short currentBlockId = headBlockIndex.get(getGroupId()); int currentPosition = headPosition.get(getGroupId()); while (currentBlockId != NULL) { accept(consumer, values.get(currentBlockId), currentPosition); long absoluteCurrentAddress = toAbsolutePosition(currentBlockId, currentPosition); currentBlockId = nextBlockIndex.get(absoluteCurrentAddress); currentPosition = nextPosition.get(absoluteCurrentAddress); } }
/** * Get slot position of element at {@code position} of {@code block} */ private long getHashPositionOfElement(Block block, int position) { checkArgument(!block.isNull(position), "position is null"); int length = block.getSliceLength(position); long hashPosition = getMaskedHash(block.hash(position, 0, length)); while (true) { int blockPosition = blockPositionByHash.get(hashPosition); if (blockPosition == EMPTY_SLOT) { // Doesn't have this element return hashPosition; } else if (elementBlock.getSliceLength(blockPosition) == length && block.equals(position, 0, elementBlock, blockPosition, 0, length)) { // Already has this element return hashPosition; } hashPosition = getMaskedHash(hashPosition + 1); } }
/** * Get slot position of element at {@code position} of {@code block} */ private long getHashPositionOfElement(Block block, int position) { checkArgument(!block.isNull(position), "position is null"); int length = block.getSliceLength(position); long hashPosition = getMaskedHash(block.hash(position, 0, length)); while (true) { int blockPosition = blockPositionByHash.get(hashPosition); if (blockPosition == EMPTY_SLOT) { // Doesn't have this element return hashPosition; } else if (elementBlock.getSliceLength(blockPosition) == length && block.equals(position, 0, elementBlock, blockPosition, 0, length)) { // Already has this element return hashPosition; } hashPosition = getMaskedHash(hashPosition + 1); } }
@Override public boolean contains(int position, Page page, int[] hashChannels) { Block block = page.getBlock(hashChannel); if (block.isNull(position)) { return nullGroupId >= 0; } long value = BIGINT.getLong(block, position); long hashPosition = getHashPosition(value, mask); // look for an empty slot or a slot containing this key while (true) { int groupId = groupIds.get(hashPosition); if (groupId == -1) { return false; } else if (value == values.get(hashPosition)) { return true; } // increment position and mask to handle wrap around hashPosition = (hashPosition + 1) & mask; } }