Skip to content

Commit 90cff77

Browse files
authored
NoSQL: Add metastore types and mappings (#3207)
Add the NoSQL specific metastore persistence types including the mapping from and to `*Polaris*Entity`.
1 parent fff2b91 commit 90cff77

File tree

83 files changed

+6979
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+6979
-0
lines changed

bom/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ dependencies {
6262
api(project(":polaris-persistence-nosql-api"))
6363
api(project(":polaris-persistence-nosql-impl"))
6464
api(project(":polaris-persistence-nosql-benchmark"))
65+
api(project(":polaris-persistence-nosql-metastore-types"))
6566
api(project(":polaris-persistence-nosql-correctness"))
6667
api(project(":polaris-persistence-nosql-cdi-common"))
6768
api(project(":polaris-persistence-nosql-cdi-quarkus"))

gradle/projects.main.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ polaris-persistence-nosql-realms-store-nosql=persistence/nosql/realms/store-nosq
7777
polaris-persistence-nosql-api=persistence/nosql/persistence/api
7878
polaris-persistence-nosql-impl=persistence/nosql/persistence/impl
7979
polaris-persistence-nosql-benchmark=persistence/nosql/persistence/benchmark
80+
polaris-persistence-nosql-metastore-types=persistence/nosql/persistence/metastore-types
8081
polaris-persistence-nosql-correctness=persistence/nosql/persistence/correctness
8182
polaris-persistence-nosql-cdi-common=persistence/nosql/persistence/cdi/common
8283
polaris-persistence-nosql-cdi-quarkus=persistence/nosql/persistence/cdi/quarkus
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
plugins {
21+
id("org.kordamp.gradle.jandex")
22+
id("polaris-server")
23+
}
24+
25+
description = "Polaris NoSQL persistence core types"
26+
27+
dependencies {
28+
implementation(project(":polaris-core"))
29+
implementation(project(":polaris-persistence-nosql-api"))
30+
implementation(project(":polaris-idgen-api"))
31+
implementation(project(":polaris-persistence-nosql-authz-api"))
32+
implementation(project(":polaris-persistence-nosql-varint"))
33+
34+
implementation(libs.guava)
35+
implementation(libs.slf4j.api)
36+
37+
implementation(platform(libs.jackson.bom))
38+
implementation("com.fasterxml.jackson.core:jackson-annotations")
39+
implementation("com.fasterxml.jackson.core:jackson-core")
40+
implementation("com.fasterxml.jackson.core:jackson-databind")
41+
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-smile")
42+
43+
compileOnly(libs.smallrye.config.core)
44+
compileOnly(platform(libs.quarkus.bom))
45+
compileOnly("io.quarkus:quarkus-core")
46+
47+
compileOnly(project(":polaris-immutables"))
48+
annotationProcessor(project(":polaris-immutables", configuration = "processor"))
49+
50+
compileOnly(libs.jakarta.annotation.api)
51+
compileOnly(libs.jakarta.validation.api)
52+
compileOnly(libs.jakarta.inject.api)
53+
compileOnly(libs.jakarta.enterprise.cdi.api)
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.persistence.nosql.coretypes;
20+
21+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
22+
import org.apache.polaris.persistence.nosql.api.index.IndexContainer;
23+
import org.apache.polaris.persistence.nosql.api.index.IndexKey;
24+
import org.apache.polaris.persistence.nosql.api.obj.BaseCommitObj;
25+
import org.apache.polaris.persistence.nosql.api.obj.ObjRef;
26+
27+
public interface ContainerObj extends BaseCommitObj {
28+
/** Holds the mapping of fully qualified names to object references. */
29+
IndexContainer<ObjRef> nameToObjRef();
30+
31+
/**
32+
* Contains the mapping of {@linkplain ObjBase#stableId() stable IDs} to fully qualified names.
33+
*
34+
* <p>This index is meant as a temporary construct during the transition from numeric ID-based
35+
* parent-child relationships and references to using fully qualified names as the primary
36+
* identifier on all APIs (catalogs, catalog state, principals, etc.).
37+
*/
38+
IndexContainer<IndexKey> stableIdToName();
39+
40+
interface Builder<O extends ContainerObj, B extends ContainerObj.Builder<O, B>>
41+
extends BaseCommitObj.Builder<O, B> {
42+
@CanIgnoreReturnValue
43+
B from(ContainerObj container);
44+
45+
@CanIgnoreReturnValue
46+
B nameToObjRef(IndexContainer<ObjRef> nameToObjRef);
47+
48+
@CanIgnoreReturnValue
49+
B stableIdToName(IndexContainer<IndexKey> stableIdToName);
50+
}
51+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.persistence.nosql.coretypes;
20+
21+
import com.fasterxml.jackson.annotation.JsonInclude;
22+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
23+
import java.time.Instant;
24+
import java.util.Map;
25+
import org.apache.polaris.persistence.nosql.api.obj.Obj;
26+
import org.immutables.value.Value;
27+
28+
public interface ObjBase extends Obj {
29+
30+
String name();
31+
32+
/**
33+
* The <em>stable</em> ID for this object, remains the same for each update of the logical object.
34+
* Raw persistence model {@link #id()} are unique for each persisted "version", because persisted
35+
* objects are immutable.
36+
*
37+
* <p>This value is constant throughout the lifetime of the object (assigned once but never
38+
* changed).
39+
*/
40+
long stableId();
41+
42+
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
43+
@Value.Default
44+
default long parentStableId() {
45+
return 0L;
46+
}
47+
48+
@Value.Default
49+
default int entityVersion() {
50+
return 1;
51+
}
52+
53+
Instant createTimestamp();
54+
55+
Instant updateTimestamp();
56+
57+
@JsonInclude(JsonInclude.Include.NON_EMPTY)
58+
Map<String, String> properties();
59+
60+
@JsonInclude(JsonInclude.Include.NON_EMPTY)
61+
Map<String, String> internalProperties();
62+
63+
interface Builder<O extends ObjBase, B extends Builder<O, B>> extends Obj.Builder<O, B> {
64+
65+
@CanIgnoreReturnValue
66+
B from(ObjBase from);
67+
68+
@CanIgnoreReturnValue
69+
B stableId(long stableId);
70+
71+
@CanIgnoreReturnValue
72+
B entityVersion(int entityVersion);
73+
74+
@CanIgnoreReturnValue
75+
B name(String name);
76+
77+
@CanIgnoreReturnValue
78+
B parentStableId(long parentStableId);
79+
80+
@CanIgnoreReturnValue
81+
B createTimestamp(Instant createTimestamp);
82+
83+
@CanIgnoreReturnValue
84+
B updateTimestamp(Instant updateTimestamp);
85+
86+
@CanIgnoreReturnValue
87+
B putProperty(String key, String value);
88+
89+
@CanIgnoreReturnValue
90+
B putProperty(Map.Entry<String, ? extends String> entry);
91+
92+
@CanIgnoreReturnValue
93+
B properties(Map<String, ? extends String> entries);
94+
95+
@CanIgnoreReturnValue
96+
B putAllProperties(Map<String, ? extends String> entries);
97+
98+
@CanIgnoreReturnValue
99+
B putInternalProperty(String key, String value);
100+
101+
@CanIgnoreReturnValue
102+
B putInternalProperty(Map.Entry<String, ? extends String> entry);
103+
104+
@CanIgnoreReturnValue
105+
B internalProperties(Map<String, ? extends String> entries);
106+
107+
@CanIgnoreReturnValue
108+
B putAllInternalProperties(Map<String, ? extends String> entries);
109+
}
110+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.persistence.nosql.coretypes.acl;
20+
21+
import com.fasterxml.jackson.annotation.JsonInclude;
22+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
23+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
24+
import java.util.OptionalInt;
25+
import org.apache.polaris.core.entity.PolarisBaseEntity;
26+
import org.apache.polaris.immutables.PolarisImmutable;
27+
import org.apache.polaris.persistence.nosql.api.obj.AbstractObjType;
28+
import org.apache.polaris.persistence.nosql.api.obj.Obj;
29+
import org.apache.polaris.persistence.nosql.api.obj.ObjType;
30+
import org.apache.polaris.persistence.nosql.authz.api.Acl;
31+
import org.apache.polaris.persistence.nosql.coretypes.ObjBase;
32+
33+
/** */
34+
@PolarisImmutable
35+
@JsonSerialize(as = ImmutableAclObj.class)
36+
@JsonDeserialize(as = ImmutableAclObj.class)
37+
public interface AclObj extends Obj {
38+
39+
ObjType TYPE = new AclObjType();
40+
41+
/**
42+
* Refers to the {@linkplain PolarisBaseEntity#getId() entity id} / {@linkplain ObjBase#stableId()
43+
* stable ID}.
44+
*/
45+
long securableId();
46+
47+
/** Refers to {@link org.apache.polaris.core.entity.PolarisEntityType}. */
48+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
49+
OptionalInt securableTypeCode();
50+
51+
Acl acl();
52+
53+
@Override
54+
default ObjType type() {
55+
return TYPE;
56+
}
57+
58+
static ImmutableAclObj.Builder builder() {
59+
return ImmutableAclObj.builder();
60+
}
61+
62+
final class AclObjType extends AbstractObjType<AclObj> {
63+
public AclObjType() {
64+
super("acl", "ACL", AclObj.class);
65+
}
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.persistence.nosql.coretypes.acl;
20+
21+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
22+
import org.apache.polaris.persistence.nosql.api.index.IndexContainer;
23+
import org.apache.polaris.persistence.nosql.api.obj.BaseCommitObj;
24+
import org.apache.polaris.persistence.nosql.api.obj.ObjRef;
25+
26+
public interface GrantsObj extends BaseCommitObj {
27+
28+
/** Index of securable keys to {@link AclObj}s. */
29+
IndexContainer<ObjRef> acls();
30+
31+
interface Builder<O extends GrantsObj, B extends BaseCommitObj.Builder<O, B>>
32+
extends BaseCommitObj.Builder<O, B> {
33+
@CanIgnoreReturnValue
34+
B from(GrantsObj container);
35+
36+
@CanIgnoreReturnValue
37+
B acls(IndexContainer<ObjRef> acls);
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.persistence.nosql.coretypes.catalog;
20+
21+
import org.apache.polaris.persistence.nosql.coretypes.ObjBase;
22+
23+
/** Objects that are contained in a catalog. */
24+
public interface CatalogBaseObj extends ObjBase {
25+
26+
interface Builder<O extends CatalogBaseObj, B extends Builder<O, B>>
27+
extends ObjBase.Builder<O, B> {}
28+
}

0 commit comments

Comments
 (0)