Module: Pacer::Core::Graph::VerticesRoute
- Includes:
- ElementRoute
- Included in:
- DexVertex, Neo4jVertex, TinkerVertex, VertexWrapper
- Defined in:
- lib/pacer/core/graph/vertices_route.rb
Overview
Basic methods for routes that contain only vertices.
Instance Method Summary (collapse)
-
- (EdgesRoute?) add_edges_to(label, to_vertices, props = {})
Create associations with the given label from all vertices matching this route to all vertices matching the given to_route.
-
- (EdgesRoute) both_e(*filters) {|EdgeMixin(Extensions::BlockFilterElement)| ... }
Extends the route with all edges from this route's matching vertices.
-
- (Object) delete!
Delete all matching vertices and all edges which link to this vertex.
-
- (element_type(:vertex)) element_type
The element type of this route for this graph implementation.
-
- (EdgesRoute) in_e(*filters) {|EdgeMixin(Extensions::BlockFilterElement)| ... }
Extends the route with in edges from this route's matching vertices.
-
- (EdgesRoute) out_e(*filters) {|EdgeMixin(Extensions::BlockFilterElement)| ... }
Extends the route with out edges from this route's matching vertices.
-
- (VerticesRoute) v(*filters) {|VertexMixin(Extensions::BlockFilterElement)| ... }
Extend route with the additional vertex property and block filters.
Methods included from ElementRoute
#[], #build_index, #clone_into, #copy_into, #e, #element_ids, #filter, #properties, #property?, #result, #subgraph
Instance Method Details
- (EdgesRoute?) add_edges_to(label, to_vertices, props = {})
Create associations with the given label from all vertices matching this route to all vertices matching the given to_route. If any properties are given, they will be applied to each created edge.
If this route emits more than one element and the to_vertices param also emits (or contains) more than one element, the resulting edges will represent a cross-product between the two collections.
If a vertex appears in either the this route or in to_vertices, it will be linked once for each time it appears.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/pacer/core/graph/vertices_route.rb', line 91 def add_edges_to(label, to_vertices, props = {}) case to_vertices when Pacer::Core::Route, Enumerable, java.util.Iterator else to_vertices = [to_vertices].compact end graph = self.graph # NOTE: this originally gave me a lot of problems but I think the issues # that caused routes to sometimes not have graphs are fixed. If the error # comes back, uncomment the fix below. Hopefully this can be removed # soon. (dw 2011-03-19) #unless graph # v = (detect { |v| v.graph } || to_vertices.detect { |v| v.graph }) # graph = v.graph if v # unless graph # Pacer.debug_info << { :error => 'No graph found', :from => self, :to => to_vertices, :graph => graph } # raise "No graph found" # end #end has_props = !props.empty? first_edge_id = last_edge_id = nil counter = 0 graph.managed_transactions do graph.managed_transaction do each do |from_v| to_vertices.each do |to_v| counter += 1 graph.managed_checkpoint if counter % graph.bulk_job_size == 0 begin edge = graph.create_edge(nil, from_v, to_v, label.to_s, props) first_edge_id ||= edge.element_id last_edge_id = edge.element_id end end end end end if first_edge_id (first_edge_id..last_edge_id).id_to_element_route(:based_on => graph.e) end end |
- (EdgesRoute) both_e(*filters) {|EdgeMixin(Extensions::BlockFilterElement)| ... }
Extends the route with all edges from this route's matching vertices.
38 39 40 41 42 43 44 |
# File 'lib/pacer/core/graph/vertices_route.rb', line 38 def both_e(*filters, &block) Pacer::Route.property_filter(chain_route(:element_type => :edge, :pipe_class => Pacer::Pipes::VertexEdgePipe, :pipe_args => Pacer::Pipes::VertexEdgePipe::Step::BOTH_EDGES, :route_name => 'bothE'), filters, block) end |
- (Object) delete!
Delete all matching vertices and all edges which link to this vertex.
65 66 67 68 |
# File 'lib/pacer/core/graph/vertices_route.rb', line 65 def delete! uniq.both_e.uniq.bulk_job { |e| e.delete! } uniq.bulk_job { |e| e.delete! } end |
- (element_type(:vertex)) element_type
The element type of this route for this graph implementation.
which graph is in use.
59 60 61 |
# File 'lib/pacer/core/graph/vertices_route.rb', line 59 def element_type graph.element_type(:vertex) end |
- (EdgesRoute) in_e(*filters) {|EdgeMixin(Extensions::BlockFilterElement)| ... }
Extends the route with in edges from this route's matching vertices.
25 26 27 28 29 30 31 |
# File 'lib/pacer/core/graph/vertices_route.rb', line 25 def in_e(*filters, &block) Pacer::Route.property_filter(chain_route(:element_type => :edge, :pipe_class => Pacer::Pipes::VertexEdgePipe, :pipe_args => Pacer::Pipes::VertexEdgePipe::Step::IN_EDGES, :route_name => 'inE'), filters, block) end |
- (EdgesRoute) out_e(*filters) {|EdgeMixin(Extensions::BlockFilterElement)| ... }
Extends the route with out edges from this route's matching vertices.
12 13 14 15 16 17 18 |
# File 'lib/pacer/core/graph/vertices_route.rb', line 12 def out_e(*filters, &block) Pacer::Route.property_filter(chain_route(:element_type => :edge, :pipe_class => Pacer::Pipes::VertexEdgePipe, :pipe_args => Pacer::Pipes::VertexEdgePipe::Step::OUT_EDGES, :route_name => 'outE'), filters, block) end |
- (VerticesRoute) v(*filters) {|VertexMixin(Extensions::BlockFilterElement)| ... }
Extend route with the additional vertex property and block filters.
51 52 53 |
# File 'lib/pacer/core/graph/vertices_route.rb', line 51 def v(*filters, &block) filter(*filters, &block) end |