private Edges readEdges()

in computer-core/src/main/java/org/apache/hugegraph/computer/core/compute/input/EdgesInput.java [209:259]


    private Edges readEdges(RandomAccessInput in) {
        try {
            int count = in.readFixedInt();
            Edges edges = this.graphFactory.createEdges(count);
            if (this.frequency == EdgeFrequency.SINGLE) {
                for (int i = 0; i < count; i++) {
                    Edge edge = this.graphFactory.createEdge();
                    // Only use targetId as subKey, use props as subValue
                    edge.targetId(StreamGraphInput.readId(in));
                    // Read subValue
                    Properties props = this.graphFactory.createProperties();
                    props.read(in);
                    edge.properties(props);
                    edges.add(edge);
                }
            } else if (this.frequency == EdgeFrequency.SINGLE_PER_LABEL) {
                for (int i = 0; i < count; i++) {
                    Edge edge = this.graphFactory.createEdge();
                    // Use label + targetId as subKey, use props as subValue
                    edge.label(StreamGraphInput.readLabel(in));
                    edge.targetId(StreamGraphInput.readId(in));
                    // Read subValue
                    Properties props = this.graphFactory.createProperties();
                    props.read(in);
                    edge.properties(props);
                    edges.add(edge);
                }
            } else {
                assert this.frequency == EdgeFrequency.MULTIPLE;
                for (int i = 0; i < count; i++) {
                    Edge edge = this.graphFactory.createEdge();
                    /*
                     * Use label + sortValues + targetId as subKey,
                     * use properties as subValue
                     */
                    edge.label(StreamGraphInput.readLabel(in));
                    edge.name(StreamGraphInput.readLabel(in));
                    edge.targetId(StreamGraphInput.readId(in));
                    // Read subValue
                    Properties props = this.graphFactory.createProperties();
                    props.read(in);
                    edge.properties(props);
                    edges.add(edge);
                }
            }
            return edges;
        } catch (IOException e) {
            throw new ComputerException("Failed to read edges from input '%s'",
                                        e, this.edgeFile.getAbsoluteFile());
        }
    }