neo4j 1.0.0.beta.27-java → 1.0.0.beta.28-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTORS +1 -0
- data/lib/neo4j.rb +38 -72
- data/lib/neo4j/{algo.rb → algo/algo.rb} +5 -1
- data/lib/neo4j/batch/batch.rb +2 -0
- data/lib/neo4j/batch/indexer.rb +108 -0
- data/lib/neo4j/batch/inserter.rb +168 -0
- data/lib/neo4j/database.rb +13 -8
- data/lib/neo4j/{mapping/class_methods/list.rb → has_list/class_methods.rb} +2 -4
- data/lib/neo4j/has_list/has_list.rb +3 -0
- data/lib/neo4j/{mapping/has_list.rb → has_list/mapping.rb} +2 -2
- data/lib/neo4j/{mapping/class_methods/relationship.rb → has_n/class_methods.rb} +42 -12
- data/lib/neo4j/has_n/decl_relationship_dsl.rb +216 -0
- data/lib/neo4j/has_n/has_n.rb +3 -0
- data/lib/neo4j/{mapping/has_n.rb → has_n/mapping.rb} +16 -7
- data/lib/neo4j/index/index.rb +5 -0
- data/lib/neo4j/index/indexer.rb +27 -22
- data/lib/neo4j/index/lucene_query.rb +3 -1
- data/lib/neo4j/jars/core/neo4j-graph-algo-0.8-1.3.M01.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-index-1.3-1.3.M01.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-kernel-1.3-1.3.M01.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-lucene-index-0.5-1.3.M01.jar +0 -0
- data/lib/neo4j/jars/ha/{neo4j-ha-0.6-SNAPSHOT.jar → neo4j-ha-0.6-1.3.M01.jar} +0 -0
- data/lib/neo4j/jars/ha/neo4j-management-1.3-1.3.M01.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-shell-1.3-1.3.M01.jar +0 -0
- data/lib/neo4j/migrations/class_methods.rb +102 -0
- data/lib/neo4j/migrations/extensions.rb +10 -9
- data/lib/neo4j/migrations/lazy_node_mixin.rb +50 -0
- data/lib/neo4j/migrations/migration.rb +84 -81
- data/lib/neo4j/migrations/migrations.rb +6 -100
- data/lib/neo4j/migrations/node_mixin.rb +80 -0
- data/lib/neo4j/migrations/ref_node_wrapper.rb +32 -0
- data/lib/neo4j/neo4j.rb +11 -0
- data/lib/neo4j/node.rb +55 -25
- data/lib/neo4j/{mapping/class_methods/init_node.rb → node_mixin/class_methods.rb} +3 -3
- data/lib/neo4j/{mapping → node_mixin}/node_mixin.rb +35 -18
- data/lib/neo4j/{mapping/class_methods/property.rb → property/class_methods.rb} +5 -4
- data/lib/neo4j/{property.rb → property/property.rb} +2 -0
- data/lib/neo4j/rails/finders.rb +21 -7
- data/lib/neo4j/rails/rails.rb +19 -0
- data/lib/neo4j/rails/timestamps.rb +1 -1
- data/lib/neo4j/relationship.rb +7 -0
- data/lib/neo4j/{mapping/class_methods/init_rel.rb → relationship_mixin/class_methods.rb} +4 -4
- data/lib/neo4j/{mapping → relationship_mixin}/relationship_mixin.rb +23 -5
- data/lib/neo4j/rels/rels.rb +85 -0
- data/lib/neo4j/rels/traverser.rb +102 -0
- data/lib/neo4j/{mapping/class_methods/rule.rb → rule/class_methods.rb} +11 -11
- data/lib/neo4j/rule/functions/count.rb +37 -0
- data/lib/neo4j/rule/functions/function.rb +74 -0
- data/lib/neo4j/rule/functions/functions.rb +3 -0
- data/lib/neo4j/rule/functions/sum.rb +29 -0
- data/lib/neo4j/rule/rule.rb +5 -0
- data/lib/neo4j/rule/rule_event_listener.rb +162 -0
- data/lib/neo4j/rule/rule_node.rb +182 -0
- data/lib/neo4j/to_java.rb +0 -14
- data/lib/neo4j/traversal/filter_predicate.rb +25 -0
- data/lib/neo4j/traversal/prune_evaluator.rb +14 -0
- data/lib/neo4j/traversal/rel_expander.rb +31 -0
- data/lib/neo4j/traversal/traversal.rb +90 -0
- data/lib/neo4j/traversal/traverser.rb +173 -0
- data/lib/neo4j/{type_converters.rb → type_converters/type_converters.rb} +0 -0
- data/lib/neo4j/version.rb +1 -1
- data/lib/test.rb~ +2 -0
- data/neo4j.gemspec +11 -10
- metadata +48 -37
- data/lib/neo4j/functions/count.rb +0 -33
- data/lib/neo4j/functions/function.rb +0 -72
- data/lib/neo4j/functions/sum.rb +0 -27
- data/lib/neo4j/jars/core/neo4j-graph-algo-0.8-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-index-1.3-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-kernel-1.3-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-lucene-index-0.5-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-management-1.3-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-shell-1.3-SNAPSHOT.jar +0 -0
- data/lib/neo4j/mapping/decl_relationship_dsl.rb +0 -214
- data/lib/neo4j/mapping/rule.rb +0 -158
- data/lib/neo4j/mapping/rule_node.rb +0 -176
- data/lib/neo4j/migrations.rb +0 -12
- data/lib/neo4j/migrations/global_migration.rb +0 -29
- data/lib/neo4j/migrations/lazy_migration_mixin.rb +0 -47
- data/lib/neo4j/migrations/migration_mixin.rb +0 -78
- data/lib/neo4j/node_mixin.rb +0 -4
- data/lib/neo4j/node_relationship.rb +0 -161
- data/lib/neo4j/node_traverser.rb +0 -224
- data/lib/neo4j/relationship_mixin.rb +0 -4
- data/lib/neo4j/relationship_traverser.rb +0 -92
data/CONTRIBUTORS
CHANGED
data/lib/neo4j.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
include Java
|
2
|
-
|
3
1
|
require 'enumerator'
|
4
2
|
require 'forwardable'
|
5
3
|
require 'time'
|
@@ -15,23 +13,22 @@ require 'will_paginate/finders/base'
|
|
15
13
|
|
16
14
|
require 'neo4j/jars/core/geronimo-jta_1.1_spec-1.1.1.jar'
|
17
15
|
require 'neo4j/jars/core/lucene-core-3.0.3.jar'
|
18
|
-
require 'neo4j/jars/core/neo4j-lucene-index-0.5-
|
19
|
-
require 'neo4j/jars/core/neo4j-
|
20
|
-
require 'neo4j/jars/core/neo4j-kernel-1.3-SNAPSHOT.jar'
|
16
|
+
require 'neo4j/jars/core/neo4j-lucene-index-0.5-1.3.M01.jar'
|
17
|
+
require 'neo4j/jars/core/neo4j-kernel-1.3-1.3.M01.jar'
|
21
18
|
|
22
19
|
module Neo4j
|
23
20
|
|
24
21
|
def self.load_local_jars
|
25
22
|
# This is a temporary fix since the HA does not yet work with this JAR
|
26
23
|
# It will be solved in a future version of the Java Neo4j library.
|
27
|
-
require 'neo4j/jars/core/neo4j-index-1.3-
|
24
|
+
require 'neo4j/jars/core/neo4j-index-1.3-1.3.M01.jar'
|
28
25
|
end
|
29
26
|
|
30
27
|
def self.load_ha_jars
|
31
28
|
require 'neo4j/jars/ha/log4j-1.2.16.jar'
|
32
|
-
require 'neo4j/jars/ha/neo4j-ha-0.6-
|
33
|
-
require 'neo4j/jars/ha/neo4j-management-1.3-
|
34
|
-
require 'neo4j/jars/ha/neo4j-shell-1.3-
|
29
|
+
require 'neo4j/jars/ha/neo4j-ha-0.6-1.3.M01.jar'
|
30
|
+
require 'neo4j/jars/ha/neo4j-management-1.3-1.3.M01.jar'
|
31
|
+
require 'neo4j/jars/ha/neo4j-shell-1.3-1.3.M01.jar'
|
35
32
|
require 'neo4j/jars/ha/netty-3.2.1.Final.jar'
|
36
33
|
require 'neo4j/jars/ha/org.apache.servicemix.bundles.jline-0.9.94_1.jar'
|
37
34
|
require 'neo4j/jars/ha/org.apache.servicemix.bundles.lucene-3.0.1_2.jar'
|
@@ -39,77 +36,46 @@ module Neo4j
|
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
module Neo4j
|
40
|
+
include Java
|
41
|
+
|
42
|
+
# Enumerator has been moved to top level in Ruby 1.9.2, make it compatible with Ruby 1.8.7
|
43
|
+
Enumerator = Enumerable::Enumerator unless defined? Enumerator
|
44
|
+
end
|
45
45
|
|
46
|
-
require 'neo4j/
|
47
|
-
require 'neo4j/type_converters'
|
48
|
-
require 'neo4j/config'
|
49
|
-
require 'neo4j/database'
|
46
|
+
require 'neo4j/version'
|
50
47
|
require 'neo4j/neo4j'
|
48
|
+
require 'neo4j/node'
|
49
|
+
require 'neo4j/relationship'
|
51
50
|
|
52
|
-
require
|
53
|
-
require "neo4j/functions/count"
|
54
|
-
require "neo4j/functions/sum"
|
51
|
+
require 'neo4j/type_converters/type_converters'
|
55
52
|
|
53
|
+
require 'neo4j/index/index'
|
56
54
|
|
55
|
+
require 'neo4j/traversal/traversal'
|
57
56
|
|
58
|
-
require 'neo4j/
|
59
|
-
|
60
|
-
require 'neo4j/
|
61
|
-
|
62
|
-
require 'neo4j/
|
63
|
-
|
64
|
-
require 'neo4j/
|
65
|
-
|
66
|
-
require 'neo4j/
|
67
|
-
|
68
|
-
require 'neo4j/
|
69
|
-
|
70
|
-
require 'neo4j/
|
71
|
-
require 'neo4j/mapping/class_methods/init_node'
|
72
|
-
require 'neo4j/mapping/class_methods/init_rel'
|
73
|
-
require 'neo4j/mapping/class_methods/property'
|
74
|
-
require 'neo4j/mapping/class_methods/relationship'
|
75
|
-
require 'neo4j/mapping/class_methods/list'
|
76
|
-
require 'neo4j/mapping/decl_relationship_dsl'
|
77
|
-
require 'neo4j/mapping/has_n'
|
78
|
-
require 'neo4j/mapping/has_list'
|
79
|
-
require 'neo4j/mapping/node_mixin'
|
80
|
-
require 'neo4j/mapping/relationship_mixin'
|
81
|
-
require 'neo4j/mapping/rule'
|
82
|
-
require 'neo4j/mapping/rule_node'
|
83
|
-
|
84
|
-
require 'neo4j/node_mixin'
|
85
|
-
require 'neo4j/relationship_mixin'
|
86
|
-
require 'neo4j/mapping/class_methods/rule'
|
87
|
-
require 'neo4j/algo'
|
88
|
-
require 'neo4j/migrations'
|
89
|
-
|
90
|
-
# rails
|
91
|
-
require 'neo4j/rails/tx_methods'
|
92
|
-
require 'neo4j/rails/transaction'
|
93
|
-
require 'neo4j/rails/railtie'
|
94
|
-
require 'neo4j/rails/validations/uniqueness'
|
95
|
-
require 'neo4j/rails/validations/non_nil'
|
96
|
-
require 'neo4j/rails/finders'
|
97
|
-
require 'neo4j/rails/mapping/property'
|
98
|
-
require 'neo4j/rails/validations'
|
99
|
-
require 'neo4j/rails/callbacks'
|
100
|
-
require 'neo4j/rails/timestamps'
|
101
|
-
require 'neo4j/rails/serialization'
|
102
|
-
require 'neo4j/rails/attributes'
|
103
|
-
require 'neo4j/rails/persistence'
|
104
|
-
require 'neo4j/rails/relationships/mapper'
|
105
|
-
require 'neo4j/rails/relationships/relationship'
|
106
|
-
require 'neo4j/rails/relationships/relationships'
|
107
|
-
require 'neo4j/rails/model'
|
108
|
-
require 'neo4j/rails/lucene_connection_closer'
|
57
|
+
require 'neo4j/property/property'
|
58
|
+
|
59
|
+
require 'neo4j/has_n/has_n'
|
60
|
+
|
61
|
+
require 'neo4j/node_mixin/node_mixin'
|
62
|
+
|
63
|
+
require 'neo4j/relationship_mixin/relationship_mixin'
|
64
|
+
|
65
|
+
require 'neo4j/rule/rule'
|
66
|
+
|
67
|
+
require 'neo4j/rels/rels'
|
68
|
+
|
69
|
+
require 'neo4j/rails/rails'
|
109
70
|
|
110
71
|
require 'neo4j/model'
|
72
|
+
|
73
|
+
require 'neo4j/migrations/migrations'
|
74
|
+
|
75
|
+
require 'neo4j/algo/algo'
|
76
|
+
|
77
|
+
require 'neo4j/batch/batch'
|
78
|
+
|
111
79
|
require 'orm_adapter/adapters/neo4j'
|
112
80
|
|
113
|
-
# hmm, looks like Enumerator have been moved in some ruby versions
|
114
|
-
Enumerator = Enumerable::Enumerator unless defined? Enumerator
|
115
81
|
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# external neo4j dependencies
|
2
|
+
require 'neo4j/to_java'
|
3
|
+
require 'neo4j/jars/core/neo4j-graph-algo-0.8-1.3.M01.jar'
|
4
|
+
|
1
5
|
module Neo4j
|
2
6
|
|
3
7
|
|
@@ -104,7 +108,7 @@ module Neo4j
|
|
104
108
|
# ==== Parameters
|
105
109
|
# * expander_proc :: a proc relationship type (symbol)
|
106
110
|
def expand(&expander_proc)
|
107
|
-
@expander = (RelExpander.create_pair(&expander_proc))
|
111
|
+
@expander = (Neo4j::Traversal::RelExpander.create_pair(&expander_proc))
|
108
112
|
self
|
109
113
|
end
|
110
114
|
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module Batch
|
3
|
+
class Indexer
|
4
|
+
|
5
|
+
delegate :field_types, :entity_type, :indexer_for, :indexed_value_for, :lucene_config, :via_relationships, :to => :@wrapped_indexer
|
6
|
+
|
7
|
+
def initialize(wrapped_indexer)
|
8
|
+
@wrapped_indexer = wrapped_indexer
|
9
|
+
@parent_indexers = wrapped_indexer.parent_indexers.collect{|i| Indexer.new(i)}
|
10
|
+
end
|
11
|
+
|
12
|
+
def indexer_for_field(field, rel_type)
|
13
|
+
dsl = via_relationships[field]
|
14
|
+
return nil if dsl.nil?
|
15
|
+
return nil if dsl.rel_type != rel_type
|
16
|
+
|
17
|
+
target_class = dsl.target_class
|
18
|
+
self.class.instance_for(target_class)
|
19
|
+
end
|
20
|
+
|
21
|
+
def index_node_via_rel(rel_type, other, node_props) #:nodoc:
|
22
|
+
return if node_props.empty? || via_relationships.empty?
|
23
|
+
props_copy = node_props.clone
|
24
|
+
|
25
|
+
while !props_copy.empty?
|
26
|
+
indexer = indexer_for_field(props_copy.keys.first, rel_type)
|
27
|
+
|
28
|
+
# put all other fields that are not of this index type in a new hash
|
29
|
+
other_index = {}
|
30
|
+
# delete all fields that are not of this index
|
31
|
+
props_copy.delete_if { |k, v| indexer != indexer_for_field(k, rel_type) && other_index[k] = v }
|
32
|
+
# add all those properties for this index
|
33
|
+
indexer && indexer.index_entity(other, props_copy)
|
34
|
+
|
35
|
+
# continue with the remaining fields
|
36
|
+
props_copy = other_index
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def index_entity(entity_id, props)
|
41
|
+
filter_props = props.keys.inject({}) { |memo, field| memo[field] = indexed_value_for(field, props[field]) if field_types.has_key?(field); memo }
|
42
|
+
|
43
|
+
while !filter_props.empty?
|
44
|
+
# pick one index type
|
45
|
+
index = batch_index_for_field(filter_props.keys[0])
|
46
|
+
# put all other fields that are not of this index type in a new hash
|
47
|
+
other_index = {}
|
48
|
+
# delete all fields that are not of this index
|
49
|
+
filter_props.delete_if { |k, v| index != batch_index_for_field(k) && other_index[k] = v }
|
50
|
+
# add all those properties for this index
|
51
|
+
index.add(entity_id, filter_props)
|
52
|
+
# continue with the remaining fields
|
53
|
+
filter_props = other_index
|
54
|
+
end
|
55
|
+
|
56
|
+
@parent_indexers.each { |i| i.index_entity(entity_id, props) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def index_flush
|
60
|
+
return nil if @batch_indexes.nil?
|
61
|
+
@batch_indexes.values.each {|index| index.flush}
|
62
|
+
end
|
63
|
+
|
64
|
+
def index_get(key, value, index_type)
|
65
|
+
index = @batch_indexes && @batch_indexes[index_type]
|
66
|
+
return nil if index.nil?
|
67
|
+
index.get(key,value)
|
68
|
+
end
|
69
|
+
|
70
|
+
def index_query(query, index_type)
|
71
|
+
index = @batch_indexes && @batch_indexes[index_type]
|
72
|
+
return nil if index.nil?
|
73
|
+
index.query(query)
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
def batch_index_for_field(field)
|
78
|
+
type = field_types[field]
|
79
|
+
@batch_indexes ||= {}
|
80
|
+
@batch_indexes[type] ||= create_batch_index_with(type)
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_batch_index_with(type)
|
84
|
+
index_config = lucene_config(type)
|
85
|
+
|
86
|
+
if entity_type == :node
|
87
|
+
self.class.index_provider.node_index("#{indexer_for}-#{type}", index_config)
|
88
|
+
else
|
89
|
+
self.class.index_provider.relationship_index("#{indexer_for}-#{type}", index_config)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class << self
|
94
|
+
attr_accessor :index_provider
|
95
|
+
|
96
|
+
def instance_for(clazz)
|
97
|
+
@instances ||= {}
|
98
|
+
@instances[clazz.to_s] ||= Indexer.new(clazz._indexer)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Mostly for testing
|
102
|
+
def clear_all_instances
|
103
|
+
@instances = nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module Batch
|
3
|
+
|
4
|
+
# = Batch Insert
|
5
|
+
# Neo4j has a batch insert mode that drops support for transactions and concurrency in favor of insertion speed.
|
6
|
+
# This is useful when you have a big dataset that needs to be loaded once. In our experience, the batch inserter will
|
7
|
+
# typically inject data around five times faster than running in normal transactional mode.
|
8
|
+
#
|
9
|
+
# Be aware that the BatchInserter is intended use is for initial import of data
|
10
|
+
# * non thread safe
|
11
|
+
# * non transactional
|
12
|
+
# * failure to successfully invoke shutdown (properly) results in corrupt database files
|
13
|
+
#
|
14
|
+
class Inserter
|
15
|
+
attr_reader :batch_inserter, :batch_indexer
|
16
|
+
include ToJava
|
17
|
+
|
18
|
+
# Creates a new batch inserter.
|
19
|
+
# Will raise an exception if Neo4j is already running at the same storage_path
|
20
|
+
#
|
21
|
+
def initialize(storage_path=Neo4j.config.storage_path, config={})
|
22
|
+
# check if neo4j is running and using the same storage path
|
23
|
+
raise "Not allowed to start batch inserter while Neo4j is already running at storage location #{storage_path}" if Neo4j.storage_path == storage_path
|
24
|
+
@batch_inserter = org.neo4j.kernel.impl.batchinsert.BatchInserterImpl.new(storage_path, config)
|
25
|
+
Indexer.index_provider = org.neo4j.index.impl.lucene.LuceneBatchInserterIndexProvider.new(@batch_inserter)
|
26
|
+
end
|
27
|
+
|
28
|
+
def running?
|
29
|
+
@batch_inserter != nil
|
30
|
+
end
|
31
|
+
|
32
|
+
# This method MUST be called after inserting is completed.
|
33
|
+
def shutdown
|
34
|
+
@batch_inserter && @batch_inserter.shutdown
|
35
|
+
@batch_inserter = nil
|
36
|
+
|
37
|
+
Indexer.index_provider
|
38
|
+
Indexer.index_provider && Indexer.index_provider.shutdown
|
39
|
+
Indexer.index_provider = nil
|
40
|
+
Indexer.clear_all_instances
|
41
|
+
end
|
42
|
+
|
43
|
+
# Creates a node. Returns a Fixnum id of the created node.
|
44
|
+
# Adds a lucene index if there is a lucene index declared on the properties
|
45
|
+
def create_node(props=nil, clazz = Neo4j::Node)
|
46
|
+
props = {} if clazz != Neo4j::Node && props.nil?
|
47
|
+
props['_classname'] = clazz.to_s if clazz != Neo4j::Node
|
48
|
+
|
49
|
+
node = @batch_inserter.create_node(props)
|
50
|
+
props && _index(node, props, clazz)
|
51
|
+
node
|
52
|
+
end
|
53
|
+
|
54
|
+
# returns true if the node exists
|
55
|
+
def node_exist?(id)
|
56
|
+
@batch_inserter.node_exists(id)
|
57
|
+
end
|
58
|
+
|
59
|
+
def ref_node
|
60
|
+
@batch_inserter.get_reference_node
|
61
|
+
end
|
62
|
+
|
63
|
+
# creates a relationship between given nodes of given type.
|
64
|
+
# Returns a fixnum id of the created relationship.
|
65
|
+
def create_rel(rel_type, from_node, to_node, props=nil, clazz=Neo4j::Relationship)
|
66
|
+
props = {} if clazz != Neo4j::Relationship && props.nil?
|
67
|
+
props['_classname'] = clazz.to_s if clazz != Neo4j::Relationship
|
68
|
+
rel = @batch_inserter.create_relationship(from_node, to_node, type_to_java(rel_type), props)
|
69
|
+
|
70
|
+
props && _index(rel, props, clazz)
|
71
|
+
|
72
|
+
from_props = node_props(from_node)
|
73
|
+
|
74
|
+
if from_props['_classname']
|
75
|
+
indexer = Indexer.instance_for(from_props['_classname'])
|
76
|
+
indexer.index_node_via_rel(rel_type, to_node, from_props)
|
77
|
+
end
|
78
|
+
|
79
|
+
to_props = node_props(to_node)
|
80
|
+
if to_props['_classname']
|
81
|
+
indexer = Indexer.instance_for(to_props['_classname'])
|
82
|
+
indexer.index_node_via_rel(rel_type, from_node, to_props)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
# Return a hash of all properties of given node
|
88
|
+
def node_props(node)
|
89
|
+
@batch_inserter.get_node_properties(node)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Sets the properties of the given node, overwrites old properties
|
93
|
+
def set_node_props(node, hash, clazz = Neo4j::Node)
|
94
|
+
@batch_inserter.set_node_properties(node, hash)
|
95
|
+
_index(node, hash, clazz)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Sets the old properties of the given relationship, overwrites old properties
|
99
|
+
def set_rel_props(rel, hash)
|
100
|
+
@batch_inserter.set_relationship_properties(rel, hash)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Returns the properties of the given relationship
|
104
|
+
def rel_props(rel)
|
105
|
+
@batch_inserter.get_relationship_properties(rel)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Returns all the relationships of the given node
|
109
|
+
def rels(node)
|
110
|
+
@batch_inserter.getRelationships(node)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Makes sure additions/updates can be seen by #index_get and #index_query
|
114
|
+
# so that they are guaranteed to return correct results.
|
115
|
+
def index_flush(clazz = Neo4j::Node)
|
116
|
+
indexer = Indexer.instance_for(clazz)
|
117
|
+
indexer.index_flush
|
118
|
+
end
|
119
|
+
|
120
|
+
# Returns matches from the index specified by index_type and class.
|
121
|
+
#
|
122
|
+
# ==== Parameters
|
123
|
+
# * key :: the lucene key
|
124
|
+
# * value :: the lucene value we look for given the key
|
125
|
+
# * index_type :: :exact or :fulltext
|
126
|
+
# * clazz :: on which clazz we want to perform the query
|
127
|
+
#
|
128
|
+
def index_get(key, value, index_type = :exact, clazz = Neo4j::Node)
|
129
|
+
indexer = Indexer.instance_for(clazz)
|
130
|
+
indexer.index_get(key, value, index_type)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Returns matches from the index specified by index_type and class.
|
134
|
+
#
|
135
|
+
# ==== Parameters
|
136
|
+
# * query :: lucene query
|
137
|
+
# * index_type :: :exact or :fulltext
|
138
|
+
# * clazz :: on which clazz we want to perform the query
|
139
|
+
#
|
140
|
+
def index_query(query, index_type = :exact, clazz = Neo4j::Node)
|
141
|
+
indexer = Indexer.instance_for(clazz)
|
142
|
+
indexer.index_query(query, index_type)
|
143
|
+
end
|
144
|
+
|
145
|
+
# index the given entity (a node or a relationship)
|
146
|
+
def _index(entity, props, clazz = Neo4j::Node) #:nodoc:
|
147
|
+
indexer = Indexer.instance_for(clazz)
|
148
|
+
indexer.index_entity(entity, props)
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
# hmm, maybe faster not wrapping this ?
|
153
|
+
def to_java_map(hash)
|
154
|
+
return nil if hash.nil?
|
155
|
+
map = java.util.HashMap.new
|
156
|
+
hash.each_pair do |k, v|
|
157
|
+
case v
|
158
|
+
when Symbol
|
159
|
+
map[k.to_s] = v.to_s
|
160
|
+
else
|
161
|
+
map[k.to_s] = v
|
162
|
+
end
|
163
|
+
end
|
164
|
+
map
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|