Skip to content

Release-1.0.3

Latest
Compare
Choose a tag to compare
@BOFA1ex BOFA1ex released this 23 Jan 11:01
· 5 commits to master since this release

Refactor

Define edge structure

class Impact extends Model.E<String> {
}

It changes must be declare bothID type and src&dst type

class Impact extends Model.E<String, String> {
}

It helps a lot when using nebula-graph, because it used src_vid->dst_vid@rank as edge_id in nebula.

It specifies the edge rank of the same edge type. The data type is int. If not specified, the default value is 0. You can insert many edges with the same edge type, source vertex, and destination vertex by using different rank values.

class Impact extends NebulaModel.E<String> {
}

class NebulaModel.E extends Model.E<NebulaEdgeID<R>, R> {
}

Fetch edge wrapper

edge("impact", "edge_id_001", "edge_id_002");

using maple-dsl-nebula

edge("impact", new NebulaEdgeID("src_vid_001", "dst_vid_002", 1L));

The NebulaEdgeID implements ID to render its fragment, it also work for other custom workaround (e.g. guid_object_identifer).

class NebulaEdgeID<R> implements ID {
    private final R src;
    private final R dst;
    private final long rank;

    public NebulaEdgeID(R src, R dst) {
        this(src, dst, 0L);
    }

    public NebulaEdgeID(R src, R dst, long rank) {
        if (src == null) throw new MapleDslException("NebulaEdge#src must not be null.");
        if (dst == null) throw new MapleDslException("NebulaEdge#dst must not be null.");
        if (rank < 0) throw new MapleDslException("NebulaEdge#rank must not be negative.");
        this.src = src;
        this.dst = dst;
        this.rank = rank;
    }

    @Override
    public String fragment() {
        return src instanceof String && dst instanceof String ?
                quote((String) src) + "->" + quote(((String) dst)) + "@" + rank :
                src + "->" + dst + "@" + rank;
    }
}

Full Changelog: v1.0.2...v1.0.3