Skip to content

[common] Introduce BitmapFileIndexMetaV2.#5028

Merged
JingsongLi merged 17 commits intoapache:masterfrom
hang8929201:bitmap-multi-level-index
Feb 24, 2025
Merged

[common] Introduce BitmapFileIndexMetaV2.#5028
JingsongLi merged 17 commits intoapache:masterfrom
hang8929201:bitmap-multi-level-index

Conversation

@hang8929201
Copy link
Copy Markdown
Contributor

Purpose

When the bitmap-indexed column cardinality is high, using the first version of the bitmap index format will take a lot of time to read the entire dictionary. But in fact we don't need a full dictionary when dealing with a small number of predicates, the performance of predicate hits on the bitmap can be improved by creating a secondary index on the dictionary.

https://docs.google.com/document/d/11dJlGlSX3dwYKKrPN0DQ2XQTsx6d9wI6DTBIiiBwomM/edit?tab=t.0

performance

cardinality 1000:
image

cardinality 10000:
image

cardinality 30000:
image

cardinality 50000:
image

cardinality 80000:
image

cardinality 100000:
image

Tests

org.apache.paimon.fileindex.bitmapindex.TestBitmapFileIndex
org.apache.paimon.spark.SparkFileIndexITCase
org.apache.paimon.benchmark.bitmap.BitmapIndexBenchmark

API and Format

Documentation

docs/content/concepts/spec/fileindex.md

Copy link
Copy Markdown
Contributor

@Tan-JiaLiang Tan-JiaLiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hang8929201 Thanks for your patience!

+1 cc @JingsongLi

@2k124
Copy link
Copy Markdown

2k124 commented Feb 8, 2025

+1

@hang8929201
Copy link
Copy Markdown
Contributor Author

I found another question that needs to be discussed. Should the index version default to v1 or v2? @Tan-JiaLiang @JingsongLi

@JingsongLi
Copy link
Copy Markdown
Contributor

I found another question that needs to be discussed. Should the index version default to v1 or v2? @Tan-JiaLiang @JingsongLi

I don't have a clear idea, although it may cause compatibility issues, bitmap should not be used too much. Maintaining the default version to 1 is a relatively conservative choice.

public static final String VERSION = "version";
public static final String INDEX_BLOCK_SIZE = "index-block-size";
public static final String ENABLE_BUFFERED_INPUT = "enable-buffered-input";
public static final String ENABLE_NEXT_OFFSET_TO_SIZE = "enable-next-offset-to-size";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is enable next offset to size? Under what circumstances can it not be size?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter is just a switch for the benchmark test.

* | ... |
* +-------------------------------------------------+-----------------
*
* index block format:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have ability to compress index block?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that it is usually more appropriate to compress the data block, our 'data block' is the roaring bitmap, which is relatively well compressed. The index block is relatively small and has high query performance requirements. I guess there is no need to compress it. Maybe in the future when there is a bad case in the business, we will design a compressed format.

Options options;

void tryDeserialize() {
if (entryList == null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can take a look to https://cwiki.apache.org/confluence/display/PAIMON/PIP-25%3A+Introduce+a+key-value+file+format+for+paimon+primary+key+table

Here just something like LevelDB sst block, we can store length to avoid deserialize all entries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't quite understand what you mean. The purpose of designing secondary indexes is to read only part of the entries.

bitmapOffsets,
offsetRef[0]);
} else {
throw new RuntimeException("invalid version: " + version);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the writer is upgraded to the latest version and the default index version is v2, if the reader is not upgraded, an error will be reported here. Is it more appropriate to use the v1 format by default or force users to upgrade the paimon version by reporting an error? @Tan-JiaLiang @JingsongLi

public static final String VERSION = "version";
public static final String INDEX_BLOCK_SIZE = "index-block-size";
public static final String ENABLE_BUFFERED_INPUT = "enable-buffered-input";
public static final String ENABLE_NEXT_OFFSET_TO_SIZE = "enable-next-offset-to-size";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter is just a switch for the benchmark test.

* | ... |
* +-------------------------------------------------+-----------------
*
* index block format:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that it is usually more appropriate to compress the data block, our 'data block' is the roaring bitmap, which is relatively well compressed. The index block is relatively small and has high query performance requirements. I guess there is no need to compress it. Maybe in the future when there is a bad case in the business, we will design a compressed format.

Options options;

void tryDeserialize() {
if (entryList == null) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't quite understand what you mean. The purpose of designing secondary indexes is to read only part of the entries.

Copy link
Copy Markdown
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi JingsongLi merged commit 958c1ec into apache:master Feb 24, 2025
13 checks passed
@hang8929201 hang8929201 deleted the bitmap-multi-level-index branch March 12, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants