-
Notifications
You must be signed in to change notification settings - Fork 342
NoSQL: Metastore implementation #3237
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
c0656d7
NoSQL: Metastore implementation
snazy 3bfd728
Remove a actually unnecessary parameter
snazy cad4692
adapt test
snazy c629810
ci javadoc
snazy 2b6f81e
rm unnecessary fallthrough
snazy 489e309
rm unnecessary duplication
snazy 8e65b35
gt javadoc
snazy e73f87a
review
snazy 4d07106
rebase-fix
snazy 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| plugins { | ||
| id("org.kordamp.gradle.jandex") | ||
| id("polaris-server") | ||
| } | ||
|
|
||
| description = "Polaris NoSQL persistence - bridge to meta-store" | ||
|
|
||
| dependencies { | ||
| implementation(project(":polaris-core")) | ||
|
|
||
| implementation(project(":polaris-persistence-nosql-api")) | ||
| implementation(project(":polaris-persistence-nosql-metastore-types")) | ||
| implementation(project(":polaris-persistence-nosql-authz-api")) | ||
| implementation(project(":polaris-persistence-nosql-authz-spi")) | ||
| implementation(project(":polaris-persistence-nosql-realms-api")) | ||
| implementation(project(":polaris-idgen-api")) | ||
| implementation(project(":polaris-api-catalog-service")) | ||
|
|
||
| implementation(platform(libs.iceberg.bom)) | ||
| implementation("org.apache.iceberg:iceberg-api") | ||
| implementation("org.apache.iceberg:iceberg-core") | ||
|
|
||
| implementation(libs.guava) | ||
| implementation(libs.slf4j.api) | ||
|
|
||
| implementation(platform(libs.jackson.bom)) | ||
| implementation("com.fasterxml.jackson.core:jackson-annotations") | ||
| implementation("com.fasterxml.jackson.core:jackson-core") | ||
| implementation("com.fasterxml.jackson.core:jackson-databind") | ||
|
|
||
| compileOnly(project(":polaris-immutables")) | ||
| annotationProcessor(project(":polaris-immutables", configuration = "processor")) | ||
|
|
||
| compileOnly(libs.jakarta.annotation.api) | ||
| compileOnly(libs.jakarta.validation.api) | ||
| compileOnly(libs.jakarta.inject.api) | ||
| compileOnly(libs.jakarta.enterprise.cdi.api) | ||
| compileOnly(libs.smallrye.common.annotation) | ||
|
|
||
| testImplementation(testFixtures(project(":polaris-core"))) | ||
| testRuntimeOnly(project(":polaris-persistence-nosql-authz-impl")) | ||
| testRuntimeOnly(project(":polaris-persistence-nosql-authz-store-nosql")) | ||
| testRuntimeOnly(testFixtures(project(":polaris-persistence-nosql-cdi-weld"))) | ||
| testImplementation(libs.weld.se.core) | ||
| testImplementation(libs.weld.junit5) | ||
| testRuntimeOnly(libs.smallrye.jandex) | ||
|
|
||
| testFixturesImplementation(project(":polaris-core")) | ||
| testFixturesImplementation(testFixtures(project(":polaris-core"))) | ||
| testFixturesImplementation(libs.jakarta.annotation.api) | ||
| testFixturesImplementation(libs.jakarta.validation.api) | ||
| testFixturesImplementation(libs.jakarta.enterprise.cdi.api) | ||
| testCompileOnly(libs.smallrye.common.annotation) | ||
| } |
178 changes: 178 additions & 0 deletions
178
...store/src/main/java/org/apache/polaris/persistence/nosql/metastore/ContentIdentifier.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,178 @@ | ||
| /* | ||
| * 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.polaris.persistence.nosql.metastore; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkArgument; | ||
| import static com.google.common.base.Preconditions.checkState; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonValue; | ||
| import com.google.errorprone.annotations.CanIgnoreReturnValue; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import org.apache.iceberg.catalog.Namespace; | ||
| import org.apache.iceberg.catalog.TableIdentifier; | ||
| import org.apache.polaris.core.storage.StorageLocation; | ||
| import org.apache.polaris.immutables.PolarisImmutable; | ||
| import org.apache.polaris.persistence.nosql.api.index.IndexKey; | ||
| import org.apache.polaris.service.types.PolicyIdentifier; | ||
| import org.immutables.value.Value; | ||
|
|
||
| @Value.Style(underrideToString = "asDotDelimitedString") | ||
| @PolarisImmutable | ||
| public interface ContentIdentifier { | ||
| @Value.Parameter | ||
| @JsonValue | ||
| List<String> elements(); | ||
|
|
||
| static ContentIdentifier identifier(List<String> elements) { | ||
| return ImmutableContentIdentifier.of(elements); | ||
| } | ||
|
|
||
| static ContentIdentifier identifier(String[] namespace, String name) { | ||
| return ImmutableContentIdentifier.builder().addElements(namespace).addElements(name).build(); | ||
| } | ||
|
|
||
| static ContentIdentifier identifier(String... elements) { | ||
| return ImmutableContentIdentifier.of(List.of(elements)); | ||
| } | ||
|
|
||
| static ContentIdentifier identifierFor(PolicyIdentifier identifier) { | ||
| return identifier(identifier.getNamespace().levels(), identifier.getName()); | ||
| } | ||
|
|
||
| static ContentIdentifier identifierFor(TableIdentifier identifier) { | ||
| return identifier(identifier.namespace().levels(), identifier.name()); | ||
| } | ||
|
|
||
| static ContentIdentifier identifierFor(Namespace namespace) { | ||
| return identifier(namespace.levels()); | ||
| } | ||
|
|
||
| /** | ||
| * Constructs a {@link ContentIdentifier} from a storage location without the scheme. | ||
| * | ||
| * <p>This is used for the locations index for location-overlap checks. | ||
| * | ||
| * <p>Valid inputs follow the values returned by {@link StorageLocation#withoutScheme() | ||
| * StorageLocation.of(previousBaseLocation).withoutScheme()}, which can, in case of "file" | ||
| * locations, contain system-specific file separators. | ||
| */ | ||
| static ContentIdentifier identifierFromLocationString(String locationString) { | ||
| var builder = builder(); | ||
| var len = locationString.length(); | ||
| var off = -1; | ||
| for (var i = 0; i < len; i++) { | ||
| var c = locationString.charAt(i); | ||
| checkArgument(c >= ' ' && c != 127, "Control characters are forbidden in locations"); | ||
| if (c == '/' || c == '\\') { | ||
dennishuo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (off != -1) { | ||
| builder.addElements(locationString.substring(off, i)); | ||
| off = -1; | ||
| } | ||
| } else { | ||
| if (off == -1) { | ||
| off = i; | ||
| } | ||
| } | ||
| } | ||
| if (off != -1) { | ||
| builder.addElements(locationString.substring(off)); | ||
| } | ||
| return builder.build(); | ||
| } | ||
|
|
||
| default ContentIdentifier parent() { | ||
| var elems = elements(); | ||
| checkState(!elems.isEmpty(), "Empty namespace has no parent"); | ||
| return ImmutableContentIdentifier.of(elems.subList(0, elems.size() - 1)); | ||
| } | ||
|
|
||
| default boolean isEmpty() { | ||
| return elements().isEmpty(); | ||
| } | ||
|
|
||
| default int length() { | ||
| return elements().size(); | ||
| } | ||
|
|
||
| default String leafName() { | ||
| var elems = elements(); | ||
| return elems.isEmpty() ? "" : elems.getLast(); | ||
| } | ||
|
|
||
| default ContentIdentifier childOf(String childName) { | ||
| var elems = elements(); | ||
| var newElements = new ArrayList<String>(elems.size() + 1); | ||
| newElements.addAll(elems); | ||
| newElements.add(childName); | ||
| return ImmutableContentIdentifier.of(newElements); | ||
| } | ||
|
|
||
| default String asDotDelimitedString() { | ||
| return String.join(".", elements()); | ||
| } | ||
|
|
||
| static ImmutableContentIdentifier.Builder builder() { | ||
| return ImmutableContentIdentifier.builder(); | ||
| } | ||
|
|
||
| default IndexKey toIndexKey() { | ||
| return IndexKey.key(String.join("\u0000", elements())); | ||
| } | ||
|
|
||
| default boolean startsWith(ContentIdentifier other) { | ||
| var elems = elements(); | ||
| var otherElems = other.elements(); | ||
| var otherSize = otherElems.size(); | ||
| if (otherSize > elems.size()) { | ||
| return false; | ||
| } | ||
| for (int i = 0; i < otherSize; i++) { | ||
| if (!elems.get(i).equals(otherElems.get(i))) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| @CanIgnoreReturnValue | ||
| static ImmutableContentIdentifier.Builder indexKeyToIdentifierBuilder( | ||
| IndexKey indexKey, ImmutableContentIdentifier.Builder builder) { | ||
| var str = indexKey.toString(); | ||
| var l = str.length(); | ||
| for (var i = 0; i < l; ) { | ||
| var iNull = str.indexOf(0, i); | ||
| if (iNull == -1) { | ||
| builder.addElements(str.substring(i)); | ||
| return builder; | ||
| } | ||
| builder.addElements(str.substring(i, iNull)); | ||
| i = iNull + 1; | ||
| } | ||
| return builder; | ||
| } | ||
|
|
||
| static ImmutableContentIdentifier.Builder indexKeyToIdentifierBuilder(IndexKey indexKey) { | ||
| return indexKeyToIdentifierBuilder(indexKey, ImmutableContentIdentifier.builder()); | ||
| } | ||
|
|
||
| static ContentIdentifier indexKeyToIdentifier(IndexKey indexKey) { | ||
| return indexKeyToIdentifierBuilder(indexKey).build(); | ||
| } | ||
| } | ||
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.
All the other factory methods are mostly self-explanatory, but this one could use some javadocs explaining what
locationStringis, expected format, etc.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.
yup, added