Repository navigation
refactor(index)!: unify file and realtime index results #597
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
Open
lxy-9602
wants to merge
4
commits into
apache:main
Choose a base branch
from
lxy-9602:refactor-rt-index-result
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <functional> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "paimon/index/index_result.h" | ||
|
|
||
| namespace paimon { | ||
|
|
||
| /// Lazily loaded row positions, shared by file and real-time index results. | ||
| template <typename Bitmap> | ||
| class PAIMON_EXPORT BitmapResult : public IndexResult<Bitmap> { | ||
| public: | ||
| using BitmapSupplier = std::function<Result<Bitmap>()>; | ||
|
|
||
| /// Construct a materialized result, rejecting negative row positions. | ||
| static Result<std::shared_ptr<BitmapResult<Bitmap>>> Create(Bitmap rows, bool is_exact); | ||
|
|
||
| explicit BitmapResult(BitmapSupplier bitmap_supplier, bool is_exact = false); | ||
|
|
||
| Result<bool> IsRemain() const override; | ||
|
|
||
| /// Load the bitmap if needed. The result owns the returned bitmap. | ||
| Result<const Bitmap*> GetBitmap() const; | ||
|
|
||
| Result<std::shared_ptr<IndexResult<Bitmap>>> And( | ||
| const std::shared_ptr<IndexResult<Bitmap>>& other) override; | ||
| Result<std::shared_ptr<IndexResult<Bitmap>>> Or( | ||
| const std::shared_ptr<IndexResult<Bitmap>>& other) override; | ||
| std::string ToString() const override; | ||
|
|
||
| private: | ||
| BitmapResult(Bitmap rows, bool is_exact); | ||
|
|
||
| mutable bool initialized_ = false; | ||
| BitmapSupplier bitmap_supplier_; | ||
| mutable Bitmap bitmap_; | ||
| }; | ||
|
|
||
| } // namespace paimon |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "paimon/result.h" | ||
| #include "paimon/visibility.h" | ||
|
|
||
| namespace paimon { | ||
|
|
||
| /// An index result within one source, read view and candidate scope. | ||
| /// Implementations are provided for RoaringBitmap32 and RoaringBitmap64. | ||
| /// Bitmap constrains And/Or to compatible result types; this base class stores no bitmap. | ||
| /// Scalar predicate results never omit matches: exact results contain only matching rows, | ||
| /// while inexact results may contain false positives. This does not guarantee search recall. | ||
| template <typename Bitmap> | ||
| class PAIMON_EXPORT IndexResult : public std::enable_shared_from_this<IndexResult<Bitmap>> { | ||
| public: | ||
| virtual ~IndexResult() = default; | ||
|
|
||
| static std::shared_ptr<IndexResult<Bitmap>> Remain(); | ||
| static std::shared_ptr<IndexResult<Bitmap>> Skip(); | ||
|
|
||
| bool IsExact() const { | ||
| return is_exact_; | ||
| } | ||
|
|
||
| /// Whether the result retains candidates. This alone does not establish exactness. | ||
| virtual Result<bool> IsRemain() const = 0; | ||
|
|
||
| /// Combine different predicates over the same source, view and candidate scope. | ||
| virtual Result<std::shared_ptr<IndexResult<Bitmap>>> And( | ||
| const std::shared_ptr<IndexResult<Bitmap>>& other) = 0; | ||
| virtual Result<std::shared_ptr<IndexResult<Bitmap>>> Or( | ||
| const std::shared_ptr<IndexResult<Bitmap>>& other) = 0; | ||
|
|
||
| virtual std::string ToString() const = 0; | ||
|
|
||
| protected: | ||
| explicit IndexResult(bool is_exact) : is_exact_(is_exact) {} | ||
|
|
||
| private: | ||
| bool is_exact_; | ||
| }; | ||
|
|
||
| template <typename Bitmap> | ||
| class PAIMON_EXPORT RemainIndexResult : public IndexResult<Bitmap> { | ||
| public: | ||
| RemainIndexResult() : IndexResult<Bitmap>(false) {} | ||
|
|
||
| Result<bool> IsRemain() const override; | ||
| Result<std::shared_ptr<IndexResult<Bitmap>>> And( | ||
| const std::shared_ptr<IndexResult<Bitmap>>& other) override; | ||
| Result<std::shared_ptr<IndexResult<Bitmap>>> Or( | ||
| const std::shared_ptr<IndexResult<Bitmap>>& other) override; | ||
| std::string ToString() const override; | ||
| }; | ||
|
|
||
| template <typename Bitmap> | ||
| class PAIMON_EXPORT SkipIndexResult : public IndexResult<Bitmap> { | ||
| public: | ||
| SkipIndexResult() : IndexResult<Bitmap>(true) {} | ||
|
|
||
| Result<bool> IsRemain() const override; | ||
| Result<std::shared_ptr<IndexResult<Bitmap>>> And( | ||
| const std::shared_ptr<IndexResult<Bitmap>>& other) override; | ||
| Result<std::shared_ptr<IndexResult<Bitmap>>> Or( | ||
| const std::shared_ptr<IndexResult<Bitmap>>& other) override; | ||
| std::string ToString() const override; | ||
| }; | ||
|
|
||
| } // namespace paimon |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Document that Bitmap and BSI only prune null checks on nanosecond timestamp columns. Value predicates now retain every candidate even when the query literal is microsecond-aligned.
IS NULLandIS NOT NULLstill use the index. This affects existing tables and belongs alongside the scalar-index guarantees so users can explain why these filters fall back to reading data.