Repository navigation
feat(realtime): add in-memory predicate indexes #504
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4f92dae
feat(realtime): add in-memory predicate indexes
lxy-9602 aa8a28d
add doc
lxy-9602 969f53d
impro offset output
lxy-9602 8fab5fa
fix comments
lxy-9602 91649d0
Merge branch 'main' into rt-mem-index
lxy-9602 dc5c88b
fix comments and ci
lxy-9602 34fea4f
fix ci
lxy-9602 c7672e9
fix comments
lxy-9602 4b91eef
Merge branch 'main' into rt-mem-index
lxy-9602 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 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
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,49 @@ | ||
| /* | ||
| * 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 <cstdint> | ||
| #include <memory> | ||
|
|
||
| #include "paimon/realtime/offset_range.h" | ||
| #include "paimon/result.h" | ||
| #include "paimon/visibility.h" | ||
|
|
||
| struct ArrowArray; | ||
|
|
||
| namespace paimon { | ||
| class RealtimeIndexReader; | ||
|
|
||
| /// Append-only in-memory index for one field, supporting one writer and concurrent readers. | ||
| class PAIMON_EXPORT RealtimeIndex { | ||
| public: | ||
| virtual ~RealtimeIndex() = default; | ||
|
|
||
| /// Consumes [_REALTIME_OFFSET, field] with increasing offsets. | ||
| virtual Status AddBatch(::ArrowArray* batch) = 0; | ||
|
|
||
| /// Creates a reader for [begin, end), sharing postings without copying. | ||
| virtual Result<std::shared_ptr<RealtimeIndexReader>> CreateReader( | ||
| const OffsetRange& offset_range) const = 0; | ||
|
|
||
| virtual uint64_t GetMemoryUsage() const = 0; | ||
| }; | ||
|
|
||
| } // 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,55 @@ | ||
| /* | ||
| * 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 <map> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "paimon/factories/factory.h" | ||
| #include "paimon/result.h" | ||
| #include "paimon/visibility.h" | ||
|
|
||
| struct ArrowSchema; | ||
|
|
||
| namespace paimon { | ||
| class MemoryPool; | ||
| class RealtimeIndex; | ||
|
|
||
| /// Factory for field indexes configured by realtime.index.<identifier>.columns. | ||
| class PAIMON_EXPORT RealtimeIndexFactory : public Factory { | ||
| public: | ||
| ~RealtimeIndexFactory() override = default; | ||
|
|
||
| /// Registry suffix for real-time index plugins. | ||
| static const char REALTIME_INDEX_IDENTIFIER_SUFFIX[]; | ||
|
|
||
| /// Resolves identifier + "-realtime" and consumes the [_REALTIME_OFFSET, field] schema. | ||
| static Result<std::shared_ptr<RealtimeIndex>> Get( | ||
| const std::string& identifier, ::ArrowSchema* write_schema, | ||
| const std::map<std::string, std::string>& options, const std::shared_ptr<MemoryPool>& pool); | ||
|
|
||
| /// Creates a new field index; consumes the [_REALTIME_OFFSET, field] schema. | ||
| virtual Result<std::shared_ptr<RealtimeIndex>> Create( | ||
| ::ArrowSchema* write_schema, const std::map<std::string, std::string>& options, | ||
| const std::shared_ptr<MemoryPool>& pool) const = 0; | ||
| }; | ||
|
|
||
| } // 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,56 @@ | ||
| /* | ||
| * 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 <optional> | ||
| #include <vector> | ||
|
|
||
| #include "paimon/predicate/function_visitor.h" | ||
| #include "paimon/utils/roaring_bitmap64.h" | ||
| #include "paimon/visibility.h" | ||
|
|
||
| namespace paimon { | ||
|
|
||
| /// Visits predicates on one indexed field, returning realtime offsets. | ||
| /// nullopt means no pruning; an empty bitmap means no candidates. False negatives are not allowed. | ||
| /// Unsupported predicates default to no pruning. Plugins override only the supported visits. | ||
| class PAIMON_EXPORT RealtimeIndexReader : public FunctionVisitor<std::optional<RoaringBitmap64>> { | ||
| public: | ||
| ~RealtimeIndexReader() override = default; | ||
|
|
||
| Result<std::optional<RoaringBitmap64>> VisitIsNotNull() override; | ||
|
lxy-9602 marked this conversation as resolved.
Resolved
|
||
| Result<std::optional<RoaringBitmap64>> VisitIsNull() override; | ||
| Result<std::optional<RoaringBitmap64>> VisitEqual(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitNotEqual(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitLessThan(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitLessOrEqual(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitGreaterThan(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitGreaterOrEqual(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitIn(const std::vector<Literal>& literals) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitNotIn( | ||
| const std::vector<Literal>& literals) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitStartsWith(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitEndsWith(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitContains(const Literal& literal) override; | ||
| Result<std::optional<RoaringBitmap64>> VisitLike(const Literal& literal) override; | ||
| }; | ||
|
|
||
| } // 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
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
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.
Uh oh!
There was an error while loading. Please reload this page.