/** * Creates a new big array containing one initial segment filled with the specified default value */ public ShortBigArray(short initialValue) { this.initialValue = initialValue; array = new short[INITIAL_SEGMENTS][]; allocateNewSegment(); }
public boolean isEmpty() { return headBlockIndex.get(getGroupId()) == NULL; }
/** * Ensures this big array is at least the specified length. If the array is smaller, segments * are added until the array is larger then the specified length. */ public void ensureCapacity(long length) { if (capacity > length) { return; } grow(length); }
nextBlockIndex.ensureCapacity(capacity); nextPosition.ensureCapacity(capacity); headBlockIndex.set(currentGroupId, insertedBlockIndex); headPosition.set(currentGroupId, insertedPosition); long absoluteTailAddress = toAbsolutePosition(tailBlockIndex.get(currentGroupId), tailPosition.get(currentGroupId)); nextBlockIndex.set(absoluteTailAddress, insertedBlockIndex); nextPosition.set(absoluteTailAddress, insertedPosition); tailBlockIndex.set(currentGroupId, insertedBlockIndex); tailPosition.set(currentGroupId, insertedPosition); groupEntryCount.increment(currentGroupId);
protected AbstractGroupCollectionAggregationState(PageBuilder pageBuilder) { this.headBlockIndex = new ShortBigArray(NULL); this.headPosition = new IntBigArray(NULL); this.nextBlockIndex = new ShortBigArray(NULL); this.nextPosition = new IntBigArray(NULL); this.tailBlockIndex = new ShortBigArray(NULL); this.tailPosition = new IntBigArray(NULL); this.currentPageBuilder = pageBuilder; this.values = new ArrayList<>(); this.sumPositions = new LongArrayList(); this.groupEntryCount = new IntBigArray(); values.add(currentPageBuilder); sumPositions.add(0L); valueBlocksRetainedSizeInBytes = 0; totalPositions = 0; capacity = 1024; nextBlockIndex.ensureCapacity(capacity); nextPosition.ensureCapacity(capacity); groupEntryCount.ensureCapacity(capacity); }
@Override public void ensureCapacity(long size) { headBlockIndex.ensureCapacity(size); headPosition.ensureCapacity(size); tailBlockIndex.ensureCapacity(size); tailPosition.ensureCapacity(size); groupEntryCount.ensureCapacity(size); }
@Override public long getEstimatedSize() { return INSTANCE_SIZE + headBlockIndex.sizeOf() + headPosition.sizeOf() + tailBlockIndex.sizeOf() + tailPosition.sizeOf() + nextBlockIndex.sizeOf() + nextPosition.sizeOf() + groupEntryCount.sizeOf() + valueBlocksRetainedSizeInBytes + // valueBlocksRetainedSizeInBytes doesn't contain the current block builder currentPageBuilder.getRetainedSizeInBytes(); }
nextBlockIndex.ensureCapacity(capacity); nextPosition.ensureCapacity(capacity); headBlockIndex.set(currentGroupId, insertedBlockIndex); headPosition.set(currentGroupId, insertedPosition); long absoluteTailAddress = toAbsolutePosition(tailBlockIndex.get(currentGroupId), tailPosition.get(currentGroupId)); nextBlockIndex.set(absoluteTailAddress, insertedBlockIndex); nextPosition.set(absoluteTailAddress, insertedPosition); tailBlockIndex.set(currentGroupId, insertedBlockIndex); tailPosition.set(currentGroupId, insertedPosition); groupEntryCount.increment(currentGroupId);
protected AbstractGroupCollectionAggregationState(PageBuilder pageBuilder) { this.headBlockIndex = new ShortBigArray(NULL); this.headPosition = new IntBigArray(NULL); this.nextBlockIndex = new ShortBigArray(NULL); this.nextPosition = new IntBigArray(NULL); this.tailBlockIndex = new ShortBigArray(NULL); this.tailPosition = new IntBigArray(NULL); this.currentPageBuilder = pageBuilder; this.values = new ArrayList<>(); this.sumPositions = new LongArrayList(); this.groupEntryCount = new IntBigArray(); values.add(currentPageBuilder); sumPositions.add(0L); valueBlocksRetainedSizeInBytes = 0; totalPositions = 0; capacity = 1024; nextBlockIndex.ensureCapacity(capacity); nextPosition.ensureCapacity(capacity); groupEntryCount.ensureCapacity(capacity); }
@Override public void ensureCapacity(long size) { headBlockIndex.ensureCapacity(size); headPosition.ensureCapacity(size); tailBlockIndex.ensureCapacity(size); tailPosition.ensureCapacity(size); groupEntryCount.ensureCapacity(size); }
@Override public long getEstimatedSize() { return INSTANCE_SIZE + headBlockIndex.sizeOf() + headPosition.sizeOf() + tailBlockIndex.sizeOf() + tailPosition.sizeOf() + nextBlockIndex.sizeOf() + nextPosition.sizeOf() + groupEntryCount.sizeOf() + valueBlocksRetainedSizeInBytes + // valueBlocksRetainedSizeInBytes doesn't contain the current block builder currentPageBuilder.getRetainedSizeInBytes(); }
public boolean isEmpty() { return headBlockIndex.get(getGroupId()) == NULL; }
/** * Creates a new big array containing one initial segment filled with the specified default value */ public ShortBigArray(short initialValue) { this.initialValue = initialValue; array = new short[INITIAL_SEGMENTS][]; allocateNewSegment(); }
/** * Ensures this big array is at least the specified length. If the array is smaller, segments * are added until the array is larger then the specified length. */ public void ensureCapacity(long length) { if (capacity > length) { return; } grow(length); }
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); } }
private void grow(long length) { // how many segments are required to get to the length? int requiredSegments = segment(length) + 1; // grow base array if necessary if (array.length < requiredSegments) { array = Arrays.copyOf(array, requiredSegments); } // add new segments while (segments < requiredSegments) { allocateNewSegment(); } }
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); } }
private void grow(long length) { // how many segments are required to get to the length? int requiredSegments = segment(length) + 1; // grow base array if necessary if (array.length < requiredSegments) { array = Arrays.copyOf(array, requiredSegments); } // add new segments while (segments < requiredSegments) { allocateNewSegment(); } }