Copilot commented on code in PR #11074:
URL: https://github.com/apache/gravitino/pull/11074#discussion_r3256233287


##########
core/src/main/java/org/apache/gravitino/storage/relational/service/MetadataObjectService.java:
##########
@@ -96,6 +97,14 @@ public class MetadataObjectService {
                   MetadataObjectService::getJobTemplateObjectsFullName)
               .build();
 
+  static final Map<MetadataObject.Type, BasePOStorageOps<?, ?>> 
TYPE_TO_STORAGE_OPS_MAP =
+      ImmutableMap.<MetadataObject.Type, BasePOStorageOps<?, ?>>builder()

Review Comment:
   Using the raw `SchemaPOStorageOps` here bypasses the physical-to-logical 
schema-name conversion applied by `SchemaMetaService`. 
`getSchemaObjectsFullName` (and table/view/function full names built from it) 
will expose storage names containing the internal hierarchy separator for 
nested schemas; wrap the schema ops with the same hierarchical conversion or 
convert schema names before joining them into full names.
   



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/BasePOStorageOps.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+
+public abstract class BasePOStorageOps<PO, Mapper> {
+  public void insertPO(Mapper mapper, PO po, boolean overwrite) {

Review Comment:
   This new public class (and most of its public API methods) lacks Javadocs. 
The repository guideline requires Javadocs for all new public/protected classes 
and methods, and the checkstyle step treats missing Javadocs as failures; add 
class-level and method-level Javadocs or reduce visibility if this is 
package-internal.



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/ViewPOStorageOps.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.exceptions.NoSuchEntityException;
+import org.apache.gravitino.storage.relational.mapper.ViewMetaMapper;
+import org.apache.gravitino.storage.relational.po.ViewPO;
+

Review Comment:
   This new public class has no class-level Javadoc. New public/protected 
classes are required to document their purpose in this repository; add Javadocs 
or make the class package-private if it is not intended as a public API.
   



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SchemaPOStorageOps.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.exceptions.NoSuchEntityException;
+import org.apache.gravitino.storage.relational.mapper.SchemaMetaMapper;
+import org.apache.gravitino.storage.relational.po.SchemaPO;
+

Review Comment:
   This new public class has no class-level Javadoc. New public/protected 
classes are required to document their purpose in this repository; add Javadocs 
or make the class package-private if it is not intended as a public API.
   



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/HierarchicalConversionPOStorageOps.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import java.util.function.UnaryOperator;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.utils.HierarchicalSchemaUtil;
+
+/**
+ * Wraps a {@link BasePOStorageOps} to bridge the hierarchical schema naming 
convention. Identifiers
+ * and namespace segments in logical form (logical separator) are translated 
to physical form
+ * (physical separator) before delegating. Two optional PO rewriters allow 
callers to translate a PO
+ * field across the boundary: {@code physicalToLogicalRewriter} converts POs 
returned from the
+ * delegate back to logical form, and {@code logicalToPhysicalRewriter} 
converts POs passed into the
+ * delegate down to storage form. The terminology used throughout this class 
is exclusively
+ * physical/logical; there is no separate read/write naming.
+ *
+ * @param <PO> persistent object type
+ * @param <Mapper> MyBatis mapper type
+ */
+public class HierarchicalConversionPOStorageOps<PO, Mapper> extends 
BasePOStorageOps<PO, Mapper> {
+
+  private final BasePOStorageOps<PO, Mapper> delegate;
+  private final UnaryOperator<PO> physicalToLogicalRewriter;
+  private final UnaryOperator<PO> logicalToPhysicalRewriter;
+
+  public HierarchicalConversionPOStorageOps(BasePOStorageOps<PO, Mapper> 
delegate) {
+    this(delegate, UnaryOperator.identity(), UnaryOperator.identity());
+  }
+
+  public HierarchicalConversionPOStorageOps(
+      BasePOStorageOps<PO, Mapper> delegate,
+      UnaryOperator<PO> physicalToLogicalRewriter,
+      UnaryOperator<PO> logicalToPhysicalRewriter) {
+    this.delegate = delegate;
+    this.physicalToLogicalRewriter = physicalToLogicalRewriter;
+    this.logicalToPhysicalRewriter = logicalToPhysicalRewriter;
+  }
+
+  @Override
+  public void insertPO(Mapper mapper, PO po, boolean overwrite) {
+    delegate.insertPO(mapper, convertLogicalToPhysical(po), overwrite);
+  }
+
+  @Override
+  public void batchInsertPOs(Mapper mapper, List<PO> pos, boolean overwrite) {
+    delegate.batchInsertPOs(mapper, convertLogicalToPhysical(pos), overwrite);
+  }
+
+  @Override
+  public Integer updatePO(Mapper mapper, PO newPO, PO oldPO) {
+    return delegate.updatePO(
+        mapper, convertLogicalToPhysical(newPO), 
convertLogicalToPhysical(oldPO));
+  }
+
+  @Override
+  public PO getPO(Mapper mapper, Long parentId, String name) {
+    return convertPhysicalToLogical(
+        delegate.getPO(mapper, parentId, toPhysicalIfHierarchical(name)));

Review Comment:
   This conversion is applied for every wrapped entity type, but only schema 
names should be translated between logical and physical separators. Table, 
view, and function services also wrap their ops with this class, so a child 
object named with the configured schema separator (for example a table named 
`a:b`) will be looked up as `a\u0001b` on parent-id reads and fail to resolve; 
gate this name conversion to `EntityType.SCHEMA` and keep child object names 
unchanged.



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/HierarchicalConversionPOStorageOps.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import java.util.function.UnaryOperator;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.utils.HierarchicalSchemaUtil;
+
+/**
+ * Wraps a {@link BasePOStorageOps} to bridge the hierarchical schema naming 
convention. Identifiers
+ * and namespace segments in logical form (logical separator) are translated 
to physical form
+ * (physical separator) before delegating. Two optional PO rewriters allow 
callers to translate a PO
+ * field across the boundary: {@code physicalToLogicalRewriter} converts POs 
returned from the
+ * delegate back to logical form, and {@code logicalToPhysicalRewriter} 
converts POs passed into the
+ * delegate down to storage form. The terminology used throughout this class 
is exclusively
+ * physical/logical; there is no separate read/write naming.
+ *
+ * @param <PO> persistent object type
+ * @param <Mapper> MyBatis mapper type
+ */
+public class HierarchicalConversionPOStorageOps<PO, Mapper> extends 
BasePOStorageOps<PO, Mapper> {
+
+  private final BasePOStorageOps<PO, Mapper> delegate;
+  private final UnaryOperator<PO> physicalToLogicalRewriter;
+  private final UnaryOperator<PO> logicalToPhysicalRewriter;
+
+  public HierarchicalConversionPOStorageOps(BasePOStorageOps<PO, Mapper> 
delegate) {
+    this(delegate, UnaryOperator.identity(), UnaryOperator.identity());
+  }
+
+  public HierarchicalConversionPOStorageOps(
+      BasePOStorageOps<PO, Mapper> delegate,
+      UnaryOperator<PO> physicalToLogicalRewriter,
+      UnaryOperator<PO> logicalToPhysicalRewriter) {
+    this.delegate = delegate;
+    this.physicalToLogicalRewriter = physicalToLogicalRewriter;
+    this.logicalToPhysicalRewriter = logicalToPhysicalRewriter;
+  }
+
+  @Override
+  public void insertPO(Mapper mapper, PO po, boolean overwrite) {
+    delegate.insertPO(mapper, convertLogicalToPhysical(po), overwrite);
+  }
+
+  @Override
+  public void batchInsertPOs(Mapper mapper, List<PO> pos, boolean overwrite) {
+    delegate.batchInsertPOs(mapper, convertLogicalToPhysical(pos), overwrite);
+  }
+
+  @Override
+  public Integer updatePO(Mapper mapper, PO newPO, PO oldPO) {
+    return delegate.updatePO(
+        mapper, convertLogicalToPhysical(newPO), 
convertLogicalToPhysical(oldPO));
+  }
+
+  @Override
+  public PO getPO(Mapper mapper, Long parentId, String name) {
+    return convertPhysicalToLogical(
+        delegate.getPO(mapper, parentId, toPhysicalIfHierarchical(name)));
+  }
+
+  @Override
+  public List<PO> listPOs(Mapper mapper, Long parentId) {
+    return convertPhysicalToLogical(delegate.listPOs(mapper, parentId));
+  }
+
+  @Override
+  public List<PO> listPOs(Mapper mapper, Namespace logicalNamespace, 
List<String> names) {
+    Namespace physicalNamespace = logicalToPhysicalNamespace(logicalNamespace);
+    List<String> physicalNames =
+        names.stream()
+            .map(HierarchicalConversionPOStorageOps::toPhysicalIfHierarchical)
+            .collect(Collectors.toList());

Review Comment:
   The wrapper converts every requested name in batch lookups, but for 
table/view/function ops these are object names, not schema path segments. This 
changes valid child names containing the schema separator before querying (for 
example `a:b` becomes the internal separator form), so batch-get can miss 
existing objects; only apply this per-name conversion when the delegate's 
entity type is `SCHEMA`.
   



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/TablePOStorageOps.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.exceptions.NoSuchEntityException;
+import org.apache.gravitino.storage.relational.mapper.TableMetaMapper;
+import org.apache.gravitino.storage.relational.po.TablePO;
+

Review Comment:
   This new public class has no class-level Javadoc. New public/protected 
classes are required to document their purpose in this repository; add Javadocs 
or make the class package-private if it is not intended as a public API.
   



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/HierarchicalConversionPOStorageOps.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import java.util.function.UnaryOperator;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.utils.HierarchicalSchemaUtil;
+
+/**
+ * Wraps a {@link BasePOStorageOps} to bridge the hierarchical schema naming 
convention. Identifiers
+ * and namespace segments in logical form (logical separator) are translated 
to physical form
+ * (physical separator) before delegating. Two optional PO rewriters allow 
callers to translate a PO
+ * field across the boundary: {@code physicalToLogicalRewriter} converts POs 
returned from the
+ * delegate back to logical form, and {@code logicalToPhysicalRewriter} 
converts POs passed into the
+ * delegate down to storage form. The terminology used throughout this class 
is exclusively
+ * physical/logical; there is no separate read/write naming.
+ *
+ * @param <PO> persistent object type
+ * @param <Mapper> MyBatis mapper type
+ */
+public class HierarchicalConversionPOStorageOps<PO, Mapper> extends 
BasePOStorageOps<PO, Mapper> {
+
+  private final BasePOStorageOps<PO, Mapper> delegate;
+  private final UnaryOperator<PO> physicalToLogicalRewriter;
+  private final UnaryOperator<PO> logicalToPhysicalRewriter;
+
+  public HierarchicalConversionPOStorageOps(BasePOStorageOps<PO, Mapper> 
delegate) {
+    this(delegate, UnaryOperator.identity(), UnaryOperator.identity());
+  }
+
+  public HierarchicalConversionPOStorageOps(
+      BasePOStorageOps<PO, Mapper> delegate,
+      UnaryOperator<PO> physicalToLogicalRewriter,
+      UnaryOperator<PO> logicalToPhysicalRewriter) {
+    this.delegate = delegate;

Review Comment:
   These new public constructors need Javadocs under the repository's 
public/protected API documentation rule. Add constructor documentation for the 
delegate and rewriter parameters, or reduce their visibility if they are only 
intended for package-internal use.



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/FunctionPOStorageOps.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.exceptions.NoSuchEntityException;
+import org.apache.gravitino.storage.relational.mapper.FunctionMetaMapper;
+import org.apache.gravitino.storage.relational.po.FunctionPO;
+

Review Comment:
   This new public class has no class-level Javadoc. New public/protected 
classes are required to document their purpose in this repository; add Javadocs 
or make the class package-private if it is not intended as a public API.
   



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