Module: Pacer::Core::Graph::VerticesRoute

Defined in:
lib/pacer-neo4j2/algo/cypher_transform.rb

Instance Method Summary collapse

Instance Method Details

#cypher(query, elements_per_query = nil) ⇒ Object



24
25
26
# File 'lib/pacer-neo4j2/algo/cypher_transform.rb', line 24

def cypher(query, elements_per_query = nil)
  raw_cypher(query, elements_per_query).paths
end

#raw_cypher(query, elements_per_query = nil) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/pacer-neo4j2/algo/cypher_transform.rb', line 15

def raw_cypher(query, elements_per_query = nil)
  reducer(element_type: :array).
    enter { Set[] }.
    leave { |x, a| x.nil? or (elements_per_query and a.length % elements_per_query == 0) }.
    reduce { |v, ids| ids << v.element_id }.
  map(element_type: :string) { |a| "start v=node(#{a.to_a.join(',')}) #{ query }"}.
    raw_cypher
end