@Override public <O> O valueOrNull(PropertyKey key) { return (O)property(key.name()).orElse(null); }
@Override public <O> O valueOrNull(PropertyKey key) { return (O)property(key.name()).orElse(null); }
@Override public void process(TitanVertex vertex, ScanMetrics metrics) { long outDegree = vertex.query().labels("knows").direction(Direction.OUT).edgeCount(); assertEquals(0, vertex.query().labels("knows").direction(Direction.IN).edgeCount()); assertEquals(1, vertex.query().labels("uid").propertyCount()); assertTrue(vertex.<Integer>property("uid").orElse(0) > 0); metrics.incrementCustom(DEGREE_COUNT,outDegree); metrics.incrementCustom(VERTEX_COUNT); }
@Override public void process(JanusGraphVertex vertex, ScanMetrics metrics) { long outDegree = vertex.query().labels("knows").direction(Direction.OUT).edgeCount(); assertEquals(0, vertex.query().labels("knows").direction(Direction.IN).edgeCount()); assertEquals(1, vertex.query().labels("uid").propertyCount()); assertTrue(vertex.<Integer>property("uid").orElse(0) > 0); metrics.incrementCustom(DEGREE_COUNT,outDegree); metrics.incrementCustom(VERTEX_COUNT); }
private void writeVertices(final XMLStreamWriter writer, final Graph graph) throws XMLStreamException { final Iterable<Vertex> vertices = getVerticesAndNormalizeIfRequired(graph); for (Vertex vertex : vertices) { writer.writeStartElement(GraphMLTokens.NODE); writer.writeAttribute(GraphMLTokens.ID, vertex.id().toString()); final Collection<String> keys = getElementKeysAndNormalizeIfRequired(vertex); writer.writeStartElement(GraphMLTokens.DATA); writer.writeAttribute(GraphMLTokens.KEY, this.vertexLabelKey); writer.writeCharacters(vertex.label()); writer.writeEndElement(); for (String key : keys) { writer.writeStartElement(GraphMLTokens.DATA); if (intersection != null && intersection.contains(key)) { writer.writeAttribute(GraphMLTokens.KEY, key.concat(GraphMLTokens.VERTEX_SUFFIX)); } else { writer.writeAttribute(GraphMLTokens.KEY, key); } // technically there can't be a null here as gremlin structure forbids that occurrence even if Graph // implementations support it, but out to empty string just in case. writer.writeCharacters(vertex.property(key).orElse("").toString()); writer.writeEndElement(); } writer.writeEndElement(); } }
@Override public Traversal<Vertex, Vertex> get_g_V_filterXlang_eq_javaX() { return g.V().filter(v -> v.get().<String>property("lang").orElse("none").equals("java")); }
@Override public Traversal<Vertex, Vertex> get_g_VX1X_filterXage_gt_30X(final Object v1Id) { return g.V(v1Id).filter(v -> v.get().<Integer>property("age").orElse(0) > 30); }
@Override public Traversal<Vertex, Vertex> get_g_VX1X_out_filterXage_gt_30X(final Object v1Id) { return g.V(v1Id).out().filter(v -> v.get().<Integer>property("age").orElse(0) > 30); }
memory.add(TELEPORTATION_ENERGY, -localTerminalEnergy); final double previousPageRank = vertex.<Double>property(this.property).orElse(0.0d); memory.add(CONVERGENCE_ERROR, Math.abs(pageRank - previousPageRank)); vertex.property(VertexProperty.Cardinality.single, this.property, pageRank);
final TraverserSet<Object> localBarrierTraversers = vertex.<TraverserSet<Object>>property(TraversalVertexProgram.ACTIVE_TRAVERSERS).orElse(new TraverserSet<>()); vertex.property(TraversalVertexProgram.ACTIVE_TRAVERSERS, localBarrierTraversers); while (barrier.hasNextBarrier()) {
/** * Returns the {@link EPackage#getNsURI() namespace URI} stored in the given {@link EPackage} vertex. * * @param ePackageVertex The vertex to read the namespace URI from. Must not be <code>null</code>. * @return The namespace URI, or <code>null</code> if none is set. */ public static String getNsURI(final Vertex ePackageVertex) { checkNotNull(ePackageVertex, "Precondition violation - argument 'ePackageVertex' must not be NULL!"); return (String) ePackageVertex.property(V_PROP__NS_URI).orElse(null); }
/** * Returns the {@link EPackage#getNsPrefix() namespace Prefix} stored in the given {@link EPackage} vertex. * * @param ePackageVertex The vertex to read the namespace Prefix from. Must not be <code>null</code>. * @return The namespace Prefix, or <code>null</code> if none is set. */ public static String getNsPrefix(final Vertex ePackageVertex) { checkNotNull(ePackageVertex, "Precondition violation - argument 'ePackageVertex' must not be NULL!"); return (String) ePackageVertex.property(V_PROP__NS_PREFIX).orElse(null); }
/** * Returns the numeric Ecore ID of the {@linkplain EObject#eContainingFeature() eContainingFeature} on the EObject * represented by the given vertex. * * @param eObjectVertex The vertex representing the EObject where the eContainingFeatureID should be retrieved. Must not be * <code>null</code>. * @return The eContainingFeatureID (which may be negative according to the Ecore standard), or <code>null</code> if * no eContainingFeatureID is set. */ public static Integer getEContainingFeatureId(final Vertex eObjectVertex) { checkNotNull(eObjectVertex, "Precondition violation - argument 'eObjectVertex' must not be NULL!"); return (Integer) eObjectVertex.property(V_PROP__ECONTAININGFEATUREID).orElse(null); }
/** * Returns the XMI contents stored in the given {@link Vertex}. * <p> * <p> * Please note that this is intended exclusively for vertices that represent {@link EPackage}s. * * @param vertex The vertex to get the XMI data from. Must not be <code>null</code>. * @return The XMI data stored in the vertex, or <code>null</code> if the vertex contains no XMI data. */ public static String getXMIContents(final Vertex vertex) { checkNotNull(vertex, "Precondition violation - argument 'vertex' must not be NULL!"); return (String) vertex.property(V_PROP__XMI_CONTENTS).orElse(null); }
private <T> Optional<T> get(Vertex vertex, String key) { return Optional.ofNullable(vertex.property(key).orElse(null)).map(e -> (T) e); }
/** * Returns the {@linkplain VertexKind kind} of the vertex. * * @param vertex The vertex to check. Must not be <code>null</code>. * @return The vertex kind, or <code>null</code> if no kind is set. */ public static VertexKind getVertexKind(final Vertex vertex) { checkNotNull(vertex, "Precondition violation - argument 'vertex' must not be NULL!"); String vertexKind = (String) vertex.property(V_PROP__KIND).orElse(null); return VertexKind.fromString(vertexKind); }
@Override public <O> O valueOrNull(PropertyKey key) { return (O)property(key.name()).orElse(null); }
@Override public Traversal<Vertex, Vertex> get_g_V_filterXlang_eq_javaX() { return g.V().filter(v -> v.get().<String>property("lang").orElse("none").equals("java")); }
@Override public Traversal<Vertex, Vertex> get_g_VX1X_filterXage_gt_30X(final Object v1Id) { return g.V(v1Id).filter(v -> v.get().<Integer>property("age").orElse(0) > 30); }
@Override public Traversal<Vertex, Vertex> get_g_VX1X_out_filterXage_gt_30X(final Object v1Id) { return g.V(v1Id).out().filter(v -> v.get().<Integer>property("age").orElse(0) > 30); }