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])
Esempio n. 3
0
 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
Esempio n. 6
0
 def __init__(self, expr, bindings):
     self.expr = expr
     self.bindings = []
     for var, val in bindings:
         self.bindings.append((var, query.expr(val)))
Esempio n. 7
0
 def __init__(self, array):
     self.array = query.expr(array)
Esempio n. 8
0
 def __init__(self, table, key, attr_name):
     self.table = table
     self.key = query.expr(key)
     self.attr_name = attr_name
Esempio n. 9
0
 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
Esempio n. 10
0
 def __init__(self, stream, index):
     self.stream = stream
     self.index = query.expr(index)
Esempio n. 11
0
 def __init__(self, parent, offset):
     self.parent = parent
     self.offset = query.expr(offset)
Esempio n. 12
0
 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)
Esempio n. 13
0
 def __init__(self, parent, key):
     self.parent = query.expr(parent)
     self.key = key
Esempio n. 14
0
 def __init__(self, parent, lowerbound, upperbound, attrname):
     self.parent = parent
     self.lowerbound = query.expr(lowerbound)
     self.upperbound = query.expr(upperbound)
     self.attrname = attrname
Esempio n. 15
0
 def __init__(self, table, key, attr_name):
     self.table = table
     self.key = query.expr(key)
     self.attr_name = attr_name
Esempio n. 16
0
 def __init__(self, parent, offset):
     self.parent = parent
     self.offset = query.expr(offset)
Esempio n. 17
0
 def __init__(self, parent, start, stop):
     self.parent = parent
     self.start = query.expr(start)
     self.stop = query.expr(stop)
Esempio n. 18
0
 def __init__(self, stream, index):
     self.stream = stream
     self.index = query.expr(index)
Esempio n. 19
0
 def __init__(self, *args):
     self.args = [query.expr(arg) for arg in args]
     assert len(self.args) == len(self.arg_wrapped_flags)
Esempio n. 20
0
 def __init__(self, *args):
     self.args = [query.expr(a) for a in args]
Esempio n. 21
0
 def __init__(self, *args):
     self.args = [query.expr(a) for a in args]
Esempio n. 22
0
 def __init__(self, parent, base, reduction):
     self.parent = parent
     self.base = query.expr(base)
     self.reduction = reduction
Esempio n. 23
0
 def __init__(self, array):
     self.array = query.expr(array)
Esempio n. 24
0
 def __init__(self, expr, bindings):
     self.expr = expr
     self.bindings = []
     for var, val in bindings:
         self.bindings.append((var, query.expr(val)))
Esempio n. 25
0
 def __init__(self, parent, start, stop):
     self.parent = parent
     self.start = query.expr(start)
     self.stop = query.expr(stop)
Esempio n. 26
0
 def __init__(self, *args):
     self.args = [query.expr(arg) for arg in args]
     assert len(self.args) == len(self.arg_wrapped_flags)
Esempio n. 27
0
 def __init__(self, parent, lowerbound, upperbound, attrname):
     self.parent = parent
     self.lowerbound = query.expr(lowerbound)
     self.upperbound = query.expr(upperbound)
     self.attrname = attrname
Esempio n. 28
0
 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())
Esempio n. 29
0
 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)
Esempio n. 30
0
 def __init__(self, value):
     self.value = [query.expr(e) for e in value]
Esempio n. 31
0
 def __init__(self, parent, base, reduction):
     self.parent = parent
     self.base = query.expr(base)
     self.reduction = reduction
Esempio n. 32
0
 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())
Esempio n. 33
0
 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]
Esempio n. 34
0
 def __init__(self, parent, key):
     self.parent = query.expr(parent)
     self.key = key
Esempio n. 35
0
 def __init__(self, value):
     self.value = [query.expr(e) for e in value]
Esempio n. 36
0
 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]