Examples of BindingMap


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

        if ( ! node.isURI() ) return ;
        Node localname = NodeFactory.createLiteral(node.getLocalName()) ;
        if ( nodeLocalname.isVariable() )
        {
            // Object is an unbound variable.
            BindingMap b = BindingFactory.create(input) ;
            // Bind a pair for subject and object variables
            b.add(Var.alloc(subjVar), node) ;
            b.add(Var.alloc(nodeLocalname), localname) ;
            bindings.add(b) ;
            return ;
        }
       
        // Object is a value / bound variable.
View Full Code Here

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("Incompatible bindings for "+v) ;
                    }
                }
                b2.add(v, n) ;
            }
            return b2 ;
        }
View Full Code Here

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

    }
   
    @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

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

                        // No rows to group, no aggregators.
                        // ==> No result rows.
                        return Iter.nullIterator() ;
                    }
                   
                    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 Iter.nullIterator() ;
                    // cast to get the static type inference to work.
                    return Iter.singletonIter((Binding)binding) ;
                }

                // 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

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

   
    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

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

        }
        return new TableData(vars, newRows) ;
    }
   
    public static Binding transform(Binding b, NodeTransform transform) {
        BindingMap b2 = BindingFactory.create() ;
        List<Var> vars = Iter.toList(b.vars()) ;
        for ( Var v : vars ) {
            Var v2 = (Var)transform.convert(v) ;
            b2.add(v2, b.get(v));
        }
        return b2 ;
    }
View Full Code Here

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

                continue ;
            Node version = NodeFactory.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

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

        List<Binding> bindings = new ArrayList<Binding>() ;
        for ( int i = 0 ; i < members.size() ; i++ )
        {
            Node idx = NodeFactoryExtra.intToNode(i) ;
            Node member = members.get(i) ;
            BindingMap b = BindingFactory.create(binding) ;
            b.add(varIndex, idx) ;
            b.add(varMember, member) ;
            bindings.add(b) ;
        }
        return new QueryIterPlainWrapper(bindings.iterator(), execCxt) ;
    }
View Full Code Here

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

    { super(PropFuncArgType.PF_ARG_SINGLE, PropFuncArgType.PF_ARG_SINGLE) ; }
   
    @Override
    public QueryIterator execEvaluated(Binding binding, PropFuncArg subject, Node predicate, PropFuncArg object, ExecutionContext execCxt)
    {
        BindingMap b = BindingFactory.create(binding) ;

        Node subj = subject.getArg() ;
        if ( ! isSameOrVar(subj, arq) ) IterLib.noResults(execCxt) ;
        if ( subj.isVariable() )
            b.add(Var.alloc(subj), arq) ;

        Node obj = object.getArg() ;
        if ( ! isSameOrVar(obj, version) ) IterLib.noResults(execCxt) ;
        if ( obj.isVariable() )
            b.add(Var.alloc(obj), version) ;
       
        return IterLib.result(b, execCxt) ;
    }
View Full Code Here

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

       
        Node namespaceNode = argObject.getArg(0) ;
        Node localnameNode = argObject.getArg(1) ;
       
        // New binding to return.
        BindingMap b = null ;
        if ( Var.isVar(namespaceNode) || Var.isVar(localnameNode) )
            b = BindingFactory.create(binding) ;
       
        if ( Var.isVar(namespaceNode) ) // .isVariable() )
        {
            b.add(Var.alloc(namespaceNode), NodeFactory.createURI(namespace)) ;
            // Check for the case of (?x ?x) (very unlikely - and even more unlikely to cause a match)
            // but it's possible for strange URI schemes.
            if ( localnameNode.isVariable() && namespaceNode.getName() == localnameNode.getName() )
                localnameNode = NodeFactory.createURI(namespace) ;
        }
        else
        {
            String ns = null ;
            // Allow both IRIs and plain literals in the namespace position.
            if ( namespaceNode.isURI() )
                ns = namespaceNode.getURI() ;
            if ( namespaceNode.isLiteral() )
                ns = NodeUtils.stringLiteral(namespaceNode) ;
            if ( ns == null || ! ns.equals(namespace) )
                return IterLib.noResults(execCxt) ;
            // Fall through and proceed to localname
        }
       
        if ( Var.isVar(localnameNode) )
            b.add(Var.alloc(localnameNode), NodeFactory.createLiteral(localname)) ;
        else
        {
            // Only string literals (plain strings or datatype xsd:string)
            String lc = NodeUtils.stringLiteral(localnameNode) ;
            if ( lc == null || ! lc.equals(localname) )
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.