public Builder statusAttributeException(final Throwable ex) { statusAttribute(Tokens.STATUS_ATTRIBUTE_EXCEPTIONS, IteratorUtils.asList( IteratorUtils.map(ExceptionUtils.getThrowableList(ex), t -> t.getClass().getName()))); statusAttribute(Tokens.STATUS_ATTRIBUTE_STACK_TRACE, ExceptionUtils.getFullStackTrace(ex)); return this; }
public static VertexProgramStrategy create(final Configuration configuration) { try { final VertexProgramStrategy.Builder builder = VertexProgramStrategy.build(); for (final String key : (List<String>) IteratorUtils.asList(configuration.getKeys())) { if (key.equals(GRAPH_COMPUTER)) builder.graphComputer((Class) Class.forName(configuration.getString(key))); else if (key.equals(WORKERS)) builder.workers(configuration.getInt(key)); else if (key.equals(PERSIST)) builder.persist(GraphComputer.Persist.valueOf(configuration.getString(key))); else if (key.equals(RESULT)) builder.result(GraphComputer.ResultGraph.valueOf(configuration.getString(key))); else if (key.equals(VERTICES)) builder.vertices((Traversal) configuration.getProperty(key)); else if (key.equals(EDGES)) builder.edges((Traversal) configuration.getProperty(key)); else builder.configure(key, configuration.getProperty(key)); } return builder.create(); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES) public void shouldAppendPartitionToVertexPropertyOverMultiProperty() { final PartitionStrategy partitionStrategy = PartitionStrategy.build() .includeMetaProperties(true) .partitionKey(partition).writePartition("A").readPartitions("A").create(); final Vertex v = g.withStrategies(partitionStrategy).addV().property(VertexProperty.Cardinality.list, "any", "thing") .property(VertexProperty.Cardinality.list, "any", "more").next(); assertNotNull(v); assertThat((List<String>) IteratorUtils.asList(g.V(v).properties("any")).stream().map(p -> ((VertexProperty) p).value()).collect(Collectors.toList()), containsInAnyOrder("thing", "more")); assertEquals("A", v.property(partition).value()); assertThat((List<String>) IteratorUtils.asList(g.V(v).properties("any")).stream().map(p -> ((VertexProperty) p).value(partition)).collect(Collectors.toList()), containsInAnyOrder("A", "A")); }
final ResponseMessage responseMessage = ResponseMessage.build(UUID.randomUUID()) .code(ResponseStatusCode.SUCCESS) .result(IteratorUtils.asList(o)).create();
assertEquals("animal", vertex.label()); assertEquals(2, IteratorUtils.count(vertex.properties("name"))); List<String> names = IteratorUtils.asList(vertex.values("name")); assertEquals(2, names.size()); assertTrue(names.contains("an animal"));
@Test public void testQueryByPageResultsMatched() { Assume.assumeTrue("Not support paging", storeFeatures().supportsQueryByPage()); HugeGraph graph = graph(); init100Books(); List<Vertex> all = graph.traversal().V().toList(); GraphTraversal<Vertex, Vertex> itor; String page = ""; int size = 20; for (int i = 0; i < 100 / size; i++) { itor = graph.traversal().V() .has("~page", page).limit(size); List<?> vertexes = IteratorUtils.asList(itor); Assert.assertEquals(size, vertexes.size()); List<Vertex> expected = all.subList(i * size, (i + 1) * size); Assert.assertEquals(expected, vertexes); page = TraversalUtil.page(itor); } Assert.assertNull(page); }
@Test public void testQueryEdgeByPageResultsMatched() { Assume.assumeTrue("Not support paging", storeFeatures().supportsQueryByPage()); HugeGraph graph = graph(); init100LookEdges(); List<Edge> all = graph.traversal().E().toList(); GraphTraversal<Edge, Edge> itor; String page = ""; int size = 20; for (int i = 0; i < 100 / size; i++) { itor = graph.traversal().E() .has("~page", page).limit(size); List<?> vertexes = IteratorUtils.asList(itor); Assert.assertEquals(size, vertexes.size()); List<Edge> expected = all.subList(i * size, (i + 1) * size); Assert.assertEquals(expected, vertexes); page = TraversalUtil.page(itor); } Assert.assertNull(page); }
Assert.assertEquals(vertex1.id(), vertex2.id()); Assert.assertEquals(vertex1.label(), vertex2.label()); Assert.assertEquals(IteratorUtils.asList(vertex1.properties()), IteratorUtils.asList(vertex2.properties())); Assert.assertEquals(vertex3.id(), vertex4.id()); Assert.assertEquals(vertex3.label(), vertex4.label()); Assert.assertEquals(IteratorUtils.asList(vertex3.properties()), IteratorUtils.asList(vertex4.properties()));
Assert.assertEquals(edge1.id(), edge2.id()); Assert.assertEquals(edge1.label(), edge2.label()); Assert.assertEquals(IteratorUtils.asList(edge1.properties()), IteratorUtils.asList(edge2.properties())); Assert.assertEquals(edge3.id(), edge4.id()); Assert.assertEquals(edge3.label(), edge4.label()); Assert.assertEquals(IteratorUtils.asList(edge3.properties()), IteratorUtils.asList(edge4.properties()));
private List<MessageFromDestination> messageFromDestination(List<VertexMessage> messages) { return IteratorUtils.asList(Iterators.filter(messages.iterator(), e -> e instanceof MessageFromDestination)); }
private List<MessageFromSource> messageFromSource(List<VertexMessage> messages) { return IteratorUtils.asList(Iterators.filter(messages.iterator(), e -> e instanceof MessageFromSource)); }
private List<VertexMessage> messages(Messenger<VertexMessage> messenger) { return IteratorUtils.asList(messenger.receiveMessages()); }
public Iterator<Edge> edges(Direction direction, String[] edgeLabels, Predicates predicates) { EdgeQueryInfo queryInfo = new EdgeQueryInfo(direction, edgeLabels, predicates, elasticMutations.getRevision()); Set<Edge> edges = queriedEdges.get(queryInfo); if (edges != null) return edges.iterator(); List<BaseVertex> vertices = siblings == null ? IteratorUtils.asList(this) : siblings; Map<Object, Set<Edge>> vertexToEdge = graph.getQueryHandler().edges(vertices.iterator(), direction, edgeLabels, predicates); vertices.forEach( vertex -> vertex.addQueriedEdges(queryInfo, vertexToEdge.get(vertex.id()))); Set<Edge> thisEdges = vertexToEdge.get(this.id()); return thisEdges != null ? thisEdges.iterator() : Collections.emptyIterator(); }
public Builder statusAttributeException(final Throwable ex) { statusAttribute(Tokens.STATUS_ATTRIBUTE_EXCEPTIONS, IteratorUtils.asList( IteratorUtils.map(ExceptionUtils.getThrowableList(ex), t -> t.getClass().getName()))); statusAttribute(Tokens.STATUS_ATTRIBUTE_STACK_TRACE, ExceptionUtils.getFullStackTrace(ex)); return this; }
public static VertexProgramStrategy create(final Configuration configuration) { try { final VertexProgramStrategy.Builder builder = VertexProgramStrategy.build(); for (final String key : (List<String>) IteratorUtils.asList(configuration.getKeys())) { if (key.equals(GRAPH_COMPUTER)) builder.graphComputer((Class) Class.forName(configuration.getString(key))); else if (key.equals(WORKERS)) builder.workers(configuration.getInt(key)); else if (key.equals(PERSIST)) builder.persist(GraphComputer.Persist.valueOf(configuration.getString(key))); else if (key.equals(RESULT)) builder.result(GraphComputer.ResultGraph.valueOf(configuration.getString(key))); else if (key.equals(VERTICES)) builder.vertices((Traversal) configuration.getProperty(key)); else if (key.equals(EDGES)) builder.edges((Traversal) configuration.getProperty(key)); else builder.configure(key, configuration.getProperty(key)); } return builder.create(); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES) public void shouldAppendPartitionToVertexPropertyOverMultiProperty() { final PartitionStrategy partitionStrategy = PartitionStrategy.build() .includeMetaProperties(true) .partitionKey(partition).writePartition("A").readPartitions("A").create(); final Vertex v = g.withStrategies(partitionStrategy).addV().property(VertexProperty.Cardinality.list, "any", "thing") .property(VertexProperty.Cardinality.list, "any", "more").next(); assertNotNull(v); assertThat((List<String>) IteratorUtils.asList(g.V(v).properties("any")).stream().map(p -> ((VertexProperty) p).value()).collect(Collectors.toList()), containsInAnyOrder("thing", "more")); assertEquals("A", v.property(partition).value()); assertThat((List<String>) IteratorUtils.asList(g.V(v).properties("any")).stream().map(p -> ((VertexProperty) p).value(partition)).collect(Collectors.toList()), containsInAnyOrder("A", "A")); }
final ResponseMessage responseMessage = ResponseMessage.build(UUID.randomUUID()) .code(ResponseStatusCode.SUCCESS) .result(IteratorUtils.asList(o)).create();
assertEquals("animal", vertex.label()); assertEquals(2, IteratorUtils.count(vertex.properties("name"))); List<String> names = IteratorUtils.asList(vertex.values("name")); assertEquals(2, names.size()); assertTrue(names.contains("an animal"));