Improve String Last/First Storage Efficiency#12879
Merged
cheddar merged 1 commit intoapache:masterfrom Sep 7, 2022
Merged
Conversation
a2462d4 to
bd68d14
Compare
rash67
commented
Aug 17, 2022
| @@ -0,0 +1,44 @@ | |||
| /* | |||
Contributor
Author
There was a problem hiding this comment.
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
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
edf5c10 to
642aebc
Compare
9 tasks
This file contains hidden or 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
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: