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

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


    public void nodetrans_05()
    {  
        // 2 transactions - no blocking reader - create a second NodeTableTrans
        Transaction txn1 = createTxn(11) ;
        NodeTableTrans ntt1 = create(txn1, node1) ;
        NodeId nodeId1 = ntt1.getBaseNodeTable().getNodeIdForNode(node1) ;
       
        ntt1.begin(txn1) ;
        NodeId nodeId2 = ntt1.getAllocateNodeId(node2) ;
        ntt1.commitPrepare(txn1) ;
        ntt1.commitEnact(txn1) ;
        ntt1.commitClearup(txn1) ;
       
        Transaction txn2 = createTxn(12) ;
        NodeTableTrans ntt2 = create(txn2, ntt1.getBaseNodeTable()) ;
        ntt2.begin(txn2) ;
        assertEquals(nodeId1, ntt2.getNodeIdForNode(node1)) ;
        assertEquals(nodeId2, ntt2.getNodeIdForNode(node2)) ;
        NodeId nodeId3 = ntt2.getAllocateNodeId(node3) ;
        assertEquals(nodeId3, ntt2.getNodeIdForNode(node3)) ;
        ntt2.commitPrepare(txn2) ;
        ntt2.commitEnact(txn2) ;
        ntt2.commitClearup(txn2) ;
View Full Code Here


    public void nodetrans_06()
    {  
        // 2 transactions - blocking reader - create a second NodeTableTrans
        Transaction txn1 = createTxn(11) ;
        NodeTableTrans ntt1 = create(txn1, node1) ;
        NodeId nodeId1 = ntt1.getBaseNodeTable().getNodeIdForNode(node1) ;
       
        ntt1.begin(txn1) ;
        NodeId nodeId2 = ntt1.getAllocateNodeId(node2) ;
        ntt1.commitPrepare(txn1) ;
       
        // READ - don't enact
        Transaction txn2 = createTxn(12) ;
        NodeTableTrans ntt2 = create(txn2, ntt1.getBaseNodeTable()) ;
        ntt2.begin(txn2) ;
        assertEquals(nodeId1, ntt2.getNodeIdForNode(node1)) ;
        assertEquals(nodeId2, ntt2.getNodeIdForNode(node2)) ;
       
        NodeId nodeId3 = ntt2.getAllocateNodeId(node3) ;
        assertEquals(nodeId3, ntt2.getNodeIdForNode(node3)) ;
        ntt2.commitPrepare(txn2) ;

       
        // READ ends.
View Full Code Here

        writeNode(nt, NodeFactoryExtra.parseNode(str)) ;
    }
   
    protected static void writeNode(NodeTable nt, Node n)
    {
        NodeId nodeId = nt.getAllocateNodeId(n) ;
        assertNotNull(nodeId) ;
        assertNotEquals(NodeId.NodeDoesNotExist, nodeId) ;
        assertNotEquals(NodeId.NodeIdAny, nodeId) ;
       
        Node n2 = nt.getNodeForNodeId(nodeId) ;
        assertEquals(n, n2) ;
       
        NodeId nodeId2 = nt.getNodeIdForNode(n) ;
        assertEquals(nodeId, nodeId2) ;
    }
View Full Code Here

        assertEquals(nodeId, nodeId2) ;
    }
   
    protected static void writeBadNode(NodeTable nt, Node badNode)
    {
        NodeId id1 = nt.allocOffset() ;
        try {
            NodeId nodeId = nt.getAllocateNodeId(badNode) ;
            fail("Expected exception for bad node: "+badNode) ;
        } catch (TDBException ex) { }
        NodeId id2 = nt.allocOffset() ;
        assertEquals(id1, id2) ;
    }
View Full Code Here

    @Test public void nodetable_bad_01()    { testNodeBad(badNode1) ; }
    @Test public void nodetable_bad_02()   
    {
        NodeTable nt = createEmptyNodeTable() ;
        writeNode(nt, "'x'") ;
        NodeId id1 = nt.allocOffset() ;
        writeBadNode(nt, badNode1) ;
        NodeId id2 = nt.allocOffset() ;
        assertEquals(id1, id2) ;
        writeNode(nt, "<http://example/x>") ;
       
    }
View Full Code Here

            Node g = null ;
            // Union graph?!
            if ( ! quad.isTriple() && ! quad.isDefaultGraph() )
                g = quad.getGraph() ;
           
            NodeId sId = nodeTable.getAllocateNodeId(s) ;
            NodeId pId = nodeTable.getAllocateNodeId(p) ;
            NodeId oId = nodeTable.getAllocateNodeId(o) ;
           
            if ( g != null )
            {
                NodeId gId = nodeTable.getAllocateNodeId(g) ;
                writerQuads.write(gId.getId()) ;
                writerQuads.write(sId.getId()) ;
                writerQuads.write(pId.getId()) ;
                writerQuads.write(oId.getId()) ;
                writerQuads.endOfRow() ;
                stats.record(gId, sId, pId, oId) ;
View Full Code Here

    public boolean addRow(Node... nodes)
    {
        try
        {
            startWrite() ;
            NodeId n[] = new NodeId[nodes.length] ;
            for (int i = 0; i < nodes.length; i++)
                n[i] = nodeTable.getAllocateNodeId(nodes[i]) ;

            Tuple<NodeId> t = Tuple.create(n) ;
            return tupleTable.add(t) ;
View Full Code Here

    public boolean deleteRow(Node... nodes)
    {
        try
        {
            startWrite() ;
            NodeId n[] = new NodeId[nodes.length] ;
            for (int i = 0; i < nodes.length; i++)
            {
                NodeId id = idForNode(nodes[i]) ;
                if (NodeId.isDoesNotExist(id)) return false ;
                n[i] = id ;
            }

            Tuple<NodeId> t = Tuple.create(n) ;
View Full Code Here

     * no tuples are found (unknown unknown).
     */
    @Override
    public Iterator<Tuple<NodeId>> findAsNodeIds(Node... nodes)
    {
        NodeId n[] = new NodeId[nodes.length] ;
        try {
            startRead() ;
            for (int i = 0; i < nodes.length; i++)
            {
                NodeId id = idForNode(nodes[i]) ;
                if (NodeId.isDoesNotExist(id)) return Iter.nullIterator() ;
                n[i] = id ;
            }
            return find(n) ; // **public call
        } finally { finishRead() ; }
View Full Code Here

    {
        if ( node == Node.ANY )
            return NodeId.NodeIdAny ;
       
        // synchronized in accessIndex
        NodeId nodeId = accessIndex(node, allocate) ;
        return nodeId ;
    }
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.