-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Improve String Last/First Storage Efficiency #12879
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rash67
force-pushed
the
byte-storage-and-string-agg-use
branch
9 times, most recently
from
August 10, 2022 19:58
a2462d4
to
bd68d14
Compare
rash67
commented
Aug 17, 2022
@@ -0,0 +1,44 @@ | |||
/* |
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.
oops, did not mean to add this file. I'll remove before finalizing the PR
processing/src/main/java/org/apache/druid/segment/serde/cell/IOIterator.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/druid/query/aggregation/SerializablePairLongStringBufferStore.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/druid/query/aggregation/SerializablePairLongStringBufferStore.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/druid/query/aggregation/SerializablePairLongStringBufferStore.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/druid/query/aggregation/SerializablePairLongStringColumnHeader.java
Show resolved
Hide resolved
...ain/java/org/apache/druid/query/aggregation/SerializablePairLongStringSimpleStagedSerde.java
Outdated
Show resolved
Hide resolved
processing/src/main/java/org/apache/druid/segment/serde/cell/CellReader.java
Outdated
Show resolved
Hide resolved
processing/src/main/java/org/apache/druid/segment/serde/cell/CellWriter.java
Show resolved
Hide resolved
processing/src/main/java/org/apache/druid/segment/serde/cell/DeserializingIOIterator.java
Outdated
Show resolved
Hide resolved
processing/src/test/java/org/apache/druid/segment/serde/cell/CellWriterTest.java
Outdated
Show resolved
Hide resolved
rash67
force-pushed
the
byte-storage-and-string-agg-use
branch
3 times, most recently
from
September 2, 2022 01:42
63b8767
to
edf5c10
Compare
-Add classes for writing cell values in LZ4 block compressed format. Payloads are indexed by element number for efficient random lookup -update SerializablePairLongStringComplexMetricSerde to use block compression -SerializablePairLongStringComplexMetricSerde also uses delta encoding of the Long by doing 2-pass encoding: buffers first to find min/max numbers and delta-encodes as integers if possible Entry points for doing block-compressed storage of byte[] payloads are the CellWriter and CellReader class. See SerializablePairLongStringComplexMetricSerde for how these are used along with how to do full column-based storage (delta encoding here) which includes 2-pass encoding to compute a column header
rash67
force-pushed
the
byte-storage-and-string-agg-use
branch
from
September 6, 2022 21:48
edf5c10
to
642aebc
Compare
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR should serve as a simple example of how to do entire column storage
which uses delta encoding as well as block compression (default LZ4).
Discussion:
This implementation was designed and discussed with @cheddar offline.
Details
-Add classes for writing cell values in LZ4 block compressed format.
Payloads are indexed by element number for efficient random lookup
-update SerializablePairLongStringComplexMetricSerde to use block
compression
-SerializablePairLongStringComplexMetricSerde also uses delta encoding
of the Long by doing 2-pass encoding: buffers first to find min/max
numbers and delta-encodes as integers if possible
Entry points for doing block-compressed storage of byte[] payloads
are the CellWriter and CellReader class. See
SerializablePairLongStringComplexMetricSerde for how these are used
along with how to do full column-based storage (delta encoding here)
which includes 2-pass encoding to compute a column header
Key changed/added classes in this PR
Storage Efficiency Improvement Measurement
The following shows a comparison of before and after on the simple
wikipedia edits dataset. The entire size went from 2.65mb to 2.25mb.
However, for the affected column, lastUser, the storage went from
730k to 330k which is about a 55% reduction in size. The overall size
did not change as much as the dominant column was page, which is not affected.
See commands to view each column's size:
Current implementation:
master u=!druid/distribution/target/apache-druid-0.24.0-SNAPSHOT/var/druid/segment-cache/wikipedia_old_format/2016-06-27T00:00:00.000Z_2016-06-28T00:00:00.000Z/2022-08-03T18:47:50.431Z/0> cat meta.smoosh | tail +2 | tr ',' ' ' | awk '{print $1,$4-$3}' | sort -rn -k2
page 1368012
last_user 731794
channel 54074
cityName 48640
sum_delta 48405
after this PR's changes
byte-storage-and-string-agg-use!druid/distribution/target/apache-druid-0.24.0-SNAPSHOT/var/druid/segment-cache/wikipedia_new_format/2016-06-27T00:00:00.000Z_2016-06-28T00:00:00.000Z/2022-08-03T19:08:23.690Z/0 *> cat meta.smoosh | tail +2 | tr ',' ' ' | awk '{print $1,$4-$3}' | sort -rn -k2
page 1368012
last_user 331024
channel 54074
cityName 48640
sum_delta 48405
This PR has: