-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-1822][RFC-27][WIP] range index support with metadata table #3475
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 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
94 changes: 94 additions & 0 deletions
94
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieSecondaryIndex.java
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,94 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| package org.apache.hudi.index; | ||
|
|
||
| import org.apache.hudi.ApiMaturityLevel; | ||
| import org.apache.hudi.PublicAPIClass; | ||
| import org.apache.hudi.PublicAPIMethod; | ||
| import org.apache.hudi.common.engine.HoodieEngineContext; | ||
| import org.apache.hudi.common.model.HoodieRecordPayload; | ||
| import org.apache.hudi.config.HoodieWriteConfig; | ||
| import org.apache.hudi.exception.HoodieIndexException; | ||
| import org.apache.hudi.table.HoodieTable; | ||
| import org.apache.hudi.table.action.HoodieWriteMetadata; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
| /** | ||
| * Base class for different types of secondary indexes. | ||
| * This is different from primary index because | ||
| * a) index lookup operation is very different (using predicates instead of sending all keys). | ||
| * b) There can be multiple secondary index configured for same table. (one column may use range index/some other column may use bloom index) | ||
| * | ||
| * @param <T> Sub type of HoodieRecordPayload | ||
| * @param <I> Type of inputs | ||
| * @param <K> Type of keys | ||
| * @param <O> Type of outputs | ||
| */ | ||
| @PublicAPIClass(maturity = ApiMaturityLevel.EVOLVING) | ||
| public abstract class HoodieSecondaryIndex<T extends HoodieRecordPayload, I, K, O> implements Serializable { | ||
|
|
||
| protected final HoodieWriteConfig config; | ||
|
|
||
| protected final HoodieEngineContext engineContext; | ||
|
|
||
| protected HoodieSecondaryIndex(HoodieWriteConfig config, HoodieEngineContext engineContext) { | ||
| this.config = config; | ||
| this.engineContext = engineContext; | ||
| } | ||
|
|
||
| /** | ||
| * Update index to quickly identify records. | ||
| */ | ||
| @PublicAPIMethod(maturity = ApiMaturityLevel.EVOLVING) | ||
| public abstract void updateIndex(HoodieWriteMetadata<O> writeMetadata, String instantTime, | ||
| HoodieTable<T, I, K, O> hoodieTable) throws HoodieIndexException; | ||
|
|
||
| /** | ||
| * Rollback the effects of the commit made at instantTime. | ||
| */ | ||
| @PublicAPIMethod(maturity = ApiMaturityLevel.EVOLVING) | ||
| public abstract boolean rollbackCommit(String instantTime); | ||
|
|
||
| /** | ||
| * TODO figure out the signature for this | ||
| public abstract List<HoodieFileGroup> findMatchingDataFiles(List<Predicate> predicates) | ||
| */ | ||
| /** | ||
| * Each index type should implement it's own logic to release any resources acquired during the process. | ||
| */ | ||
| public void close() { | ||
| } | ||
|
|
||
| public enum SecondaryIndexType { | ||
| /* TODO: also support multiple secondary index on same table - different columns can have different values */ | ||
| RANGE, | ||
| BLOOM, /* TODO: we can leverage same bloom index used for primary key */ | ||
| CUCKOO, /* TODO: implementation, For medium cardinality, cuckoo index likely performs better than bloom index https://www.vldb.org/pvldb/vol13/p3559-kipf.pdf */ | ||
| POINT /* TODO: Finding exact value quickly. maybe useful for primary key lookups too. */ | ||
| } | ||
|
|
||
| public HoodieWriteConfig getWriteConfig() { | ||
| return this.config; | ||
| } | ||
|
|
||
| public HoodieEngineContext getEngineContext() { | ||
| return this.engineContext; | ||
| } | ||
| } |
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.
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.
@satishkotha : may I know why we need this extra condition. base file is always going to be HFile for metadata table right? Or do we have plans for any other partition where base file will not be Hfile in metadata table?
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.
@nsivabalan We were initially considering parquet file format as an option of range index. So I added it as a config to support sorting on parquet files in metadata table. Now that we have finalized HFile format (at least for short term), we can probably remove config. Sorry for delay, I missed your mention. Feel free to ping me on slack if you have any followups