xunliu commented on code in PR #4690:
URL: https://github.com/apache/gravitino/pull/4690#discussion_r1741635872
##########
core/src/main/java/org/apache/gravitino/meta/UserEntity.java:
##########
@@ -44,18 +45,22 @@ public class UserEntity implements User, Entity, Auditable,
HasIdentifier {
public static final Field AUDIT_INFO =
Field.required("audit_info", AuditInfo.class, "The audit details of the
user entity.");
- public static final Field ROLE_NAMES =
- Field.optional("role_names", List.class, "The role names of the user
entity");
+ public static final Field ROLE_NAMES_SUPPLIER =
+ Field.required(
+ "role_names_supplier", Supplier.class, "The role names supplier of
the user entity");
- public static final Field ROLE_IDS =
- Field.optional("role_ids", List.class, "The role ids of the user
entity");
+ public static final Field ROLE_IDS_SUPPLIER =
+ Field.required(
+ "role_ids_supplier", Supplier.class, "The role ids supplier of the
user entity");
private Long id;
private String name;
private AuditInfo auditInfo;
- private List<String> roleNames;
- private List<Long> roleIds;
private Namespace namespace;
+ // The roleIds is a lazy field to avoid unnecessary cost.
+ private Supplier<List<Long>> roleIdsSupplier = () -> null;
+ // The roleNames is a lazy field to avoid unnecessary cost.
+ private Supplier<List<String>> roleNamesSupplier = () -> null;
Review Comment:
I think we need to use one `Role` object variable to replace `roleIds` and
`roleNames` two variable.
##########
core/src/main/java/org/apache/gravitino/meta/GroupEntity.java:
##########
@@ -38,21 +39,25 @@ public class GroupEntity implements Group, Entity,
Auditable, HasIdentifier {
public static final Field NAME =
Field.required("name", String.class, "The name of the group entity.");
- public static final Field ROLE_NAMES =
- Field.optional("role_names", List.class, "The role names of the group
entity.");
+ public static final Field ROLE_NAMES_SUPPLIER =
+ Field.required(
+ "role_names_supplier", Supplier.class, "The role names supplier of
the group entity.");
- public static final Field ROLE_IDS =
- Field.optional("role_ids", List.class, "The role names of the group
entity.");
+ public static final Field ROLE_IDS_SUPPLIER =
+ Field.required(
+ "role_ids_supplier", Supplier.class, "The role ids supplier of the
group entity.");
public static final Field AUDIT_INFO =
Field.required("audit_info", AuditInfo.class, "The audit details of the
group entity.");
private Long id;
private String name;
private AuditInfo auditInfo;
- private List<String> roleNames;
- private List<Long> roleIds;
private Namespace namespace;
+ // The roleIds is a lazy field to avoid unnecessary cost.
+ private Supplier<List<Long>> roleIdsSupplier = () -> null;
+ // The roleNames is a lazy field to avoid unnecessary cost.
+ private Supplier<List<String>> roleNamesSupplier = () -> null;
Review Comment:
I think we need to use one `Role` object variable to replace `roleIds` and
`roleNames` two variable.
--
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]