XN137 commented on code in PR #2465:
URL: https://github.com/apache/polaris/pull/2465#discussion_r2315490475


##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java:
##########
@@ -421,38 +422,13 @@ public List<PolarisChangeTrackingVersions> 
lookupEntityVersions(
         .collect(Collectors.toList());
   }
 
-  @Nonnull
-  @Override
-  public Page<EntityNameLookupRecord> listEntities(
-      @Nonnull PolarisCallContext callCtx,
-      long catalogId,
-      long parentId,
-      @Nonnull PolarisEntityType entityType,
-      @Nonnull PolarisEntitySubType entitySubType,
-      @Nonnull PageToken pageToken) {
-    // TODO: only fetch the properties required for creating an 
EntityNameLookupRecord
-    return loadEntities(
-        callCtx,
-        catalogId,
-        parentId,
-        entityType,
-        entitySubType,
-        entity -> true,
-        EntityNameLookupRecord::new,
-        pageToken);
-  }
-
-  @Nonnull
-  @Override
-  public <T> Page<T> loadEntities(
-      @Nonnull PolarisCallContext callCtx,
+  private PreparedQuery buildEntityQuery(

Review Comment:
   wondering: can it be static?



##########
persistence/relational-jdbc/src/main/resources/h2/schema-v2.sql:
##########
@@ -63,6 +63,9 @@ CREATE INDEX IF NOT EXISTS idx_locations ON 
entities(realm_id, catalog_id, locat
 
 -- TODO: create indexes based on all query pattern.
 CREATE INDEX IF NOT EXISTS idx_entities ON entities (realm_id, catalog_id, id);
+CREATE INDEX IF NOT EXISTS idx_entities_lookup
+    ON entities (realm_id, catalog_id, parent_id, type_code, sub_type_code)
+    INCLUDE (id, name);

Review Comment:
   according to https://h2database.com/html/commands.html#create_index 
`INCLUDE` can only be used on a unique index in H2
   
   did we confirm this works?



##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/models/EntityNameLookup.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.polaris.persistence.relational.jdbc.models;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+import org.apache.polaris.core.entity.EntityNameLookupRecord;
+import org.apache.polaris.persistence.relational.jdbc.DatabaseType;
+
+public class EntityNameLookup implements Converter<EntityNameLookupRecord> {

Review Comment:
   rename to `EntityNameLookupRecordConverter` ?



##########
polaris-core/src/main/java/org/apache/polaris/core/entity/HasEntityId.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.polaris.core.entity;
+
+public interface HasEntityId {
+  long getCatalogId();

Review Comment:
   should we add the same documentation as the fields in `PolarisEntityCore` ?
   
   > // the id of the catalog associated to that entity. NULL_ID if this entity 
is top-level like
   > // a catalog



##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/pagination/EntityIdToken.java:
##########
@@ -41,7 +42,7 @@ default String getT() {
     return ID;
   }
 
-  static @Nullable EntityIdToken fromEntity(PolarisBaseEntity entity) {
+  static @Nullable EntityIdToken fromEntity(HasEntityId entity) {

Review Comment:
   nit: mark the `entity` parameter `@Nullable`



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