Java Code Examples for org.apache.tinkerpop.gremlin.structure.VertexProperty#value()
The following examples show how to use
org.apache.tinkerpop.gremlin.structure.VertexProperty#value() .
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: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldDetachPropertyOfVertexPropertyWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(DetachedVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); assertEquals("dah", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("bah", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("xxx").property("to-change","bah").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(1, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 2
Source File: AbstractLabel.java From sqlg with MIT License | 5 votes |
Partition addPartition(Vertex partitionVertex) { Preconditions.checkState(this.getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()); VertexProperty<String> from = partitionVertex.property(SQLG_SCHEMA_PARTITION_FROM); VertexProperty<String> to = partitionVertex.property(SQLG_SCHEMA_PARTITION_TO); VertexProperty<String> in = partitionVertex.property(SQLG_SCHEMA_PARTITION_IN); VertexProperty<String> partitionType = partitionVertex.property(SQLG_SCHEMA_PARTITION_PARTITION_TYPE); VertexProperty<String> partitionExpression = partitionVertex.property(SQLG_SCHEMA_PARTITION_PARTITION_EXPRESSION); Partition partition; if (from.isPresent()) { Preconditions.checkState(to.isPresent()); Preconditions.checkState(!in.isPresent()); partition = new Partition( this.sqlgGraph, this, partitionVertex.value(SQLG_SCHEMA_PARTITION_NAME), from.value(), to.value(), PartitionType.from(partitionType.<String>value()), partitionExpression.isPresent() ? partitionExpression.<String>value() : null); } else { Preconditions.checkState(in.isPresent()); Preconditions.checkState(!to.isPresent()); partition = new Partition( this.sqlgGraph, this, partitionVertex.value(SQLG_SCHEMA_PARTITION_NAME), in.value(), PartitionType.from(partitionType.<String>value()), partitionExpression.isPresent() ? partitionExpression.<String>value() : null); } this.partitions.put(partitionVertex.value(SQLG_SCHEMA_PARTITION_NAME), partition); return partition; }
Example 3
Source File: CharterPortaalFondsFacetDescription.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
@Override public List<String> getValues(Vertex vertex) { VertexProperty<String> fondsNaamProp = vertex.property(FONDS_NAAM); String fondsNaam = fondsNaamProp.isPresent() ? fondsNaamProp.value() : ""; VertexProperty<String> fondsProp = vertex.property(FONDS); String fonds = fondsNaamProp.isPresent() ? fondsProp.value() : ""; return Lists.newArrayList(createFacetValue(fondsNaam, fonds)); }
Example 4
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldUseActualPropertyOfVertexPropertyWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertEquals(vp, element); assertEquals(label, element.label()); assertEquals(value, element.value()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("xxx").property("new","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(2, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 5
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldUseActualPropertyOfVertexPropertyWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertEquals(vp, element); assertEquals(label, element.label()); assertEquals(value, element.value()); assertEquals("dah", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("bah", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("xxx").property("to-change","bah").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(1, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 6
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldReferenceVertexPropertyWhenRemoved() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("to-remove","blah"); final String label = vp.label(); final Object value = vp.value(); final VertexProperty vpToKeep = v.property("to-keep","dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyRemoved(final VertexProperty element) { assertThat(element, instanceOf(ReferenceVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("to-remove").drop().iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(vpToKeep.value(), g.V(v).values("to-keep").next()); assertThat(triggered.get(), is(true)); }
Example 7
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldReferencePropertyOfVertexPropertyWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(ReferenceVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("xxx").property("new","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(2, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 8
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldReferencePropertyOfVertexPropertyWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(ReferenceVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); assertEquals("dah", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("bah", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("xxx").property("to-change","bah").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(1, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 9
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldDetachVertexPropertyWhenRemoved() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("to-remove","blah"); final String label = vp.label(); final Object value = vp.value(); final VertexProperty vpToKeep = v.property("to-keep","dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyRemoved(final VertexProperty element) { assertThat(element, instanceOf(DetachedVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("to-remove").drop().iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(vpToKeep.value(), g.V(v).values("to-keep").next()); assertThat(triggered.get(), is(true)); }
Example 10
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldDetachPropertyOfVertexPropertyWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(DetachedVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("xxx").property("new","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(2, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 11
Source File: GraphOMRSClassificationMapper.java From egeria with Apache License 2.0 | 5 votes |
private Object getVertexProperty(Vertex vertex, String propName) { VertexProperty vp = vertex.property(propName); if (vp == null || !vp.isPresent()) return null; else return vp.value(); }
Example 12
Source File: ShortestPathVertexProgram.java From tinkerpop with Apache License 2.0 | 5 votes |
/** * Move any valid path into the VP's memory. * @param vertex The current vertex. * @param memory The VertexProgram's memory. */ private void collectShortestPaths(final Vertex vertex, final Memory memory) { final VertexProperty<Map<Vertex, Pair<Number, Set<Path>>>> pathProperty = vertex.property(PATHS); if (pathProperty.isPresent()) { final Map<Vertex, Pair<Number, Set<Path>>> paths = pathProperty.value(); final List<Path> result = new ArrayList<>(); for (final Pair<Number, Set<Path>> pair : paths.values()) { for (final Path path : pair.getValue1()) { if (isEndVertex(vertex)) { if (this.distanceEqualsNumberOfHops || this.maxDistance == null || NumberHelper.compare(pair.getValue0(), this.maxDistance) <= 0) { result.add(path); } } } } pathProperty.remove(); memory.add(SHORTEST_PATHS, result); } }
Example 13
Source File: SourceFileModel.java From windup with Eclipse Public License 1.0 | 5 votes |
/** * Contains a boolean indicating that the reporting system should generate a source report for this {@link SourceFileModel}. */ default boolean isGenerateSourceReport() { VertexProperty result = getElement().property(GENERATE_SOURCE_REPORT); if (!result.isPresent()) return false; return (Boolean)result.value(); }
Example 14
Source File: ShortestDistanceVertexProgram.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Override public void execute(final Vertex vertex, Messenger<Long> messenger, final Memory memory) { if (memory.isInitialIteration()) { if (vertex.id().equals(Long.valueOf(seed).longValue())) { // The seed sends a single message to start the computation log.debug("Sent initial message from {}", vertex.id()); // The seed's distance to itself is zero vertex.property(VertexProperty.Cardinality.single, DISTANCE, 0L); messenger.sendMessage(incidentMessageScope, 0L); } } else { Iterator<Long> distances = messenger.receiveMessages(); // Find minimum distance among all incoming messages, or null if no messages came in Long shortestDistanceSeenOnThisIteration = IteratorUtils.stream(distances).reduce((a, b) -> Math.min(a, b)).orElse(null); if (null == shortestDistanceSeenOnThisIteration) return; // no messages to process or forward on this superstep VertexProperty<Long> currentShortestVP = vertex.property(DISTANCE); if (!currentShortestVP.isPresent() || currentShortestVP.value() > shortestDistanceSeenOnThisIteration) { // First/shortest distance seen by this vertex: store it and forward to neighbors vertex.property(VertexProperty.Cardinality.single, DISTANCE, shortestDistanceSeenOnThisIteration); messenger.sendMessage(incidentMessageScope, shortestDistanceSeenOnThisIteration); } // else: no new winner, ergo no reason to send message to neighbors } }
Example 15
Source File: PostProcessManager.java From atlas with Apache License 2.0 | 5 votes |
@Override public void processItem(Object vertexId) { batchCounter++; counter++; try { Vertex vertex = bulkLoadGraph.traversal().V(vertexId).next(); boolean isTypeVertex = vertex.property(TYPENAME_PROPERTY_KEY).isPresent(); VertexProperty typeNameProperty = vertex.property(ENTITY_TYPE_PROPERTY_KEY); if (!isTypeVertex && typeNameProperty.isPresent()) { String typeName = (String) typeNameProperty.value(); if (!typePropertiesMap.containsKey(typeName)) { return; } Map<String, List<String>> collectionTypeProperties = typePropertiesMap.get(typeName); for (String key : nonPrimitiveCategoryKeys) { if (!collectionTypeProperties.containsKey(key)) { continue; } for(String propertyName : collectionTypeProperties.get(key)) { processor.process(vertex, typeName, propertyName); } } } commitBatch(); } catch (Exception ex) { LOG.error("processItem: v[{}] error!", vertexId, ex); } }
Example 16
Source File: GraphOMRSEntityMapper.java From egeria with Apache License 2.0 | 5 votes |
private Object getVertexProperty(Vertex vertex, String propName) { VertexProperty vp = vertex.property(propName); if (vp == null || !vp.isPresent()) return null; else return vp.value(); }
Example 17
Source File: ReferenceVertexProperty.java From tinkerpop with Apache License 2.0 | 4 votes |
public ReferenceVertexProperty(final VertexProperty<V> vertexProperty) { super(vertexProperty); this.vertex = null == vertexProperty.element() ? null : ReferenceFactory.detach(vertexProperty.element()); this.value = vertexProperty.value(); }
Example 18
Source File: GraphSONMessageSerializerGremlinV2d0Test.java From tinkerpop with Apache License 2.0 | 4 votes |
@Test public void shouldSerializeVertexWithEmbeddedMap() throws Exception { final Graph graph = TinkerGraph.open(); final Vertex v = graph.addVertex(); final Map<String, Object> map = new HashMap<>(); map.put("x", 500); map.put("y", "some"); final ArrayList<Object> friends = new ArrayList<>(); friends.add("x"); friends.add(5); friends.add(map); v.property(VertexProperty.Cardinality.single, "friends", friends); final List list = IteratorUtils.list(graph.vertices()); final ResponseMessage response = convert(list); assertCommon(response); final List<Vertex> vertexList = (List<Vertex>) response.getResult().getData(); assertEquals(1, vertexList.size()); final Vertex deserializedVertex = vertexList.get(0); assertEquals(v.id(), deserializedVertex.id()); assertEquals(Vertex.DEFAULT_LABEL, deserializedVertex.label()); final List<VertexProperty> properties = new ArrayList<>(); deserializedVertex.properties().forEachRemaining(properties::add); assertEquals(1, properties.size()); final VertexProperty friendsProperty = properties.get(0); final List<Object> deserializedInnerList = (List<Object>) friendsProperty.value(); assertEquals(3, deserializedInnerList.size()); assertEquals("x", deserializedInnerList.get(0)); assertEquals(5, deserializedInnerList.get(1)); final Map<String, Object> deserializedInnerInnerMap = (Map<String, Object>) deserializedInnerList.get(2); assertEquals(2, deserializedInnerInnerMap.size()); assertEquals(500, deserializedInnerInnerMap.get("x")); assertEquals("some", deserializedInnerInnerMap.get("y")); }
Example 19
Source File: GraphSONMessageSerializerV3d0Test.java From tinkerpop with Apache License 2.0 | 4 votes |
@Test public void shouldSerializeVertexWithEmbeddedMap() throws Exception { final Graph graph = TinkerGraph.open(); final Vertex v = graph.addVertex(); final Map<String, Object> map = new HashMap<>(); map.put("x", 500); map.put("y", "some"); final ArrayList<Object> friends = new ArrayList<>(); friends.add("x"); friends.add(5); friends.add(map); v.property(VertexProperty.Cardinality.single, "friends", friends); final List list = IteratorUtils.list(graph.vertices()); final ResponseMessage response = convert(list); assertCommon(response); final List<Vertex> vertexList = (List<Vertex>) response.getResult().getData(); assertEquals(1, vertexList.size()); final Vertex deserializedVertex = vertexList.get(0); assertEquals(v.id(), deserializedVertex.id()); assertEquals(Vertex.DEFAULT_LABEL, deserializedVertex.label()); final List<VertexProperty> properties = new ArrayList<>(); deserializedVertex.properties().forEachRemaining(properties::add); assertEquals(1, properties.size()); final VertexProperty friendsProperty = properties.get(0); final List<Object> deserializedInnerList = (List<Object>) friendsProperty.value(); assertEquals(3, deserializedInnerList.size()); assertEquals("x", deserializedInnerList.get(0)); assertEquals(5, deserializedInnerList.get(1)); final Map<String, Object> deserializedInnerInnerMap = (Map<String, Object>) deserializedInnerList.get(2); assertEquals(2, deserializedInnerInnerMap.size()); assertEquals(500, deserializedInnerInnerMap.get("x")); assertEquals("some", deserializedInnerInnerMap.get("y")); }
Example 20
Source File: TitanEventualGraphTest.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
/** * Tests the correct interpretation of the commit time and that timestamps can be read */ @Test public void testTimestampSetting() { clopen(option(GraphDatabaseConfiguration.STORE_META_TIMESTAMPS,"edgestore"),true, option(GraphDatabaseConfiguration.STORE_META_TTL,"edgestore"),true); // Transaction 1: Init graph with two vertices, having set "name" and "age" properties TitanTransaction tx1 = graph.buildTransaction().commitTime(Instant.ofEpochSecond(100)).start(); String name = "name"; String age = "age"; String address = "address"; TitanVertex v1 = tx1.addVertex(name, "a"); TitanVertex v2 = tx1.addVertex(age, "14", name, "b", age, "42"); tx1.commit(); // Fetch vertex ids long id1 = getId(v1); long id2 = getId(v2); // Transaction 2: Remove "name" property from v1, set "address" property; create // an edge v2 -> v1 TitanTransaction tx2 = graph.buildTransaction().commitTime(Instant.ofEpochSecond(1000)).start(); v1 = getV(tx2,id1); v2 = getV(tx2,id2); for (Iterator<VertexProperty<Object>> propiter = v1.properties(name); propiter.hasNext(); ) { VertexProperty prop = propiter.next(); if (features.hasTimestamps()) { Instant t = prop.value("~timestamp"); assertEquals(100,t.getEpochSecond()); assertEquals(Instant.ofEpochSecond(0, 1000).getNano(),t.getNano()); } if (features.hasCellTTL()) { Duration d = prop.value("~ttl"); assertEquals(0l, d.getSeconds()); assertTrue(d.isZero()); } } assertEquals(1, v1.query().propertyCount()); assertEquals(1, v1.query().has("~timestamp", Cmp.GREATER_THAN, Instant.ofEpochSecond(10)).propertyCount()); assertEquals(1, v1.query().has("~timestamp", Instant.ofEpochSecond(100, 1000)).propertyCount()); v1.property(name).remove(); v1.property(VertexProperty.Cardinality.single, address, "xyz"); Edge edge = v2.addEdge("parent",v1); tx2.commit(); Object edgeId = edge.id(); TitanVertex afterTx2 = getV(graph,id1); // Verify that "name" property is gone assertFalse(afterTx2.keys().contains(name)); // Verify that "address" property is set assertEquals("xyz", afterTx2.value(address)); // Verify that the edge is properly registered with the endpoint vertex assertCount(1, afterTx2.query().direction(IN).labels("parent").edges()); // Verify that edge is registered under the id assertNotNull(getE(graph,edgeId)); graph.tx().commit(); // Transaction 3: Remove "address" property from v1 with earlier timestamp than // when the value was set TitanTransaction tx3 = graph.buildTransaction().commitTime(Instant.ofEpochSecond(200)).start(); v1 = getV(tx3,id1); v1.property(address).remove(); tx3.commit(); TitanVertex afterTx3 = getV(graph,id1); graph.tx().commit(); // Verify that "address" is still set assertEquals("xyz", afterTx3.value(address)); // Transaction 4: Modify "age" property on v2, remove edge between v2 and v1 TitanTransaction tx4 = graph.buildTransaction().commitTime(Instant.ofEpochSecond(2000)).start(); v2 = getV(tx4,id2); v2.property(VertexProperty.Cardinality.single, age, "15"); getE(tx4,edgeId).remove(); tx4.commit(); TitanVertex afterTx4 = getV(graph,id2); // Verify that "age" property is modified assertEquals("15", afterTx4.value(age)); // Verify that edge is no longer registered with the endpoint vertex assertCount(0, afterTx4.query().direction(OUT).labels("parent").edges()); // Verify that edge entry disappeared from id registry assertNull(getE(graph,edgeId)); // Transaction 5: Modify "age" property on v2 with earlier timestamp TitanTransaction tx5 = graph.buildTransaction().commitTime(Instant.ofEpochSecond(1500)).start(); v2 = getV(tx5,id2); v2.property(VertexProperty.Cardinality.single, age, "16"); tx5.commit(); TitanVertex afterTx5 = getV(graph,id2); // Verify that the property value is unchanged assertEquals("15", afterTx5.value(age)); }