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])
示例#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
示例#6
0
 def __init__(self, expr, bindings):
     self.expr = expr
     self.bindings = []
     for var, val in bindings:
         self.bindings.append((var, query.expr(val)))
示例#7
0
 def __init__(self, array):
     self.array = query.expr(array)
示例#8
0
 def __init__(self, table, key, attr_name):
     self.table = table
     self.key = query.expr(key)
     self.attr_name = attr_name
示例#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
示例#10
0
 def __init__(self, stream, index):
     self.stream = stream
     self.index = query.expr(index)
示例#11
0
 def __init__(self, parent, offset):
     self.parent = parent
     self.offset = query.expr(offset)
示例#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)
示例#13
0
 def __init__(self, parent, key):
     self.parent = query.expr(parent)
     self.key = key
示例#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
示例#15
0
 def __init__(self, table, key, attr_name):
     self.table = table
     self.key = query.expr(key)
     self.attr_name = attr_name
示例#16
0
 def __init__(self, parent, offset):
     self.parent = parent
     self.offset = query.expr(offset)
示例#17
0
 def __init__(self, parent, start, stop):
     self.parent = parent
     self.start = query.expr(start)
     self.stop = query.expr(stop)
示例#18
0
 def __init__(self, stream, index):
     self.stream = stream
     self.index = query.expr(index)
示例#19
0
 def __init__(self, *args):
     self.args = [query.expr(arg) for arg in args]
     assert len(self.args) == len(self.arg_wrapped_flags)
示例#20
0
 def __init__(self, *args):
     self.args = [query.expr(a) for a in args]
示例#21
0
 def __init__(self, *args):
     self.args = [query.expr(a) for a in args]
示例#22
0
 def __init__(self, parent, base, reduction):
     self.parent = parent
     self.base = query.expr(base)
     self.reduction = reduction
示例#23
0
 def __init__(self, array):
     self.array = query.expr(array)
示例#24
0
 def __init__(self, expr, bindings):
     self.expr = expr
     self.bindings = []
     for var, val in bindings:
         self.bindings.append((var, query.expr(val)))
示例#25
0
 def __init__(self, parent, start, stop):
     self.parent = parent
     self.start = query.expr(start)
     self.stop = query.expr(stop)
示例#26
0
 def __init__(self, *args):
     self.args = [query.expr(arg) for arg in args]
     assert len(self.args) == len(self.arg_wrapped_flags)
示例#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
示例#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())
示例#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)
示例#30
0
 def __init__(self, value):
     self.value = [query.expr(e) for e in value]
示例#31
0
 def __init__(self, parent, base, reduction):
     self.parent = parent
     self.base = query.expr(base)
     self.reduction = reduction
示例#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())
示例#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]
示例#34
0
 def __init__(self, parent, key):
     self.parent = query.expr(parent)
     self.key = key
示例#35
0
 def __init__(self, value):
     self.value = [query.expr(e) for e in value]
示例#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]