Package com.hp.hpl.jena.tdb.base.block

Examples of com.hp.hpl.jena.tdb.base.block.Block


        check(id) ;
        checkIfClosed() ;
        ByteBuffer bb = ByteBuffer.allocate(blockSize) ;
        readByteBuffer(id, bb) ;
        bb.rewind() ;
        Block block = new Block(id, bb) ;
        return block ;
    }
View Full Code Here


    public Block allocate(int blockSize)
    {
        checkIfClosed() ;
        // Might as well allocate now.
        // This allocates the id.
        Block block = blockMgr.allocate(blockSize) ;
        // [TxTDB:TODO]
        // But we "copy" it by allocating ByteBuffer space.
        if ( active )
        {
            block = replicate(block) ;
            writeBlocks.put(block.getId(), block) ;
        }
        return block ;
    }
View Full Code Here

    @Override
    public Block getRead(long id)
    {
        checkIfClosed() ;
        Block block = localBlock(id) ;
        if ( block != null )
            return block ;
        block = blockMgr.getRead(id) ;
        if ( active )
            readBlocks.add(block.getId()) ;
        return block ;
    }
View Full Code Here

    @Override
    public Block getReadIterator(long id)
    {
        //logState() ;
        checkIfClosed() ;
        Block block = localBlock(id) ;
        if ( block == null )
            block = blockMgr.getReadIterator(id) ;
        if ( block == null )
            throw new BlockException("No such block: "+getLabel()+" "+id) ;
        if ( active )
            iteratorBlocks.add(block.getId()) ;
        return block ;
    }
View Full Code Here

    {
        // NB: If we are in a stack of BlockMgrs, after a transaction has committed,
        // we would be called via getRead and the upper Blockgr does the promotion.
        checkActive() ;
        checkIfClosed() ;
        Block block = localBlock(id) ;
        if ( block != null )
            return block ;
       
        // Get-as-read.
        block = blockMgr.getRead(id) ;
View Full Code Here

        if ( writeBuffer == null || spaceRequired > writeBuffer.remaining() )
        {
            // Too big. Have flushed buffering if buffering.
            inAllocWrite = true ;
            ByteBuffer bb = ByteBuffer.allocate(bytesSpace) ;
            allocBlock = new Block(filesize, bb)
            allocLocation = -1 ;
            //log.info("AW:"+state()+"-> ----") ;
            return allocBlock ;
        }
       
        // Will fit.
        inAllocWrite = true ;
        int start = writeBuffer.position() ;
        // Old values for restoration
        oldBufferPosn = start ;
        oldBufferLimit = writeBuffer.limit() ;
       
        // id (but don't tell the caller yet).
        allocLocation = filesize+start ;
       
        // Slice it.
        writeBuffer.putInt(bytesSpace) ;
        writeBuffer.position(start + SizeOfInt) ;
        writeBuffer.limit(start+spaceRequired) ;
        ByteBuffer bb = writeBuffer.slice() ;

        allocBlock = new Block(allocLocation, bb) ;

        if ( logging )
            log("AW: %s->0x%X", state(), allocLocation) ;
        return allocBlock ;
    }
View Full Code Here

    {
        try {
            for ( int id = 0 ; id < 9999999 ; id++)
            {
                if ( ! blkMgr.valid(id) ) break ;
                Block blk = blkMgr.getRead(id) ;
                out.print("id="+blk.getId()+"  ") ;
                ByteBufferLib.print(out, blk.getByteBuffer()) ;
            }
        } catch (Exception ex) {
            ex.printStackTrace() ;
        }
    }
View Full Code Here

        if ( blkSize > 0 && blkSize != this.blockSize )
            throw new FileException("Fixed blocksize only: request= "+blkSize+" / fixed size="+this.blockSize) ;
       
        int x = blocks.size() ;
        ByteBuffer bb = ByteBuffer.allocate(blkSize) ;
        Block block = new Block(x, bb) ;
        blocks.add(block) ;
        return block;
    }
View Full Code Here

    @Override
    public Block read(long id)
    {
        check(id) ;
        Block blk = blocks.get((int)id) ;
        if ( safeModeThisMgr )
            return blk.replicate() ;
        else
            return blk ;
    }
View Full Code Here

   
    @Test
    public void fileaccess_50()
    {
        BlockAccess file = make() ;
        Block b1 = data(file, 10) ;
        Block b2 = data(file, 20) ;
        file.write(b1) ;
        file.write(b2) ;
       
        Block b1a = file.read(b1.getId()) ;
        Block b2a = file.read(b2.getId()) ;

        assertNotSame(b1a, b1) ;
        assertNotSame(b2a, b2) ;
        sameValue(b1, b1a) ;
        sameValue(b2, b2a) ;
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.tdb.base.block.Block

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.