Class: Pacer::Neo4j::Graph

Inherits:
PacerGraph
  • Object
show all
Defined in:
lib/pacer-neo4j/graph.rb,
lib/pacer-neo4j/lucene_filter.rb

Constant Summary collapse

JDate =
java.util.Date

Instance Method Summary collapse

Instance Method Details

#allow_auto_txObject



22
23
24
# File 'lib/pacer-neo4j/graph.rb', line 22

def allow_auto_tx
  blueprints_graph.allow_auto_tx
end

#allow_auto_tx=(b) ⇒ Object



18
19
20
# File 'lib/pacer-neo4j/graph.rb', line 18

def allow_auto_tx=(b)
  blueprints_graph.allow_auto_tx = b
end

#before_commit(&block) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/pacer-neo4j/graph.rb', line 71

def before_commit(&block)
  return unless block
  TransactionEventHandler.new(self).tap do |h|
    h.before_commit = block
    neo_graph.registerTransactionEventHandler h
  end
end

#cypher(query) ⇒ Object



32
33
34
# File 'lib/pacer-neo4j/graph.rb', line 32

def cypher(query)
  [query].to_route(element_type: :string, graph: self).cypher
end

#drop_handler(h) ⇒ Object



79
80
81
# File 'lib/pacer-neo4j/graph.rb', line 79

def drop_handler(h)
  neo_graph.unregisterTransactionEventHandler h
end

#key_index_cache(type, name, size = :undefined) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/pacer-neo4j/graph.rb', line 36

def key_index_cache(type, name, size = :undefined)
  indexer = lucene_auto_index(type)
  if size == :undefined
    indexer.getCacheCapacity name
  else
    indexer.setCacheCapacity name, size
  end
end

#lucene(query, opts = {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/pacer-neo4j/lucene_filter.rb', line 4

def lucene(query, opts = {})
  opts = { back: self, element_type: :vertex }.merge opts
  chain_route(opts.merge(query: query,
                         filter: :lucene,
                         index: choose_index(opts)))
end

#neo_graphObject



45
46
47
# File 'lib/pacer-neo4j/graph.rb', line 45

def neo_graph
  blueprints_graph.raw_graph
end

#on_commit(&block) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/pacer-neo4j/graph.rb', line 49

def on_commit(&block)
  return unless block
  TransactionEventHandler.new(self).tap do |h|
    h.on_commit = block
    neo_graph.registerTransactionEventHandler h
  end
end

#on_commit_failed(&block) ⇒ Object

This is actually only called if the commit fails and then it internally tries to rollback. It seems that it’s actually possible for it to fail to rollback here, too…

An exception in before_commit can definitely trigger this.

Regular rollbacks do not get seen by the transaction system and no callback happens.



63
64
65
66
67
68
69
# File 'lib/pacer-neo4j/graph.rb', line 63

def on_commit_failed(&block)
  return unless block
  TransactionEventHandler.new(self).tap do |h|
    h.on_commit_failed = block
    neo_graph.registerTransactionEventHandler h
  end
end

#safe_transactionsObject



14
15
16
# File 'lib/pacer-neo4j/graph.rb', line 14

def safe_transactions
  blueprints_graph.getCheckElementsInTransaction
end

#safe_transactions=(b) ⇒ Object

I’m not sure exactly what this impacts but if it is false, many Pacer tests fail.

Presumably Neo4j is faster with it set to false.



10
11
12
# File 'lib/pacer-neo4j/graph.rb', line 10

def safe_transactions=(b)
  blueprints_graph.setCheckElementsInTransaction b
end

#transaction(*args, &block) ⇒ Object



26
27
28
29
30
# File 'lib/pacer-neo4j/graph.rb', line 26

def transaction(*args, &block)
  blueprints_graph.transaction do
    super
  end
end