xloya commented on code in PR #5908:
URL: https://github.com/apache/gravitino/pull/5908#discussion_r1893653482
##########
core/src/main/java/org/apache/gravitino/catalog/ModelOperationDispatcher.java:
##########
@@ -40,40 +49,114 @@ public ModelOperationDispatcher(
@Override
public NameIdentifier[] listModels(Namespace namespace) throws
NoSuchSchemaException {
- throw new UnsupportedOperationException("Not implemented");
+ return TreeLockUtils.doWithTreeLock(
+ NameIdentifier.of(namespace.levels()),
+ LockType.READ,
+ () ->
+ doWithCatalog(
+ getCatalogIdentifier(NameIdentifier.of(namespace.levels())),
+ c -> c.doWithModelOps(m -> m.listModels(namespace)),
+ NoSuchSchemaException.class));
}
@Override
public Model getModel(NameIdentifier ident) throws NoSuchModelException {
- throw new UnsupportedOperationException("Not implemented");
+ NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ Model model =
+ TreeLockUtils.doWithTreeLock(
+ ident,
+ LockType.READ,
+ () ->
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithModelOps(m -> m.getModel(ident)),
+ NoSuchModelException.class));
+
+ return EntityCombinedModel.of(model)
+ .withHiddenPropertiesSet(
+ getHiddenPropertyNames(
+ catalogIdent, HasPropertyMetadata::modelPropertiesMetadata,
model.properties()));
}
@Override
public Model registerModel(NameIdentifier ident, String comment, Map<String,
String> properties)
throws NoSuchModelException, ModelAlreadyExistsException {
- throw new UnsupportedOperationException("Not implemented");
+ NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ Map<String, String> updatedProperties =
checkAndUpdateProperties(catalogIdent, properties);
Review Comment:
I think this method could be put into the write tree lock function, so that
there is no need to get a read lock anymore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]