pacer-orient 2.0.0-java → 2.1.0-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.
- checksums.yaml +7 -0
- data/.gitignore +5 -1
- data/README.md +5 -16
- data/Rakefile +3 -2
- data/lib/pacer-orient/encoder.rb +109 -0
- data/lib/pacer-orient/factory_container.rb +26 -0
- data/lib/pacer-orient/graph.rb +230 -19
- data/lib/pacer-orient/orient_type.rb +79 -0
- data/lib/pacer-orient/property.rb +60 -0
- data/lib/pacer-orient/record_id.rb +5 -0
- data/lib/pacer-orient/rspec.rb +10 -6
- data/lib/pacer-orient/version.rb +4 -4
- data/lib/pacer-orient-2.1.0-standalone.jar +0 -0
- data/lib/pacer-orient.rb +75 -1
- data/pacer-orient.gemspec +4 -4
- data/pom.xml +25 -47
- metadata +24 -26
- data/lib/pacer-orient-1.0.0-standalone.jar +0 -0
- data/lib/pacer-orient-2.0.0-standalone.jar +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae4c997eba45204e9613c0e967992afa83446de5
|
4
|
+
data.tar.gz: 993cfec0e2021dfcbdc15dfa12d977ff2c6cd407
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a294fce502976561afb02005cd85757366f0c8f6227538834eae5871582acf52c8fd78bde4b9f537b001c7454ae988850b50b9788faf6286ca8360b4c46c04a1
|
7
|
+
data.tar.gz: 64604585eaa4cbbe65087b0e011b6c6f0a9f44fd94a4839d5d1e7e5a704de207728838b7efd87274aa533d8f07d3d2e5eb25e4076d61f85c15eedc7fa7222072
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,32 +1,21 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
*Note:* The Pacer test suite does not pass with this graph adapter,
|
4
|
-
therefore this adapter is currently only experimental. Graphs with fully
|
5
|
-
passing test suites currently include TinkerGraph, Neo4j and Dex.
|
1
|
+
# Orient Graph Database Adapter for Pacer
|
6
2
|
|
7
3
|
[Pacer](https://github.com/pangloss/pacer) is a
|
8
4
|
[JRuby](http://jruby.org) graph traversal framework built on the
|
9
5
|
[Tinkerpop](http://www.tinkerpop.com) stack.
|
10
6
|
|
11
|
-
This plugin enables full
|
12
|
-
[OrientDB](http://http://www.orientechnologies.com/) graph support in Pacer.
|
7
|
+
This plugin enables full [Orient](http://orient.org) graph support in Pacer.
|
13
8
|
|
14
9
|
|
15
10
|
## Usage
|
16
11
|
|
17
|
-
Here is how you open a
|
12
|
+
Here is how you open a Orient graph in Pacer.
|
18
13
|
|
19
14
|
require 'pacer'
|
20
15
|
require 'pacer-orient'
|
21
16
|
|
22
|
-
# Graph
|
23
|
-
graph = Pacer.orient '
|
24
|
-
|
25
|
-
# In memory graph
|
26
|
-
graph = Pacer.orient 'memory:foo'
|
27
|
-
|
28
|
-
# Remote graph
|
29
|
-
graph = Pacer.orient 'remote:localhost/graph', 'username', 'password'
|
17
|
+
# Graph will be created if it doesn't exist
|
18
|
+
graph = Pacer.orient 'path/to/graph'
|
30
19
|
|
31
20
|
All other operations are identical across graph implementations (except
|
32
21
|
where certain features are not supported). See Pacer's documentation for
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ file 'pom.xml' => 'lib/pacer-orient/version.rb' do
|
|
7
7
|
open 'pom.xml', 'w' do |f|
|
8
8
|
pom.each_line do |line|
|
9
9
|
line.sub!(%r{<gem.version>.*</gem.version>}, "<gem.version>#{ Pacer::Orient::VERSION }</gem.version>")
|
10
|
-
line.sub!(%r{<
|
10
|
+
line.sub!(%r{<orient.version>.*</orient.version>}, "<orient.version>#{ Pacer::Orient::ORIENT_VERSION }</orient.version>")
|
11
11
|
line.sub!(%r{<pipes.version>.*</pipes.version>}, "<pipes.version>#{ Pacer::Orient::PIPES_VERSION }</pipes.version>")
|
12
12
|
f << line
|
13
13
|
end
|
@@ -22,7 +22,7 @@ file Pacer::Orient::JAR_PATH => 'pom.xml' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
task :note do
|
25
|
-
puts "NOTE: touch lib/pacer-
|
25
|
+
puts "NOTE: touch lib/pacer-orient/version.rb (or rake touch) to force everything to rebuild"
|
26
26
|
end
|
27
27
|
|
28
28
|
task :build => [:note, Pacer::Orient::JAR_PATH]
|
@@ -32,3 +32,4 @@ desc 'Touch version.rb so that the jar rebuilds'
|
|
32
32
|
task :touch do
|
33
33
|
system 'touch', 'lib/pacer-orient/version.rb'
|
34
34
|
end
|
35
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
module Pacer::Orient
|
4
|
+
class Encoder
|
5
|
+
JavaDate = java.util.Date
|
6
|
+
JavaSet = java.util.Set
|
7
|
+
JavaMap = java.util.Map
|
8
|
+
JavaList = java.util.List
|
9
|
+
|
10
|
+
def self.encode_property(value)
|
11
|
+
case value
|
12
|
+
when nil
|
13
|
+
nil
|
14
|
+
when String
|
15
|
+
value = value.strip
|
16
|
+
value = nil if value == ''
|
17
|
+
value
|
18
|
+
when Numeric
|
19
|
+
if value.is_a? Bignum
|
20
|
+
Marshal.dump(value).to_java_bytes
|
21
|
+
else
|
22
|
+
value.to_java
|
23
|
+
end
|
24
|
+
when true, false
|
25
|
+
value.to_java
|
26
|
+
when DateTime, Time, JavaDate
|
27
|
+
f = if value.is_a? JavaDate
|
28
|
+
value.getTime / 1000.0
|
29
|
+
else
|
30
|
+
value.to_time.to_f
|
31
|
+
end
|
32
|
+
i = f.truncate
|
33
|
+
r = (f.remainder(1) * 10000).round
|
34
|
+
if value.is_a? DateTime
|
35
|
+
c = 1
|
36
|
+
elsif value.is_a? Time and value.utc?
|
37
|
+
c = 2
|
38
|
+
else
|
39
|
+
c = 3
|
40
|
+
end
|
41
|
+
["D", i, r, c].pack("ANnc").to_java_bytes
|
42
|
+
when Date
|
43
|
+
["D", value.to_time.to_i].pack("AN").to_java_bytes
|
44
|
+
when Set
|
45
|
+
value.map { |x| encode_property(x) }.to_hashset
|
46
|
+
when Hash
|
47
|
+
value.to_hash_map { |k, v| [encode_property(k), encode_property(v)] }
|
48
|
+
when Enumerable
|
49
|
+
value.map { |x| encode_property(x) }.to_list
|
50
|
+
when JavaSet, JavaMap, JavaList
|
51
|
+
value
|
52
|
+
else
|
53
|
+
Marshal.dump(value).to_java_bytes
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.decode_property(value)
|
58
|
+
case value
|
59
|
+
when ArrayJavaProxy
|
60
|
+
str = String.from_java_bytes(value)
|
61
|
+
flag = str[0]
|
62
|
+
case flag
|
63
|
+
when 'D'
|
64
|
+
data = str.unpack("ANnc")
|
65
|
+
i = data[1]
|
66
|
+
r = data[2]
|
67
|
+
c = data[3]
|
68
|
+
if r
|
69
|
+
t = Time.at(i + (r / 10000.0))
|
70
|
+
case c
|
71
|
+
when 1
|
72
|
+
t.utc.to_datetime
|
73
|
+
when 2
|
74
|
+
t.utc
|
75
|
+
else
|
76
|
+
t
|
77
|
+
end
|
78
|
+
else
|
79
|
+
Time.at(i).utc.to_date
|
80
|
+
end
|
81
|
+
else
|
82
|
+
Marshal.load str
|
83
|
+
end
|
84
|
+
when JavaDate
|
85
|
+
Time.at(value.getTime() / 1000.0)
|
86
|
+
when JavaSet
|
87
|
+
s = Set[]
|
88
|
+
value.each do |v|
|
89
|
+
s.add decode_property(v)
|
90
|
+
end
|
91
|
+
s
|
92
|
+
when JavaMap
|
93
|
+
h = {}
|
94
|
+
value.each do |k, v|
|
95
|
+
h[decode_property(k)] = decode_property(v)
|
96
|
+
end
|
97
|
+
h
|
98
|
+
when JavaList
|
99
|
+
a = []
|
100
|
+
value.each do |v|
|
101
|
+
a.push decode_property(v)
|
102
|
+
end
|
103
|
+
a
|
104
|
+
else
|
105
|
+
value
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Pacer::Orient
|
2
|
+
class FactoryContainer
|
3
|
+
attr_reader :factory
|
4
|
+
|
5
|
+
def initialize(f)
|
6
|
+
@factory = f
|
7
|
+
end
|
8
|
+
|
9
|
+
def get
|
10
|
+
factory.get
|
11
|
+
end
|
12
|
+
|
13
|
+
def getTx
|
14
|
+
factory.getTx
|
15
|
+
end
|
16
|
+
|
17
|
+
def getNoTx
|
18
|
+
factory.getNoTx
|
19
|
+
end
|
20
|
+
|
21
|
+
# Pacer calls shutdown on all cached graphs when it exits. Orient caches this factory.
|
22
|
+
def shutdown
|
23
|
+
factory.close
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/pacer-orient/graph.rb
CHANGED
@@ -1,28 +1,239 @@
|
|
1
|
-
require '
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
require 'pacer-orient/orient_type'
|
4
|
+
require 'pacer-orient/property'
|
5
|
+
require 'pacer-orient/encoder'
|
6
|
+
require 'pacer-orient/record_id'
|
7
|
+
require 'pacer-orient/factory_container'
|
2
8
|
|
3
9
|
module Pacer
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
module Orient
|
11
|
+
class Graph < PacerGraph
|
12
|
+
import com.orientechnologies.orient.core.sql.OCommandSQL
|
13
|
+
import com.orientechnologies.orient.core.metadata.schema.OType
|
14
|
+
import com.orientechnologies.orient.core.metadata.schema.OClass
|
15
|
+
|
16
|
+
# Marked the types that should be most commonly used.
|
17
|
+
OTYPES = {
|
18
|
+
:any => OType::ANY,
|
19
|
+
:boolean => OType::BOOLEAN, # use this one
|
20
|
+
:bool => OType::BOOLEAN,
|
21
|
+
:short => OType::SHORT,
|
22
|
+
:integer => OType::INTEGER,
|
23
|
+
:int => OType::INTEGER,
|
24
|
+
:long => OType::LONG, # use this one
|
25
|
+
:float => OType::FLOAT,
|
26
|
+
:double => OType::DOUBLE, # use this one
|
27
|
+
:decimal => OType::DECIMAL, # use this one
|
28
|
+
:date => OType::DATE, # use this one
|
29
|
+
:datetime => OType::DATETIME, # use this one
|
30
|
+
:date_time => OType::DATETIME,
|
31
|
+
:byte => OType::BYTE,
|
32
|
+
:string => OType::STRING, # use this one
|
33
|
+
:binary => OType::BINARY,
|
34
|
+
:embedded => OType::EMBEDDED,
|
35
|
+
:embeddedlist => OType::EMBEDDEDLIST,
|
36
|
+
:embeddedset => OType::EMBEDDEDSET,
|
37
|
+
:embeddedmap => OType::EMBEDDEDMAP,
|
38
|
+
:link => OType::LINK,
|
39
|
+
:linklist => OType::LINKLIST,
|
40
|
+
:linkset => OType::LINKSET,
|
41
|
+
:linkmap => OType::LINKMAP,
|
42
|
+
:linkbag => OType::LINKBAG,
|
43
|
+
:transient => OType::TRANSIENT,
|
44
|
+
:custom => OType::CUSTOM
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
ITYPES = {
|
49
|
+
:range_dictionary => OClass::INDEX_TYPE::DICTIONARY,
|
50
|
+
:range_fulltext => OClass::INDEX_TYPE::FULLTEXT,
|
51
|
+
:range_full_text => OClass::INDEX_TYPE::FULLTEXT,
|
52
|
+
:range_notunique => OClass::INDEX_TYPE::NOTUNIQUE,
|
53
|
+
:range_not_unique => OClass::INDEX_TYPE::NOTUNIQUE,
|
54
|
+
:range_unique => OClass::INDEX_TYPE::UNIQUE,
|
55
|
+
:proxy => OClass::INDEX_TYPE::PROXY,
|
56
|
+
:dictionary => OClass::INDEX_TYPE::DICTIONARY_HASH_INDEX,
|
57
|
+
:fulltext => OClass::INDEX_TYPE::FULLTEXT_HASH_INDEX,
|
58
|
+
:full_text => OClass::INDEX_TYPE::FULLTEXT_HASH_INDEX,
|
59
|
+
:notunique => OClass::INDEX_TYPE::NOTUNIQUE_HASH_INDEX,
|
60
|
+
:not_unique => OClass::INDEX_TYPE::NOTUNIQUE_HASH_INDEX,
|
61
|
+
:spatial => OClass::INDEX_TYPE::SPATIAL,
|
62
|
+
:unique => OClass::INDEX_TYPE::UNIQUE_HASH_INDEX
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
def orient_graph
|
67
|
+
blueprints_graph.raw_graph
|
68
|
+
end
|
69
|
+
|
70
|
+
def allow_auto_tx=(b)
|
71
|
+
blueprints_graph.setAutoStartTx b
|
72
|
+
end
|
73
|
+
|
74
|
+
def allow_auto_tx
|
75
|
+
blueprints_graph.autoStartTx
|
76
|
+
end
|
77
|
+
|
78
|
+
def on_commit(&block)
|
79
|
+
return unless block
|
80
|
+
# todo
|
81
|
+
end
|
82
|
+
|
83
|
+
def on_commit_failed(&block)
|
84
|
+
return unless block
|
85
|
+
# todo
|
86
|
+
end
|
87
|
+
|
88
|
+
def before_commit(&block)
|
89
|
+
return unless block
|
90
|
+
# todo
|
91
|
+
end
|
92
|
+
|
93
|
+
def drop_handler(h)
|
94
|
+
# todo
|
95
|
+
end
|
96
|
+
|
97
|
+
# NOTE: if you use lightweight edges (they are on by default), g.e will only return edges that have been reified by having properties added to
|
98
|
+
# them.
|
99
|
+
def lightweight_edges
|
100
|
+
blueprints_graph.useLightweightEdges
|
101
|
+
end
|
102
|
+
|
103
|
+
alias lightweight_edges? lightweight_edges
|
104
|
+
|
105
|
+
def lightweight_edges=(b)
|
106
|
+
blueprints_graph.useLightweightEdges = b
|
107
|
+
end
|
108
|
+
|
109
|
+
def use_class_for_edge_label
|
110
|
+
blueprints_graph.useClassForEdgeLabel
|
111
|
+
end
|
112
|
+
|
113
|
+
def use_class_for_edge_label=(b)
|
114
|
+
blueprints_graph.useClassForEdgeLabel = b
|
115
|
+
end
|
116
|
+
|
117
|
+
def use_class_for_vertex_label
|
118
|
+
blueprints_graph.useClassForVertexLabel
|
119
|
+
end
|
120
|
+
|
121
|
+
def use_class_for_vertex_label=(b)
|
122
|
+
blueprints_graph.useClassForVertexLabel = b
|
123
|
+
end
|
124
|
+
|
125
|
+
def sql(extensions, sql = nil, *args)
|
126
|
+
if extensions.is_a? String
|
127
|
+
args = args.unshift sql if sql
|
128
|
+
sql = extensions
|
129
|
+
extensions = []
|
130
|
+
end
|
131
|
+
sql_command(sql, *args).iterator.to_route(based_on: self.v(extensions))
|
132
|
+
end
|
133
|
+
|
134
|
+
def sql_e(extensions, sql = nil, *args)
|
135
|
+
if extensions.is_a? String
|
136
|
+
args = args.unshift sql if sql
|
137
|
+
sql = extensions
|
138
|
+
extensions = []
|
139
|
+
end
|
140
|
+
sql_command(sql, *args).iterator.to_route(based_on: self.e(extensions))
|
141
|
+
end
|
142
|
+
|
143
|
+
def sql_command(sql, *args)
|
144
|
+
args = args.map { |a| encoder.encode_property(a) }
|
145
|
+
blueprints_graph.command(OCommandSQL.new(sql)).execute(*args)
|
146
|
+
end
|
147
|
+
|
148
|
+
def orient_type!(t, element_type = :vertex)
|
149
|
+
r = orient_type(t, element_type)
|
150
|
+
if r
|
151
|
+
r
|
152
|
+
else
|
153
|
+
in_pure_transaction do
|
154
|
+
t = if element_type == :vertex
|
155
|
+
blueprints_graph.createVertexType(t.to_s)
|
156
|
+
elsif element_type == :edge
|
157
|
+
blueprints_graph.createEdgeType(t.to_s)
|
158
|
+
end
|
159
|
+
OrientType.new self, element_type, t if t
|
16
160
|
end
|
17
|
-
Pacer.open_graphs[[url, username]] = graph
|
18
161
|
end
|
19
|
-
graph
|
20
162
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
163
|
+
|
164
|
+
def orient_type(t = nil, element_type = :vertex)
|
165
|
+
t ||= :V if element_type == :vertex
|
166
|
+
t ||= :E if element_type == :edge
|
167
|
+
if t.is_a? String or t.is_a? Symbol
|
168
|
+
t = if element_type == :vertex
|
169
|
+
blueprints_graph.getVertexType(t.to_s)
|
170
|
+
elsif element_type == :edge
|
171
|
+
blueprints_graph.getEdgeType(t.to_s)
|
172
|
+
end
|
173
|
+
OrientType.new self, element_type, t if t
|
174
|
+
elsif t.is_a? OrientType
|
175
|
+
t
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def property_type(t)
|
180
|
+
if t.is_a? String or t.is_a? Symbol
|
181
|
+
OTYPES[t.to_sym]
|
182
|
+
else
|
183
|
+
t
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def index_type(t)
|
188
|
+
if t.is_a? String or t.is_a? Symbol
|
189
|
+
ITYPES[t.to_sym]
|
190
|
+
else
|
191
|
+
t
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def add_vertex_types(*types)
|
196
|
+
in_pure_transaction do
|
197
|
+
types.map do |t|
|
198
|
+
existing = orient_type(t, :vertex)
|
199
|
+
if existing
|
200
|
+
existing
|
201
|
+
else
|
202
|
+
t = blueprints_graph.createVertexType(t.to_s)
|
203
|
+
OrientType.new(self, :vertex, t) if t
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def create_key_index(name, element_type = :vertex, itype = :non_unique)
|
210
|
+
type = orient_type(nil, element_type)
|
211
|
+
type.property!(name).create_index!(itype) if type
|
212
|
+
end
|
213
|
+
|
214
|
+
def drop_key_index(name, element_type = :vertex)
|
215
|
+
in_pure_transaction do
|
216
|
+
super
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
private
|
221
|
+
|
222
|
+
def in_pure_transaction
|
223
|
+
if @in_pure_transaction
|
224
|
+
yield
|
225
|
+
else
|
226
|
+
begin
|
227
|
+
@in_pure_transaction = true
|
228
|
+
transaction do
|
229
|
+
orient_graph.rollback
|
230
|
+
yield
|
231
|
+
end
|
232
|
+
ensure
|
233
|
+
@in_pure_transaction = false
|
234
|
+
end
|
235
|
+
end
|
24
236
|
end
|
25
|
-
PacerGraph.new(Pacer::YamlEncoder, open, shutdown)
|
26
237
|
end
|
27
238
|
end
|
28
239
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Pacer::Orient
|
2
|
+
class OrientType
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
attr_reader :graph, :element_type, :type
|
6
|
+
|
7
|
+
# TODO: setters like in Property, once I figure out what these settings do.
|
8
|
+
|
9
|
+
def_delegators :@type,
|
10
|
+
:name, :short_name, :type_name, :abstract?, :strict_mode?,
|
11
|
+
:base_classes,
|
12
|
+
:class_indexes, :indexes, :involved_indexes,
|
13
|
+
:size, :over_size,
|
14
|
+
:cluster_selection, :cluster_ids,
|
15
|
+
:custom_keys, :custom
|
16
|
+
|
17
|
+
alias class_indices class_indexes
|
18
|
+
alias indices indexes
|
19
|
+
alias involved_indices involved_indexes
|
20
|
+
|
21
|
+
def initialize(graph, element_type, type)
|
22
|
+
@graph = graph
|
23
|
+
@element_type = type
|
24
|
+
@type = type
|
25
|
+
end
|
26
|
+
|
27
|
+
def raw_property(name)
|
28
|
+
if name.is_a? Symbol or name.is_a? String
|
29
|
+
type.getProperty name.to_s
|
30
|
+
else
|
31
|
+
name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def property(name)
|
36
|
+
p = raw_property(name)
|
37
|
+
Property.new self, p if p
|
38
|
+
end
|
39
|
+
|
40
|
+
def property!(name, otype)
|
41
|
+
p = raw_property(name)
|
42
|
+
unless p
|
43
|
+
p = graph.send(:in_pure_transaction) do
|
44
|
+
type.createProperty(name.to_s, graph.property_type(otype))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
Property.new self, p
|
48
|
+
end
|
49
|
+
|
50
|
+
def super_class
|
51
|
+
if base_classes.any?
|
52
|
+
OrientType.new graph, type.getSuperClass
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def set_super_class(sc)
|
57
|
+
type.setSuperClass graph.orient_type(element_type, sc)
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
def drop_property!(name)
|
62
|
+
type.dropProperty name
|
63
|
+
end
|
64
|
+
|
65
|
+
def properties
|
66
|
+
type.properties.map { |p| Property.new self, p }
|
67
|
+
end
|
68
|
+
|
69
|
+
def indexed_properties
|
70
|
+
type.indexedProperties.map { |p| Property.new self, p }
|
71
|
+
end
|
72
|
+
|
73
|
+
def inspect
|
74
|
+
abs = "Abstract" if abstract?
|
75
|
+
strict = " (strict)" if strict_mode?
|
76
|
+
"#<#{ abs }#{ type_name.capitalize }Type #{ name }#{ strict }>"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Pacer::Orient
|
2
|
+
class Property
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
attr_reader :el_type, :property
|
6
|
+
|
7
|
+
def_delegators :@property,
|
8
|
+
:name, :full_name, :not_null?, :collate,
|
9
|
+
:mandatory?, :readonly?, :min, :max, :index,
|
10
|
+
:indexed?, :regexp, :type, :custom, :custom_keys
|
11
|
+
|
12
|
+
def initialize(el_type, property)
|
13
|
+
@el_type = el_type
|
14
|
+
@property = property
|
15
|
+
end
|
16
|
+
|
17
|
+
def graph
|
18
|
+
el_type.graph
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_index!(index_type = :not_unique)
|
22
|
+
unless indexed?
|
23
|
+
graph.send(:in_pure_transaction) do
|
24
|
+
property.createIndex graph.index_type(index_type)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def drop_index!
|
31
|
+
graph.drop_key_index name if indexed?
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_type!(t)
|
36
|
+
# Not implemented as of 1.7.8
|
37
|
+
fail Pacer::InternalError.new("Type migration is a planned Orient 2.x feature")
|
38
|
+
end
|
39
|
+
|
40
|
+
def drop!
|
41
|
+
el_type.drop_property! name
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
[ :set_name, :set_not_null, :set_collate,
|
46
|
+
:set_mandatory, :set_readonly, :set_min, :set_max,
|
47
|
+
:set_regexp, :set_custom, :remove_custom, :clear_custom
|
48
|
+
].each do |setter|
|
49
|
+
define_method(setter) do |*args|
|
50
|
+
property.send setter, *args
|
51
|
+
self
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def inspect
|
56
|
+
"#<#{ el_type.type_name.capitalize }Property #{ el_type.name }.#{ property.name } (#{ type })>"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/lib/pacer-orient/rspec.rb
CHANGED
@@ -13,20 +13,24 @@ class RSpec::GraphRunner
|
|
13
13
|
|
14
14
|
def orient_graph
|
15
15
|
return @orient_graph if @orient_graph
|
16
|
-
|
16
|
+
path1 = File.expand_path('/tmp/spec.orient')
|
17
|
+
dir = Pathname.new(path1)
|
18
|
+
dir.rmtree if dir.exist?
|
19
|
+
@orient_graph = Pacer.orient(path1, lightweight_edges: false, edge_classes: false)
|
17
20
|
end
|
18
21
|
|
22
|
+
# Can't use 2 graphs on 1 thread.
|
19
23
|
def orient_graph2
|
20
24
|
return @orient_graph2 if @orient_graph2
|
21
|
-
@orient_graph2 = Pacer.
|
25
|
+
@orient_graph2 = Pacer.tg
|
22
26
|
end
|
23
27
|
|
24
28
|
def orient_graph_no_indices
|
25
29
|
return @orient_graph_no_indices if @orient_graph_no_indices
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@orient_graph_no_indices
|
30
|
+
path3 = File.expand_path('/tmp/spec.orient.3')
|
31
|
+
dir = Pathname.new(path3)
|
32
|
+
dir.rmtree if dir.exist?
|
33
|
+
@orient_graph_no_indices = Pacer.orient(path3, lightweight_edges: false, edge_classes: false)
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
data/lib/pacer-orient/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Pacer
|
2
2
|
module Orient
|
3
|
-
VERSION = "2.
|
3
|
+
VERSION = "2.1.0"
|
4
4
|
JAR = "pacer-orient-#{ VERSION }-standalone.jar"
|
5
5
|
JAR_PATH = "lib/#{ JAR }"
|
6
|
-
|
7
|
-
PIPES_VERSION = "2.
|
8
|
-
PACER_REQ = ">= 1.
|
6
|
+
ORIENT_VERSION = "1.7.8"
|
7
|
+
PIPES_VERSION = "2.5.0"
|
8
|
+
PACER_REQ = ">= 1.5.2"
|
9
9
|
end
|
10
10
|
end
|
Binary file
|
data/lib/pacer-orient.rb
CHANGED
@@ -1,6 +1,80 @@
|
|
1
|
+
require 'pacer' unless defined? Pacer
|
2
|
+
|
3
|
+
lib_path = File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
|
4
|
+
$:.unshift lib_path unless $:.any? { |path| path == lib_path }
|
5
|
+
|
1
6
|
require 'pacer-orient/version'
|
2
7
|
|
3
|
-
require 'pacer'
|
4
8
|
require Pacer::Orient::JAR
|
5
9
|
|
6
10
|
require 'pacer-orient/graph'
|
11
|
+
|
12
|
+
Pacer::FunctionResolver.clear_cache
|
13
|
+
|
14
|
+
module Pacer
|
15
|
+
# Add 'static methods' to the Pacer namespace.
|
16
|
+
class << self
|
17
|
+
# Return a graph for the given path. Will create a graph if none exists at
|
18
|
+
# that location.
|
19
|
+
#
|
20
|
+
# If the graph is opened from a path, it will be registered to be closed by
|
21
|
+
# Ruby's at_exit callback, but if an already open graph is given, it will
|
22
|
+
# not.
|
23
|
+
def orient(url = nil, args = nil)
|
24
|
+
if url.nil?
|
25
|
+
url = "memory:#{ next_orient_name }"
|
26
|
+
elsif url.is_a? String and url !~ /^(plocal|local|remote|memory):/
|
27
|
+
url = "plocal:#{ url }"
|
28
|
+
end
|
29
|
+
if args
|
30
|
+
username = args.delete :username
|
31
|
+
password = args.delete :password
|
32
|
+
transactional = args.delete :transactional
|
33
|
+
lightweight_edges = args.delete :lightweight_edges
|
34
|
+
edge_classes = args.delete :edge_classes
|
35
|
+
vertex_classes = args.delete :vertex_classes
|
36
|
+
end
|
37
|
+
if url.is_a? String
|
38
|
+
open = proc do
|
39
|
+
# TODO: can / should I cache connections? Is it essential to shut down Orient?
|
40
|
+
factory = Pacer.open_graphs[[url, username]]
|
41
|
+
unless factory
|
42
|
+
factory =
|
43
|
+
if username
|
44
|
+
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.new url, username, password
|
45
|
+
else
|
46
|
+
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.new url
|
47
|
+
end
|
48
|
+
Pacer.open_graphs[[url, username]] = Pacer::Orient::FactoryContainer.new(factory)
|
49
|
+
end
|
50
|
+
if transactional == false
|
51
|
+
graph = factory.getNoTx()
|
52
|
+
else
|
53
|
+
graph = factory.getTx()
|
54
|
+
end
|
55
|
+
graph.useLightweightEdges = lightweight_edges if lightweight_edges == false
|
56
|
+
graph.useClassForEdgeLabel = edge_classes if edge_classes == false
|
57
|
+
graph.useClassForVertexLabel = vertex_classes if vertex_classes == false
|
58
|
+
#graph.setAutoStartTx false
|
59
|
+
graph
|
60
|
+
end
|
61
|
+
shutdown = proc do |g|
|
62
|
+
factory = Pacer.open_graphs.delete [url, username]
|
63
|
+
factory.shutdown if factory
|
64
|
+
end
|
65
|
+
Orient::Graph.new(Pacer::Orient::Encoder, open, shutdown)
|
66
|
+
else
|
67
|
+
# Don't register the new graph so that it won't be automatically closed.
|
68
|
+
graph = url
|
69
|
+
Orient::Graph.new Pacer::Orient::Encoder, proc { graph }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def next_orient_name
|
76
|
+
@next_orient_name ||= "orient000"
|
77
|
+
@next_orient_name.succ!
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/pacer-orient.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "pacer-orient"
|
7
7
|
s.version = Pacer::Orient::VERSION
|
8
8
|
s.platform = 'java'
|
9
|
-
s.authors = ["
|
10
|
-
s.email = ["
|
11
|
-
s.homepage = "http://
|
12
|
-
s.summary = %q{
|
9
|
+
s.authors = ["Darrick Wiebe"]
|
10
|
+
s.email = ["dw@xnlogic.com"]
|
11
|
+
s.homepage = "http://orientechnologies.com"
|
12
|
+
s.summary = %q{Orient jars and related code for Pacer}
|
13
13
|
s.description = s.summary
|
14
14
|
|
15
15
|
s.add_dependency 'pacer', Pacer::Orient::PACER_REQ
|
data/pom.xml
CHANGED
@@ -3,69 +3,47 @@
|
|
3
3
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
4
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
5
5
|
<modelVersion>4.0.0</modelVersion>
|
6
|
-
<groupId>com.
|
6
|
+
<groupId>com.xnlogic.pacer</groupId>
|
7
7
|
<artifactId>pacer-orient</artifactId>
|
8
|
-
<!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-
|
8
|
+
<!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-orient/version.rb -->
|
9
9
|
<properties>
|
10
|
-
<
|
11
|
-
<
|
12
|
-
<pipes.version>2.
|
10
|
+
<orient.version>1.7.8</orient.version>
|
11
|
+
<gem.version>2.1.0</gem.version>
|
12
|
+
<pipes.version>2.5.0</pipes.version>
|
13
13
|
</properties>
|
14
|
-
<!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-
|
14
|
+
<!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-orient/version.rb -->
|
15
15
|
<version>${gem.version}</version>
|
16
16
|
<packaging>pom</packaging>
|
17
17
|
<url>https://github.com/pangloss/pacer</url>
|
18
|
-
<name>Pacer
|
18
|
+
<name>Pacer Orient dependencies and related code.</name>
|
19
19
|
<description>
|
20
20
|
</description>
|
21
21
|
<inceptionYear>2011</inceptionYear>
|
22
22
|
<developers>
|
23
23
|
<developer>
|
24
|
-
<name>
|
25
|
-
<email>
|
26
|
-
<url>http://github.com/
|
24
|
+
<name>Darrick Wiebe</name>
|
25
|
+
<email>darrick@innatesoftware.com</email>
|
26
|
+
<url>http://github.com/pangloss</url>
|
27
27
|
</developer>
|
28
28
|
</developers>
|
29
29
|
<dependencies>
|
30
|
-
|
31
|
-
<
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
<
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
<
|
43
|
-
|
44
|
-
|
45
|
-
<version>${pipes.version}</version>
|
46
|
-
</dependency>
|
30
|
+
<dependency>
|
31
|
+
<groupId>com.orientechnologies</groupId>
|
32
|
+
<artifactId>orient-commons</artifactId>
|
33
|
+
<version>${orient.version}</version>
|
34
|
+
</dependency>
|
35
|
+
<dependency>
|
36
|
+
<groupId>com.orientechnologies</groupId>
|
37
|
+
<artifactId>orientdb-core</artifactId>
|
38
|
+
<version>${orient.version}</version>
|
39
|
+
</dependency>
|
40
|
+
<dependency>
|
41
|
+
<groupId>com.orientechnologies</groupId>
|
42
|
+
<artifactId>orientdb-graphdb</artifactId>
|
43
|
+
<version>${orient.version}</version>
|
44
|
+
</dependency>
|
47
45
|
</dependencies>
|
48
46
|
|
49
|
-
<repositories>
|
50
|
-
<repository>
|
51
|
-
<id>tinkerpop-repository</id>
|
52
|
-
<name>TinkerPop Maven2 Repository</name>
|
53
|
-
<url>http://tinkerpop.com/maven2</url>
|
54
|
-
<snapshots>
|
55
|
-
<enabled>true</enabled>
|
56
|
-
<updatePolicy>always</updatePolicy>
|
57
|
-
</snapshots>
|
58
|
-
</repository>
|
59
|
-
</repositories>
|
60
|
-
|
61
|
-
<distributionManagement>
|
62
|
-
<repository>
|
63
|
-
<id>tinkerpop-repository</id>
|
64
|
-
<name>TinkerPop Maven2 Repository</name>
|
65
|
-
<url>ftp://ftp.tinkerpop.com:21/public/maven2/</url>
|
66
|
-
</repository>
|
67
|
-
</distributionManagement>
|
68
|
-
|
69
47
|
<build>
|
70
48
|
<directory>${basedir}/target</directory>
|
71
49
|
<finalName>${project.artifactId}-${project.version}</finalName>
|
metadata
CHANGED
@@ -1,35 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pacer-orient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.0
|
6
5
|
platform: java
|
7
6
|
authors:
|
8
|
-
-
|
7
|
+
- Darrick Wiebe
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: pacer
|
16
15
|
version_requirements: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
|
-
- -
|
17
|
+
- - '>='
|
19
18
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
21
|
-
none: false
|
19
|
+
version: 1.5.2
|
22
20
|
requirement: !ruby/object:Gem::Requirement
|
23
21
|
requirements:
|
24
|
-
- -
|
22
|
+
- - '>='
|
25
23
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
27
|
-
none: false
|
24
|
+
version: 1.5.2
|
28
25
|
prerelease: false
|
29
26
|
type: :runtime
|
30
|
-
description:
|
27
|
+
description: Orient jars and related code for Pacer
|
31
28
|
email:
|
32
|
-
-
|
29
|
+
- dw@xnlogic.com
|
33
30
|
executables: []
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
@@ -38,40 +35,41 @@ files:
|
|
38
35
|
- Gemfile
|
39
36
|
- README.md
|
40
37
|
- Rakefile
|
41
|
-
- lib/pacer-orient-1.0.0-standalone.jar
|
42
38
|
- lib/pacer-orient.rb
|
39
|
+
- lib/pacer-orient/encoder.rb
|
40
|
+
- lib/pacer-orient/factory_container.rb
|
43
41
|
- lib/pacer-orient/graph.rb
|
42
|
+
- lib/pacer-orient/orient_type.rb
|
43
|
+
- lib/pacer-orient/property.rb
|
44
|
+
- lib/pacer-orient/record_id.rb
|
44
45
|
- lib/pacer-orient/rspec.rb
|
45
46
|
- lib/pacer-orient/version.rb
|
46
47
|
- pacer-orient.gemspec
|
47
48
|
- pom.xml
|
48
49
|
- pom/standalone.xml
|
49
|
-
- lib/pacer-orient-2.
|
50
|
-
homepage: http://
|
50
|
+
- lib/pacer-orient-2.1.0-standalone.jar
|
51
|
+
homepage: http://orientechnologies.com
|
51
52
|
licenses: []
|
53
|
+
metadata: {}
|
52
54
|
post_install_message:
|
53
55
|
rdoc_options: []
|
54
56
|
require_paths:
|
55
57
|
- lib
|
56
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
59
|
requirements:
|
58
|
-
- -
|
60
|
+
- - '>='
|
59
61
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
61
|
-
MA==
|
62
|
-
none: false
|
62
|
+
version: '0'
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - '>='
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
68
|
-
MA==
|
69
|
-
none: false
|
67
|
+
version: '0'
|
70
68
|
requirements: []
|
71
69
|
rubyforge_project: pacer-orient
|
72
|
-
rubygems_version: 1.
|
70
|
+
rubygems_version: 2.1.9
|
73
71
|
signing_key:
|
74
|
-
specification_version:
|
75
|
-
summary:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Orient jars and related code for Pacer
|
76
74
|
test_files: []
|
77
75
|
has_rdoc:
|
Binary file
|
Binary file
|