rebat 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/rebat.rb +23 -0
- data/lib/rebat/client.rb +81 -0
- data/lib/rebat/selector.rb +54 -0
- data/lib/rebat/thrift/rebat_constants.rb +12 -0
- data/lib/rebat/thrift/rebat_d_b.rb +246 -0
- data/lib/rebat/thrift/rebat_types.rb +68 -0
- data/lib/rebat/version.rb +3 -0
- data/rebat.gemspec +19 -0
- metadata +72 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3-p125@rebatdb
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Omar Mekky
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Rebat
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rebat'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rebat
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/rebat.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'thrift'
|
2
|
+
|
3
|
+
# thrift sources. load order is important.
|
4
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), 'rebat', 'thrift')
|
5
|
+
|
6
|
+
require 'rebat/thrift/rebat_d_b'
|
7
|
+
require 'rebat/thrift/rebat_constants'
|
8
|
+
require 'rebat/thrift/rebat_types'
|
9
|
+
|
10
|
+
require 'rebat/version'
|
11
|
+
|
12
|
+
module Rebat
|
13
|
+
autoload :Selector, 'rebat/selector'
|
14
|
+
autoload :Client, 'rebat/client'
|
15
|
+
|
16
|
+
class << self
|
17
|
+
attr_accessor :relations
|
18
|
+
|
19
|
+
def new(*args)
|
20
|
+
Rebat::Client.new(*args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/rebat/client.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
class Rebat::Client
|
2
|
+
def initialize(host, port, relations)
|
3
|
+
@transport = Thrift::BufferedTransport.new(Thrift::Socket.new(host, port))
|
4
|
+
@protocol = Thrift::BinaryProtocol.new(@transport)
|
5
|
+
@client = Rebat::Thrift::RebatDB::Client.new(@protocol)
|
6
|
+
|
7
|
+
@transport.open
|
8
|
+
end
|
9
|
+
|
10
|
+
def send(&block)
|
11
|
+
begin
|
12
|
+
@transport.open unless @transport.open?
|
13
|
+
yield @client
|
14
|
+
rescue Thrift::Exception => tx
|
15
|
+
print 'Thrift::Exception: ', tx.message, "\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def close
|
20
|
+
@transport.close
|
21
|
+
end
|
22
|
+
|
23
|
+
def add(from_entity_id, from_entity_type, to_entity_id, to_entity_type, weight, relation_id)
|
24
|
+
edge = Rebat::Thrift::Edge.new
|
25
|
+
|
26
|
+
edge.fromEntityId = from_entity_id
|
27
|
+
edge.fromEntityType = from_entity_type
|
28
|
+
edge.toEntityId = to_entity_id
|
29
|
+
edge.toEntityType = to_entity_type
|
30
|
+
edge.weight = weight
|
31
|
+
edge.relationId = relation_id
|
32
|
+
|
33
|
+
self.send do |client|
|
34
|
+
client.addQuery(edge)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def updateWeight(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id, new_weight)
|
39
|
+
edge = Rebat::Thrift::Edge.new
|
40
|
+
|
41
|
+
edge.fromEntityId = from_entity_id
|
42
|
+
edge.fromEntityType = from_entity_type
|
43
|
+
edge.toEntityId = to_entity_id
|
44
|
+
edge.toEntityType = to_entity_type
|
45
|
+
edge.relationId = relation_id
|
46
|
+
|
47
|
+
self.send do |client|
|
48
|
+
client.updateWeightQuery(edge, new_weight)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def delete(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id)
|
53
|
+
edge = Rebat::Thrift::Edge.new
|
54
|
+
|
55
|
+
edge.fromEntityId = from_entity_id
|
56
|
+
edge.fromEntityType = from_entity_type
|
57
|
+
edge.toEntityId = to_entity_id
|
58
|
+
edge.toEntityType = to_entity_type
|
59
|
+
edge.relationId = relation_id
|
60
|
+
|
61
|
+
self.send do |client|
|
62
|
+
client.deleteQuery(edge)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def where(*args)
|
67
|
+
Rebat::Selector.new(self).where *args
|
68
|
+
end
|
69
|
+
|
70
|
+
def union(*args)
|
71
|
+
Rebat::Selector.new(self).union *args
|
72
|
+
end
|
73
|
+
|
74
|
+
def intersect(*args)
|
75
|
+
Rebat::Selector.new(self).intersect *args
|
76
|
+
end
|
77
|
+
|
78
|
+
def exclude(*args)
|
79
|
+
Rebat::Selector.new(self).exclude *args
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Rebat::Selector
|
2
|
+
attr_reader :client
|
3
|
+
|
4
|
+
def initialize(client)
|
5
|
+
@client = client
|
6
|
+
@query_list = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def where(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id)
|
10
|
+
@query_list << create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id, Rebat::Thrift::QueryType::WHERE)
|
11
|
+
return self
|
12
|
+
end
|
13
|
+
|
14
|
+
def union(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id)
|
15
|
+
@query_list << create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id, Rebat::Thrift::QueryType::UNION)
|
16
|
+
return self
|
17
|
+
end
|
18
|
+
|
19
|
+
def intersect(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id)
|
20
|
+
@query_list << create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id, Rebat::Thrift::QueryType::INTERSECT)
|
21
|
+
return self
|
22
|
+
end
|
23
|
+
|
24
|
+
def exclude(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id)
|
25
|
+
@query_list << create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id, Rebat::Thrift::QueryType::EXCLUDE)
|
26
|
+
return self
|
27
|
+
end
|
28
|
+
|
29
|
+
def entries
|
30
|
+
@client.send do |client|
|
31
|
+
return client.selectQuery(@query_list)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
attr_reader :query_list
|
37
|
+
|
38
|
+
def create_query(from_entity_id, from_entity_type, to_entity_id, to_entity_type, relation_id, qtype)
|
39
|
+
edge = Rebat::Thrift::Edge.new
|
40
|
+
|
41
|
+
edge.fromEntityId = from_entity_id unless from_entity_id.nil?
|
42
|
+
edge.fromEntityType = from_entity_type unless from_entity_type.nil?
|
43
|
+
edge.toEntityId = to_entity_id unless to_entity_id.nil?
|
44
|
+
edge.toEntityType = to_entity_type unless to_entity_type.nil?
|
45
|
+
edge.relationId = relation_id
|
46
|
+
|
47
|
+
query = Rebat::Thrift::Query.new
|
48
|
+
|
49
|
+
query.edge = edge
|
50
|
+
query.qtype = qtype
|
51
|
+
|
52
|
+
return query
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.8.0)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
require 'rebat_types'
|
9
|
+
|
10
|
+
module Rebat
|
11
|
+
module Thrift
|
12
|
+
module RebatDB
|
13
|
+
class Client
|
14
|
+
include ::Thrift::Client
|
15
|
+
|
16
|
+
def addQuery(edge)
|
17
|
+
send_addQuery(edge)
|
18
|
+
return recv_addQuery()
|
19
|
+
end
|
20
|
+
|
21
|
+
def send_addQuery(edge)
|
22
|
+
send_message('addQuery', AddQuery_args, :edge => edge)
|
23
|
+
end
|
24
|
+
|
25
|
+
def recv_addQuery()
|
26
|
+
result = receive_message(AddQuery_result)
|
27
|
+
return result.success unless result.success.nil?
|
28
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'addQuery failed: unknown result')
|
29
|
+
end
|
30
|
+
|
31
|
+
def deleteQuery(edge)
|
32
|
+
send_deleteQuery(edge)
|
33
|
+
return recv_deleteQuery()
|
34
|
+
end
|
35
|
+
|
36
|
+
def send_deleteQuery(edge)
|
37
|
+
send_message('deleteQuery', DeleteQuery_args, :edge => edge)
|
38
|
+
end
|
39
|
+
|
40
|
+
def recv_deleteQuery()
|
41
|
+
result = receive_message(DeleteQuery_result)
|
42
|
+
return result.success unless result.success.nil?
|
43
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'deleteQuery failed: unknown result')
|
44
|
+
end
|
45
|
+
|
46
|
+
def updateWeightQuery(edge, weight)
|
47
|
+
send_updateWeightQuery(edge, weight)
|
48
|
+
return recv_updateWeightQuery()
|
49
|
+
end
|
50
|
+
|
51
|
+
def send_updateWeightQuery(edge, weight)
|
52
|
+
send_message('updateWeightQuery', UpdateWeightQuery_args, :edge => edge, :weight => weight)
|
53
|
+
end
|
54
|
+
|
55
|
+
def recv_updateWeightQuery()
|
56
|
+
result = receive_message(UpdateWeightQuery_result)
|
57
|
+
return result.success unless result.success.nil?
|
58
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'updateWeightQuery failed: unknown result')
|
59
|
+
end
|
60
|
+
|
61
|
+
def selectQuery(queryList)
|
62
|
+
send_selectQuery(queryList)
|
63
|
+
return recv_selectQuery()
|
64
|
+
end
|
65
|
+
|
66
|
+
def send_selectQuery(queryList)
|
67
|
+
send_message('selectQuery', SelectQuery_args, :queryList => queryList)
|
68
|
+
end
|
69
|
+
|
70
|
+
def recv_selectQuery()
|
71
|
+
result = receive_message(SelectQuery_result)
|
72
|
+
return result.success unless result.success.nil?
|
73
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'selectQuery failed: unknown result')
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
class Processor
|
79
|
+
include ::Thrift::Processor
|
80
|
+
|
81
|
+
def process_addQuery(seqid, iprot, oprot)
|
82
|
+
args = read_args(iprot, AddQuery_args)
|
83
|
+
result = AddQuery_result.new()
|
84
|
+
result.success = @handler.addQuery(args.edge)
|
85
|
+
write_result(result, oprot, 'addQuery', seqid)
|
86
|
+
end
|
87
|
+
|
88
|
+
def process_deleteQuery(seqid, iprot, oprot)
|
89
|
+
args = read_args(iprot, DeleteQuery_args)
|
90
|
+
result = DeleteQuery_result.new()
|
91
|
+
result.success = @handler.deleteQuery(args.edge)
|
92
|
+
write_result(result, oprot, 'deleteQuery', seqid)
|
93
|
+
end
|
94
|
+
|
95
|
+
def process_updateWeightQuery(seqid, iprot, oprot)
|
96
|
+
args = read_args(iprot, UpdateWeightQuery_args)
|
97
|
+
result = UpdateWeightQuery_result.new()
|
98
|
+
result.success = @handler.updateWeightQuery(args.edge, args.weight)
|
99
|
+
write_result(result, oprot, 'updateWeightQuery', seqid)
|
100
|
+
end
|
101
|
+
|
102
|
+
def process_selectQuery(seqid, iprot, oprot)
|
103
|
+
args = read_args(iprot, SelectQuery_args)
|
104
|
+
result = SelectQuery_result.new()
|
105
|
+
result.success = @handler.selectQuery(args.queryList)
|
106
|
+
write_result(result, oprot, 'selectQuery', seqid)
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
# HELPER FUNCTIONS AND STRUCTURES
|
112
|
+
|
113
|
+
class AddQuery_args
|
114
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
115
|
+
EDGE = 1
|
116
|
+
|
117
|
+
FIELDS = {
|
118
|
+
EDGE => {:type => ::Thrift::Types::STRUCT, :name => 'edge', :class => Rebat::Thrift::Edge}
|
119
|
+
}
|
120
|
+
|
121
|
+
def struct_fields; FIELDS; end
|
122
|
+
|
123
|
+
def validate
|
124
|
+
end
|
125
|
+
|
126
|
+
::Thrift::Struct.generate_accessors self
|
127
|
+
end
|
128
|
+
|
129
|
+
class AddQuery_result
|
130
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
131
|
+
SUCCESS = 0
|
132
|
+
|
133
|
+
FIELDS = {
|
134
|
+
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
|
135
|
+
}
|
136
|
+
|
137
|
+
def struct_fields; FIELDS; end
|
138
|
+
|
139
|
+
def validate
|
140
|
+
end
|
141
|
+
|
142
|
+
::Thrift::Struct.generate_accessors self
|
143
|
+
end
|
144
|
+
|
145
|
+
class DeleteQuery_args
|
146
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
147
|
+
EDGE = 1
|
148
|
+
|
149
|
+
FIELDS = {
|
150
|
+
EDGE => {:type => ::Thrift::Types::STRUCT, :name => 'edge', :class => Rebat::Thrift::Edge}
|
151
|
+
}
|
152
|
+
|
153
|
+
def struct_fields; FIELDS; end
|
154
|
+
|
155
|
+
def validate
|
156
|
+
end
|
157
|
+
|
158
|
+
::Thrift::Struct.generate_accessors self
|
159
|
+
end
|
160
|
+
|
161
|
+
class DeleteQuery_result
|
162
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
163
|
+
SUCCESS = 0
|
164
|
+
|
165
|
+
FIELDS = {
|
166
|
+
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
|
167
|
+
}
|
168
|
+
|
169
|
+
def struct_fields; FIELDS; end
|
170
|
+
|
171
|
+
def validate
|
172
|
+
end
|
173
|
+
|
174
|
+
::Thrift::Struct.generate_accessors self
|
175
|
+
end
|
176
|
+
|
177
|
+
class UpdateWeightQuery_args
|
178
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
179
|
+
EDGE = 1
|
180
|
+
WEIGHT = 2
|
181
|
+
|
182
|
+
FIELDS = {
|
183
|
+
EDGE => {:type => ::Thrift::Types::STRUCT, :name => 'edge', :class => Rebat::Thrift::Edge},
|
184
|
+
WEIGHT => {:type => ::Thrift::Types::I64, :name => 'weight'}
|
185
|
+
}
|
186
|
+
|
187
|
+
def struct_fields; FIELDS; end
|
188
|
+
|
189
|
+
def validate
|
190
|
+
end
|
191
|
+
|
192
|
+
::Thrift::Struct.generate_accessors self
|
193
|
+
end
|
194
|
+
|
195
|
+
class UpdateWeightQuery_result
|
196
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
197
|
+
SUCCESS = 0
|
198
|
+
|
199
|
+
FIELDS = {
|
200
|
+
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
|
201
|
+
}
|
202
|
+
|
203
|
+
def struct_fields; FIELDS; end
|
204
|
+
|
205
|
+
def validate
|
206
|
+
end
|
207
|
+
|
208
|
+
::Thrift::Struct.generate_accessors self
|
209
|
+
end
|
210
|
+
|
211
|
+
class SelectQuery_args
|
212
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
213
|
+
QUERYLIST = 1
|
214
|
+
|
215
|
+
FIELDS = {
|
216
|
+
QUERYLIST => {:type => ::Thrift::Types::LIST, :name => 'queryList', :element => {:type => ::Thrift::Types::STRUCT, :class => Rebat::Thrift::Query}}
|
217
|
+
}
|
218
|
+
|
219
|
+
def struct_fields; FIELDS; end
|
220
|
+
|
221
|
+
def validate
|
222
|
+
end
|
223
|
+
|
224
|
+
::Thrift::Struct.generate_accessors self
|
225
|
+
end
|
226
|
+
|
227
|
+
class SelectQuery_result
|
228
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
229
|
+
SUCCESS = 0
|
230
|
+
|
231
|
+
FIELDS = {
|
232
|
+
SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Rebat::Thrift::Edge}}
|
233
|
+
}
|
234
|
+
|
235
|
+
def struct_fields; FIELDS; end
|
236
|
+
|
237
|
+
def validate
|
238
|
+
end
|
239
|
+
|
240
|
+
::Thrift::Struct.generate_accessors self
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.8.0)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
|
8
|
+
module Rebat
|
9
|
+
module Thrift
|
10
|
+
module QueryType
|
11
|
+
WHERE = 0
|
12
|
+
INTERSECT = 1
|
13
|
+
UNION = 2
|
14
|
+
NOT = 3
|
15
|
+
VALUE_MAP = {0 => "WHERE", 1 => "INTERSECT", 2 => "UNION", 3 => "NOT"}
|
16
|
+
VALID_VALUES = Set.new([WHERE, INTERSECT, UNION, NOT]).freeze
|
17
|
+
end
|
18
|
+
|
19
|
+
class Edge
|
20
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
21
|
+
FROMENTITYID = 1
|
22
|
+
FROMENTITYTYPE = 2
|
23
|
+
TOENTITYID = 3
|
24
|
+
TOENTITYTYPE = 4
|
25
|
+
WEIGHT = 5
|
26
|
+
RELATIONID = 6
|
27
|
+
|
28
|
+
FIELDS = {
|
29
|
+
FROMENTITYID => {:type => ::Thrift::Types::I64, :name => 'fromEntityId', :optional => true},
|
30
|
+
FROMENTITYTYPE => {:type => ::Thrift::Types::STRING, :name => 'fromEntityType', :optional => true},
|
31
|
+
TOENTITYID => {:type => ::Thrift::Types::I64, :name => 'toEntityId', :optional => true},
|
32
|
+
TOENTITYTYPE => {:type => ::Thrift::Types::STRING, :name => 'toEntityType', :optional => true},
|
33
|
+
WEIGHT => {:type => ::Thrift::Types::I64, :name => 'weight', :default => 0, :optional => true},
|
34
|
+
RELATIONID => {:type => ::Thrift::Types::I64, :name => 'relationId', :optional => true}
|
35
|
+
}
|
36
|
+
|
37
|
+
def struct_fields; FIELDS; end
|
38
|
+
|
39
|
+
def validate
|
40
|
+
end
|
41
|
+
|
42
|
+
::Thrift::Struct.generate_accessors self
|
43
|
+
end
|
44
|
+
|
45
|
+
class Query
|
46
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
47
|
+
EDGE = 1
|
48
|
+
QTYPE = 2
|
49
|
+
|
50
|
+
FIELDS = {
|
51
|
+
EDGE => {:type => ::Thrift::Types::STRUCT, :name => 'edge', :class => Rebat::Thrift::Edge},
|
52
|
+
QTYPE => {:type => ::Thrift::Types::I32, :name => 'qtype', :default => 0, :optional => true, :enum_class => Rebat::Thrift::QueryType}
|
53
|
+
}
|
54
|
+
|
55
|
+
def struct_fields; FIELDS; end
|
56
|
+
|
57
|
+
def validate
|
58
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field edge is unset!') unless @edge
|
59
|
+
unless @qtype.nil? || Rebat::Thrift::QueryType::VALID_VALUES.include?(@qtype)
|
60
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field qtype!')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
::Thrift::Struct.generate_accessors self
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
data/rebat.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rebat/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Omar Mekky", "Khaled Gomaa"]
|
6
|
+
gem.email = ["omar.mekky@mashsolvents.com", "khaled.hassan@mashsolvents.com"]
|
7
|
+
gem.description = %q{Rebat DB driver for ruby }
|
8
|
+
gem.summary = %q{Rebat DB driver for ruby }
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rebat"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Rebat::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'thrift', '>= 0.8.0'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rebat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Omar Mekky
|
9
|
+
- Khaled Gomaa
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-09-16 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thrift
|
17
|
+
requirement: &70286233997100 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.8.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70286233997100
|
26
|
+
description: ! 'Rebat DB driver for ruby '
|
27
|
+
email:
|
28
|
+
- omar.mekky@mashsolvents.com
|
29
|
+
- khaled.hassan@mashsolvents.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- .rvmrc
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- lib/rebat.rb
|
41
|
+
- lib/rebat/client.rb
|
42
|
+
- lib/rebat/selector.rb
|
43
|
+
- lib/rebat/thrift/rebat_constants.rb
|
44
|
+
- lib/rebat/thrift/rebat_d_b.rb
|
45
|
+
- lib/rebat/thrift/rebat_types.rb
|
46
|
+
- lib/rebat/version.rb
|
47
|
+
- rebat.gemspec
|
48
|
+
homepage: ''
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.17
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Rebat DB driver for ruby
|
72
|
+
test_files: []
|