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

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


    }
   
    protected abstract BlockAccess make() ;
    protected static Block data(BlockAccess file, int len)
    {
        Block b = file.allocate(len) ;
        for (int i = 0 ; i < len ; i++ )
            b.getByteBuffer().put((byte)(i&0xFF)) ;
        return b ;
    }
View Full Code Here


        assertTrue(file.isEmpty()) ;
    }
   
    @Test public void fileaccess_02()
    {
        Block b = data(file, blkSize) ;
        file.write(b) ;
    }
View Full Code Here

        file.write(b) ;
    }

    @Test public void fileaccess_03()
    {
        Block b1 = data(file, blkSize) ;
        file.write(b1) ;
        long x = b1.getId() ;
        Block b9 = file.read(x) ;
        assertNotSame(b1, b9) ;
        assertTrue(sameValue(b1, b9)) ;
        b9 = file.read(x) ;
        assertNotSame(b1, b9) ;
        assertTrue(sameValue(b1, b9)) ;
View Full Code Here

        assertTrue(sameValue(b1, b9)) ;
    }
   
    @Test public void fileaccess_04()
    {
        Block b1 = data(file, blkSize) ;
        Block b2 = data(file, blkSize) ;
        file.write(b1) ;
        file.write(b2) ;
       
        long x = b1.getId() ;
        Block b8 = file.read(b1.getId()) ;
        Block b9 = file.read(b1.getId()) ;
        assertNotSame(b8, b9) ;
        assertTrue(b8.getId() == b9.getId()) ;
    }
View Full Code Here

    }
   
    @Test(expected=FileException.class)
    public void fileaccess_05()
    {
        Block b1 = data(file, 10) ;
        Block b2 = data(file, 20) ;
        file.write(b1) ;
       
        // Should not work. b2 not written.  
        Block b2a = file.read(b2.getId()) ;
    }   
View Full Code Here

   
    private void writePrealloc(int sizeOfBuffer, int... sizes)
    {
        ObjectFile file = make(sizeOfBuffer) ;
        int N = sizes.length ;
        Block blocks[] = new Block[N] ;
        ByteBuffer read[] = new ByteBuffer[N] ;
       
        for ( int i = 0 ; i < N ; i++ )
        {
            blocks[i] = file.allocWrite(sizes[i]) ;
View Full Code Here

        assertEquals(0, file.length()) ;
    }

    @Test public void objectfile_02()
    {
        Block block = file.allocWrite(10) ;
        fill(block.getByteBuffer()) ;
        file.completeWrite(block) ;
        long x1 = block.getId() ;
        assertEquals(0, x1) ;
       
        ByteBuffer bb = file.read(x1) ;
       
        // position
       
        assertTrue(sameValue(block.getByteBuffer(), bb)) ;
    }
View Full Code Here

        assertEquals(0, x1) ;
    }

    @Test public void objectfile_04()
    {
        Block block1 = file.allocWrite(10) ;
        fill(block1.getByteBuffer()) ;
        file.completeWrite(block1) ;
       
        Block block2 = file.allocWrite(20) ;
        fill(block2.getByteBuffer()) ;
        file.completeWrite(block2) ;
       
        long x1 = block1.getId() ;
        long x2 = block2.getId() ;
       
        assertFalse(x1 == x2) ;
    }
View Full Code Here

    public Block allocate(int size)
    {
        long addr = alloc ;
        ByteBuffer bb = ByteBuffer.allocate(size) ;
        alloc += (size + SizeOfInt) ;
        return new Block((int)addr, bb) ;
    }
View Full Code Here

        bytes.position((int)id) ;
        int len = bytes.getInt() ;
        ByteBuffer bb = ByteBuffer.allocate(len) ;
        // Copy out the bytes - copy for safety.
        bytes.get(bb.array(), 0, len) ;
        return new Block(id, bb) ;
    }
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.