Package org.apache.gravitino.model
Interface ModelCatalog
The ModelCatalog interface defines the public API for managing model objects in a schema. If the
catalog implementation supports model objects, it should implement this interface.
-
Method Summary
Modifier and TypeMethodDescriptionalterModel
(NameIdentifier ident, ModelChange... changes) Applies thechanges
to a model in the catalog.alterModelVersion
(NameIdentifier ident, int version, ModelVersionChange... changes) Applies the specifiedchanges
to a model version identified by its version number.alterModelVersion
(NameIdentifier ident, String alias, ModelVersionChange... changes) Applies the specifiedchanges
to a model version identified by its alias.boolean
deleteModel
(NameIdentifier ident) Delete the model from the catalog.boolean
deleteModelVersion
(NameIdentifier ident, int version) Delete the model version by theNameIdentifier
and version number.boolean
deleteModelVersion
(NameIdentifier ident, String alias) Delete the model version by theNameIdentifier
and version alias.getModel
(NameIdentifier ident) Get a model metadata byNameIdentifier
from the catalog.getModelVersion
(NameIdentifier ident, int version) Get a model version by theNameIdentifier
and version number from the catalog.getModelVersion
(NameIdentifier ident, String alias) Get a model version by theNameIdentifier
and version alias from the catalog.getModelVersionUri
(NameIdentifier ident, int version, String uriName) Get the URI of the model artifact with a specified version number and URI name.getModelVersionUri
(NameIdentifier ident, String alias, String uriName) Get the URI of the model artifact with a specified version alias and URI name.default void
linkModelVersion
(NameIdentifier ident, String uri, String[] aliases, String comment, Map<String, String> properties) Link a new model version to the registered model object.void
linkModelVersion
(NameIdentifier ident, Map<String, String> uris, String[] aliases, String comment, Map<String, String> properties) Link a new model version to the registered model object.listModels
(Namespace namespace) List the models in a schema namespace from the catalog.List all the versions with their information of the register model byNameIdentifier
in the catalog.int[]
listModelVersions
(NameIdentifier ident) List all the versions of the register model byNameIdentifier
in the catalog.default boolean
modelExists
(NameIdentifier ident) Check if a model exists using anNameIdentifier
from the catalog.default boolean
modelVersionExists
(NameIdentifier ident, int version) Check if the model version exists by theNameIdentifier
and version number.default boolean
modelVersionExists
(NameIdentifier ident, String alias) Check if the model version exists by theNameIdentifier
and version alias.registerModel
(NameIdentifier ident, String comment, Map<String, String> properties) Register a model in the catalog if the model is not existed, otherwise theModelAlreadyExistsException
will be thrown.default Model
registerModel
(NameIdentifier ident, Map<String, String> uris, String[] aliases, String comment, Map<String, String> properties) Register a model in the catalog if the model is not existed, otherwise theModelAlreadyExistsException
will be thrown.
-
Method Details
-
listModels
List the models in a schema namespace from the catalog.- Parameters:
namespace
- A schema namespace.- Returns:
- An array of model identifiers in the namespace.
- Throws:
NoSuchSchemaException
- If the schema does not exist.
-
getModel
Get a model metadata byNameIdentifier
from the catalog.- Parameters:
ident
- A model identifier.- Returns:
- The model metadata.
- Throws:
NoSuchModelException
- If the model does not exist.
-
modelExists
Check if a model exists using anNameIdentifier
from the catalog.- Parameters:
ident
- A model identifier.- Returns:
- true If the model exists, false if the model does not exist.
-
registerModel
Model registerModel(NameIdentifier ident, String comment, Map<String, String> properties) throws NoSuchSchemaException, ModelAlreadyExistsExceptionRegister a model in the catalog if the model is not existed, otherwise theModelAlreadyExistsException
will be thrown. TheModel
object will be created when the model is registered, users can calllinkModelVersion(NameIdentifier, Map, String[], String, Map)
to link the model version to the registeredModel
.- Parameters:
ident
- The name identifier of the model.comment
- The comment of the model. The comment is optional and can be null.properties
- The properties of the model. The properties are optional and can be null or empty.- Returns:
- The registered model object.
- Throws:
NoSuchSchemaException
- If the schema does not exist.ModelAlreadyExistsException
- If the model already registered.
-
registerModel
default Model registerModel(NameIdentifier ident, Map<String, String> uris, String[] aliases, String comment, Map<String, throws NoSuchSchemaException, ModelAlreadyExistsException, ModelVersionAliasesAlreadyExistExceptionString> properties) Register a model in the catalog if the model is not existed, otherwise theModelAlreadyExistsException
will be thrown. TheModel
object will be created when the model is registered, in the meantime, the model version (version 0) will also be created and linked to the registered model.- Parameters:
ident
- The name identifier of the model.uris
- The names and URIs of the model version artifact.aliases
- The aliases of the model version. The aliases should be unique in this model, otherwise theModelVersionAliasesAlreadyExistException
will be thrown. The aliases are optional and can be empty. Also, be aware that the alias cannot be a number or a number string.comment
- The comment of the model. The comment is optional and can be null.properties
- The properties of the model. The properties are optional and can be null or empty.- Returns:
- The registered model object.
- Throws:
NoSuchSchemaException
- If the schema does not exist when register a model.ModelAlreadyExistsException
- If the model already registered.ModelVersionAliasesAlreadyExistException
- If the aliases already exist in the model.
-
deleteModel
Delete the model from the catalog. If the model does not exist, return false. Otherwise, return true. The deletion of the model will also delete all the model versions linked to this model.- Parameters:
ident
- The name identifier of the model.- Returns:
- True if the model is deleted, false if the model does not exist.
-
listModelVersions
List all the versions of the register model byNameIdentifier
in the catalog.- Parameters:
ident
- The name identifier of the model.- Returns:
- An array of version numbers of the model.
- Throws:
NoSuchModelException
- If the model does not exist.
-
listModelVersionInfos
List all the versions with their information of the register model byNameIdentifier
in the catalog.- Parameters:
ident
- The name identifier of the model.- Returns:
- An array of version information of the model.
- Throws:
NoSuchModelException
- If the model does not exist.
-
getModelVersion
Get a model version by theNameIdentifier
and version number from the catalog.- Parameters:
ident
- The name identifier of the model.version
- The version number of the model.- Returns:
- The model version object.
- Throws:
NoSuchModelVersionException
- If the model version does not exist.
-
getModelVersion
Get a model version by theNameIdentifier
and version alias from the catalog.- Parameters:
ident
- The name identifier of the model.alias
- The version alias of the model.- Returns:
- The model version object.
- Throws:
NoSuchModelVersionException
- If the model version does not exist.
-
modelVersionExists
Check if the model version exists by theNameIdentifier
and version number. If the model version exists, return true, otherwise return false.- Parameters:
ident
- The name identifier of the model.version
- The version number of the model.- Returns:
- True if the model version exists, false if the model version does not exist.
-
modelVersionExists
Check if the model version exists by theNameIdentifier
and version alias. If the model version exists, return true, otherwise return false.- Parameters:
ident
- The name identifier of the model.alias
- The version alias of the model.- Returns:
- True if the model version exists, false if the model version does not exist.
-
linkModelVersion
default void linkModelVersion(NameIdentifier ident, String uri, String[] aliases, String comment, Map<String, String> properties) throws NoSuchModelException, ModelVersionAliasesAlreadyExistExceptionLink a new model version to the registered model object. The new model version will be added to the model object. If the model object does not exist, it will throw an exception. If the version alias already exists in the model, it will throw an exception.- Parameters:
ident
- The name identifier of the model.uri
- The URI of the model version artifact.aliases
- The aliases of the model version. The aliases should be unique in this model, otherwise theModelVersionAliasesAlreadyExistException
will be thrown. The aliases are optional and can be empty. Also, be aware that the alias cannot be a number or a number string.comment
- The comment of the model version. The comment is optional and can be null.properties
- The properties of the model version. The properties are optional and can be null or empty.- Throws:
NoSuchModelException
- If the model does not exist.ModelVersionAliasesAlreadyExistException
- If the aliases already exist in the model.
-
linkModelVersion
void linkModelVersion(NameIdentifier ident, Map<String, String> uris, String[] aliases, String comment, Map<String, throws NoSuchModelException, ModelVersionAliasesAlreadyExistExceptionString> properties) Link a new model version to the registered model object. The new model version will be added to the model object. If the model object does not exist, it will throw an exception. If the version alias already exists in the model, it will throw an exception.- Parameters:
ident
- The name identifier of the model.uris
- The names and URIs of the model version artifact.aliases
- The aliases of the model version. The aliases should be unique in this model, otherwise theModelVersionAliasesAlreadyExistException
will be thrown. The aliases are optional and can be empty. Also, be aware that the alias cannot be a number or a number string.comment
- The comment of the model version. The comment is optional and can be null.properties
- The properties of the model version. The properties are optional and can be null or empty.- Throws:
NoSuchModelException
- If the model does not exist.ModelVersionAliasesAlreadyExistException
- If the aliases already exist in the model.
-
getModelVersionUri
String getModelVersionUri(NameIdentifier ident, int version, String uriName) throws NoSuchModelVersionException, NoSuchModelVersionURINameException Get the URI of the model artifact with a specified version number and URI name.- Parameters:
ident
- The name identifier of the model.version
- The version number of the model.uriName
- The name of the URI. If null, the default URI will be used.- Returns:
- The URI of the model version.
- Throws:
NoSuchModelVersionException
- If the model version does not exist.NoSuchModelVersionURINameException
-
getModelVersionUri
String getModelVersionUri(NameIdentifier ident, String alias, String uriName) throws NoSuchModelVersionException, NoSuchModelVersionURINameException Get the URI of the model artifact with a specified version alias and URI name.- Parameters:
ident
- The name identifier of the model.alias
- The version alias of the model.uriName
- The name of the URI. If null, the default URI will be used.- Returns:
- The URI of the model version.
- Throws:
NoSuchModelVersionException
- If the model version does not exist.NoSuchModelVersionURINameException
-
deleteModelVersion
Delete the model version by theNameIdentifier
and version number. If the model version does not exist, return false. If the model version is deleted, return true.- Parameters:
ident
- The name identifier of the model.version
- The version number of the model.- Returns:
- True if the model version is deleted, false if the model version does not exist.
-
deleteModelVersion
Delete the model version by theNameIdentifier
and version alias. If the model version does not exist, return false. If the model version is deleted, return true.- Parameters:
ident
- The name identifier of the model.alias
- The version alias of the model.- Returns:
- True if the model version is deleted, false if the model version does not exist.
-
alterModel
Model alterModel(NameIdentifier ident, ModelChange... changes) throws NoSuchModelException, IllegalArgumentException Applies thechanges
to a model in the catalog.Implementations may reject the changes. If any change is rejected, no changes should be applied to the model.
- Parameters:
ident
- theNameIdentifier
instance of the model to alterchanges
- the severalModelChange
instances to apply to the model- Returns:
- the updated
Model
instance - Throws:
NoSuchModelException
- If the model does not existIllegalArgumentException
- If the change is rejected by the implementation
-
alterModelVersion
ModelVersion alterModelVersion(NameIdentifier ident, int version, ModelVersionChange... changes) throws NoSuchModelException, NoSuchModelVersionException, IllegalArgumentException Applies the specifiedchanges
to a model version identified by its version number.If any change is rejected by the implementation, no changes will be applied.
- Parameters:
ident
- theNameIdentifier
of the model to be alteredversion
- the version number of the model version to be alteredchanges
- one or moreModelVersionChange
instances to apply- Returns:
- the updated
ModelVersion
instance - Throws:
NoSuchModelVersionException
- if the specified model version does not existIllegalArgumentException
- if any change is rejected by the implementationNoSuchModelException
-
alterModelVersion
ModelVersion alterModelVersion(NameIdentifier ident, String alias, ModelVersionChange... changes) throws NoSuchModelException, IllegalArgumentException Applies the specifiedchanges
to a model version identified by its alias.If any change is rejected by the implementation, no changes will be applied.
- Parameters:
ident
- theNameIdentifier
of the model to be alteredalias
- the alias of the model version to be alteredchanges
- one or moreModelVersionChange
instances to apply- Returns:
- the updated
ModelVersion
instance - Throws:
NoSuchModelVersionException
- if the specified model version does not existIllegalArgumentException
- if any change is rejected by the implementationNoSuchModelException
-