Jackie-Jiang commented on a change in pull request #6320:
URL: https://github.com/apache/incubator-pinot/pull/6320#discussion_r537847693
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/segment/creator/impl/inv/OffHeapBitmapInvertedIndexCreator.java
##########
@@ -181,33 +184,45 @@ public void seal()
}
// Create bitmaps from inverted index buffers and serialize them to file
- try (DataOutputStream offsetDataStream = new DataOutputStream(
- new BufferedOutputStream(new FileOutputStream(_invertedIndexFile)));
- FileOutputStream bitmapFileStream = new
FileOutputStream(_invertedIndexFile);
- DataOutputStream bitmapDataStream = new DataOutputStream(new
BufferedOutputStream(bitmapFileStream))) {
- int bitmapOffset = (_cardinality + 1) * Integer.BYTES;
- offsetDataStream.writeInt(bitmapOffset);
- bitmapFileStream.getChannel().position(bitmapOffset);
-
+ ByteBuffer offsetBuffer = null;
+ ByteBuffer bitmapBuffer = null;
+ try (FileChannel channel = new RandomAccessFile(_invertedIndexFile,
"rw").getChannel()) {
+ // map the offsets buffer
+ int startOfBitmaps = (_cardinality + 1) * Integer.BYTES;
+ offsetBuffer = channel.map(FileChannel.MapMode.READ_WRITE, 0,
startOfBitmaps)
+ .order(ByteOrder.BIG_ENDIAN);
+ offsetBuffer.putInt(startOfBitmaps);
+ bitmapBuffer = channel.map(FileChannel.MapMode.READ_WRITE,
startOfBitmaps, Integer.MAX_VALUE - startOfBitmaps)
+ .order(ByteOrder.LITTLE_ENDIAN);
+ RoaringBitmapWriter<RoaringBitmap> writer =
RoaringBitmapWriter.writer().get();
Review comment:
The bitmap could be dense (when cardinality is very low), but won't be
contiguous. What is the old behavior? We don't explicitly call `runOptimize()`
on the `MutableRoaringBitmap`, will it perform RLE automatically? If not, we
can disable it here to keep the same behavior and have better performance.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]