Leomrlin commented on code in PR #716: URL: https://github.com/apache/geaflow/pull/716#discussion_r2664106908
########## geaflow-ai/src/main/java/org/apache/geaflow/ai/graph/LocalFileGraphAccessor.java: ########## @@ -0,0 +1,152 @@ +/* + * 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.geaflow.ai.graph; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.function.Function; +import org.apache.geaflow.ai.graph.io.*; + +public class LocalFileGraphAccessor implements GraphAccessor { + + private final String resourcePath; + private final ClassLoader resourceClassLoader; + private final Graph graph; + + public LocalFileGraphAccessor(ClassLoader classLoader, String resourcePath, Long limit, + Function<Vertex, Vertex> vertexMapper, + Function<Edge, Edge> edgeMapper) { + this.resourcePath = resourcePath; + this.resourceClassLoader = classLoader; + try { + this.graph = GraphFileReader.getGraph(resourceClassLoader, resourcePath, limit, + vertexMapper, edgeMapper); + } catch (Throwable e) { + throw new RuntimeException("Init local graph error", e); + } + } + + @Override + public GraphSchema getGraphSchema() { + return graph.getGraphSchema(); + } + + @Override + public GraphVertex getVertex(String label, String id) { + return new GraphVertex(graph.getVertex(label, id)); + } + + @Override + public GraphEdge getEdge(String label, String src, String dst) { + return new GraphEdge(graph.getEdge(label, src, dst)); + } Review Comment: There was confusion here. Now we consistently use `null` to represent no result, and if the value is non-null, the internal entities are also guaranteed to be non-null. Null checks have been added at the usage sites. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
