mchades commented on code in PR #5908:
URL: https://github.com/apache/gravitino/pull/5908#discussion_r1891692416


##########
core/src/main/java/org/apache/gravitino/catalog/ModelOperationDispatcher.java:
##########
@@ -40,40 +49,131 @@ 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);
+    TreeLockUtils.doWithTreeLock(
+        catalogIdent,
+        LockType.READ,
+        () ->
+            doWithCatalog(
+                catalogIdent,
+                c ->
+                    c.doWithPropertiesMeta(
+                        p -> {
+                          
validatePropertyForCreate(p.filesetPropertiesMetadata(), properties);

Review Comment:
   shuold be `modelPropertiesMetadata()`



##########
core/src/main/java/org/apache/gravitino/catalog/ModelOperationDispatcher.java:
##########
@@ -84,16 +184,76 @@ public void linkModelVersion(
       String comment,
       Map<String, String> properties)
       throws NoSuchModelException, ModelVersionAliasesAlreadyExistException {
-    throw new UnsupportedOperationException("Not implemented");
+    NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+    TreeLockUtils.doWithTreeLock(
+        catalogIdent,
+        LockType.READ,
+        () ->
+            doWithCatalog(
+                catalogIdent,
+                c ->
+                    c.doWithPropertiesMeta(
+                        p -> {
+                          
validatePropertyForCreate(p.filesetPropertiesMetadata(), properties);
+                          return null;
+                        }),
+                IllegalArgumentException.class));
+
+    long uid = idGenerator.nextId();
+    StringIdentifier stringId = StringIdentifier.fromId(uid);
+    Map<String, String> updatedProperties =
+        StringIdentifier.newPropertiesWithId(stringId, properties);

Review Comment:
   can we reuse the code block since it's duplicated in `registerModel` 



##########
core/src/main/java/org/apache/gravitino/catalog/ModelOperationDispatcher.java:
##########
@@ -40,40 +49,131 @@ 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);
+    TreeLockUtils.doWithTreeLock(

Review Comment:
   why do we need lock here?



##########
core/src/main/java/org/apache/gravitino/catalog/ModelOperationDispatcher.java:
##########
@@ -84,16 +184,76 @@ public void linkModelVersion(
       String comment,
       Map<String, String> properties)
       throws NoSuchModelException, ModelVersionAliasesAlreadyExistException {
-    throw new UnsupportedOperationException("Not implemented");
+    NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+    TreeLockUtils.doWithTreeLock(
+        catalogIdent,
+        LockType.READ,
+        () ->
+            doWithCatalog(
+                catalogIdent,
+                c ->
+                    c.doWithPropertiesMeta(
+                        p -> {
+                          
validatePropertyForCreate(p.filesetPropertiesMetadata(), properties);

Review Comment:
   shuold be `modelPropertiesMetadata()`



-- 
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]

Reply via email to