rethinkdb 1.2.0.1

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.
@@ -0,0 +1,137 @@
1
+ # Copyright 2010-2012 RethinkDB, all rights reserved.
2
+ module RethinkDB
3
+ module RQL_Protob_Mixin
4
+ include P_Mixin
5
+ @@token = 0 # We need a new token every time we compile a query
6
+ @@backtrace = []
7
+
8
+ # Right now the only special case is :compare, but in general we might have
9
+ # terms that don't follow the conventions and we need a place to store that.
10
+ def handle_special_cases(message, query_type, query_args)
11
+ #PP.pp ["special_case", message, query_type, query_args]
12
+ case query_type
13
+ when :compare then
14
+ message.comparison = enum_type(Builtin::Comparison, *query_args)
15
+ throw :unknown_comparator_error if not message.comparison
16
+ return true
17
+ else return false
18
+ end
19
+ end
20
+
21
+ ################################################################################
22
+ # I apologize for the code after this. I was originally doing something
23
+ # clever to generate the S-expressions, so they don't always match the
24
+ # protobufs perfectly, and the complexity necessary to handle that got
25
+ # pushed down into protobuf compilation. Later the cleverness went away,
26
+ # but I left the code below intact rather than refactoring for two reasons:
27
+ # 1) It's fragile and took about a day to get right, so refactoring it
28
+ # probably isn't free.
29
+ # 2) We are probably going to have to change protobuf implementations for
30
+ # speed reasons anyway, at which point this will have to be rewritten,
31
+ # and rewriting it twice doesn't make sense
32
+ ################################################################################
33
+
34
+ # Compile an RQL query into a protobuf.
35
+ def comp(message_class, args, repeating=false)
36
+ # H4x to make the backtraces print right until we fix the protobuf.
37
+ message_class = S.rewrite(message_class);
38
+ #PP.pp(["A", message_class, args, repeating]) #DEBUG
39
+
40
+ # Handle special cases of arguments:
41
+ # * When we're compiling a repeating term, in which case we want to
42
+ # compile the elements of [args] rather than [args] itself.
43
+ # * Objects, which correspond to optional argument specifications.
44
+ # * Empty arguments
45
+ return args.map {|arg| comp(message_class, arg)} if repeating
46
+ args = args[0] if args.class == Array and args[0].class == Hash
47
+ raise TypeError,"Can't build #{message_class} from #{args.inspect}." if args == []
48
+
49
+ # Handle terminal parts of the protobuf, where we have to actually pack values.
50
+ if message_class.kind_of? Symbol
51
+ # It's easier for the user if we allow both atoms and 1-element lists
52
+ args = [args] if args.class != Array
53
+ if args.length != 1
54
+ then raise TypeError,"Can't build #{message_class} from #{args.inspect}." end
55
+ # Coercing symbols into strings makes our attribute notation more consistent
56
+ args[0] = args[0].to_s if args[0].class == Symbol
57
+ return args[0]
58
+ end
59
+
60
+ # Handle nonterminal parts of the protobuf, where we have to descend
61
+ message = message_class.new
62
+ if (message_type_class = C.class_types[message_class])
63
+ query_type = S.rewrite(args[0]) # Our first argument is the type of our variant.
64
+ message.type = enum_type(message_type_class, query_type)
65
+ raise TypeError,"No type '#{query_type}' for '#{message_class}'."if !message.type
66
+
67
+ if args.length == 1 # Our variant takes no arguments of its own.
68
+ return message
69
+ else # Compile our variant's arguments.
70
+ query_args = args[1..-1]
71
+ query_args = [query_args] if C.trampolines.include? query_type
72
+ return message if handle_special_cases(message, query_type, query_args)
73
+
74
+ # The general, non-special case.
75
+ query_type = C.query_rewrites[query_type] || query_type
76
+ field_metadata = message_class.fields.select{|x,y| y.name==query_type}.to_a[0]
77
+ if not field_metadata
78
+ then raise ArgumentError,"No field '#{query_type}' in '#{message_class}'." end
79
+ field = field_metadata[1]
80
+ message_set(message, query_type,
81
+ comp(field.type, query_args,field.rule==:repeated))
82
+ end
83
+ # Handle cases where we aren't constructing a toplevel variant type.
84
+ elsif args.class == Array
85
+ # Handle the case where we're constructinga the fields in order.
86
+ args = args.map{|x| x == nil ? RQL.expr(x) : x}
87
+ fields = message.fields.sort_by {|kv| kv[0]}
88
+ fields.zip(args).each {|_params|;field = _params[0][1];arg = _params[1]
89
+ if arg == S.skip
90
+ if field.rule != :optional
91
+ raise RuntimeError, "Cannot skip non-optional rule."
92
+ end
93
+ else
94
+ message_set(message, field.name,
95
+ comp(field.type, arg, field.rule==:repeated)) if arg != nil
96
+ end
97
+ }
98
+ else
99
+ # Handle the case where the user provided neither an Array nor a Hash,
100
+ # in which case they probably provided an Atom that we should treat as a
101
+ # single argument (allowing this makes the interface cleaner).
102
+ message = comp(message_class, [args], repeating)
103
+ end
104
+ return message
105
+ rescue => e # Add our own, semantic backtrace to exceptions
106
+ new_msg = repeating ? e.message :
107
+ e.message + "\n...when compiling #{message_class} with:\n#{args.pretty_inspect}"
108
+ raise e.class, new_msg
109
+ end
110
+
111
+ def handle_special_query_cases(sexp)
112
+ if C.nonatomic_variants.include?(sexp[0])
113
+ sexp[0] = sexp[0].to_s.split('_')[0].to_sym
114
+ res = query(sexp)
115
+ res.write_query.atomic = false
116
+ return res
117
+ end
118
+ return nil
119
+ end
120
+
121
+ # Construct a protobuf query from an RQL query by inferring the query type.
122
+ def query(sexp)
123
+ raise TypeError, "Cannot build query from #{sexp.inspect}" if sexp.class != Array
124
+ if (m = handle_special_query_cases(sexp))
125
+ then q = m
126
+ elsif enum_type(WriteQuery::WriteQueryType, S.rewrite(sexp[0]))
127
+ then q = comp(Query, [:write, *sexp])
128
+ elsif enum_type(MetaQuery::MetaQueryType, sexp[0])
129
+ then q = comp(Query, [:meta, *sexp])
130
+ else q = comp(Query, [:read, sexp])
131
+ end
132
+ q.token = (@@token += 1)
133
+ return q
134
+ end
135
+ end
136
+ module RQL_Protob; extend RQL_Protob_Mixin; end
137
+ end
data/lib/query.rb ADDED
@@ -0,0 +1,111 @@
1
+ # Copyright 2010-2012 RethinkDB, all rights reserved.
2
+ module RethinkDB
3
+ # An RQL query that can be sent to the RethinkDB cluster. This class contains
4
+ # only functions that work for any type of query. Queries are either
5
+ # constructed by methods in the RQL module, or by invoking the instance
6
+ # methods of a query on other queries.
7
+ class RQL_Query
8
+ def boolop? # :nodoc:
9
+ false
10
+ end
11
+ # Run the invoking query using the most recently opened connection. See
12
+ # Connection#run for more details.
13
+ def run(*args)
14
+ Connection.last_connection.send(:run, self, *args)
15
+ end
16
+
17
+ def set_body(val, context=nil) # :nodoc:
18
+ @context = context || caller
19
+ @body = val
20
+ end
21
+
22
+ def initialize(init_body, context=nil) # :nodoc:
23
+ set_body(init_body, context)
24
+ end
25
+
26
+ def ==(rhs) # :nodoc:
27
+ raise ArgumentError,"
28
+ Cannot use inline ==/!= with RQL queries, use .eq() instead if
29
+ you want a query that does equality comparison.
30
+
31
+ If you need to see whether two queries are the same, compare
32
+ their S-expression representations like: `query1.sexp ==
33
+ query2.sexp`."
34
+ end
35
+
36
+ # Return the S-expression representation of a query. Used for
37
+ # equality comparison and advanced debugging.
38
+ def sexp
39
+ S.clean_lst @body
40
+ end
41
+ attr_accessor :body, :marked, :context
42
+
43
+ # Compile into either a protobuf class or a query.
44
+ def as _class # :nodoc:
45
+ RQL_Protob.comp(_class, sexp)
46
+ end
47
+ def query(map={S.conn_outdated => false}) # :nodoc:
48
+ RQL_Protob.query(S.replace(sexp, map))
49
+ end
50
+
51
+ def print_backtrace(bt) # :nodoc:
52
+ #PP.pp [bt, bt.map{|x| BT.expand x}.flatten, sexp]
53
+ begin
54
+ BT.with_marked_error(self, bt) {
55
+ query = "Query: #{inspect}\n #{BT.with_highlight {inspect}}"
56
+ line = "Line: #{BT.line || "Unknown"}"
57
+ line + "\n" + query
58
+ }
59
+ rescue Exception => e
60
+ PP.pp [bt, e] if $DEBUG
61
+ "<Internal error in query pretty printer.>"
62
+ end
63
+ end
64
+
65
+ def pprint # :nodoc:
66
+ return @body.inspect if @body.class != Array
67
+ return "" if @body == []
68
+ case @body[0]
69
+ when :call then
70
+ if @body[2].length == 1
71
+ @body[2][0].inspect + "." + RQL_Query.new(@body[1],@context).inspect
72
+ else
73
+ func = @body[1][0].to_s
74
+ func_args = @body[1][1..-1].map{|x| x.inspect}
75
+ call_args = @body[2].map{|x| x.inspect}
76
+ func + "(" + (func_args + call_args).join(", ") + ")"
77
+ end
78
+ else
79
+ func = @body[0].to_s
80
+ func_args = @body[1..-1].map{|x| x.inspect}
81
+ func + "(" + func_args.join(", ") + ")"
82
+ end
83
+ end
84
+
85
+ def real_inspect(args) # :nodoc:
86
+ str = args[:str] || pprint
87
+ (BT.highlight and @marked) ? "\000"*str.length : str
88
+ end
89
+
90
+ def inspect # :nodoc:
91
+ real_inspect({})
92
+ end
93
+
94
+ # Dereference aliases (see utils.rb) and possibly dispatch to RQL
95
+ # (because the caller may be trying to use the more convenient
96
+ # inline version of an RQL function).
97
+ def method_missing(m, *args, &block) # :nodoc:
98
+ if (m2 = C.method_aliases[m]); then return self.send(m2, *args, &block); end
99
+ if RQL.methods.map{|x| x.to_sym}.include?(m)
100
+ return RQL.send(m, *[self, *args], &block)
101
+ end
102
+ super(m, *args, &block)
103
+ end
104
+ end
105
+ end
106
+
107
+ load 'tables.rb'
108
+ load 'sequence.rb'
109
+ load 'streams.rb'
110
+ load 'jsons.rb'
111
+ load 'writes.rb'
@@ -0,0 +1,687 @@
1
+ ### Generated by rprotoc. DO NOT EDIT!
2
+ ### <proto file: ../../src/rdb_protocol/query_language.proto>
3
+ # message TableRef {
4
+ # required string db_name = 1;
5
+ # required string table_name = 2;
6
+ # optional bool use_outdated = 3 [default = false]; //Use and outdated version of this table
7
+ # };
8
+ #
9
+ # message VarTermTuple {
10
+ # required string var = 1;
11
+ # required Term term = 2;
12
+ # };
13
+ #
14
+ # message Term {
15
+ # enum TermType {
16
+ # JSON_NULL = 0; //can't use just "NULL" here we get in trouble
17
+ # VAR = 1;
18
+ # LET = 2;
19
+ # CALL = 3;
20
+ # IF = 4;
21
+ # ERROR = 5;
22
+ # NUMBER = 6;
23
+ # STRING = 7;
24
+ # JSON = 8;
25
+ # BOOL = 9;
26
+ # ARRAY = 10;
27
+ # OBJECT = 11;
28
+ # GETBYKEY = 12;
29
+ # TABLE = 13;
30
+ # JAVASCRIPT = 14;
31
+ # IMPLICIT_VAR = 15;
32
+ # };
33
+ #
34
+ # required TermType type = 1;
35
+ #
36
+ # optional string var = 2;
37
+ #
38
+ # message Let {
39
+ # repeated VarTermTuple binds = 1;
40
+ # required Term expr = 2;
41
+ # };
42
+ #
43
+ # optional Let let = 3;
44
+ #
45
+ # message Call {
46
+ # required Builtin builtin = 1;
47
+ # repeated Term args = 2;
48
+ # };
49
+ #
50
+ # optional Call call = 4;
51
+ #
52
+ # message If {
53
+ # required Term test = 1;
54
+ # required Term true_branch = 2;
55
+ # required Term false_branch = 3;
56
+ # };
57
+ #
58
+ # optional If if_ = 5;
59
+ #
60
+ # optional string error = 6;
61
+ #
62
+ # optional double number = 7;
63
+ #
64
+ # optional string valuestring = 8;
65
+ #
66
+ # optional string jsonstring = 9;
67
+ #
68
+ # optional bool valuebool = 10;
69
+ #
70
+ # repeated Term array = 11;
71
+ #
72
+ # repeated VarTermTuple object = 12;
73
+ # message GetByKey {
74
+ # required TableRef table_ref = 1;
75
+ # required string attrname = 2;
76
+ # required Term key = 3;
77
+ # };
78
+ #
79
+ # optional GetByKey get_by_key = 14;
80
+ #
81
+ # message Table {
82
+ # required TableRef table_ref = 1;
83
+ # };
84
+ #
85
+ # optional Table table = 15;
86
+ #
87
+ # optional string javascript = 16;
88
+ #
89
+ # // reserved for RethinkDB internal use.
90
+ # extensions 1000 to 1099;
91
+ # };
92
+ #
93
+ # message Builtin {
94
+ # enum BuiltinType {
95
+ # NOT = 1;
96
+ # GETATTR = 2;
97
+ # IMPLICIT_GETATTR = 3;
98
+ # HASATTR = 4;
99
+ # IMPLICIT_HASATTR = 5;
100
+ # PICKATTRS = 6;
101
+ # IMPLICIT_PICKATTRS = 7;
102
+ # MAPMERGE = 8;
103
+ # ARRAYAPPEND = 9;
104
+ # SLICE = 11; // slice(thing_to_slice, None/left extent, None/right extent)
105
+ # ADD = 14;
106
+ # SUBTRACT = 15;
107
+ # MULTIPLY = 16;
108
+ # DIVIDE = 17;
109
+ # MODULO = 18;
110
+ # COMPARE = 19;
111
+ # FILTER = 20;
112
+ # MAP = 21; // operates over streams
113
+ # CONCATMAP = 22;
114
+ # ORDERBY = 23;
115
+ # DISTINCT = 24;
116
+ # LENGTH = 26;
117
+ # UNION = 27;
118
+ # NTH = 28;
119
+ # STREAMTOARRAY = 29;
120
+ # ARRAYTOSTREAM = 30;
121
+ # REDUCE = 31;
122
+ # GROUPEDMAPREDUCE = 32;
123
+ # ANY = 35;
124
+ # ALL = 36;
125
+ # RANGE = 37;
126
+ # IMPLICIT_WITHOUT = 38;
127
+ # WITHOUT = 39;
128
+ # };
129
+ #
130
+ # enum Comparison {
131
+ # EQ = 1;
132
+ # NE = 2;
133
+ # LT = 3;
134
+ # LE = 4;
135
+ # GT = 5;
136
+ # GE = 6;
137
+ # };
138
+ #
139
+ # required BuiltinType type = 1;
140
+ #
141
+ # optional string attr = 2; //used if type is GETATTR of HASATTR
142
+ #
143
+ # repeated string attrs = 3; //used if type is PICKATTRS or WITHOUT
144
+ #
145
+ # optional Comparison comparison = 4;
146
+ #
147
+ # message Filter {
148
+ # required Predicate predicate = 1;
149
+ # };
150
+ #
151
+ # optional Filter filter = 5;
152
+ #
153
+ # message Map {
154
+ # required Mapping mapping = 1;
155
+ # };
156
+ #
157
+ # optional Map map = 6;
158
+ #
159
+ # message ConcatMap {
160
+ # required Mapping mapping = 1;
161
+ # };
162
+ #
163
+ # optional ConcatMap concat_map = 7;
164
+ #
165
+ # message OrderBy {
166
+ # required string attr = 1;
167
+ # optional bool ascending = 2 [default = true];
168
+ # };
169
+ #
170
+ # repeated OrderBy order_by = 8;
171
+ #
172
+ # optional Reduction reduce = 9;
173
+ #
174
+ # message GroupedMapReduce {
175
+ # required Mapping group_mapping = 1;
176
+ # required Mapping value_mapping = 2;
177
+ # required Reduction reduction = 3;
178
+ # };
179
+ #
180
+ # optional GroupedMapReduce grouped_map_reduce = 10;
181
+ #
182
+ # message Range {
183
+ # required string attrname = 1;
184
+ # optional Term lowerbound = 2;
185
+ # optional Term upperbound = 3;
186
+ # };
187
+ #
188
+ # optional Range range = 11;
189
+ # };
190
+ #
191
+ # message Reduction {
192
+ # required Term base = 1;
193
+ # required string var1 = 2;
194
+ # required string var2 = 3;
195
+ # required Term body = 4;
196
+ # };
197
+ #
198
+ # message Mapping {
199
+ # required string arg = 1;
200
+ # required Term body = 2;
201
+ # extensions 1000 to 1099;
202
+ # };
203
+ #
204
+ # message Predicate {
205
+ # required string arg = 1;
206
+ # required Term body = 2;
207
+ # };
208
+ #
209
+ # message ReadQuery {
210
+ # required Term term = 1;
211
+ # optional int64 max_chunk_size = 2; //may be 0 for unlimited
212
+ # optional int64 max_age = 3;
213
+ #
214
+ # // reserved for RethinkDB internal use.
215
+ # extensions 1000 to 1099;
216
+ # };
217
+ #
218
+ # message WriteQuery {
219
+ # enum WriteQueryType {
220
+ # UPDATE = 1;
221
+ # DELETE = 2;
222
+ # MUTATE = 3;
223
+ # INSERT = 4;
224
+ # FOREACH = 6;
225
+ # POINTUPDATE = 7;
226
+ # POINTDELETE = 8;
227
+ # POINTMUTATE = 9;
228
+ # };
229
+ #
230
+ # required WriteQueryType type = 1;
231
+ # optional bool atomic = 11 [default = true];
232
+ #
233
+ # message Update {
234
+ # required Term view = 1;
235
+ # required Mapping mapping = 2;
236
+ # };
237
+ #
238
+ # optional Update update = 2;
239
+ #
240
+ # message Delete {
241
+ # required Term view = 1;
242
+ # };
243
+ #
244
+ # optional Delete delete = 3;
245
+ #
246
+ # message Mutate {
247
+ # required Term view = 1;
248
+ # required Mapping mapping = 2;
249
+ # };
250
+ #
251
+ # optional Mutate mutate = 4;
252
+ #
253
+ # message Insert {
254
+ # required TableRef table_ref = 1;
255
+ # repeated Term terms = 2;
256
+ # optional bool overwrite = 3 [default = false];
257
+ # };
258
+ #
259
+ # optional Insert insert = 5;
260
+ #
261
+ # message ForEach {
262
+ # required Term stream = 1;
263
+ # required string var = 2;
264
+ # repeated WriteQuery queries = 3;
265
+ # };
266
+ #
267
+ # optional ForEach for_each = 7;
268
+ #
269
+ # message PointUpdate {
270
+ # required TableRef table_ref = 1;
271
+ # required string attrname = 2;
272
+ # required Term key = 3;
273
+ # required Mapping mapping = 4;
274
+ # };
275
+ #
276
+ # optional PointUpdate point_update = 8;
277
+ #
278
+ # message PointDelete {
279
+ # required TableRef table_ref = 1;
280
+ # required string attrname = 2;
281
+ # required Term key = 3;
282
+ # };
283
+ #
284
+ # optional PointDelete point_delete = 9;
285
+ #
286
+ # message PointMutate {
287
+ # required TableRef table_ref = 1;
288
+ # required string attrname = 2;
289
+ # required Term key = 3;
290
+ # required Mapping mapping = 4;
291
+ # };
292
+ #
293
+ # optional PointMutate point_mutate = 10;
294
+ # };
295
+ #
296
+ # message MetaQuery {
297
+ # enum MetaQueryType {
298
+ # CREATE_DB = 1; //db_name
299
+ # DROP_DB = 2; //db_name
300
+ # LIST_DBS = 3;
301
+ #
302
+ # CREATE_TABLE = 4;
303
+ # DROP_TABLE = 5;
304
+ # LIST_TABLES = 6; //db_name
305
+ # };
306
+ # required MetaQueryType type = 1;
307
+ # optional string db_name = 2;
308
+ #
309
+ # message CreateTable {
310
+ # optional string datacenter = 1;
311
+ # required TableRef table_ref = 3;
312
+ # optional string primary_key = 4 [default = "id"];
313
+ # optional int64 cache_size = 5 [default = 1073741824]; //notice that's a gigabyte right there.
314
+ # }
315
+ # optional CreateTable create_table = 3;
316
+ #
317
+ # optional TableRef drop_table = 4;
318
+ # };
319
+ #
320
+ # message Query {
321
+ # enum QueryType {
322
+ # READ = 1; //Begin reading from a stream (and possibly finish if it's short)
323
+ # WRITE = 2; //Write to a table (currently does not create a stream)
324
+ # CONTINUE = 3; //Continue reading from a stream
325
+ # STOP = 4; //Stop reading from a stream and release its resources
326
+ # META = 5; //Meta operations that create, drop, or list databases/tables
327
+ # }
328
+ #
329
+ # required QueryType type = 1;
330
+ #
331
+ # required int64 token = 2;
332
+ #
333
+ # optional ReadQuery read_query = 3;
334
+ # optional WriteQuery write_query = 4;
335
+ # optional MetaQuery meta_query = 5;
336
+ # }
337
+ #
338
+ # message Response {
339
+ # enum StatusCode {
340
+ # SUCCESS_EMPTY = 0;
341
+ # SUCCESS_JSON = 1;
342
+ # SUCCESS_PARTIAL = 2; //need to send CONTINUE repeatedly until SUCCESS_STREAM
343
+ # SUCCESS_STREAM = 3;
344
+ #
345
+ # BROKEN_CLIENT = 101; // Means the client is misbehaving, not the user
346
+ # BAD_QUERY = 102;
347
+ # RUNTIME_ERROR = 103;
348
+ # }
349
+ # required StatusCode status_code = 1;
350
+ #
351
+ # required int64 token = 2;
352
+ #
353
+ # repeated string response = 3;
354
+ #
355
+ # optional string error_message = 4;
356
+ #
357
+ # message Backtrace {
358
+ # repeated string frame = 1;
359
+ # };
360
+ #
361
+ # optional Backtrace backtrace = 5;
362
+ # }
363
+
364
+ require 'protobuf/message/message'
365
+ require 'protobuf/message/enum'
366
+ require 'protobuf/message/service'
367
+ require 'protobuf/message/extend'
368
+
369
+ class TableRef < ::Protobuf::Message
370
+ defined_in __FILE__
371
+ required :string, :db_name, 1
372
+ required :string, :table_name, 2
373
+ optional :bool, :use_outdated, 3, :default => false
374
+ end
375
+ class VarTermTuple < ::Protobuf::Message
376
+ defined_in __FILE__
377
+ required :string, :var, 1
378
+ required :Term, :term, 2
379
+ end
380
+ class Term < ::Protobuf::Message
381
+ defined_in __FILE__
382
+ class TermType < ::Protobuf::Enum
383
+ defined_in __FILE__
384
+ JSON_NULL = value(:JSON_NULL, 0)
385
+ VAR = value(:VAR, 1)
386
+ LET = value(:LET, 2)
387
+ CALL = value(:CALL, 3)
388
+ IF = value(:IF, 4)
389
+ ERROR = value(:ERROR, 5)
390
+ NUMBER = value(:NUMBER, 6)
391
+ STRING = value(:STRING, 7)
392
+ JSON = value(:JSON, 8)
393
+ BOOL = value(:BOOL, 9)
394
+ ARRAY = value(:ARRAY, 10)
395
+ OBJECT = value(:OBJECT, 11)
396
+ GETBYKEY = value(:GETBYKEY, 12)
397
+ TABLE = value(:TABLE, 13)
398
+ JAVASCRIPT = value(:JAVASCRIPT, 14)
399
+ IMPLICIT_VAR = value(:IMPLICIT_VAR, 15)
400
+ end
401
+ required :TermType, :type, 1
402
+ optional :string, :var, 2
403
+ class Let < ::Protobuf::Message
404
+ defined_in __FILE__
405
+ repeated :VarTermTuple, :binds, 1
406
+ required :Term, :expr, 2
407
+ end
408
+ optional :Let, :let, 3
409
+ class Call < ::Protobuf::Message
410
+ defined_in __FILE__
411
+ required :Builtin, :builtin, 1
412
+ repeated :Term, :args, 2
413
+ end
414
+ optional :Call, :call, 4
415
+ class If < ::Protobuf::Message
416
+ defined_in __FILE__
417
+ required :Term, :test, 1
418
+ required :Term, :true_branch, 2
419
+ required :Term, :false_branch, 3
420
+ end
421
+ optional :If, :if_, 5
422
+ optional :string, :error, 6
423
+ optional :double, :number, 7
424
+ optional :string, :valuestring, 8
425
+ optional :string, :jsonstring, 9
426
+ optional :bool, :valuebool, 10
427
+ repeated :Term, :array, 11
428
+ repeated :VarTermTuple, :object, 12
429
+ class GetByKey < ::Protobuf::Message
430
+ defined_in __FILE__
431
+ required :TableRef, :table_ref, 1
432
+ required :string, :attrname, 2
433
+ required :Term, :key, 3
434
+ end
435
+ optional :GetByKey, :get_by_key, 14
436
+ class Table < ::Protobuf::Message
437
+ defined_in __FILE__
438
+ required :TableRef, :table_ref, 1
439
+ end
440
+ optional :Table, :table, 15
441
+ optional :string, :javascript, 16
442
+ extensions 1000..1099
443
+ end
444
+ class Builtin < ::Protobuf::Message
445
+ defined_in __FILE__
446
+ class BuiltinType < ::Protobuf::Enum
447
+ defined_in __FILE__
448
+ NOT = value(:NOT, 1)
449
+ GETATTR = value(:GETATTR, 2)
450
+ IMPLICIT_GETATTR = value(:IMPLICIT_GETATTR, 3)
451
+ HASATTR = value(:HASATTR, 4)
452
+ IMPLICIT_HASATTR = value(:IMPLICIT_HASATTR, 5)
453
+ PICKATTRS = value(:PICKATTRS, 6)
454
+ IMPLICIT_PICKATTRS = value(:IMPLICIT_PICKATTRS, 7)
455
+ MAPMERGE = value(:MAPMERGE, 8)
456
+ ARRAYAPPEND = value(:ARRAYAPPEND, 9)
457
+ SLICE = value(:SLICE, 11)
458
+ ADD = value(:ADD, 14)
459
+ SUBTRACT = value(:SUBTRACT, 15)
460
+ MULTIPLY = value(:MULTIPLY, 16)
461
+ DIVIDE = value(:DIVIDE, 17)
462
+ MODULO = value(:MODULO, 18)
463
+ COMPARE = value(:COMPARE, 19)
464
+ FILTER = value(:FILTER, 20)
465
+ MAP = value(:MAP, 21)
466
+ CONCATMAP = value(:CONCATMAP, 22)
467
+ ORDERBY = value(:ORDERBY, 23)
468
+ DISTINCT = value(:DISTINCT, 24)
469
+ LENGTH = value(:LENGTH, 26)
470
+ UNION = value(:UNION, 27)
471
+ NTH = value(:NTH, 28)
472
+ STREAMTOARRAY = value(:STREAMTOARRAY, 29)
473
+ ARRAYTOSTREAM = value(:ARRAYTOSTREAM, 30)
474
+ REDUCE = value(:REDUCE, 31)
475
+ GROUPEDMAPREDUCE = value(:GROUPEDMAPREDUCE, 32)
476
+ ANY = value(:ANY, 35)
477
+ ALL = value(:ALL, 36)
478
+ RANGE = value(:RANGE, 37)
479
+ IMPLICIT_WITHOUT = value(:IMPLICIT_WITHOUT, 38)
480
+ WITHOUT = value(:WITHOUT, 39)
481
+ end
482
+ class Comparison < ::Protobuf::Enum
483
+ defined_in __FILE__
484
+ EQ = value(:EQ, 1)
485
+ NE = value(:NE, 2)
486
+ LT = value(:LT, 3)
487
+ LE = value(:LE, 4)
488
+ GT = value(:GT, 5)
489
+ GE = value(:GE, 6)
490
+ end
491
+ required :BuiltinType, :type, 1
492
+ optional :string, :attr, 2
493
+ repeated :string, :attrs, 3
494
+ optional :Comparison, :comparison, 4
495
+ class Filter < ::Protobuf::Message
496
+ defined_in __FILE__
497
+ required :Predicate, :predicate, 1
498
+ end
499
+ optional :Filter, :filter, 5
500
+ class Map < ::Protobuf::Message
501
+ defined_in __FILE__
502
+ required :Mapping, :mapping, 1
503
+ end
504
+ optional :Map, :map, 6
505
+ class ConcatMap < ::Protobuf::Message
506
+ defined_in __FILE__
507
+ required :Mapping, :mapping, 1
508
+ end
509
+ optional :ConcatMap, :concat_map, 7
510
+ class OrderBy < ::Protobuf::Message
511
+ defined_in __FILE__
512
+ required :string, :attr, 1
513
+ optional :bool, :ascending, 2, :default => true
514
+ end
515
+ repeated :OrderBy, :order_by, 8
516
+ optional :Reduction, :reduce, 9
517
+ class GroupedMapReduce < ::Protobuf::Message
518
+ defined_in __FILE__
519
+ required :Mapping, :group_mapping, 1
520
+ required :Mapping, :value_mapping, 2
521
+ required :Reduction, :reduction, 3
522
+ end
523
+ optional :GroupedMapReduce, :grouped_map_reduce, 10
524
+ class Range < ::Protobuf::Message
525
+ defined_in __FILE__
526
+ required :string, :attrname, 1
527
+ optional :Term, :lowerbound, 2
528
+ optional :Term, :upperbound, 3
529
+ end
530
+ optional :Range, :range, 11
531
+ end
532
+ class Reduction < ::Protobuf::Message
533
+ defined_in __FILE__
534
+ required :Term, :base, 1
535
+ required :string, :var1, 2
536
+ required :string, :var2, 3
537
+ required :Term, :body, 4
538
+ end
539
+ class Mapping < ::Protobuf::Message
540
+ defined_in __FILE__
541
+ required :string, :arg, 1
542
+ required :Term, :body, 2
543
+ extensions 1000..1099
544
+ end
545
+ class Predicate < ::Protobuf::Message
546
+ defined_in __FILE__
547
+ required :string, :arg, 1
548
+ required :Term, :body, 2
549
+ end
550
+ class ReadQuery < ::Protobuf::Message
551
+ defined_in __FILE__
552
+ required :Term, :term, 1
553
+ optional :int64, :max_chunk_size, 2
554
+ optional :int64, :max_age, 3
555
+ extensions 1000..1099
556
+ end
557
+ class WriteQuery < ::Protobuf::Message
558
+ defined_in __FILE__
559
+ class WriteQueryType < ::Protobuf::Enum
560
+ defined_in __FILE__
561
+ UPDATE = value(:UPDATE, 1)
562
+ DELETE = value(:DELETE, 2)
563
+ MUTATE = value(:MUTATE, 3)
564
+ INSERT = value(:INSERT, 4)
565
+ FOREACH = value(:FOREACH, 6)
566
+ POINTUPDATE = value(:POINTUPDATE, 7)
567
+ POINTDELETE = value(:POINTDELETE, 8)
568
+ POINTMUTATE = value(:POINTMUTATE, 9)
569
+ end
570
+ required :WriteQueryType, :type, 1
571
+ optional :bool, :atomic, 11, :default => true
572
+ class Update < ::Protobuf::Message
573
+ defined_in __FILE__
574
+ required :Term, :view, 1
575
+ required :Mapping, :mapping, 2
576
+ end
577
+ optional :Update, :update, 2
578
+ class Delete < ::Protobuf::Message
579
+ defined_in __FILE__
580
+ required :Term, :view, 1
581
+ end
582
+ optional :Delete, :delete, 3
583
+ class Mutate < ::Protobuf::Message
584
+ defined_in __FILE__
585
+ required :Term, :view, 1
586
+ required :Mapping, :mapping, 2
587
+ end
588
+ optional :Mutate, :mutate, 4
589
+ class Insert < ::Protobuf::Message
590
+ defined_in __FILE__
591
+ required :TableRef, :table_ref, 1
592
+ repeated :Term, :terms, 2
593
+ optional :bool, :overwrite, 3, :default => false
594
+ end
595
+ optional :Insert, :insert, 5
596
+ class ForEach < ::Protobuf::Message
597
+ defined_in __FILE__
598
+ required :Term, :stream, 1
599
+ required :string, :var, 2
600
+ repeated :WriteQuery, :queries, 3
601
+ end
602
+ optional :ForEach, :for_each, 7
603
+ class PointUpdate < ::Protobuf::Message
604
+ defined_in __FILE__
605
+ required :TableRef, :table_ref, 1
606
+ required :string, :attrname, 2
607
+ required :Term, :key, 3
608
+ required :Mapping, :mapping, 4
609
+ end
610
+ optional :PointUpdate, :point_update, 8
611
+ class PointDelete < ::Protobuf::Message
612
+ defined_in __FILE__
613
+ required :TableRef, :table_ref, 1
614
+ required :string, :attrname, 2
615
+ required :Term, :key, 3
616
+ end
617
+ optional :PointDelete, :point_delete, 9
618
+ class PointMutate < ::Protobuf::Message
619
+ defined_in __FILE__
620
+ required :TableRef, :table_ref, 1
621
+ required :string, :attrname, 2
622
+ required :Term, :key, 3
623
+ required :Mapping, :mapping, 4
624
+ end
625
+ optional :PointMutate, :point_mutate, 10
626
+ end
627
+ class MetaQuery < ::Protobuf::Message
628
+ defined_in __FILE__
629
+ class MetaQueryType < ::Protobuf::Enum
630
+ defined_in __FILE__
631
+ CREATE_DB = value(:CREATE_DB, 1)
632
+ DROP_DB = value(:DROP_DB, 2)
633
+ LIST_DBS = value(:LIST_DBS, 3)
634
+ CREATE_TABLE = value(:CREATE_TABLE, 4)
635
+ DROP_TABLE = value(:DROP_TABLE, 5)
636
+ LIST_TABLES = value(:LIST_TABLES, 6)
637
+ end
638
+ required :MetaQueryType, :type, 1
639
+ optional :string, :db_name, 2
640
+ class CreateTable < ::Protobuf::Message
641
+ defined_in __FILE__
642
+ optional :string, :datacenter, 1
643
+ required :TableRef, :table_ref, 3
644
+ optional :string, :primary_key, 4, :default => "id"
645
+ optional :int64, :cache_size, 5, :default => 1073741824
646
+ end
647
+ optional :CreateTable, :create_table, 3
648
+ optional :TableRef, :drop_table, 4
649
+ end
650
+ class Query < ::Protobuf::Message
651
+ defined_in __FILE__
652
+ class QueryType < ::Protobuf::Enum
653
+ defined_in __FILE__
654
+ READ = value(:READ, 1)
655
+ WRITE = value(:WRITE, 2)
656
+ CONTINUE = value(:CONTINUE, 3)
657
+ STOP = value(:STOP, 4)
658
+ META = value(:META, 5)
659
+ end
660
+ required :QueryType, :type, 1
661
+ required :int64, :token, 2
662
+ optional :ReadQuery, :read_query, 3
663
+ optional :WriteQuery, :write_query, 4
664
+ optional :MetaQuery, :meta_query, 5
665
+ end
666
+ class Response < ::Protobuf::Message
667
+ defined_in __FILE__
668
+ class StatusCode < ::Protobuf::Enum
669
+ defined_in __FILE__
670
+ SUCCESS_EMPTY = value(:SUCCESS_EMPTY, 0)
671
+ SUCCESS_JSON = value(:SUCCESS_JSON, 1)
672
+ SUCCESS_PARTIAL = value(:SUCCESS_PARTIAL, 2)
673
+ SUCCESS_STREAM = value(:SUCCESS_STREAM, 3)
674
+ BROKEN_CLIENT = value(:BROKEN_CLIENT, 101)
675
+ BAD_QUERY = value(:BAD_QUERY, 102)
676
+ RUNTIME_ERROR = value(:RUNTIME_ERROR, 103)
677
+ end
678
+ required :StatusCode, :status_code, 1
679
+ required :int64, :token, 2
680
+ repeated :string, :response, 3
681
+ optional :string, :error_message, 4
682
+ class Backtrace < ::Protobuf::Message
683
+ defined_in __FILE__
684
+ repeated :string, :frame, 1
685
+ end
686
+ optional :Backtrace, :backtrace, 5
687
+ end