Package com.hp.hpl.jena.sparql.engine.binding

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap


        {
            if ( parentBinding == null || parentBinding.isEmpty() )
                return b ;
       
            // This is the result.  Could have BindingBase.setParent etc. 
            BindingMap b2 = BindingFactory.create(parentBinding) ;

            // Copy the resultSet bindings to the combined result binding with checking.
            for ( Iterator<Var> iter = b.vars() ; iter.hasNext(); )
            {
                Var v = iter.next();
                Node n = b.get(v) ;
                if ( b2.contains(v) )
                {
                    Node n2 = b2.get(v) ;
                    if ( n2.equals(n) )
                        Log.warn(this, "Binding already for "+v+" (same value)" ) ;
                    else
                    {
                        Log.fatal(this, "Binding already for "+v+" (different values)" ) ;
                        throw new ARQInternalErrorException("QueryIteratorResultSet: Incompatible bindings for "+v) ;
                    }
                }
                b2.add(v, n) ;
            }
            return b2 ;
        }
View Full Code Here


            return node ;
        }

        private Binding mapper(Triple r)
        {
            BindingMap results = BindingFactory.create(binding) ;

            if ( ! insert(s, r.getSubject(), results) )
                return null ;
            if ( ! insert(p, r.getPredicate(), results) )
                return null ;
View Full Code Here

    }
   
    @Override
    public Binding accept(Binding binding)
    {
        BindingMap b = BindingFactory.create(binding) ;
        for ( Var v : exprs.getVars() )
        {
            // Not this, where expressions do not see the new bindings.
            // Node n = exprs.get(v, bind, funcEnv) ;
            // which gives (Lisp) "let" semantics, not "let*" semantics
            Node n = exprs.get(v, b, getExecContext()) ;
           
            if ( n == null )
                // Expression failed to evaluate - no assignment
                continue ;
               
            // Check is already has a value; if so, must be sameValueAs
            if ( b.contains(v) )
            {
                // Optimization may linearize to push a stream through an (extend). 
                if ( false && mustBeNewVar )
                    throw new QueryExecException("Already set: "+v) ;
               
                Node n2 = b.get(v) ;
                if ( ! n2.sameValueAs(n) )
                    //throw new QueryExecException("Already set: "+v) ;
                    // Error in single assignment.
                    return null ;
                continue ;
            }
            b.add(v, n) ;
        }
        return b ;
    }
View Full Code Here

                        // No rows to group, no aggregators.
                        // ==> No result rows.
                        return new QueryIterNullIterator(execCxt) ;
                    }
                   
                    BindingMap binding = BindingFactory.create() ;

                    for ( Iterator<ExprAggregator> aggIter = aggregators.iterator() ; aggIter.hasNext() ; )
                    {
                        ExprAggregator agg = aggIter.next();
                        Var v = agg.getVar() ;
                        Node value = agg.getAggregator().getValueEmpty() ;
                        if ( value != null )
                            binding.add(v, value) ;
                    }
                       
                    if ( binding == null )
                        // This does not happen if there are any aggregators.
                        return new QueryIterNullIterator(execCxt) ;
                    return QueryIterSingleton.create(binding, execCxt) ;
                }

                // Phase 2 : There was input and so there are some groups.
                // For each bucket, get binding, add aggregator values to the binding.
                // We used AccNull so there are always accumulators.
               
                if ( noAggregators )
                    // We used placeholder so there are always the key.
                    return  accumulators.keys().iterator() ;
               
                List<Binding> results = new ArrayList<Binding>() ;

                for ( Binding k : accumulators.keys() )
                {
                    Collection<Pair<Var, Accumulator>> accs = accumulators.get(k) ;
                    BindingMap b = BindingFactory.create(k) ;
                   
                    for ( Pair<Var, Accumulator> pair : accs )
                    {
                        Var v = pair.getLeft() ;
                        NodeValue value = pair.getRight().getValue() ;
                        Node n = (value==null) ? null : value.asNode() ;
                        if ( v == null || n == null )
                        {}
                        else
                            b.add(v, n) ;
                    }
                    results.add(b) ;
                }
                return results.iterator() ;
            }
View Full Code Here

   
    static private Binding copyProject(VarExprList vars, Binding binding, ExecutionContext execCxt)
    {
        // No group vars (implicit or explicit) => working on whole result set.
        // Still need a BindingMap to assign to later.
        BindingMap x = BindingFactory.create() ;
        for ( Iterator<Var> iter = vars.getVars().iterator() ; iter.hasNext() ; )
        {
            Var var = iter.next() ;
            Node node = vars.get(var, binding, execCxt) ;
            // Null returned for unbound and error.
            if ( node != null )
                x.add(var, node) ;
        }
        return x ;
    }
View Full Code Here

        if ( node == Node.ANY )
            node = null ;
       
        if ( node != null || triple != null )
        {
            BindingMap b2 = BindingFactory.create(b) ;
            if ( node != null )
                bind(b2, reifNodeVar, node) ;
            if ( triple != null )
            {
                bind(b2, varS, triple.getMatchSubject()) ;
View Full Code Here

    }

    private Binding buildBinding(Resource soln)
    {
        // foreach row
        BindingMap rb = BindingFactory.create() ;
       
        StmtIterator bindingIter = soln.listProperties(ResultSetGraphVocab.binding) ;
        for ( ; bindingIter.hasNext() ; )
        {
            Resource binding = bindingIter.nextStatement().getResource() ;
           
            String var = binding.getRequiredProperty(ResultSetGraphVocab.variable).getString() ;
            try {
                RDFNode val = binding.getRequiredProperty(ResultSetGraphVocab.value).getObject() ;
                rb.add(Var.alloc(var), val.asNode()) ;
            } catch (PropertyNotFoundException ex)
            {
                Log.warn(this, "Failed to get value for ?"+var) ;
            }
           
View Full Code Here

       
        if ( ! matches )
            return null ;
       
        // If compatible, merge. Iterate over variables in right but not in left.
        BindingMap b = BindingFactory.create(bindingLeft) ;
        for ( Iterator<Var> vIter = bindingRight.vars() ; vIter.hasNext() ; )
        {
            Var v = vIter.next();
            Node n = bindingRight.get(v) ;
            if ( ! bindingLeft.contains(v) )
                b.add(v, n) ;
        }
        return b ;
    }
View Full Code Here

    { return ; }
   
    private Binding getOneSolution() throws XMLStreamException
    {
        // At the start of <result>
        BindingMap binding = BindingFactory.create() ;
        String varName = null ;
       
        while(parser.hasNext())
        {
            int event = parser.next();
View Full Code Here

                continue ;
            Node version = Node.createLiteral(info.getVersion()) ;
            if ( ! isSameOrVar(obj, version) )
                continue ;
           
            BindingMap b = BindingFactory.create(binding) ;
            if ( subj.isVariable() )
                b.add(Var.alloc(subj), info.getIRI()) ;
            if ( subj.isVariable() )
                b.add(Var.alloc(obj), version) ;
            results.add(b) ;
        }
        return new QueryIterPlainWrapper(results.iterator(), execCxt) ;
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.engine.binding.BindingMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.