// Path: titan-core/src/main/java/com/thinkaurelius/titan/graphdb/relations/RelationCache.java
// public class RelationCache implements Iterable<LongObjectCursor<Object>> {
// 
//     private static final LongObjectHashMap<Object> EMPTY = new LongObjectHashMap<>(0);
// 
//     public final Direction direction;
//     public final long typeId;
//     public final long relationId;
//     private final Object other;
//     private final LongObjectHashMap<Object> properties;
// 
//     public RelationCache(final Direction direction, final long typeId, final long relationId,
//                          final Object other, final LongObjectHashMap<Object> properties) {
//         this.direction = direction;
//         this.typeId = typeId;
//         this.relationId = relationId;
//         this.other = other;
//         this.properties = (properties == null || properties.size() > 0) ? properties : EMPTY;
//     }
// 
//     public RelationCache(final Direction direction, final long typeId, final long relationId,
//                          final Object other) {
//         this(direction,typeId,relationId,other,null);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public <O> O get(long key) {
//         return (O) properties.get(key);
//     }
// 
//     public boolean hasProperties() {
//         return properties != null && !properties.isEmpty();
//     }
// 
//     public int numProperties() {
//         return properties.size();
//     }
// 
//     public Object getValue() {
//         return other;
//     }
// 
//     public Long getOtherVertexId() {
//         return (Long) other;
//     }
// 
//     public Iterator<LongObjectCursor<Object>> propertyIterator() {
//         return properties.iterator();
//     }
// 
//     @Override
//     public Iterator<LongObjectCursor<Object>> iterator() {
//         return propertyIterator();
//     }
// 
//     @Override
//     public String toString() {
//          return typeId + "-" + direction + "->" + other + ":" + relationId;
//     }
// 
// }


import com.carrotsearch.hppc.cursors.LongObjectCursor;
import com.google.common.base.Preconditions;
import com.thinkaurelius.titan.core.*;
import com.thinkaurelius.titan.diskstorage.Entry;
import com.thinkaurelius.titan.diskstorage.StaticBuffer;
import com.thinkaurelius.titan.graphdb.database.RelationReader;
import com.thinkaurelius.titan.graphdb.idmanagement.IDManager;
import com.thinkaurelius.titan.graphdb.internal.InternalRelationType;
import com.thinkaurelius.titan.graphdb.relations.RelationCache;
import com.thinkaurelius.titan.graphdb.types.TypeInspector;
import com.thinkaurelius.titan.hadoop.formats.util.input.SystemTypeInspector;
import com.thinkaurelius.titan.hadoop.formats.util.input.TitanHadoopSetup;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerEdge;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.NoSuchElementException;

        /*Since we are filtering out system relation types, we might end up with vertices that have no incident relations.
         This is especially true for schema vertices. Those are filtered out.     */
        if (!foundVertexState) {
            log.trace("Vertex {} has unknown lifecycle state", vertexId);
            return null;
        } else if (!tv.edges(Direction.BOTH).hasNext() && !tv.properties().hasNext()) {
            log.trace("Vertex {} has no relations", vertexId);
            return null;
        }
        return tv;
    }

    public TinkerVertex getOrCreateVertex(final long vertexId, final String label, final TinkerGraph tg) {
        TinkerVertex v;

        try {
            v = (TinkerVertex)tg.vertices(vertexId).next();
        } catch (NoSuchElementException e) {
            if (null != label) {
                v = (TinkerVertex) tg.addVertex(T.label, label, T.id, vertexId);
            } else {
                v = (TinkerVertex) tg.addVertex(T.id, vertexId);
            }
        }

        return v;
    }

    private VertexProperty.Cardinality getPropertyKeyCardinality(String name) {
// Path: titan-core/src/main/java/com/thinkaurelius/titan/graphdb/relations/RelationCache.java
// public class RelationCache implements Iterable<LongObjectCursor<Object>> {
// 
//     private static final LongObjectHashMap<Object> EMPTY = new LongObjectHashMap<>(0);
// 
//     public final Direction direction;
//     public final long typeId;
//     public final long relationId;
//     private final Object other;
//     private final LongObjectHashMap<Object> properties;
// 
//     public RelationCache(final Direction direction, final long typeId, final long relationId,
//                          final Object other, final LongObjectHashMap<Object> properties) {
//         this.direction = direction;
//         this.typeId = typeId;
//         this.relationId = relationId;
//         this.other = other;
//         this.properties = (properties == null || properties.size() > 0) ? properties : EMPTY;
//     }
// 
//     public RelationCache(final Direction direction, final long typeId, final long relationId,
//                          final Object other) {
//         this(direction,typeId,relationId,other,null);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public <O> O get(long key) {
//         return (O) properties.get(key);
//     }
// 
//     public boolean hasProperties() {
//         return properties != null && !properties.isEmpty();
//     }
// 
//     public int numProperties() {
//         return properties.size();
//     }
// 
//     public Object getValue() {
//         return other;
//     }
// 
//     public Long getOtherVertexId() {
//         return (Long) other;
//     }
// 
//     public Iterator<LongObjectCursor<Object>> propertyIterator() {
//         return properties.iterator();
//     }
// 
//     @Override
//     public Iterator<LongObjectCursor<Object>> iterator() {
//         return propertyIterator();
//     }
// 
//     @Override
//     public String toString() {
//          return typeId + "-" + direction + "->" + other + ":" + relationId;
//     }
// 
// }


// Path: titan-hadoop-parent/titan-hadoop-core/src/main/java/com/thinkaurelius/titan/hadoop/formats/util/TitanVertexDeserializer.java
import com.carrotsearch.hppc.cursors.LongObjectCursor;
import com.google.common.base.Preconditions;
import com.thinkaurelius.titan.core.*;
import com.thinkaurelius.titan.diskstorage.Entry;
import com.thinkaurelius.titan.diskstorage.StaticBuffer;
import com.thinkaurelius.titan.graphdb.database.RelationReader;
import com.thinkaurelius.titan.graphdb.idmanagement.IDManager;
import com.thinkaurelius.titan.graphdb.internal.InternalRelationType;
import com.thinkaurelius.titan.graphdb.relations.RelationCache;
import com.thinkaurelius.titan.graphdb.types.TypeInspector;
import com.thinkaurelius.titan.hadoop.formats.util.input.SystemTypeInspector;
import com.thinkaurelius.titan.hadoop.formats.util.input.TitanHadoopSetup;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerEdge;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.NoSuchElementException;


        /*Since we are filtering out system relation types, we might end up with vertices that have no incident relations.
         This is especially true for schema vertices. Those are filtered out.     */
        if (!foundVertexState) {
            log.trace("Vertex {} has unknown lifecycle state", vertexId);
            return null;
        } else if (!tv.edges(Direction.BOTH).hasNext() && !tv.properties().hasNext()) {
            log.trace("Vertex {} has no relations", vertexId);
            return null;
        }
        return tv;
    }

    public TinkerVertex getOrCreateVertex(final long vertexId, final String label, final TinkerGraph tg) {
        TinkerVertex v;

        try {
            v = (TinkerVertex)tg.vertices(vertexId).next();
        } catch (NoSuchElementException e) {
            if (null != label) {
                v = (TinkerVertex) tg.addVertex(T.label, label, T.id, vertexId);
            } else {
                v = (TinkerVertex) tg.addVertex(T.id, vertexId);
            }
        }

        return v;
    }

    private VertexProperty.Cardinality getPropertyKeyCardinality(String name) {
        RelationType rt = typeManager.getRelationType(name);