Package com.hp.hpl.jena.tdb.store

Examples of com.hp.hpl.jena.tdb.store.NodeId


            System.out.println(label) ;
        Iterator<Pair<NodeId, Node>> iter = nodeTable.all() ;
        for ( ; iter.hasNext() ; )
        {
            Pair<NodeId, Node> x = iter.next() ;
            NodeId nodeId = x.getLeft() ;
            Node node = x.getRight() ;
            System.out.println(nodeId+" "+node) ;
        }
    }
View Full Code Here


        for ( int i = 0 ; i < patternTuple.size() ; i++ )
        {
            Node n = patternTuple.get(i) ;
            // Substitution and turning into NodeIds
            // Variables unsubstituted are null NodeIds
            NodeId nId = idFor(nodeTable, input, n) ;
            if ( NodeId.isDoesNotExist(nId) )
                new NullIterator<BindingNodeId>() ;
            ids[i] = nId ;
            if ( nId == null )
                var[i] = asVar(n) ;
View Full Code Here

   
    @Override
    protected Iterator<BindingNodeId> makeNextStage(final BindingNodeId input)
    {
        // ---- Convert to NodeIds
        NodeId ids[] = new NodeId[patternTuple.size()] ;
        // Variables for this tuple after subsitution
        final Var[] var = new Var[patternTuple.size()] ;

        prepare(nodeTupleTable.getNodeTable(), patternTuple, input, ids, var) ;
       
        Iterator<Tuple<NodeId>> iterMatches = nodeTupleTable.find(Tuple.create(ids))
       
        // ** Allow a triple or quad filter here.
        if ( filter != null )
            iterMatches = Iter.filter(iterMatches, filter) ;
       
        // If we want to reduce to RDF semantics over quads,
        // we need to reduce the quads to unique triples.
        // We do that by having the graph slot as "any", then running
        // through a distinct-ifier.
        // Assumes quads are GSPO - zaps the first slot.
        // Assumes that tuples are not shared.
        if ( anyGraphs )
        {
            iterMatches = Iter.operate(iterMatches, quadsToAnyTriples) ;
            // If any slots were set, then the index would be ???G and we can use distinctAdjacent.
            // If all slots are unset, the index is probably GSPO (SPOG would be better in this one case).
            // This is a safe, if potentially costly, choice.
           
            //Guaranteed
            //iterMatches = Iter.distinct(iterMatches) ;
           
            // This depends on the way indexes are choose and
            // the indexing pattern. It assumes that the index
            // chosen ends in G so same triples are adjacent
            // in a union query.
            // If any slot is defined, then the index will be X??G.
            // if no slot is defined, then the index will be ???G.
            //  See TupleTable.scanAllIndex that ensures the latter.
            //  The former assumes indexes are either G... or ...G.
            //  No G part way through.
            iterMatches = Iter.distinctAdjacent(iterMatches) ;
        }
       
        // Map Tuple<NodeId> to BindingNodeId
        Transform<Tuple<NodeId>, BindingNodeId> binder = new Transform<Tuple<NodeId>, BindingNodeId>()
        {
            @Override
            public BindingNodeId convert(Tuple<NodeId> tuple)
            {
                BindingNodeId output = new BindingNodeId(input) ;
                for ( int i = 0 ; i < var.length ; i++ )
                {
                    Var v = var[i] ;
                    if ( v == null )
                        continue ;
                    NodeId id = tuple.get(i) ;
                    if ( reject(output, v, id) )
                        return null ;
                    output.put(v, id) ;
                }
                return output ;
View Full Code Here

    /** Return null for variables, and for nodes, the node id or NodeDoesNotExist */
    private static NodeId idFor(NodeTable nodeTable, BindingNodeId input, Node node)
    {
        if ( Var.isVar(node) )
        {
            NodeId n = input.get((Var.alloc(node))) ;
            // Bound to NodeId or null.
            return n ;
        }
        // May return NodeId.NodeDoesNotExist which must not be null.
        return nodeTable.getNodeIdForNode(node) ;
View Full Code Here

            return NodeId.NodeIdAny ;
       
        synchronized (lock)
        {
            // Check caches.
            NodeId nodeId = cacheLookup(node) ;
            if ( nodeId != null )
                return nodeId ;

            if ( allocate )
                nodeId = baseTable.getAllocateNodeId(node) ;
View Full Code Here

       
        for ( ; iter1.hasNext() ; )
        {
            Node n = iter1.next() ;
           
            NodeId nId = node2id_Cache.get(n) ;
            if ( !id2node_Cache.containsKey(nId) )
                throw new TDBException("Inconsistent: "+n+" => "+nId) ;
            if ( notPresent.contains(n) )
                throw new TDBException("Inconsistent: "+n+" in notPresent cache (1)") ;
        }
        Iterator<NodeId> iter2 = Iter.toList(id2node_Cache.keys()).iterator() ; ;
        for ( ; iter2.hasNext() ; )
        {
            NodeId nId = iter2.next() ;
            Node n =  id2node_Cache.get(nId) ;
            if ( !node2id_Cache.containsKey(n) )
                throw new TDBException("Inconsistent: "+nId+" => "+n) ;
            if ( notPresent.contains(n) )
                throw new TDBException("Inconsistent: "+n+" in notPresent cache (2)") ;
View Full Code Here

        for ( ; vIter.hasNext() ; )
        {
            Var v = vIter.next() ;
            if ( v == null )
                throw new IllegalArgumentException("Null key") ;
            NodeId n = other.get(v) ;
            if ( n == null )
                throw new IllegalArgumentException("("+v+","+n+")") ;
            super.put(v, n) ;
        }
    }
View Full Code Here

        for ( Var v : this )
        {
            if ( ! first )
                sb.append(" ") ;
            first = false ;
            NodeId x = get(v) ;
            sb.append(v) ;
            sb.append(" = ") ;
            sb.append(x) ;
        }
           
View Full Code Here

   
    @Override
    public NodeId getAllocateNodeId(Node node)
    {
        //info("getAllocateNodeId("+node+") =>") ;
        NodeId nId = nodeTable.getAllocateNodeId(node) ;
        info("getAllocateNodeId("+node+") => "+nId) ;
        return nId ;
    }
View Full Code Here

    @Override
    public NodeId getNodeIdForNode(Node node)
    {
        //info("getNodeIdForNode("+node+") =>") ;
        NodeId nId = nodeTable.getNodeIdForNode(node) ;
        info("getNodeIdForNode("+node+") => "+nId) ;
        return nId ;
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.tdb.store.NodeId

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.