-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Introduce file index read/write framework. (#3177)
- Loading branch information
1 parent
ffb9032
commit b3eeea9
Showing
42 changed files
with
994 additions
and
111 deletions.
There are no files selected for viewing
This file contains 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 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 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
69 changes: 69 additions & 0 deletions
69
paimon-common/src/main/java/org/apache/paimon/fileindex/FileIndexOptions.java
This file contains 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,69 @@ | ||
/* | ||
* 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.paimon.fileindex; | ||
|
||
import org.apache.paimon.CoreOptions; | ||
import org.apache.paimon.options.Options; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
/** Options of file index column. */ | ||
public class FileIndexOptions { | ||
|
||
// if the filter size greater than fileIndexInManifestThreshold, we put it in file | ||
private final long fileIndexInManifestThreshold; | ||
|
||
private final Map<String, Map<String, Options>> indexTypeOptions; | ||
|
||
public FileIndexOptions() { | ||
this(CoreOptions.FILE_INDEX_IN_MANIFEST_THRESHOLD.defaultValue().getBytes()); | ||
} | ||
|
||
public FileIndexOptions(long fileIndexInManifestThreshold) { | ||
this.indexTypeOptions = new HashMap<>(); | ||
this.fileIndexInManifestThreshold = fileIndexInManifestThreshold; | ||
} | ||
|
||
public void computeIfAbsent(String column, String indexType) { | ||
indexTypeOptions | ||
.computeIfAbsent(column, c -> new HashMap<>()) | ||
.computeIfAbsent(indexType, i -> new Options()); | ||
} | ||
|
||
public Options get(String column, String indexType) { | ||
return Optional.ofNullable(indexTypeOptions.getOrDefault(column, null)) | ||
.map(x -> x.get(indexType)) | ||
.orElse(null); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return indexTypeOptions.isEmpty(); | ||
} | ||
|
||
public long fileIndexInManifestThreshold() { | ||
return fileIndexInManifestThreshold; | ||
} | ||
|
||
public Set<Map.Entry<String, Map<String, Options>>> entrySet() { | ||
return indexTypeOptions.entrySet(); | ||
} | ||
} |
This file contains 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 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.