pacer-orient 2.1.0.pre-java → 2.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pacer-orient.rb +19 -6
- data/lib/pacer-orient/encoder.rb +118 -3
- data/lib/pacer-orient/factory_container.rb +26 -0
- data/lib/pacer-orient/graph.rb +197 -10
- data/lib/pacer-orient/orient_type.rb +88 -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 -3
- data/lib/pacer-orient/version.rb +2 -2
- data/pom.xml +1 -1
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2fdd8ddfc4598b083a169ccb43bc73bd5fbeb71
|
4
|
+
data.tar.gz: 927e24d2325d80d8c43bf5dbb02960e9985be2c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4f1593a4cbc034406287fe45365626a41a8ed6acea60210927d38a0f0329cf8f01c2ff79016adb31cd4e26f3b3acf086878c04b953dfaed3fc2d97856394b2
|
7
|
+
data.tar.gz: 1df25c40515d3ea6413e77c3f3d23cdc8d89508f383f8338eb0aee770d81998eb78ba5b51e2e7ed2b71d51c5e05572bd765f9ef6ec7adef23266f99f1eb4a634
|
data/lib/pacer-orient.rb
CHANGED
@@ -26,8 +26,14 @@ module Pacer
|
|
26
26
|
elsif url.is_a? String and url !~ /^(plocal|local|remote|memory):/
|
27
27
|
url = "plocal:#{ url }"
|
28
28
|
end
|
29
|
-
|
30
|
-
|
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
|
31
37
|
if url.is_a? String
|
32
38
|
open = proc do
|
33
39
|
# TODO: can / should I cache connections? Is it essential to shut down Orient?
|
@@ -41,19 +47,26 @@ module Pacer
|
|
41
47
|
end
|
42
48
|
Pacer.open_graphs[[url, username]] = Pacer::Orient::FactoryContainer.new(factory)
|
43
49
|
end
|
44
|
-
|
45
|
-
|
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
|
46
59
|
graph
|
47
60
|
end
|
48
61
|
shutdown = proc do |g|
|
49
62
|
factory = Pacer.open_graphs.delete [url, username]
|
50
63
|
factory.shutdown if factory
|
51
64
|
end
|
52
|
-
Orient::Graph.new(Pacer::
|
65
|
+
Orient::Graph.new(Pacer::Orient::Encoder, open, shutdown)
|
53
66
|
else
|
54
67
|
# Don't register the new graph so that it won't be automatically closed.
|
55
68
|
graph = url
|
56
|
-
Orient::Graph.new Pacer::
|
69
|
+
Orient::Graph.new Pacer::Orient::Encoder, proc { graph }
|
57
70
|
end
|
58
71
|
end
|
59
72
|
|
data/lib/pacer-orient/encoder.rb
CHANGED
@@ -3,6 +3,9 @@ require 'java'
|
|
3
3
|
module Pacer::Orient
|
4
4
|
class Encoder
|
5
5
|
JavaDate = java.util.Date
|
6
|
+
JavaSet = java.util.Set
|
7
|
+
JavaMap = java.util.Map
|
8
|
+
JavaList = java.util.List
|
6
9
|
|
7
10
|
def self.encode_property(value)
|
8
11
|
case value
|
@@ -20,7 +23,24 @@ module Pacer::Orient
|
|
20
23
|
end
|
21
24
|
when true, false
|
22
25
|
value.to_java
|
23
|
-
when JavaDate
|
26
|
+
when JavaDate
|
27
|
+
value
|
28
|
+
when Time
|
29
|
+
value.to_java
|
30
|
+
when DateTime
|
31
|
+
value.to_time.to_java
|
32
|
+
when Date
|
33
|
+
t = value.to_time
|
34
|
+
(t + Time.zone_offset(t.zone)).utc.to_java
|
35
|
+
when Set
|
36
|
+
value.map { |x| encode_property(x) }.to_hashset
|
37
|
+
when Hash
|
38
|
+
value.to_hash_map { |k, v| [encode_property(k), encode_property(v)] }
|
39
|
+
when Enumerable
|
40
|
+
value.map { |x| encode_property(x) }.to_list
|
41
|
+
when JavaSet, JavaMap, JavaList
|
42
|
+
value
|
43
|
+
when ArrayJavaProxy
|
24
44
|
value
|
25
45
|
else
|
26
46
|
Marshal.dump(value).to_java_bytes
|
@@ -28,11 +48,106 @@ module Pacer::Orient
|
|
28
48
|
end
|
29
49
|
|
30
50
|
def self.decode_property(value)
|
31
|
-
|
32
|
-
|
51
|
+
case value
|
52
|
+
when ArrayJavaProxy
|
53
|
+
if value[0] == 4 and value[1] == 8
|
54
|
+
begin
|
55
|
+
Marshal.load String.from_java_bytes(value)
|
56
|
+
rescue TypeError
|
57
|
+
value
|
58
|
+
end
|
59
|
+
else
|
60
|
+
value
|
61
|
+
end
|
62
|
+
when JavaDate
|
63
|
+
Time.at(value.getTime() / 1000.0).utc
|
64
|
+
when Time
|
65
|
+
value.utc
|
66
|
+
when JavaSet
|
67
|
+
s = Set[]
|
68
|
+
value.each do |v|
|
69
|
+
s.add decode_property(v)
|
70
|
+
end
|
71
|
+
s
|
72
|
+
when JavaMap
|
73
|
+
h = {}
|
74
|
+
value.each do |k, v|
|
75
|
+
h[decode_property(k)] = decode_property(v)
|
76
|
+
end
|
77
|
+
h
|
78
|
+
when JavaList
|
79
|
+
a = []
|
80
|
+
value.each do |v|
|
81
|
+
a.push decode_property(v)
|
82
|
+
end
|
83
|
+
a
|
33
84
|
else
|
34
85
|
value
|
35
86
|
end
|
36
87
|
end
|
37
88
|
end
|
89
|
+
|
90
|
+
|
91
|
+
# This is an alternate encoder that uses a binary representation of Dates and DateTimes that allows the database to return the correct type and has
|
92
|
+
# much better handling of timezones than the standard approach which turns all dates into basic java.util.Date objects.
|
93
|
+
class BinaryDateEncoder
|
94
|
+
JavaDate = java.util.Date
|
95
|
+
|
96
|
+
def self.encode_property(value)
|
97
|
+
case value
|
98
|
+
when DateTime, Time, JavaDate
|
99
|
+
f = if value.is_a? JavaDate
|
100
|
+
value.getTime / 1000.0
|
101
|
+
else
|
102
|
+
value.to_time.to_f
|
103
|
+
end
|
104
|
+
i = f.truncate
|
105
|
+
r = (f.remainder(1) * 10000).round
|
106
|
+
if value.is_a? DateTime
|
107
|
+
c = 1
|
108
|
+
elsif value.is_a? Time and value.utc?
|
109
|
+
c = 2
|
110
|
+
else
|
111
|
+
c = 3
|
112
|
+
end
|
113
|
+
["D", i, r, c].pack("ANnc").to_java_bytes
|
114
|
+
when Date
|
115
|
+
["D", value.to_time.to_i].pack("AN").to_java_bytes
|
116
|
+
else
|
117
|
+
Encoder.encode_property(value)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.decode_property(value)
|
122
|
+
case value
|
123
|
+
when ArrayJavaProxy
|
124
|
+
str = String.from_java_bytes(value)
|
125
|
+
flag = str[0]
|
126
|
+
case flag
|
127
|
+
when 'D'
|
128
|
+
data = str.unpack("ANnc")
|
129
|
+
i = data[1]
|
130
|
+
r = data[2]
|
131
|
+
c = data[3]
|
132
|
+
if r
|
133
|
+
t = Time.at(i + (r / 10000.0))
|
134
|
+
case c
|
135
|
+
when 1
|
136
|
+
t.utc.to_datetime
|
137
|
+
when 2
|
138
|
+
t.utc
|
139
|
+
else
|
140
|
+
t
|
141
|
+
end
|
142
|
+
else
|
143
|
+
Time.at(i).utc.to_date
|
144
|
+
end
|
145
|
+
else
|
146
|
+
Encoder.decode_property value
|
147
|
+
end
|
148
|
+
else
|
149
|
+
Encoder.decode_property value
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
38
153
|
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,8 +1,68 @@
|
|
1
1
|
require 'set'
|
2
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'
|
8
|
+
|
3
9
|
module Pacer
|
4
10
|
module Orient
|
5
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
|
+
|
6
66
|
def orient_graph
|
7
67
|
blueprints_graph.raw_graph
|
8
68
|
end
|
@@ -33,22 +93,149 @@ module Pacer
|
|
33
93
|
def drop_handler(h)
|
34
94
|
# todo
|
35
95
|
end
|
36
|
-
end
|
37
96
|
|
38
|
-
|
39
|
-
|
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 = 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 = 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
|
+
unless args.frozen?
|
145
|
+
args = args.map { |a| encoder.encode_property(a) }
|
146
|
+
end
|
147
|
+
blueprints_graph.command(OCommandSQL.new(sql)).execute(*args)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Find or create a vertex or edge class
|
151
|
+
def orient_type!(t, element_type = :vertex)
|
152
|
+
r = orient_type(t, element_type)
|
153
|
+
if r
|
154
|
+
r
|
155
|
+
else
|
156
|
+
in_pure_transaction do
|
157
|
+
t = if element_type == :vertex
|
158
|
+
blueprints_graph.createVertexType(t.to_s)
|
159
|
+
elsif element_type == :edge
|
160
|
+
blueprints_graph.createEdgeType(t.to_s)
|
161
|
+
end
|
162
|
+
OrientType.new self, element_type, t if t
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
40
166
|
|
41
|
-
def
|
42
|
-
|
167
|
+
def orient_type(t = nil, element_type = :vertex)
|
168
|
+
t ||= :V if element_type == :vertex
|
169
|
+
t ||= :E if element_type == :edge
|
170
|
+
if t.is_a? String or t.is_a? Symbol
|
171
|
+
t = if element_type == :vertex
|
172
|
+
blueprints_graph.getVertexType(t.to_s)
|
173
|
+
elsif element_type == :edge
|
174
|
+
blueprints_graph.getEdgeType(t.to_s)
|
175
|
+
end
|
176
|
+
OrientType.new self, element_type, t if t
|
177
|
+
elsif t.is_a? OrientType
|
178
|
+
t
|
179
|
+
end
|
43
180
|
end
|
44
181
|
|
45
|
-
def
|
46
|
-
|
182
|
+
def property_type(t)
|
183
|
+
if t.is_a? String or t.is_a? Symbol
|
184
|
+
OTYPES[t.to_sym]
|
185
|
+
else
|
186
|
+
t
|
187
|
+
end
|
47
188
|
end
|
48
189
|
|
49
|
-
|
50
|
-
|
51
|
-
|
190
|
+
def index_type(t)
|
191
|
+
if t.is_a? String or t.is_a? Symbol
|
192
|
+
ITYPES[t.to_sym]
|
193
|
+
else
|
194
|
+
t
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def add_vertex_types(*types)
|
199
|
+
in_pure_transaction do
|
200
|
+
types.map do |t|
|
201
|
+
existing = orient_type(t, :vertex)
|
202
|
+
if existing
|
203
|
+
existing
|
204
|
+
else
|
205
|
+
t = blueprints_graph.createVertexType(t.to_s)
|
206
|
+
OrientType.new(self, :vertex, t) if t
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def create_key_index(name, element_type = :vertex, itype = :non_unique)
|
213
|
+
type = orient_type(nil, element_type)
|
214
|
+
type.property!(name).create_index!(itype) if type
|
215
|
+
end
|
216
|
+
|
217
|
+
def drop_key_index(name, element_type = :vertex)
|
218
|
+
in_pure_transaction do
|
219
|
+
super
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
private
|
224
|
+
|
225
|
+
def in_pure_transaction
|
226
|
+
if @in_pure_transaction
|
227
|
+
yield
|
228
|
+
else
|
229
|
+
begin
|
230
|
+
@in_pure_transaction = true
|
231
|
+
transaction do
|
232
|
+
orient_graph.rollback
|
233
|
+
yield
|
234
|
+
end
|
235
|
+
ensure
|
236
|
+
@in_pure_transaction = false
|
237
|
+
end
|
238
|
+
end
|
52
239
|
end
|
53
240
|
end
|
54
241
|
end
|
@@ -0,0 +1,88 @@
|
|
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 indexed?(name)
|
36
|
+
p = property(name)
|
37
|
+
p.indexed? if p
|
38
|
+
end
|
39
|
+
|
40
|
+
def property(name)
|
41
|
+
p = raw_property(name)
|
42
|
+
Property.new self, p if p
|
43
|
+
end
|
44
|
+
|
45
|
+
def property!(name, otype)
|
46
|
+
p = raw_property(name)
|
47
|
+
unless p
|
48
|
+
p = graph.send(:in_pure_transaction) do
|
49
|
+
type.createProperty(name.to_s, graph.property_type(otype))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
Property.new self, p
|
53
|
+
end
|
54
|
+
|
55
|
+
def super_class
|
56
|
+
if base_classes.any?
|
57
|
+
OrientType.new graph, type.getSuperClass
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_super_class(sc)
|
62
|
+
graph.send(:in_pure_transaction) do
|
63
|
+
type.setSuperClass graph.orient_type(element_type, sc)
|
64
|
+
end
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
def drop_property!(name)
|
69
|
+
graph.send(:in_pure_transaction) do
|
70
|
+
type.dropProperty name
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def properties
|
75
|
+
type.properties.map { |p| Property.new self, p }
|
76
|
+
end
|
77
|
+
|
78
|
+
def indexed_properties
|
79
|
+
type.indexedProperties.map { |p| Property.new self, p }
|
80
|
+
end
|
81
|
+
|
82
|
+
def inspect
|
83
|
+
abs = "Abstract" if abstract?
|
84
|
+
strict = " (strict)" if strict_mode?
|
85
|
+
"#<#{ abs }#{ type_name.capitalize }Type #{ name }#{ strict }>"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
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,17 +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
|
-
|
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)
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
data/lib/pacer-orient/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Pacer
|
2
2
|
module Orient
|
3
|
-
VERSION = "2.1.
|
3
|
+
VERSION = "2.1.1"
|
4
4
|
JAR = "pacer-orient-#{ VERSION }-standalone.jar"
|
5
5
|
JAR_PATH = "lib/#{ JAR }"
|
6
6
|
ORIENT_VERSION = "1.7.8"
|
7
7
|
PIPES_VERSION = "2.5.0"
|
8
|
-
PACER_REQ = ">= 1.5.
|
8
|
+
PACER_REQ = ">= 1.5.2"
|
9
9
|
end
|
10
10
|
end
|
data/pom.xml
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
<!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-orient/version.rb -->
|
9
9
|
<properties>
|
10
10
|
<orient.version>1.7.8</orient.version>
|
11
|
-
<gem.version>2.1.
|
11
|
+
<gem.version>2.1.1</gem.version>
|
12
12
|
<pipes.version>2.5.0</pipes.version>
|
13
13
|
</properties>
|
14
14
|
<!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-orient/version.rb -->
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pacer-orient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Darrick Wiebe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pacer
|
@@ -16,12 +16,12 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.5.
|
19
|
+
version: 1.5.2
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
22
|
- - '>='
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.5.
|
24
|
+
version: 1.5.2
|
25
25
|
prerelease: false
|
26
26
|
type: :runtime
|
27
27
|
description: Orient jars and related code for Pacer
|
@@ -37,13 +37,17 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- lib/pacer-orient.rb
|
39
39
|
- lib/pacer-orient/encoder.rb
|
40
|
+
- lib/pacer-orient/factory_container.rb
|
40
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
|
41
45
|
- lib/pacer-orient/rspec.rb
|
42
46
|
- lib/pacer-orient/version.rb
|
43
47
|
- pacer-orient.gemspec
|
44
48
|
- pom.xml
|
45
49
|
- pom/standalone.xml
|
46
|
-
- lib/pacer-orient-2.1.
|
50
|
+
- lib/pacer-orient-2.1.1-standalone.jar
|
47
51
|
homepage: http://orientechnologies.com
|
48
52
|
licenses: []
|
49
53
|
metadata: {}
|
@@ -58,9 +62,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
62
|
version: '0'
|
59
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
64
|
requirements:
|
61
|
-
- - '
|
65
|
+
- - '>='
|
62
66
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
67
|
+
version: '0'
|
64
68
|
requirements: []
|
65
69
|
rubyforge_project: pacer-orient
|
66
70
|
rubygems_version: 2.1.9
|