Module: Pacer
- Defined in:
- lib/pacer-neo4j2.rb,
lib/pacer-neo4j2/algo.rb,
lib/pacer-neo4j2/graph.rb,
lib/pacer-neo4j2/version.rb,
lib/pacer-neo4j2/algo/wrapping.rb,
lib/pacer-neo4j2/lucene_filter.rb,
lib/pacer-neo4j2/algo/path_pipe.rb,
lib/pacer-neo4j2/tx_data_wrapper.rb,
lib/pacer-neo4j2/blueprints_graph.rb,
lib/pacer-neo4j2/algo/path_wrapper.rb,
lib/pacer-neo4j2/algo/cypher_transform.rb,
lib/pacer-neo4j2/algo/block_path_expander.rb,
lib/pacer-neo4j2/raw_vertex_wrapping_pipe.rb,
lib/pacer-neo4j2/algo/block_cost_evaluator.rb,
lib/pacer-neo4j2/transaction_event_handler.rb,
lib/pacer-neo4j2/algo/block_estimate_evaluator.rb,
lib/pacer-neo4j2/algo/traversal_branch_wrapper.rb
Defined Under Namespace
Modules: Core, Filter, Neo4j2, Transform
Class Method Summary collapse
- .neo2_batch(path) ⇒ Object
-
.neo4j2(path_or_graph, args = nil, graph_class = Pacer::Neo4j2::BlueprintsGraph) ⇒ Object
Return a graph for the given path.
Class Method Details
.neo2_batch(path) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/pacer-neo4j2.rb', line 84 def neo2_batch(path) bp_neo_class = com.tinkerpop.blueprints.impls.neo4jbatch.Neo4j2BatchGraph 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 |
.neo4j2(path_or_graph, args = nil, graph_class = Pacer::Neo4j2::BlueprintsGraph) ⇒ 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.
It is recommended that *in production* the ‘allow_auto_tx` option be set to `false` to prevent hard-to-debug errors caused by Blueprints’ automatically starting transactions which it never automatically commits or rolls back. You can also set ‘allow_auto_read_tx` in the same way. When working in the console, enabling automatic read transactons is generally recommended, together with periodic use of `rollback_implicit_transaction`
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/pacer-neo4j2.rb', line 53 def neo4j2(path_or_graph, args = nil, graph_class = Pacer::Neo4j2::BlueprintsGraph) 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 = graph_class.new(raw_graph) else if args graph = graph_class.new(path, args.to_hash_map) else graph = graph_class.new(path) end graph.allow_auto_tx = false graph.allow_auto_read_tx = true 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 Neo4j2::Graph.new(Pacer::YamlEncoder, open, shutdown) else # Don't register the new graph so that it won't be automatically closed. Neo4j2::Graph.new Pacer::YamlEncoder, proc { graph_class.new(path_or_graph) } end end |