@Override public void map(final Vertex vertex, final MapEmitter<Object, Double> emitter) { final Property pageRank = vertex.property(PageRankVertexProgram.PAGE_RANK); if (pageRank.isPresent()) { emitter.emit(vertex.id(), (Double) pageRank.value()); } }
@Override public void map(final Vertex vertex, final MapEmitter<Object, Long> emitter) { final Property distance = vertex.property(ShortestDistanceVertexProgram.DISTANCE); if (distance.isPresent()) { emitter.emit(vertex.id(), (Long) distance.value()); } }
@Override public void map(final Vertex vertex, final MapEmitter<Object, Long> emitter) { final Property distance = vertex.property(ShortestDistanceVertexProgram.DISTANCE); if (distance.isPresent()) { emitter.emit(vertex.id(), (Long) distance.value()); } }
@Override public void map(final Vertex vertex, final MapEmitter<Object, Double> emitter) { final Property pageRank = vertex.property(PageRankVertexProgram.PAGE_RANK); if (pageRank.isPresent()) { emitter.emit(vertex.id(), (Double) pageRank.value()); } }
private void assertGeoshape(Function<Geoshape,Geoshape> makeGeoshape) { graph.traversal().E().has("place").toList().forEach(e-> { assertTrue(e.property("shape").isPresent()); Geoshape place = (Geoshape) e.property("place").value(); Geoshape expected = makeGeoshape.apply(place); Geoshape actual = (Geoshape) e.property("shape").value(); assertEquals(expected, actual); }); }
assertEquals(v1id, getId(v)); TitanEdge e = Iterables.getOnlyElement(changes.getEdges(v, Change.REMOVED, Direction.OUT, "knows")); assertFalse(e.property("weight").isPresent()); assertEquals(v, e.vertex(Direction.IN)); e = Iterables.getOnlyElement(changes.getEdges(v, Change.ADDED, Direction.OUT, "knows"));
@Override public boolean isPresent() { return this.property.isPresent(); }
@Override public boolean isPresent() { return this.baseProperty.isPresent(); }
assertEquals(111.1, v1.<Float>value("weight").doubleValue(), 0.01); Edge e = getOnlyElement(v1.query().direction(Direction.OUT).labels("knows").edges()); assertFalse(e.property("weight").isPresent()); e.property("weight", 44.4); tx2.commit();
assertEquals(111.1, v1.<Float>value("weight").doubleValue(), 0.01); final Edge e = Iterables.getOnlyElement(v1.query().direction(Direction.OUT).labels("knows").edges()); assertFalse(e.property("weight").isPresent()); e.property("weight", 44.4); tx2.commit(); JanusGraphEdge e1 = Iterables.getOnlyElement(changes.getEdges(v, Change.REMOVED, Direction.OUT, "knows")); assertFalse(e1.property("weight").isPresent()); assertEquals(v, e1.vertex(Direction.IN)); e1 = Iterables.getOnlyElement(changes.getEdges(v, Change.ADDED, Direction.OUT, "knows"));
/** * If the value is present, return the value, else return the provided value. * * @param otherValue The value to return if the property is not present * @return A value */ public default V orElse(final V otherValue) { return this.isPresent() ? this.value() : otherValue; }
/** * If the value is present, return the value, else generate a value given the {@link Supplier}. * * @param valueSupplier The supplier to use to generate a value if the property is not present * @return A value */ public default V orElseGet(final Supplier<? extends V> valueSupplier) { return this.isPresent() ? this.value() : valueSupplier.get(); }
/** * If the property is present, the consume the value as specified by the {@link Consumer}. * * @param consumer The consumer to process the existing value. */ public default void ifPresent(final Consumer<? super V> consumer) { if (this.isPresent()) consumer.accept(this.value()); }
v3 = graph.addVertex(); Edge e = v1.addEdge("knows", v3); assertFalse(e.property("age").isPresent());
v3 = graph.addVertex(); Edge e = v1.addEdge("knows", v3); assertFalse(e.property("age").isPresent());
@Override public void map(final Vertex vertex, final MapEmitter<Serializable, Long> emitter) { final Property<Serializable> cluster = vertex.property(PeerPressureVertexProgram.CLUSTER); if (cluster.isPresent()) { emitter.emit(cluster.value(), 1l); } }
@Override public <V> Property<V> property(final String key, final V value) { if (this.removed) throw elementAlreadyRemoved(Edge.class, id); ElementHelper.validateProperty(key, value); final Property oldProperty = super.property(key); final Property<V> newProperty = new TinkerProperty<>(this, key, value); if (null == this.properties) this.properties = new HashMap<>(); this.properties.put(key, newProperty); TinkerHelper.autoUpdateIndex(this, key, value, oldProperty.isPresent() ? oldProperty.value() : null); return newProperty; }
@Override public void map(final Vertex vertex, final MapEmitter<Object, Double> emitter) { final Property pageRank = vertex.property(PageRankVertexProgram.PAGE_RANK); if (pageRank.isPresent()) { emitter.emit(vertex.id(), (Double) pageRank.value()); } }
@Override public void map(final Vertex vertex, final MapEmitter<NullObject, Serializable> emitter) { final Property<Serializable> cluster = vertex.property(PeerPressureVertexProgram.CLUSTER); if (cluster.isPresent()) { emitter.emit(NullObject.instance(), cluster.value()); } }
public static void validatePropertyEquality(final Property originalProperty, final Property otherProperty) { assertEquals(originalProperty, otherProperty); assertEquals(otherProperty, originalProperty); if (originalProperty.isPresent()) { assertEquals(originalProperty.key(), otherProperty.key()); assertEquals(originalProperty.value(), otherProperty.value()); assertEquals(originalProperty.element(), otherProperty.element()); } }