Class: Cadet::BatchInserter::Session
- Inherits:
-
Session
- Object
- Session
- Cadet::BatchInserter::Session
show all
- Defined in:
- lib/cadet/batch_inserter/batch_inserter.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Session
#get_node, #method_missing
Constructor Details
#initialize(db) ⇒ Session
Returns a new instance of Session.
9
10
11
12
|
# File 'lib/cadet/batch_inserter/batch_inserter.rb', line 9
def initialize(db)
@db = db
@index_provider = Cadet::CadetIndex::IndexProvider.new(db)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Cadet::Session
Class Method Details
.open(location) ⇒ Object
19
20
21
|
# File 'lib/cadet/batch_inserter/batch_inserter.rb', line 19
def self.open(location)
new BatchInserters.inserter(location)
end
|
Instance Method Details
#close ⇒ Object
14
15
16
17
|
# File 'lib/cadet/batch_inserter/batch_inserter.rb', line 14
def close
@index_provider.shutdown
super
end
|
#constraint(label, property) ⇒ Object
27
28
29
|
# File 'lib/cadet/batch_inserter/batch_inserter.rb', line 27
def constraint(label, property)
index = @index_provider.nodeIndex label, {"type" => "exact"}
end
|
#create_node(label, property, value) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/cadet/batch_inserter/batch_inserter.rb', line 41
def create_node(label, property, value)
n = Node.new(@db.createNode({property => value}, DynamicLabel.label(label)), @db)
index = @index_provider.nodeIndex label, {"type" => "exact"}
index.add(n.underlying, property, value)
n
end
|
#find_node(label, property, value) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/cadet/batch_inserter/batch_inserter.rb', line 31
def find_node(label, property, value)
index = @index_provider.nodeIndex label, {"type" => "exact"}
result = IteratorUtil.firstOrNull(index.get(property, value))
if result
return Node.new(result, @db)
else
return nil
end
end
|
#transaction ⇒ Object
23
24
25
|
# File 'lib/cadet/batch_inserter/batch_inserter.rb', line 23
def transaction
yield
end
|