Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Direction


        int typecompare = t1.compareTo(t2);
        if (typecompare != 0) return typecompare;
        assert t1.equals(t2);

        //2) Direction
        Direction dir1 = null, dir2 = null;
        for (int i = 0; i < r1.getLen(); i++)
            if (r1.getVertex(i).equals(vertex)) {
                dir1 = EdgeDirection.fromPosition(i);
                break;
            }
        for (int i = 0; i < r2.getLen(); i++)
            if (r2.getVertex(i).equals(vertex)) {
                dir2 = EdgeDirection.fromPosition(i);
                break;
            }
        assert dir1 != null && dir2 != null; // ("Either relation is not incident on vertex [%s]", vertex);
        int dirCompare = EdgeDirection.position(dir1) - EdgeDirection.position(dir2);
        if (dirCompare != 0) return dirCompare;

        // Breakout: If type&direction are the same and the type is unique in the direction it follows that the relations are the same
        if (t1.isUnique(dir1)) return 0;

        // 3) Compare sort key values
        for (long typeid : t1.getSortKey()) {
            int keycompare = compareOnKey(r1, r2, typeid, t1.getSortOrder());
            if (keycompare != 0) return keycompare;
        }
        // 4) Compare property objects or other vertices
        if (r1.isProperty()) {
            Object o1 = ((TitanProperty) r1).getValue();
            Object o2 = ((TitanProperty) r2).getValue();
            Preconditions.checkArgument(o1 != null && o2 != null);
            if (!o1.equals(o2)) {
                int objectcompare = 0;
                if (Comparable.class.isAssignableFrom(((TitanKey) t1).getDataType())) {
                    objectcompare = ((Comparable) o1).compareTo(o2);
                } else {
                    objectcompare = System.identityHashCode(o1) - System.identityHashCode(o2);
                }
                if (objectcompare != 0) return objectcompare;
            }
        } else {
            Preconditions.checkArgument(r1.isEdge() && r2.isEdge());
            int vertexcompare = r1.getVertex(EdgeDirection.position(dir1.opposite())).
                    compareTo(r2.getVertex(EdgeDirection.position(dir1.opposite())));
            if (vertexcompare != 0) return vertexcompare;
        }
        //TODO: if graph is simple, return 0
        // 5)compare relation ids
        return r1.compareTo(r2);
View Full Code Here


        LongObjectOpenHashMap properties = parseHeaderOnly ? null : new LongObjectOpenHashMap(4);
        long[] typeAndDir = IDHandler.readEdgeType(column);
        int dirID = (int) typeAndDir[1];
        long typeId = typeAndDir[0];

        Direction dir;
        RelationType rtype;
        switch (dirID) {
            case PROPERTY_DIR:
                dir = Direction.OUT;
                rtype = RelationType.PROPERTY;
View Full Code Here

    public Entry writeRelation(InternalRelation relation, int position, StandardTitanTx tx) {
        Preconditions.checkArgument(position < relation.getLen());
        TitanType type = relation.getType();
        long typeid = type.getID();

        Direction dir = EdgeDirection.fromPosition(position);
        int dirID = getDirID(dir, relation.isProperty() ? RelationType.PROPERTY : RelationType.EDGE);

        DataOutput colOut = serializer.getDataOutput(DEFAULT_COLUMN_CAPACITY, true);
        IDHandler.writeEdgeType(colOut, typeid, dirID);
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.Direction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.