Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/Entry.java
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | public class QueryHandler { | ||||
public void writeNode(long nodeId) { | public void writeNode(long nodeId) { | ||||
try { | try { | ||||
out.writeLong(nodeId); | out.writeLong(nodeId); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new RuntimeException("Cannot write response to client: " + e); | throw new RuntimeException("Cannot write response to client: " + e); | ||||
} | } | ||||
} | } | ||||
public void writeEdge(long srcId, long dstId) { | |||||
writeNode(srcId); | |||||
writeNode(dstId); | |||||
} | |||||
public void writePath(ArrayList<Long> path) { | public void writePath(ArrayList<Long> path) { | ||||
for (Long nodeId : path) { | for (Long nodeId : path) { | ||||
writeNode(nodeId); | writeNode(nodeId); | ||||
} | } | ||||
writeNode(PATH_SEPARATOR_ID); | writeNode(PATH_SEPARATOR_ID); | ||||
} | } | ||||
public void open() { | public void open() { | ||||
Show All 29 Lines | public class QueryHandler { | ||||
public void visit_nodes(String direction, String edgesFmt, long srcNodeId) { | public void visit_nodes(String direction, String edgesFmt, long srcNodeId) { | ||||
open(); | open(); | ||||
Traversal t = new Traversal(this.graph, direction, edgesFmt); | Traversal t = new Traversal(this.graph, direction, edgesFmt); | ||||
t.visitNodesVisitor(srcNodeId, this::writeNode); | t.visitNodesVisitor(srcNodeId, this::writeNode); | ||||
close(); | close(); | ||||
} | } | ||||
public void visit_edges(String direction, String edgesFmt, long srcNodeId) { | |||||
open(); | |||||
Traversal t = new Traversal(this.graph, direction, edgesFmt); | |||||
t.visitNodesVisitor(srcNodeId, null, this::writeEdge); | |||||
close(); | |||||
} | |||||
public void visit_paths(String direction, String edgesFmt, | public void visit_paths(String direction, String edgesFmt, | ||||
long srcNodeId) { | long srcNodeId) { | ||||
open(); | open(); | ||||
Traversal t = new Traversal(this.graph, direction, edgesFmt); | Traversal t = new Traversal(this.graph, direction, edgesFmt); | ||||
t.visitPathsVisitor(srcNodeId, this::writePath); | t.visitPathsVisitor(srcNodeId, this::writePath); | ||||
close(); | close(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |