roryqi commented on code in PR #12234: URL: https://github.com/apache/gravitino/pull/12234#discussion_r3683527141
########## core/src/main/java/org/apache/gravitino/RelationTarget.java: ########## @@ -0,0 +1,77 @@ +/* + * 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; + +import com.google.common.base.Preconditions; +import java.util.Optional; +import javax.annotation.Nullable; + +/** + * Represents a target entity in a relation update, with optional metadata carried by the relation + * row. + */ +public final class RelationTarget { Review Comment: Yes. I clarified `RelationTarget` as the target endpoint of a relation edge. The source endpoint is passed separately to `updateEntityRelations`, and the optional relation value belongs to the edge. ########## core/src/main/java/org/apache/gravitino/SupportsRelationOperations.java: ########## @@ -92,6 +94,55 @@ <E extends Entity & HasIdentifier> List<E> listEntitiesByRelation( Type relType, NameIdentifier nameIdentifier, Entity.EntityType identType, boolean allFields) throws IOException; + /** + * List the entities according to a given entity in a specific relation, optionally filtering by + * an exact value carried by the relation row. + * + * @param <E> the type of entities returned. + * @param relType The type of relation. + * @param nameIdentifier The given entity identifier. + * @param identType The entity type of parameter nameIdentifier represents. + * @param relationValue The exact relation value to match, or null to return all relations. Review Comment: Added more context in the Javadocs. The relation value is metadata stored on the relation edge, not on either endpoint entity. For this feature it is the tag assignment value; null means no value filter and delegates to the existing relation listing behavior. ########## core/src/main/java/org/apache/gravitino/RelationTarget.java: ########## @@ -0,0 +1,77 @@ +/* + * 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; + +import com.google.common.base.Preconditions; +import java.util.Optional; +import javax.annotation.Nullable; + +/** + * Represents a target entity in a relation update, with optional metadata carried by the relation + * row. + */ +public final class RelationTarget { Review Comment: I checked this direction. `NameIdentifier` has a private constructor and represents only the name path, while this object also needs the entity type and optional edge value. Making it a subclass would require widening `NameIdentifier` and would make relation-edge metadata look like an identifier property. I kept `RelationTarget` as a wrapper so the existing `NameIdentifier[]` overload stays intact, and value-carrying updates use an explicit target endpoint object. The Javadocs now call this out as the target endpoint of the relation edge. -- 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]
