/** * Get a list of all Configurations, excluding the template configuration; if none exist, * return an empty list * * @return List<Map<String, Object>> */ public List<Map<String, Object>> getConfigurations() { final List<Map<String, Object>> graphConfigurations = graph.traversal().V().has(PROPERTY_TEMPLATE, false).valueMap().toList(); return graphConfigurations.stream().map(this::deserializeVertexProperties).collect(Collectors.toList()); }
/** * Get template configuration if exists, else return null. * * @return Map<String, Object> */ public Map<String, Object> getTemplateConfiguration() { final List<Map<String, Object>> templateConfigurations = graph.traversal().V().has(PROPERTY_TEMPLATE, true).valueMap().toList(); if (templateConfigurations.size() == 0) return null; if (templateConfigurations.size() > 1) { log.warn("Your configuration management graph is an a bad state. Please " + "ensure you have just one template configuration. The behavior " + "of the class' APIs are henceforth unpredictable until this is fixed."); } templateConfigurations.get(0).remove(PROPERTY_TEMPLATE); return deserializeVertexProperties(templateConfigurations.get(0)); }
/** * Get Configuration according to supplied graphName mapped to a specific * {@link Graph}; if does not exist, return null. * * @return Map<String, Object> */ public Map<String, Object> getConfiguration(final String configName) { final List<Map<String, Object>> graphConfiguration = graph.traversal().V().has(PROPERTY_GRAPH_NAME, configName).valueMap().toList(); if (graphConfiguration.isEmpty()) return null; else if (graphConfiguration.size() > 1) { // this case shouldn't happen because our index has a unique constraint log.warn("Your configuration management graph is an a bad state. Please " + "ensure you have just one configuration per graph. The behavior " + "of the class' APIs are henceforth unpredictable until this is fixed."); } return deserializeVertexProperties(graphConfiguration.get(0)); }
@Test public void testReadWideVertexWithManyProperties() { int numProps = 1 << 16; long numV = 1; mgmt.makePropertyKey("p").cardinality(Cardinality.LIST).dataType(Integer.class).make(); mgmt.commit(); finishSchema(); for (int j = 0; j < numV; j++) { Vertex v = graph.addVertex(); for (int i = 0; i < numProps; i++) { v.property("p", i); } } graph.tx().commit(); assertEquals(numV, (long) graph.traversal().V().count().next()); Map<String, Object> propertiesOnVertex = graph.traversal().V().valueMap().next(); List<?> valuesOnP = (List)propertiesOnVertex.values().iterator().next(); assertEquals(numProps, valuesOnP.size()); Graph g = GraphFactory.open("target/test-classes/cassandra-read.properties"); GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class)); assertEquals(numV, (long) t.V().count().next()); propertiesOnVertex = t.V().valueMap().next(); valuesOnP = (List)propertiesOnVertex.values().iterator().next(); assertEquals(numProps, valuesOnP.size()); }
/** * @see GraphTraversal#valueMap(boolean, String...) * @deprecated As of release 3.4.0, deprecated in favor of {@link __#valueMap(String...)} in conjunction with * {@link GraphTraversal#with(String, Object)}. */ @Deprecated public static <A extends Element, B> GraphTraversal<A, Map<Object, B>> valueMap(final boolean includeTokens, final String... propertyKeys) { return __.<A>start().valueMap(includeTokens, propertyKeys); }
/** * @see GraphTraversal#valueMap(String...) */ public static <A extends Element, B> GraphTraversal<A, Map<Object, B>> valueMap(final String... propertyKeys) { return __.<A>start().valueMap(propertyKeys); }
@Override public Traversal<Vertex, Map<Object, Object>> get_g_V_valueMapXtrueX() { return g.V().valueMap(true); }
@Override public Traversal<Vertex, Map<Object, List>> get_g_V_valueMap() { return g.V().valueMap(); }
@Override public Traversal<Vertex, Map<Object, List>> get_g_V_valueMapXname_ageX() { return g.V().valueMap("name", "age"); }
@Override public Traversal<Vertex, Object> get_g_V_valueMap_selectXaX() { return g.V().valueMap().select("a"); }
@Override public Traversal<Vertex, Object> get_g_V_valueMap_selectXlast_aX() { return g.V().valueMap().select(Pop.last, "a"); }
@Override public Traversal<Vertex, Map<String, Object>> get_g_V_valueMap_selectXall_a_bX() { return g.V().valueMap().select(Pop.all, "a", "b"); }
@Override public Traversal<Vertex, String> get_g_V_valueMap_unfold_mapXkeyX() { return g.V().valueMap().<Map.Entry<String, List>>unfold().map(m -> m.get().getKey()); }
@Override public Traversal<Vertex, Map<Object, Object>> get_g_V_valueMapXname_ageX_withXtokens_labelsX_byXunfoldX() { return g.V().valueMap("name", "age").with(WithOptions.tokens, WithOptions.labels).by(__.unfold()); }
@Override public Traversal<Vertex, Double> get_g_V_hasXageX_valueMap_mathXit_plus_itXbyXselectXageX_unfoldXX() { // https://issues.apache.org/jira/browse/TINKERPOP-1979 - should work in OLAP return g.V().has("age").valueMap().math("_+_").by(select("age").unfold()); }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldHidePartitionKeyForValueMapWithEmptyKeys() { final GraphTraversalSource gOverA = g.withStrategies(PartitionStrategy.build() .includeMetaProperties(true) .partitionKey(partition).writePartition("A").readPartitions("A").create()); final Vertex v = gOverA.addV().property("any", "thing").next(); assertEquals(1L, (long) gOverA.V(v).valueMap().count().next()); assertEquals("thing", ((List) gOverA.V(v).valueMap().next().get("any")).get(0)); }
@Override public Traversal<Vertex, Map<Object, List<Object>>> get_g_V_hasLabelXpersonX_programXpageRank_rankX_order_byXrank_ascX_valueMapXname_rankX() { return g.V().hasLabel("person").program(PageRankVertexProgram.build().property("rank").create(graph)).order().by("rank", Order.asc).valueMap("name", "rank"); }
@Override public Traversal<Vertex, Map<Object, Object>> get_g_V_asXaX_hasXname_markoX_outXcreatedX_asXbX_addVXselectXaX_labelX_propertyXtest_selectXbX_labelX_valueMap_withXtokensX() { return g.V().as("a").has("name", "marko").out("created").as("b").addV(select("a").label()).property("test", select("b").label()).valueMap().with(WithOptions.tokens); } }
@Override public Traversal<Vertex, Map<Object, List<Object>>> get_g_V_hasXname_rippleX_inXcreatedX_peerPressure_withXedges_outEX_withXpropertyName_clusterX_repeatXunionXidentity__bothX_timesX2X_dedup_valueMapXname_clusterX() { return g.V().has("name", "ripple").in("created").peerPressure().with(PeerPressure.edges,__.outE()).with(PeerPressure.propertyName, "cluster").repeat(__.union(__.identity(), __.both())).times(2).dedup().valueMap("name", "cluster"); } }
@Override public Traversal<Vertex, Map<Object, List<Object>>> get_g_V_hasXname_rippleX_inXcreatedX_peerPressure_byXoutEX_byXclusterX_repeatXunionXidentity__bothX_timesX2X_dedup_valueMapXname_clusterX() { return g.V().has("name", "ripple").in("created").peerPressure().by(__.outE()).by("cluster").repeat(__.union(__.identity(), __.both())).times(2).dedup().valueMap("name", "cluster"); }