def _start(self, term, **global_opt_args): token = self.next_token self.next_token += 1 # Construct query query = p.Query() query.type = p.Query.START query.token = token # Set global opt args # The 'db' option will default to this connection's default # if not otherwise specified. if 'db' in global_opt_args: global_opt_args['db'] = DB(global_opt_args['db']) else: if self.db: global_opt_args['db'] = self.db for k,v in global_opt_args.iteritems(): pair = query.global_optargs.add() pair.key = k expr(v).build(pair.val) # Compile query to protobuf term.build(query.query) return self._send_query(query, term)
def __init__(self, *args, **optargs): self.args = [expr(e) for e in args] self.optargs = {} for k in optargs.keys(): if optargs[k] is (): continue self.optargs[k] = expr(optargs[k])
def __init__(self, input, group_mapping, value_mapping, reduction_base, reduction_func): self.input = input self.group_mapping = group_mapping self.value_mapping = value_mapping self.reduction_base = query.expr(reduction_base) self.reduction_func = reduction_func
def __init__(self, lmbd): vrs = [] vrids = [] for i in xrange(lmbd.func_code.co_argcount): vrs.append(Var(Func.nextVarId)) vrids.append(Func.nextVarId) Func.nextVarId += 1 self.vrs = vrs self.args = [MakeArray(*vrids), expr(lmbd(*vrs))] self.optargs = {}
def func_wrap(val): val = expr(val) # Scan for IMPLICIT_VAR or JS def ivar_scan(node): if not isinstance(node, RqlQuery): return False if isinstance(node, ImplicitVar): return True if any([ivar_scan(arg) for arg in node.args]): return True if any([ivar_scan(arg) for k,arg in node.optargs.iteritems()]): return True return False if ivar_scan(val): return Func(lambda x: val) return val
def __init__(self, expr, bindings): self.expr = expr self.bindings = [] for var, val in bindings: self.bindings.append((var, query.expr(val)))
def __init__(self, array): self.array = query.expr(array)
def __init__(self, table, key, attr_name): self.table = table self.key = query.expr(key) self.attr_name = attr_name
def __init__(self, stream, index): self.stream = stream self.index = query.expr(index)
def __init__(self, parent, offset): self.parent = parent self.offset = query.expr(offset)
def __init__(self, test, true_branch, false_branch): # TODO: Actually support things other than `JSONExpression` self.test = query.expr(test) self.true_branch = query.expr(true_branch) self.false_branch = query.expr(false_branch)
def __init__(self, parent, key): self.parent = query.expr(parent) self.key = key
def __init__(self, parent, lowerbound, upperbound, attrname): self.parent = parent self.lowerbound = query.expr(lowerbound) self.upperbound = query.expr(upperbound) self.attrname = attrname
def __init__(self, parent, start, stop): self.parent = parent self.start = query.expr(start) self.stop = query.expr(stop)
def __init__(self, *args): self.args = [query.expr(arg) for arg in args] assert len(self.args) == len(self.arg_wrapped_flags)
def __init__(self, *args): self.args = [query.expr(a) for a in args]
def __init__(self, parent, base, reduction): self.parent = parent self.base = query.expr(base) self.reduction = reduction
def __init__(self, value): for k, v in value.iteritems(): assert isinstance(k, str) self.value = dict((k, query.expr(v)) for k, v in value.iteritems())
def __init__(self, value): self.value = [query.expr(e) for e in value]
def __init__(self, table, entries): self.table = table if isinstance(entries, query.StreamExpression): self.entries = [entries] else: self.entries = [query.expr(e) for e in entries]