flockdb 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flockdb}
8
- s.version = "0.4.2"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Freels", "Rael Dornfest", "Nick Kallen"]
12
- s.date = %q{2011-02-28}
12
+ s.date = %q{2010-10-19}
13
13
  s.description = %q{Get your flock on in Ruby.}
14
14
  s.email = %q{freels@twitter.com}
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,9 @@ Gem::Specification.new do |s|
25
25
  "flockdb.gemspec",
26
26
  "lib/flock.rb",
27
27
  "lib/flock/client.rb",
28
+ "lib/flock/gen-rb/flock_d_b.rb",
29
+ "lib/flock/gen-rb/flockdb_constants.rb",
30
+ "lib/flock/gen-rb/flockdb_types.rb",
28
31
  "lib/flock/mixins/sizeable.rb",
29
32
  "lib/flock/mock_service.rb",
30
33
  "lib/flock/operation.rb",
@@ -35,11 +38,7 @@ Gem::Specification.new do |s|
35
38
  "lib/flock/operations/select_operation.rb",
36
39
  "lib/flock/operations/simple_operation.rb",
37
40
  "lib/flock/service.rb",
38
- "lib/flock/thrift/edges.rb",
39
- "lib/flock/thrift/edges_types.rb",
40
- "lib/flock/thrift/flock_constants.rb",
41
- "lib/flock/thrift/flock_types.rb",
42
- "lib/flock/thrift/shards.rb",
41
+ "lib/flock/thrift.rb",
43
42
  "lib/flockdb.rb",
44
43
  "spec/execute_operations_spec.rb",
45
44
  "spec/flock_spec.rb",
@@ -5,11 +5,13 @@ require 'thrift_client'
5
5
  require 'flock/mixins/sizeable'
6
6
 
7
7
  # thrift sources. load order is important.
8
- require 'flock/thrift/flock_types'
9
- require 'flock/thrift/flock_constants'
10
- require 'flock/thrift/shards'
11
- require 'flock/thrift/edges_types'
12
- require 'flock/thrift/edges'
8
+ module Flock
9
+ module Edges
10
+ module FlockDB
11
+ end
12
+ end
13
+ end
14
+ require 'flock/thrift'
13
15
 
14
16
  require 'flock/operation'
15
17
  require 'flock/operations/query_term'
@@ -24,6 +26,13 @@ require 'flock/client'
24
26
  module Flock
25
27
  autoload :MockService, 'flock/mock_service'
26
28
 
29
+ FlockException = Edges::FlockException
30
+ Priority = Edges::Priority
31
+ CursorStart = -1
32
+ CursorEnd = 0
33
+ Page = Edges::Page
34
+ Results = Edges::Results
35
+
27
36
  class UnknownGraphError < FlockException
28
37
  def initialize(graph)
29
38
  super("Unable to look up id for graph #{graph.inspect}. Register graphs with Flock.graphs = <graph list>.")
@@ -94,7 +94,7 @@ class Flock::Client
94
94
  current_transaction
95
95
  end
96
96
 
97
- result = yield self
97
+ result = yield self if block.arity == 1
98
98
  ops.apply if new_transaction
99
99
  result
100
100
 
@@ -0,0 +1,523 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'flockdb_types'
9
+
10
+ module Flock
11
+ module Edges
12
+ module FlockDB
13
+ class Client
14
+ include ::Thrift::Client
15
+
16
+ def contains(source_id, graph_id, destination_id)
17
+ send_contains(source_id, graph_id, destination_id)
18
+ return recv_contains()
19
+ end
20
+
21
+ def send_contains(source_id, graph_id, destination_id)
22
+ send_message('contains', Contains_args, :source_id => source_id, :graph_id => graph_id, :destination_id => destination_id)
23
+ end
24
+
25
+ def recv_contains()
26
+ result = receive_message(Contains_result)
27
+ return result.success unless result.success.nil?
28
+ raise result.ex unless result.ex.nil?
29
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'contains failed: unknown result')
30
+ end
31
+
32
+ def get(source_id, graph_id, destination_id)
33
+ send_get(source_id, graph_id, destination_id)
34
+ return recv_get()
35
+ end
36
+
37
+ def send_get(source_id, graph_id, destination_id)
38
+ send_message('get', Get_args, :source_id => source_id, :graph_id => graph_id, :destination_id => destination_id)
39
+ end
40
+
41
+ def recv_get()
42
+ result = receive_message(Get_result)
43
+ return result.success unless result.success.nil?
44
+ raise result.ex unless result.ex.nil?
45
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get failed: unknown result')
46
+ end
47
+
48
+ def select2(queries)
49
+ send_select2(queries)
50
+ return recv_select2()
51
+ end
52
+
53
+ def send_select2(queries)
54
+ send_message('select2', Select2_args, :queries => queries)
55
+ end
56
+
57
+ def recv_select2()
58
+ result = receive_message(Select2_result)
59
+ return result.success unless result.success.nil?
60
+ raise result.ex unless result.ex.nil?
61
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'select2 failed: unknown result')
62
+ end
63
+
64
+ def count2(queries)
65
+ send_count2(queries)
66
+ return recv_count2()
67
+ end
68
+
69
+ def send_count2(queries)
70
+ send_message('count2', Count2_args, :queries => queries)
71
+ end
72
+
73
+ def recv_count2()
74
+ result = receive_message(Count2_result)
75
+ return result.success unless result.success.nil?
76
+ raise result.ex unless result.ex.nil?
77
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'count2 failed: unknown result')
78
+ end
79
+
80
+ def select_edges(queries)
81
+ send_select_edges(queries)
82
+ return recv_select_edges()
83
+ end
84
+
85
+ def send_select_edges(queries)
86
+ send_message('select_edges', Select_edges_args, :queries => queries)
87
+ end
88
+
89
+ def recv_select_edges()
90
+ result = receive_message(Select_edges_result)
91
+ return result.success unless result.success.nil?
92
+ raise result.ex unless result.ex.nil?
93
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'select_edges failed: unknown result')
94
+ end
95
+
96
+ def execute(operations)
97
+ send_execute(operations)
98
+ recv_execute()
99
+ end
100
+
101
+ def send_execute(operations)
102
+ send_message('execute', Execute_args, :operations => operations)
103
+ end
104
+
105
+ def recv_execute()
106
+ result = receive_message(Execute_result)
107
+ raise result.ex unless result.ex.nil?
108
+ return
109
+ end
110
+
111
+ def count(operations)
112
+ send_count(operations)
113
+ return recv_count()
114
+ end
115
+
116
+ def send_count(operations)
117
+ send_message('count', Count_args, :operations => operations)
118
+ end
119
+
120
+ def recv_count()
121
+ result = receive_message(Count_result)
122
+ return result.success unless result.success.nil?
123
+ raise result.ex unless result.ex.nil?
124
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'count failed: unknown result')
125
+ end
126
+
127
+ def select(operations, page)
128
+ send_select(operations, page)
129
+ return recv_select()
130
+ end
131
+
132
+ def send_select(operations, page)
133
+ send_message('select', Select_args, :operations => operations, :page => page)
134
+ end
135
+
136
+ def recv_select()
137
+ result = receive_message(Select_result)
138
+ return result.success unless result.success.nil?
139
+ raise result.ex unless result.ex.nil?
140
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'select failed: unknown result')
141
+ end
142
+
143
+ end
144
+
145
+ class Processor
146
+ include ::Thrift::Processor
147
+
148
+ def process_contains(seqid, iprot, oprot)
149
+ args = read_args(iprot, Contains_args)
150
+ result = Contains_result.new()
151
+ begin
152
+ result.success = @handler.contains(args.source_id, args.graph_id, args.destination_id)
153
+ rescue Flock::Edges::FlockException => ex
154
+ result.ex = ex
155
+ end
156
+ write_result(result, oprot, 'contains', seqid)
157
+ end
158
+
159
+ def process_get(seqid, iprot, oprot)
160
+ args = read_args(iprot, Get_args)
161
+ result = Get_result.new()
162
+ begin
163
+ result.success = @handler.get(args.source_id, args.graph_id, args.destination_id)
164
+ rescue Flock::Edges::FlockException => ex
165
+ result.ex = ex
166
+ end
167
+ write_result(result, oprot, 'get', seqid)
168
+ end
169
+
170
+ def process_select2(seqid, iprot, oprot)
171
+ args = read_args(iprot, Select2_args)
172
+ result = Select2_result.new()
173
+ begin
174
+ result.success = @handler.select2(args.queries)
175
+ rescue Flock::Edges::FlockException => ex
176
+ result.ex = ex
177
+ end
178
+ write_result(result, oprot, 'select2', seqid)
179
+ end
180
+
181
+ def process_count2(seqid, iprot, oprot)
182
+ args = read_args(iprot, Count2_args)
183
+ result = Count2_result.new()
184
+ begin
185
+ result.success = @handler.count2(args.queries)
186
+ rescue Flock::Edges::FlockException => ex
187
+ result.ex = ex
188
+ end
189
+ write_result(result, oprot, 'count2', seqid)
190
+ end
191
+
192
+ def process_select_edges(seqid, iprot, oprot)
193
+ args = read_args(iprot, Select_edges_args)
194
+ result = Select_edges_result.new()
195
+ begin
196
+ result.success = @handler.select_edges(args.queries)
197
+ rescue Flock::Edges::FlockException => ex
198
+ result.ex = ex
199
+ end
200
+ write_result(result, oprot, 'select_edges', seqid)
201
+ end
202
+
203
+ def process_execute(seqid, iprot, oprot)
204
+ args = read_args(iprot, Execute_args)
205
+ result = Execute_result.new()
206
+ begin
207
+ @handler.execute(args.operations)
208
+ rescue Flock::Edges::FlockException => ex
209
+ result.ex = ex
210
+ end
211
+ write_result(result, oprot, 'execute', seqid)
212
+ end
213
+
214
+ def process_count(seqid, iprot, oprot)
215
+ args = read_args(iprot, Count_args)
216
+ result = Count_result.new()
217
+ begin
218
+ result.success = @handler.count(args.operations)
219
+ rescue Flock::Edges::FlockException => ex
220
+ result.ex = ex
221
+ end
222
+ write_result(result, oprot, 'count', seqid)
223
+ end
224
+
225
+ def process_select(seqid, iprot, oprot)
226
+ args = read_args(iprot, Select_args)
227
+ result = Select_result.new()
228
+ begin
229
+ result.success = @handler.select(args.operations, args.page)
230
+ rescue Flock::Edges::FlockException => ex
231
+ result.ex = ex
232
+ end
233
+ write_result(result, oprot, 'select', seqid)
234
+ end
235
+
236
+ end
237
+
238
+ # HELPER FUNCTIONS AND STRUCTURES
239
+
240
+ class Contains_args
241
+ include ::Thrift::Struct
242
+ SOURCE_ID = 1
243
+ GRAPH_ID = 2
244
+ DESTINATION_ID = 3
245
+
246
+ ::Thrift::Struct.field_accessor self, :source_id, :graph_id, :destination_id
247
+ FIELDS = {
248
+ SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
249
+ GRAPH_ID => {:type => ::Thrift::Types::I32, :name => 'graph_id'},
250
+ DESTINATION_ID => {:type => ::Thrift::Types::I64, :name => 'destination_id'}
251
+ }
252
+
253
+ def struct_fields; FIELDS; end
254
+
255
+ def validate
256
+ end
257
+
258
+ end
259
+
260
+ class Contains_result
261
+ include ::Thrift::Struct
262
+ SUCCESS = 0
263
+ EX = 1
264
+
265
+ ::Thrift::Struct.field_accessor self, :success, :ex
266
+ FIELDS = {
267
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'},
268
+ EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
269
+ }
270
+
271
+ def struct_fields; FIELDS; end
272
+
273
+ def validate
274
+ end
275
+
276
+ end
277
+
278
+ class Get_args
279
+ include ::Thrift::Struct
280
+ SOURCE_ID = 1
281
+ GRAPH_ID = 2
282
+ DESTINATION_ID = 3
283
+
284
+ ::Thrift::Struct.field_accessor self, :source_id, :graph_id, :destination_id
285
+ FIELDS = {
286
+ SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
287
+ GRAPH_ID => {:type => ::Thrift::Types::I32, :name => 'graph_id'},
288
+ DESTINATION_ID => {:type => ::Thrift::Types::I64, :name => 'destination_id'}
289
+ }
290
+
291
+ def struct_fields; FIELDS; end
292
+
293
+ def validate
294
+ end
295
+
296
+ end
297
+
298
+ class Get_result
299
+ include ::Thrift::Struct
300
+ SUCCESS = 0
301
+ EX = 1
302
+
303
+ ::Thrift::Struct.field_accessor self, :success, :ex
304
+ FIELDS = {
305
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Flock::Edges::Edge},
306
+ EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
307
+ }
308
+
309
+ def struct_fields; FIELDS; end
310
+
311
+ def validate
312
+ end
313
+
314
+ end
315
+
316
+ class Select2_args
317
+ include ::Thrift::Struct
318
+ QUERIES = 1
319
+
320
+ ::Thrift::Struct.field_accessor self, :queries
321
+ FIELDS = {
322
+ QUERIES => {:type => ::Thrift::Types::LIST, :name => 'queries', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectQuery}}
323
+ }
324
+
325
+ def struct_fields; FIELDS; end
326
+
327
+ def validate
328
+ end
329
+
330
+ end
331
+
332
+ class Select2_result
333
+ include ::Thrift::Struct
334
+ SUCCESS = 0
335
+ EX = 1
336
+
337
+ ::Thrift::Struct.field_accessor self, :success, :ex
338
+ FIELDS = {
339
+ SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::Results}},
340
+ EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
341
+ }
342
+
343
+ def struct_fields; FIELDS; end
344
+
345
+ def validate
346
+ end
347
+
348
+ end
349
+
350
+ class Count2_args
351
+ include ::Thrift::Struct
352
+ QUERIES = 1
353
+
354
+ ::Thrift::Struct.field_accessor self, :queries
355
+ FIELDS = {
356
+ QUERIES => {:type => ::Thrift::Types::LIST, :name => 'queries', :element => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectOperation}}}
357
+ }
358
+
359
+ def struct_fields; FIELDS; end
360
+
361
+ def validate
362
+ end
363
+
364
+ end
365
+
366
+ class Count2_result
367
+ include ::Thrift::Struct
368
+ SUCCESS = 0
369
+ EX = 1
370
+
371
+ ::Thrift::Struct.field_accessor self, :success, :ex
372
+ FIELDS = {
373
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'},
374
+ EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
375
+ }
376
+
377
+ def struct_fields; FIELDS; end
378
+
379
+ def validate
380
+ end
381
+
382
+ end
383
+
384
+ class Select_edges_args
385
+ include ::Thrift::Struct
386
+ QUERIES = 1
387
+
388
+ ::Thrift::Struct.field_accessor self, :queries
389
+ FIELDS = {
390
+ QUERIES => {:type => ::Thrift::Types::LIST, :name => 'queries', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::EdgeQuery}}
391
+ }
392
+
393
+ def struct_fields; FIELDS; end
394
+
395
+ def validate
396
+ end
397
+
398
+ end
399
+
400
+ class Select_edges_result
401
+ include ::Thrift::Struct
402
+ SUCCESS = 0
403
+ EX = 1
404
+
405
+ ::Thrift::Struct.field_accessor self, :success, :ex
406
+ FIELDS = {
407
+ SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::EdgeResults}},
408
+ EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
409
+ }
410
+
411
+ def struct_fields; FIELDS; end
412
+
413
+ def validate
414
+ end
415
+
416
+ end
417
+
418
+ class Execute_args
419
+ include ::Thrift::Struct
420
+ OPERATIONS = 1
421
+
422
+ ::Thrift::Struct.field_accessor self, :operations
423
+ FIELDS = {
424
+ OPERATIONS => {:type => ::Thrift::Types::STRUCT, :name => 'operations', :class => Flock::Edges::ExecuteOperations}
425
+ }
426
+
427
+ def struct_fields; FIELDS; end
428
+
429
+ def validate
430
+ end
431
+
432
+ end
433
+
434
+ class Execute_result
435
+ include ::Thrift::Struct
436
+ EX = 1
437
+
438
+ ::Thrift::Struct.field_accessor self, :ex
439
+ FIELDS = {
440
+ EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
441
+ }
442
+
443
+ def struct_fields; FIELDS; end
444
+
445
+ def validate
446
+ end
447
+
448
+ end
449
+
450
+ class Count_args
451
+ include ::Thrift::Struct
452
+ OPERATIONS = 1
453
+
454
+ ::Thrift::Struct.field_accessor self, :operations
455
+ FIELDS = {
456
+ OPERATIONS => {:type => ::Thrift::Types::LIST, :name => 'operations', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectOperation}}
457
+ }
458
+
459
+ def struct_fields; FIELDS; end
460
+
461
+ def validate
462
+ end
463
+
464
+ end
465
+
466
+ class Count_result
467
+ include ::Thrift::Struct
468
+ SUCCESS = 0
469
+ EX = 1
470
+
471
+ ::Thrift::Struct.field_accessor self, :success, :ex
472
+ FIELDS = {
473
+ SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'},
474
+ EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
475
+ }
476
+
477
+ def struct_fields; FIELDS; end
478
+
479
+ def validate
480
+ end
481
+
482
+ end
483
+
484
+ class Select_args
485
+ include ::Thrift::Struct
486
+ OPERATIONS = 1
487
+ PAGE = 2
488
+
489
+ ::Thrift::Struct.field_accessor self, :operations, :page
490
+ FIELDS = {
491
+ OPERATIONS => {:type => ::Thrift::Types::LIST, :name => 'operations', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectOperation}},
492
+ PAGE => {:type => ::Thrift::Types::STRUCT, :name => 'page', :class => Flock::Edges::Page}
493
+ }
494
+
495
+ def struct_fields; FIELDS; end
496
+
497
+ def validate
498
+ end
499
+
500
+ end
501
+
502
+ class Select_result
503
+ include ::Thrift::Struct
504
+ SUCCESS = 0
505
+ EX = 1
506
+
507
+ ::Thrift::Struct.field_accessor self, :success, :ex
508
+ FIELDS = {
509
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Flock::Edges::Results},
510
+ EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
511
+ }
512
+
513
+ def struct_fields; FIELDS; end
514
+
515
+ def validate
516
+ end
517
+
518
+ end
519
+
520
+ end
521
+
522
+ end
523
+ end