Java Code Examples for org.apache.tinkerpop.gremlin.structure.Direction#IN

The following examples show how to use org.apache.tinkerpop.gremlin.structure.Direction#IN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForeignKey.java    From sqlg with MIT License 5 votes vote down vote up
private ForeignKey(String key) {
    this.compositeKeys.add(key);
    this.concatenatedIdentifiers += key;
    this.direction = key.endsWith(Topology.IN_VERTEX_COLUMN_END) ? Direction.IN : Direction.OUT;
    int indexOfDot = key.indexOf(".");
    String foreignKeySchema = key.substring(0, indexOfDot);
    String foreignKeyTable = key.substring(indexOfDot + 1);
    this.schemaTable = SchemaTable.of(foreignKeySchema, foreignKeyTable);
}
 
Example 2
Source File: RelationIdentifier.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
TitanRelation findRelation(TitanTransaction tx) {
    TitanVertex v = ((StandardTitanTx)tx).getInternalVertex(outVertexId);
    if (v == null || v.isRemoved()) return null;
    TitanVertex typeVertex = tx.getVertex(typeId);
    if (typeVertex == null) return null;
    if (!(typeVertex instanceof RelationType))
        throw new IllegalArgumentException("Invalid RelationIdentifier: typeID does not reference a type");

    RelationType type = (RelationType) typeVertex;
    Iterable<? extends TitanRelation> rels;
    if (((RelationType) typeVertex).isEdgeLabel()) {
        Direction dir = Direction.OUT;
        TitanVertex other = ((StandardTitanTx)tx).getInternalVertex(inVertexId);
        if (other==null || other.isRemoved()) return null;
        if (((StandardTitanTx) tx).isPartitionedVertex(v) && !((StandardTitanTx) tx).isPartitionedVertex(other)) { //Swap for likely better performance
            TitanVertex tmp = other;
            other = v;
            v = tmp;
            dir = Direction.IN;
        }
        rels = ((VertexCentricQueryBuilder) v.query()).noPartitionRestriction().types((EdgeLabel) type).direction(dir).adjacent(other).edges();
    } else {
        rels = ((VertexCentricQueryBuilder) v.query()).noPartitionRestriction().types((PropertyKey) type).properties();
    }

    for (TitanRelation r : rels) {
        //Find current or previous relation
        if (r.longId() == relationId ||
                ((r instanceof StandardRelation) && ((StandardRelation) r).getPreviousID() == relationId)) return r;
    }
    return null;
}
 
Example 3
Source File: EdgeDirection.java    From grakn with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Direction fromPosition(int pos) {
    switch (pos) {
        case 0:
            return Direction.OUT;

        case 1:
            return Direction.IN;

        default:
            throw new IllegalArgumentException("Invalid position:" + pos);
    }
}
 
Example 4
Source File: EdgeIndexModel.java    From hgraphdb with Apache License 2.0 5 votes vote down vote up
public Edge deserialize(Result result) {
    byte[] bytes = result.getRow();
    PositionedByteRange buffer = new SimplePositionedByteRange(bytes);
    Object vertexId1 = ValueUtils.deserializeWithSalt(buffer);
    Direction direction = OrderedBytes.decodeInt8(buffer) == 1 ? Direction.IN : Direction.OUT;
    boolean isUnique = OrderedBytes.decodeInt8(buffer) == 1;
    String key = OrderedBytes.decodeString(buffer);
    String label = OrderedBytes.decodeString(buffer);
    Object value = ValueUtils.deserialize(buffer);
    Object vertexId2;
    Object edgeId;
    if (isUnique) {
        Cell vertexId2Cell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.VERTEX_ID_BYTES);
        vertexId2 = ValueUtils.deserialize(CellUtil.cloneValue(vertexId2Cell));
        Cell edgeIdCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.EDGE_ID_BYTES);
        edgeId = ValueUtils.deserialize(CellUtil.cloneValue(edgeIdCell));
    } else {
        vertexId2 = ValueUtils.deserialize(buffer);
        edgeId = ValueUtils.deserialize(buffer);
    }
    Cell createdAttsCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.CREATED_AT_BYTES);
    Long createdAt = ValueUtils.deserialize(CellUtil.cloneValue(createdAttsCell));
    Map<String, Object> properties = new HashMap<>();
    properties.put(key, value);
    HBaseEdge newEdge;
    if (direction == Direction.IN) {
        newEdge = new HBaseEdge(graph, edgeId, label, createdAt, null, properties, false,
                graph.findOrCreateVertex(vertexId1),
                graph.findOrCreateVertex(vertexId2));
    } else {
        newEdge = new HBaseEdge(graph, edgeId, label, createdAt, null, properties, false,
                graph.findOrCreateVertex(vertexId2),
                graph.findOrCreateVertex(vertexId1));
    }
    HBaseEdge edge = (HBaseEdge) graph.findOrCreateEdge(edgeId);
    edge.copyFrom(newEdge);
    edge.setIndexKey(new IndexMetadata.Key(ElementType.EDGE, label, key));
    edge.setIndexTs(createdAttsCell.getTimestamp());
    return edge;
}
 
Example 5
Source File: DirectoryVertex.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Adjacency(label = "parent", direction = Direction.IN)
public abstract List<? extends FileVertex> getItems();
 
Example 6
Source File: God.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Adjacency(label = "father", direction = Direction.IN)
Set<? extends God> getSonsSet();
 
Example 7
Source File: God.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Adjacency(label = "father", direction = Direction.IN, operation = Adjacency.Operation.GET)
Iterator<? extends God> obtainSons();
 
Example 8
Source File: NamespaceMetaModel.java    From windup with Eclipse Public License 1.0 4 votes vote down vote up
@Adjacency(label = XmlFileModel.NAMESPACE, direction = Direction.IN)
void addXmlResource(XmlFileModel facet);
 
Example 9
Source File: ForeignKey.java    From sqlg with MIT License 4 votes vote down vote up
public boolean isIn() {
    return this.direction == Direction.IN;
}
 
Example 10
Source File: AdjacencyMethodHandlerTest.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Adjacency(label = "father", direction = Direction.IN)
<N extends God> N addSon(String badArg, String worseArg);
 
Example 11
Source File: GodAlternative.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Adjacency(label = "father", direction = Direction.IN)
<N extends God> N addSon(ClassInitializer<? extends N> type);
 
Example 12
Source File: God.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Adjacency(label = "father", direction = Direction.IN)
God getSon();
 
Example 13
Source File: JavaInterfaceVertex.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Incidence(label = "implements", direction = Direction.IN, operation = Incidence.Operation.GET)
Iterator<VertexFrame> getImplementors();
 
Example 14
Source File: God.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Adjacency(label = "father", direction = Direction.IN, operation = Adjacency.Operation.ADD)
<N extends God> N includeSon(ClassInitializer<? extends N> type);
 
Example 15
Source File: God.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Incidence(label = "father", direction = Direction.IN)
List<? extends EdgeFrame> getSonEdgesList();
 
Example 16
Source File: AdjacencyMethodHandlerTest.java    From Ferma with Apache License 2.0 4 votes vote down vote up
@Adjacency(label = "father", direction = Direction.IN)
<N extends God> N addSon(String badArg);
 
Example 17
Source File: ArchiveModel.java    From windup with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Contains the parent archive.
 */
@Adjacency(label = PARENT_ARCHIVE, direction = Direction.IN)
void setParentArchive(ArchiveModel archive);
 
Example 18
Source File: EjbSessionBeanModel.java    From windup with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * References the Deployment Descriptor containing EJB.
 */
@Adjacency(label = EjbDeploymentDescriptorModel.EJB_SESSION_BEAN, direction = Direction.IN)
EjbDeploymentDescriptorModel getEjbDeploymentDescriptor();
 
Example 19
Source File: JavaParameterModel.java    From windup with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * The {@link JavaMethodModel} containing this parameter.
 */
@Adjacency(label = JavaMethodModel.METHOD_PARAMETER, direction = Direction.IN)
public JavaMethodModel getJavaMethod();
 
Example 20
Source File: EjbMessageDrivenModel.java    From windup with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * References the Deployment Descriptor containing EJB.
 */
@Adjacency(label = EjbDeploymentDescriptorModel.MESSAGE_DRIVEN, direction = Direction.IN)
public EjbDeploymentDescriptorModel getEjbDeploymentDescriptor();