Ejemplo n.º 1
0
    def read_translate(self, query, bindings_set=[{}], reqd_bound_vars=[]):
        query_triples = self.parser.parse(query)
        ret_evals = []
        bindings_set = explode_bindings_set(bindings_set)
        if len(reqd_bound_vars) == 0:
            reqd_bound_vars = find_vars(query_triples, is_lit_var)
            if len(reqd_bound_vars) == 0:
                p('Warning: no required bound variables.  Are there any _vars?'
                  )

        #for triples in sub_var_bindings_set(query_triples, bindings_set) :
        for bindings in bindings_set:
            #p('bindings',bindings)
            #p('reqd_bound_vars',reqd_bound_vars)
            new_reqd_bound_vars = []
            provided_bindings = []
            for var in reqd_bound_vars:
                if var in bindings:
                    provided_bindings.append(var)
                else:
                    new_reqd_bound_vars.append(var)
            reqd_bound_vars = new_reqd_bound_vars

            #p('reqd_bound_vars',reqd_bound_vars)
            #p('provided_bindings',provided_bindings)
            triples = sub_var_bindings(query_triples, bindings)
            begin_compile = time.time()
            ret_comp = self.compiler.compile(triples, reqd_bound_vars)
            end_compile = time.time()
            #p('ret_comp',ret_comp)
            if 'time' in self.options:
                print 'compile time:', end_compile - begin_compile
                self.cum_comp_time += end_compile - begin_compile
            if ret_comp == False:
                raise CompilerException(
                    "Couldn't compile ... sorry I don't have more here")
            begin_eval = time.time()
            #for i in range(100) :
            ret_eval = self.evaluator.evaluate(ret_comp)
            end_eval = time.time()
            if 'time' in self.options:
                print 'eval time:', end_eval - begin_eval
                self.cum_eval_time += end_eval - begin_eval
            for ret in ret_eval:
                for var in provided_bindings:
                    ret[var] = bindings[var]
            #p('ret_eval',ret_eval)
            ret_evals.extend(ret_eval)

        return ret_evals
Ejemplo n.º 2
0
 def read_translate(self, query, bindings_set = [{}], reqd_bound_vars = []) :
   query_triples = self.parser.parse(query)
   ret_evals = []
   bindings_set = explode_bindings_set(bindings_set)
   if len(reqd_bound_vars) == 0 :
     reqd_bound_vars = find_vars(query_triples, is_lit_var)
     if len(reqd_bound_vars) == 0 :
       p('Warning: no required bound variables.  Are there any _vars?')
   
   #for triples in sub_var_bindings_set(query_triples, bindings_set) :
   for bindings in bindings_set :
     #p('bindings',bindings)
     #p('reqd_bound_vars',reqd_bound_vars)
     new_reqd_bound_vars = []
     provided_bindings = []
     for var in reqd_bound_vars :
       if var in bindings :
         provided_bindings.append(var)
       else :
         new_reqd_bound_vars.append(var)
     reqd_bound_vars = new_reqd_bound_vars
     
     #p('reqd_bound_vars',reqd_bound_vars)
     #p('provided_bindings',provided_bindings)
     triples = sub_var_bindings(query_triples, bindings)
     begin_compile = time.time()
     ret_comp = self.compiler.compile(triples, reqd_bound_vars)
     end_compile = time.time()
     #p('ret_comp',ret_comp)
     if 'time' in self.options :
       print 'compile time:',end_compile-begin_compile
       self.cum_comp_time += end_compile-begin_compile
     if ret_comp == False :
       raise CompilerException("Couldn't compile ... sorry I don't have more here")
     begin_eval = time.time()
     #for i in range(100) :
     ret_eval = self.evaluator.evaluate(ret_comp)
     end_eval = time.time()
     if 'time' in self.options :
       print 'eval time:',end_eval-begin_eval
       self.cum_eval_time += end_eval-begin_eval
     for ret in ret_eval :
       for var in provided_bindings :
         ret[var] = bindings[var]
     #p('ret_eval',ret_eval)
     ret_evals.extend(ret_eval)
     
   return ret_evals
Ejemplo n.º 3
0
 def write_translate(self, query, bindings_set=[{}]):
     # TODO: figure out what this even means!
     p('write_translate')
     p('query', query)
     p('bindings_set', bindings_set)
     pass
Ejemplo n.º 4
0
 def write_translate(self, query, bindings_set = [{}]) :
   # TODO: figure out what this even means!
   p('write_translate')
   p('query',query)
   p('bindings_set',bindings_set)
   pass