Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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])
Ejemplo 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
Ejemplo n.º 4
0
    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 = {}
Ejemplo n.º 5
0
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
Ejemplo 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)))
Ejemplo n.º 7
0
 def __init__(self, array):
     self.array = query.expr(array)
Ejemplo n.º 8
0
 def __init__(self, table, key, attr_name):
     self.table = table
     self.key = query.expr(key)
     self.attr_name = attr_name
Ejemplo 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
Ejemplo n.º 10
0
 def __init__(self, stream, index):
     self.stream = stream
     self.index = query.expr(index)
Ejemplo n.º 11
0
 def __init__(self, parent, offset):
     self.parent = parent
     self.offset = query.expr(offset)
Ejemplo 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)
Ejemplo n.º 13
0
 def __init__(self, parent, key):
     self.parent = query.expr(parent)
     self.key = key
Ejemplo 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
Ejemplo n.º 15
0
 def __init__(self, table, key, attr_name):
     self.table = table
     self.key = query.expr(key)
     self.attr_name = attr_name
Ejemplo n.º 16
0
 def __init__(self, parent, offset):
     self.parent = parent
     self.offset = query.expr(offset)
Ejemplo n.º 17
0
 def __init__(self, parent, start, stop):
     self.parent = parent
     self.start = query.expr(start)
     self.stop = query.expr(stop)
Ejemplo n.º 18
0
 def __init__(self, stream, index):
     self.stream = stream
     self.index = query.expr(index)
Ejemplo 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)
Ejemplo n.º 20
0
 def __init__(self, *args):
     self.args = [query.expr(a) for a in args]
Ejemplo n.º 21
0
 def __init__(self, *args):
     self.args = [query.expr(a) for a in args]
Ejemplo n.º 22
0
 def __init__(self, parent, base, reduction):
     self.parent = parent
     self.base = query.expr(base)
     self.reduction = reduction
Ejemplo n.º 23
0
 def __init__(self, array):
     self.array = query.expr(array)
Ejemplo 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)))
Ejemplo n.º 25
0
 def __init__(self, parent, start, stop):
     self.parent = parent
     self.start = query.expr(start)
     self.stop = query.expr(stop)
Ejemplo 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)
Ejemplo 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
Ejemplo 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())
Ejemplo 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)
Ejemplo n.º 30
0
 def __init__(self, value):
     self.value = [query.expr(e) for e in value]
Ejemplo n.º 31
0
 def __init__(self, parent, base, reduction):
     self.parent = parent
     self.base = query.expr(base)
     self.reduction = reduction
Ejemplo 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())
Ejemplo 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]
Ejemplo n.º 34
0
 def __init__(self, parent, key):
     self.parent = query.expr(parent)
     self.key = key
Ejemplo n.º 35
0
 def __init__(self, value):
     self.value = [query.expr(e) for e in value]
Ejemplo 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]