-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce raw fwd index version V5 containing implicit num doc length, improving space efficiency #14105
Introduce raw fwd index version V5 containing implicit num doc length, improving space efficiency #14105
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #14105 +/- ##
============================================
+ Coverage 61.75% 63.76% +2.01%
- Complexity 207 1535 +1328
============================================
Files 2436 2626 +190
Lines 133233 144646 +11413
Branches 20636 22136 +1500
============================================
+ Hits 82274 92239 +9965
- Misses 44911 45596 +685
- Partials 6048 6811 +763
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…wIndexCreatorV2Test.java
…tiValueFixedByteRawIndexCreatorV2Test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's introduce a new forward index version v5 for this new format
/** | ||
Same as MultiValueFixedByteRawIndexCreator, but without storing the number of elements for each row. | ||
*/ | ||
public class MultiValueFixedByteRawIndexCreatorV2 extends MultiValueFixedByteRawIndexCreator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to add a new creator because creator is used to handle creation of different version of forward index. Instead, we want to add a new raw index version v5
for this new format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/** | ||
Same as FixedByteChunkMVForwardIndexReader, but the number of elements for each row is inferred | ||
*/ | ||
public final class FixedByteChunkMVForwardIndexReaderV2 extends FixedByteChunkMVForwardIndexReader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call it V5 to be consistent with index version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.../pinot/segment/local/segment/index/readers/forward/FixedByteChunkMVForwardIndexReaderV2.java
Outdated
Show resolved
Hide resolved
…orward index creator version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
|
||
/** | ||
* Forward index writer that extends {@link VarByteChunkForwardIndexWriterV4} with the only difference being the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the only difference. Let's also document the value format difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
...ache/pinot/segment/local/segment/index/readers/forward/VarByteChunkForwardIndexReaderV4.java
Show resolved
Hide resolved
…wIndexCreatorV2Test.java
…tiValueFixedByteRawIndexCreatorV2Test
…orward index creator version.
…dex' into master-improved-MV-fixed-byte-index
… reader to fetch version number.
@@ -81,6 +80,12 @@ public VarByteChunkForwardIndexReaderV4(PinotDataBuffer dataBuffer, FieldSpec.Da | |||
_isSingleValue = isSingleValue; | |||
} | |||
|
|||
public void validateIndexVersion(PinotDataBuffer dataBuffer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant we can add a getVersion()
method into this class, and override it in v5 reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a few minor comments
@@ -76,11 +76,13 @@ | |||
public class VarByteChunkForwardIndexWriterV4 implements VarByteChunkWriter { | |||
public static final int VERSION = 4; | |||
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(VarByteChunkForwardIndexWriterV4.class); | |||
// Use the run-time concrete class to retrieve the logger | |||
protected final Logger _logger = LoggerFactory.getLogger(this.getClass()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected final Logger _logger = LoggerFactory.getLogger(this.getClass()); | |
protected final Logger _logger = LoggerFactory.getLogger(getClass()); |
The data layout of the multi-value fixed byte raw forward index can be optimized to enhance storage efficiency.
Consider the following multi-value document as an example:
[int(1), int(2), int(3)]
. The current binary data layout inMVFixedBytesRawFwdIndex
is as follows:0x00000010 0x00000003 0x00000001 0x00000002 0x00000003
.0x00000010
is an integer representing the total payload length of the byte array containing the multi-value document content, which in this case is 16 bytes.0x00000003
is an integer explicitly representing the number of elements in the multi-value document (i.e., 3).0x00000001 0x00000002 0x00000003
are 3 integers representing the 3 values of the multi-value document: 1, 2, and 3.In Pinot, the fixed byte raw forward index can only contain one specific fixed-length data type:
int
,long
,float
, ordouble
. Rather than explicitly specifying the number of elements for each document using an integer, this value can be omitted and instead inferred implicitly using the following calculation:If the forward index uses the passthrough chunk compression type (i.e., no compression), we can save 4 bytes per document by omitting the explicit element count. This results in the following savings:
0
elements, we save50%
.1
element, we save33%
.2
elements, we save25%
.For forward indexes that leverage compression to reduce data size, the savings can be even more significant in some scenarios. This PR includes a unit test,
VarByteChunkV5Test#validateCompressionRatioIncrease
, which demonstrates this. In particular, we usedZStandard
as the chunk compressor and inserted 1 million short multi-value (MV) documents, where the length follows a Gaussian distribution. In this experiment, the values of each integer in the MV documents were also somewhat repetitive. Under these conditions, we observed 50%+ reduction in on-disk file size compared to V4 fwd index writer versionThis PR introduces the implicit length optimization via
VarByteChunkForwardIndexWriterV5
on the write path, alongsideVarByteChunkForwardIndexReaderV5
on the read path.MultiValueFixedByteRawIndexCreator
andForwardIndexReaderFactory
are also modified accordingly to use the new index writer and reader when the index version is set to 5 or greater. After this PR is merged, other composite forward indexes such as theCLPForwardIndexCreatorV1
forward index can leverage these new classes to significantly improve the overall compression ratio.