use of com.baidu.hugegraph.computer.core.graph.edge.Edges in project hugegraph-computer by hugegraph.
the class EdgeMessageRecvPartitionTest method addTenDuplicateEdgeBuffer.
private static void addTenDuplicateEdgeBuffer(Consumer<NetworkBuffer> consumer) throws IOException {
for (long i = 0L; i < 10L; i++) {
Vertex vertex = graphFactory().createVertex();
vertex.id(BytesId.of(i));
Edges edges = graphFactory().createEdges(2);
for (long j = i + 1; j < i + 3; j++) {
Edge edge = graphFactory().createEdge();
edge.targetId(BytesId.of(j));
Properties properties = graphFactory().createProperties();
properties.put("p1", new LongValue(i));
edge.properties(properties);
edges.add(edge);
}
vertex.edges(edges);
ReceiverUtil.consumeBuffer(writeEdges(vertex), consumer);
}
for (long i = 0L; i < 10L; i++) {
Vertex vertex = graphFactory().createVertex();
vertex.id(BytesId.of(i));
Edges edges = graphFactory().createEdges(2);
for (long j = i + 1; j < i + 3; j++) {
Edge edge = graphFactory().createEdge();
edge.targetId(BytesId.of(j));
Properties properties = graphFactory().createProperties();
properties.put("p2", new LongValue(2L * i));
edge.properties(properties);
edges.add(edge);
}
vertex.edges(edges);
ReceiverUtil.consumeBuffer(writeEdges(vertex), consumer);
}
}
use of com.baidu.hugegraph.computer.core.graph.edge.Edges in project hugegraph-computer by hugegraph.
the class EdgeMessageRecvPartitionTest method addTenEdgeBuffer.
public static void addTenEdgeBuffer(Consumer<NetworkBuffer> consumer) throws IOException {
for (long i = 0L; i < 10L; i++) {
Vertex vertex = graphFactory().createVertex();
vertex.id(BytesId.of(i));
Edges edges = graphFactory().createEdges(2);
for (long j = i + 1; j < i + 3; j++) {
Edge edge = graphFactory().createEdge();
edge.targetId(BytesId.of(j));
Properties properties = graphFactory().createProperties();
properties.put("p1", new LongValue(i));
edge.properties(properties);
edges.add(edge);
}
vertex.edges(edges);
ReceiverUtil.consumeBuffer(writeEdges(vertex), consumer);
}
}
use of com.baidu.hugegraph.computer.core.graph.edge.Edges in project hugegraph-computer by hugegraph.
the class TriangleCount method getOutNeighbors.
private static Set<Id> getOutNeighbors(Vertex vertex) {
Set<Id> outNeighbors = new HashSet<>();
Edges edges = vertex.edges();
for (Edge edge : edges) {
Id targetId = edge.targetId();
if (!vertex.id().equals(targetId)) {
outNeighbors.add(targetId);
}
}
return outNeighbors;
}
use of com.baidu.hugegraph.computer.core.graph.edge.Edges in project hugegraph-computer by hugegraph.
the class FileGraphPartition method compute0.
private long compute0(ComputationContext context) {
long activeVertexCount = 0L;
while (this.vertexInput.hasNext()) {
Vertex vertex = this.vertexInput.next();
vertex.reactivate();
Edges edges = this.edgesInput.edges(this.vertexInput.idPointer());
vertex.edges(edges);
this.computation.compute0(context, vertex);
if (vertex.active()) {
activeVertexCount++;
}
try {
this.saveVertexStatusAndValue(vertex);
} catch (IOException e) {
throw new ComputerException("Error occurred when saveVertex: %s", e, vertex);
}
}
return activeVertexCount;
}
use of com.baidu.hugegraph.computer.core.graph.edge.Edges in project hugegraph-computer by hugegraph.
the class EdgesInput method edges.
public Edges edges(ReusablePointer vidPointer) {
try {
while (this.input.available() > 0) {
long startPosition = this.input.position();
this.idPointer.read(this.input);
int status = vidPointer.compareTo(this.idPointer);
if (status < 0) {
// No edges
/*
* The current batch belong to vertex that vertex id is
* bigger than specified id.
*/
this.input.seek(startPosition);
return EmptyEdges.instance();
} else if (status == 0) {
// Has edges
this.valuePointer.read(this.input);
Edges edges = this.readEdges(this.valuePointer.input());
if (edges.size() < this.flushThreshold) {
return edges;
} else {
return new SuperEdges(vidPointer, edges, startPosition);
}
} else {
/*
* The current batch belong to vertex that vertex id is
* smaller than specified id.
*/
int valueLength = this.input.readFixedInt();
this.input.skip(valueLength);
}
}
return EmptyEdges.instance();
} catch (IOException e) {
throw new ComputerException("Can't read from edges input '%s'", e, this.edgeFile.getAbsoluteFile());
}
}
Aggregations