Sha256: 40590f2e50e10265c81e254cce6e81519d435c2cf1738c5f5c694feca0322ab9
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module Cadet module BatchInserter class BatchInserter < Cadet::Session include_package "org.neo4j.unsafe.batchinsert" include_package "org.neo4j.index.impl.lucene" def initialize(db) @db = db #@index_provider = LuceneBatchInserterIndexProviderNewImpl.new(db) @index_provider = Cadet::IndexProvider.new(db) end def close @index_provider.shutdown super end def self.open(location) new BatchInserters.inserter(location) end def transaction yield end def constraint(label, property) index = @index_provider.nodeIndex label, {"type" => "exact"} index.setCacheCapacity property, 100000 end def find_node_by_label_and_property(label, property, value) index = @index_provider.nodeIndex label, {"type" => "exact"} result = org.neo4j.helpers.collection.IteratorUtil.firstOrNull(index.get(property, value)) if result return Cadet::BatchInserter::Node.new(@db, result) else return nil end end def create_node_with(label, props={}) n = Cadet::BatchInserter::Node.make @db, props, label index = @index_provider.nodeIndex label, {"type" => "exact"} index.add(n.node, props) n end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cadet-0.0.1-java | lib/cadet/batch_inserter/batch_inserter.rb |