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; }
public TinkerModuleV2d0() { super("tinkergraph-2.0"); addSerializer(TinkerGraph.class, new TinkerGraphJacksonSerializer()); addDeserializer(TinkerGraph.class, new TinkerGraphJacksonDeserializer()); }
public TinkerModuleV2d0() { super("tinkergraph-2.0"); addSerializer(TinkerGraph.class, new TinkerGraphJacksonSerializer()); addDeserializer(TinkerGraph.class, new TinkerGraphJacksonDeserializer()); }
TinkerGraph tg = TinkerGraph.open(); Preconditions.checkNotNull(value); VertexProperty.Cardinality card = getPropertyKeyCardinality(type.name()); tv.property(card, type.name(), value, T.id, relation.relationId); } else { assert type.isEdgeLabel(); te = (TinkerEdge)outV.addEdge(type.name(), tv, T.id, relation.relationId); } else if (relation.direction.equals(Direction.OUT)) { te = (TinkerEdge)tv.addEdge(type.name(), inV, T.id, relation.relationId); } else { throw new RuntimeException("Direction.BOTH is not supported"); te.property(rt.name(), next.value); } else { throw new RuntimeException("Metaedges are not supported"); 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;
private static TinkerGraph getTinkerGraphWithNumberManager() { final Configuration conf = getNumberIdManagerConfiguration(); return TinkerGraph.open(conf); }
/** * Open a new {@link TinkerGraph} instance. * <p/> * <b>Reference Implementation Help:</b> If a {@link Graph} implementation does not require a {@code Configuration} * (or perhaps has a default configuration) it can choose to implement a zero argument * {@code open()} method. This is an optional constructor method for TinkerGraph. It is not enforced by the Gremlin * Test Suite. */ public static TinkerGraph open() { return open(EMPTY_CONFIGURATION); }
public TinkerModule() { super("tinkergraph-1.0"); addSerializer(TinkerGraph.class, new TinkerGraphJacksonSerializer()); addDeserializer(TinkerGraph.class, new TinkerGraphJacksonDeserializer()); } }
private TinkerIoRegistryV2d0() { register(GryoIo.class, TinkerGraph.class, new TinkerGraphGryoSerializer()); register(GraphSONIo.class, null, new TinkerModuleV2d0()); }
private TinkerIoRegistryV1d0() { register(GryoIo.class, TinkerGraph.class, new TinkerGraphGryoSerializer()); register(GraphSONIo.class, null, new TinkerModule()); }
private TinkerIoRegistryV3d0() { register(GryoIo.class, TinkerGraph.class, new TinkerGraphGryoSerializer()); register(GraphSONIo.class, null, new TinkerModuleV2d0()); }
public static void removeElementIndex(final TinkerEdge edge) { final TinkerGraph graph = (TinkerGraph) edge.graph(); if (graph.edgeIndex != null) graph.edgeIndex.removeElement(edge); }
public static void autoUpdateIndex(final TinkerEdge edge, final String key, final Object newValue, final Object oldValue) { final TinkerGraph graph = (TinkerGraph) edge.graph(); if (graph.edgeIndex != null) graph.edgeIndex.autoUpdate(key, newValue, oldValue, edge); }
public static void removeElementIndex(final TinkerVertex vertex) { final TinkerGraph graph = (TinkerGraph) vertex.graph(); if (graph.vertexIndex != null) graph.vertexIndex.removeElement(vertex); }
public static void autoUpdateIndex(final TinkerVertex vertex, final String key, final Object newValue, final Object oldValue) { final TinkerGraph graph = (TinkerGraph) vertex.graph(); if (graph.vertexIndex != null) graph.vertexIndex.autoUpdate(key, newValue, oldValue, vertex); }
/** * Create the "modern" graph which has the same structure as the "classic" graph from TinkerPop 2.x but includes * 3.x features like vertex labels. */ public static TinkerGraph createModern() { final TinkerGraph g = getTinkerGraphWithNumberManager(); generateModern(g); return g; }
/** * This method only has an effect if the {@link #GREMLIN_TINKERGRAPH_GRAPH_LOCATION} is set, in which case the * data in the graph is persisted to that location. This method may be called multiple times and does not release * resources. */ @Override public void close() { if (graphLocation != null) saveGraph(); }
@Override public boolean willAllowId(final Object id) { return edgeIdManager.allow(id); } }
@Override public Variables variables() { if (null == this.variables) this.variables = new TinkerGraphVariables(); return this.variables; }