private final long readPointer(int logicalPosition) { if (logicalPosition < 0 | logicalPosition >= this.numRecords) { throw new IndexOutOfBoundsException(); } final int bufferNum = logicalPosition / this.indexEntriesPerSegment; final int segmentOffset = logicalPosition % this.indexEntriesPerSegment; return this.sortIndex.get(bufferNum).getLong(segmentOffset * this.indexEntrySize); }
/** * Reads a long integer value (64bit, 8 bytes) from the given position, in little endian byte order. * This method's speed depends on the system's native byte order, and it * is possibly slower than {@link #getLong(int)}. For most cases (such as * transient storage in memory or serialization for I/O and network), * it suffices to know that the byte order in which the value is written is the same as the * one in which it is read, and {@link #getLong(int)} is the preferable choice. * * @param index The position from which the value will be read. * @return The long value at the given position. * * @throws IndexOutOfBoundsException Thrown, if the index is negative, or larger then the segment * size minus 8. */ public final long getLongLittleEndian(int index) { if (LITTLE_ENDIAN) { return getLong(index); } else { return Long.reverseBytes(getLong(index)); } }
private final long readPointer(int logicalPosition) { if (logicalPosition < 0 | logicalPosition >= this.numRecords) { throw new IndexOutOfBoundsException(); } final int bufferNum = logicalPosition / this.indexEntriesPerSegment; final int segmentOffset = logicalPosition % this.indexEntriesPerSegment; return this.sortIndex.get(bufferNum).getLong(segmentOffset * this.indexEntrySize); }
/** * Reads a long integer value (64bit, 8 bytes) from the given position, in big endian byte order. * This method's speed depends on the system's native byte order, and it * is possibly slower than {@link #getLong(int)}. For most cases (such as * transient storage in memory or serialization for I/O and network), * it suffices to know that the byte order in which the value is written is the same as the * one in which it is read, and {@link #getLong(int)} is the preferable choice. * * @param index The position from which the value will be read. * @return The long value at the given position. * * @throws IndexOutOfBoundsException Thrown, if the index is negative, or larger then the segment * size minus 8. */ public final long getLongBigEndian(int index) { if (LITTLE_ENDIAN) { return Long.reverseBytes(getLong(index)); } else { return getLong(index); } }
/** * Reads a long integer value (64bit, 8 bytes) from the given position, in little endian byte order. * This method's speed depends on the system's native byte order, and it * is possibly slower than {@link #getLong(int)}. For most cases (such as * transient storage in memory or serialization for I/O and network), * it suffices to know that the byte order in which the value is written is the same as the * one in which it is read, and {@link #getLong(int)} is the preferable choice. * * @param index The position from which the value will be read. * @return The long value at the given position. * * @throws IndexOutOfBoundsException Thrown, if the index is negative, or larger then the segment * size minus 8. */ public final long getLongLittleEndian(int index) { if (LITTLE_ENDIAN) { return getLong(index); } else { return Long.reverseBytes(getLong(index)); } }
/** * Reads a double-precision floating point value (64bit, 8 bytes) from the given position, in the system's * native byte order. This method offers the best speed for double reading and should be used * unless a specific byte order is required. In most cases, it suffices to know that the * byte order in which the value is written is the same as the one in which it is read * (such as transient storage in memory, or serialization for I/O and network), making this * method the preferable choice. * * @param index The position from which the value will be read. * @return The double value at the given position. * * @throws IndexOutOfBoundsException Thrown, if the index is negative, or larger then the segment * size minus 8. */ public final double getDouble(int index) { return Double.longBitsToDouble(getLong(index)); }
/** * Reads a long integer value (64bit, 8 bytes) from the given position, in big endian byte order. * This method's speed depends on the system's native byte order, and it * is possibly slower than {@link #getLong(int)}. For most cases (such as * transient storage in memory or serialization for I/O and network), * it suffices to know that the byte order in which the value is written is the same as the * one in which it is read, and {@link #getLong(int)} is the preferable choice. * * @param index The position from which the value will be read. * @return The long value at the given position. * * @throws IndexOutOfBoundsException Thrown, if the index is negative, or larger then the segment * size minus 8. */ public final long getLongBigEndian(int index) { if (LITTLE_ENDIAN) { return Long.reverseBytes(getLong(index)); } else { return getLong(index); } }
/** * Reads a double-precision floating point value (64bit, 8 bytes) from the given position, in the system's * native byte order. This method offers the best speed for double reading and should be used * unless a specific byte order is required. In most cases, it suffices to know that the * byte order in which the value is written is the same as the one in which it is read * (such as transient storage in memory, or serialization for I/O and network), making this * method the preferable choice. * * @param index The position from which the value will be read. * @return The double value at the given position. * * @throws IndexOutOfBoundsException Thrown, if the index is negative, or larger then the segment * size minus 8. */ public final double getDouble(int index) { return Double.longBitsToDouble(getLong(index)); }
@Override public T next(T target) { if (this.current < this.size) { this.current++; if (this.currentOffset > lastIndexEntryOffset) { this.currentOffset = 0; this.currentIndexSegment = sortIndex.get(++this.currentSegment); } long pointer = this.currentIndexSegment.getLong(this.currentOffset); this.currentOffset += indexEntrySize; try { return getRecordFromBuffer(target, pointer); } catch (IOException ioe) { throw new RuntimeException(ioe); } } else { return null; } } };
@Override public T next(T target) { if (this.current < this.size) { this.current++; if (this.currentOffset > lastIndexEntryOffset) { this.currentOffset = 0; this.currentIndexSegment = sortIndex.get(++this.currentSegment); } long pointer = this.currentIndexSegment.getLong(this.currentOffset); this.currentOffset += indexEntrySize; try { return getRecordFromBuffer(target, pointer); } catch (IOException ioe) { throw new RuntimeException(ioe); } } else { return null; } } };
@Override public int compare(int i, int j) { final int bufferNumI = i / this.indexEntriesPerSegment; final int segmentOffsetI = (i % this.indexEntriesPerSegment) * this.indexEntrySize; final int bufferNumJ = j / this.indexEntriesPerSegment; final int segmentOffsetJ = (j % this.indexEntriesPerSegment) * this.indexEntrySize; final MemorySegment segI = this.sortIndex.get(bufferNumI); final MemorySegment segJ = this.sortIndex.get(bufferNumJ); int val = MemorySegment.compare(segI, segJ, segmentOffsetI + OFFSET_LEN, segmentOffsetJ + OFFSET_LEN, this.numKeyBytes); if (val != 0 || this.normalizedKeyFullyDetermines) { return this.useNormKeyUninverted ? val : -val; } final long pointerI = segI.getLong(segmentOffsetI); final long pointerJ = segJ.getLong(segmentOffsetJ); return compareRecords(pointerI, pointerJ); }
@Override public int compare(int i, int j) { final int bufferNumI = i / this.indexEntriesPerSegment; final int segmentOffsetI = (i % this.indexEntriesPerSegment) * this.indexEntrySize; final int bufferNumJ = j / this.indexEntriesPerSegment; final int segmentOffsetJ = (j % this.indexEntriesPerSegment) * this.indexEntrySize; final MemorySegment segI = this.sortIndex.get(bufferNumI); final MemorySegment segJ = this.sortIndex.get(bufferNumJ); int val = MemorySegment.compare(segI, segJ, segmentOffsetI + OFFSET_LEN, segmentOffsetJ + OFFSET_LEN, this.numKeyBytes); if (val != 0 || this.normalizedKeyFullyDetermines) { return this.useNormKeyUninverted ? val : -val; } final long pointerI = segI.getLong(segmentOffsetI); final long pointerJ = segJ.getLong(segmentOffsetJ); return compareRecords(pointerI, pointerJ); }
final long pointer = currentIndexSegment.getLong(offset); this.recordBuffer.setReadPosition(pointer); this.serializer.copy(this.recordBuffer, output); final long pointer = currentIndexSegment.getLong(offset); this.recordBuffer.setReadPosition(pointer); this.serializer.copy(this.recordBuffer, output);
final long pointer = currentIndexSegment.getLong(offset); this.recordBuffer.setReadPosition(pointer); this.serializer.copy(this.recordBuffer, output); final long pointer = currentIndexSegment.getLong(offset); this.recordBuffer.setReadPosition(pointer); this.serializer.copy(this.recordBuffer, output);
final long pointer = currentIndexSegment.getLong(offset); this.recordBuffer.setReadPosition(pointer); this.serializer.copy(this.recordBuffer, output); final long pointer = currentIndexSegment.getLong(offset); this.recordBuffer.setReadPosition(pointer); this.serializer.copy(this.recordBuffer, output);
final long pointer = currentIndexSegment.getLong(offset); this.recordBuffer.setReadPosition(pointer); this.serializer.copy(this.recordBuffer, output); final long pointer = currentIndexSegment.getLong(offset); this.recordBuffer.setReadPosition(pointer); this.serializer.copy(this.recordBuffer, output);
final long pointer = this.bucket.getLong(this.bucketInSegmentOffset + BUCKET_POINTER_START_OFFSET + (this.numInSegment * POINTER_LEN)); this.numInSegment++; final long forwardPointer = this.bucket.getLong(this.bucketInSegmentOffset + HEADER_FORWARD_OFFSET); if (forwardPointer == BUCKET_FORWARD_POINTER_NOT_SET) { return null;
final long pointer = this.bucket.getLong(this.bucketInSegmentOffset + BUCKET_POINTER_START_OFFSET + (this.numInSegment * POINTER_LEN)); this.numInSegment++; final long forwardPointer = this.bucket.getLong(this.bucketInSegmentOffset + HEADER_FORWARD_OFFSET); if (forwardPointer == BUCKET_FORWARD_POINTER_NOT_SET) { return null;
for (int j = 0; j < NUM_ENTRIES_PER_BUCKET && j < count; j++) { pointerOffset = bucketOffset + BUCKET_POINTER_START_OFFSET + (j * POINTER_LEN); pointer = segment.getLong(pointerOffset); partition.readRecordAt(pointer, tempHolder); pointer = this.compactionMemory.appendRecord(tempHolder); segment.putLong(pointerOffset, pointer); long overflowPointer = segment.getLong(bucketOffset + HEADER_FORWARD_OFFSET); if(overflowPointer != BUCKET_FORWARD_POINTER_NOT_SET) { count += partition.overflowSegments[overflowSegNum].getInt(bucketOffset + HEADER_COUNT_OFFSET); while(current < count) { pointer = partition.overflowSegments[overflowSegNum].getLong(pointerOffset); partition.readRecordAt(pointer, tempHolder); pointer = this.compactionMemory.appendRecord(tempHolder); if(current % NUM_ENTRIES_PER_BUCKET == 0) { count += partition.overflowSegments[overflowSegNum].getInt(bucketOffset + HEADER_COUNT_OFFSET); overflowPointer = partition.overflowSegments[overflowSegNum].getLong(bucketOffset + HEADER_FORWARD_OFFSET); if(overflowPointer == BUCKET_FORWARD_POINTER_NOT_SET) { break;
final long originalForwardPointer = bucket.getLong(bucketInSegmentPos + HEADER_FORWARD_OFFSET); final long forwardForNewBucket;