Module: Pacer
- Defined in:
- lib/pacer-neo4j.rb,
lib/pacer-neo4j/algo.rb,
lib/pacer-neo4j/graph.rb,
lib/pacer-neo4j/version.rb,
lib/pacer-neo4j/algo/wrapping.rb,
lib/pacer-neo4j/lucene_filter.rb,
lib/pacer-neo4j/algo/path_pipe.rb,
lib/pacer-neo4j/tx_data_wrapper.rb,
lib/pacer-neo4j/blueprints_graph.rb,
lib/pacer-neo4j/algo/path_wrapper.rb,
lib/pacer-neo4j/algo/cypher_transform.rb,
lib/pacer-neo4j/algo/block_path_expander.rb,
lib/pacer-neo4j/raw_vertex_wrapping_pipe.rb,
lib/pacer-neo4j/algo/block_cost_evaluator.rb,
lib/pacer-neo4j/transaction_event_handler.rb,
lib/pacer-neo4j/algo/block_estimate_evaluator.rb,
lib/pacer-neo4j/algo/traversal_branch_wrapper.rb
Defined Under Namespace
Modules: Core, Filter, Neo4j, Transform
Class Method Summary collapse
-
.neo4j(path_or_graph, args = nil) ⇒ Object
Return a graph for the given path.
- .neo_batch(path) ⇒ Object
Class Method Details
.neo4j(path_or_graph, args = nil) ⇒ Object
Return a graph for the given path. Will create a graph if none exists at that location. (The graph is only created if data is actually added to it).
If the graph is opened from a path, it will be registered to be closed by Ruby’s at_exit callback, but if an already open graph is given, it will not.
Please note that Pacer turns on Neo4j’s checkElementsInTransaction feature by default. For some sort of performance improvement at the expense of an odd consistency model within transactions that require considerable more complexity in client code, you can use ‘graph.setCheckElementsInTransaction(false)` to disable the feature.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/pacer-neo4j.rb', line 44 def neo4j(path_or_graph, args = nil) if path_or_graph.is_a? String path = File.(path_or_graph) open = proc do raw_graph = Pacer.open_graphs[path] if raw_graph graph = Pacer::Neo4j::BlueprintsGraph.new(raw_graph) else if args graph = Pacer::Neo4j::BlueprintsGraph.new(path, args.to_hash_map) else graph = Pacer::Neo4j::BlueprintsGraph.new(path) end graph.allow_auto_tx = false Pacer.open_graphs[path] = graph.raw_graph graph.setCheckElementsInTransaction true end graph end shutdown = proc do |g| g.blueprints_graph.shutdown Pacer.open_graphs.delete path end Neo4j::Graph.new(Pacer::YamlEncoder, open, shutdown) else # Don't register the new graph so that it won't be automatically closed. Neo4j::Graph.new Pacer::YamlEncoder, proc { Pacer::Neo4j::BlueprintsGraph.new(path_or_graph) } end end |
.neo_batch(path) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/pacer-neo4j.rb', line 74 def neo_batch(path) bp_neo_class = com.tinkerpop.blueprints.impls.neo4jbatch.Neo4jBatchGraph path = File.(path) open = proc do graph = bp_neo_class.new(path) Pacer.open_graphs[path] = :open_batch_graph graph end shutdown = proc do |g| g.blueprints_graph.shutdown Pacer.open_graphs.delete path end g = PacerGraph.new(Pacer::YamlEncoder, open, shutdown) g.disable_transactions = true g end |