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

Examples of com.hp.hpl.jena.tdb.base.file.FileException


    @Override
    public void reposition(long posn)
    {
        if ( inAllocWrite )
            throw new FileException("In the middle of an alloc-write") ;
        if ( posn < 0 || posn > length() )
            throw new IllegalArgumentException("reposition: Bad location: "+posn) ;
        flushOutputBuffer() ;
        file.truncate(posn) ;
        filesize = posn ;
View Full Code Here


    {
        if ( logging )
            log("R(0x%X)", loc) ;
       
        if ( inAllocWrite )
            throw new FileException("In the middle of an alloc-write") ;
        if ( loc < 0 )
            throw new IllegalArgumentException("ObjectFile.read["+file.getLabel()+"]: Bad read: "+loc) ;
       
        // Maybe it's in the in the write buffer.
        // Maybe the write buffer should keep more structure?
        if ( loc >= filesize )
        {
            if ( loc >= filesize+writeBuffer.position() )
                throw new IllegalArgumentException("ObjectFileStorage.read["+file.getLabel()+"]: Bad read: location="+loc+" >= max="+(filesize+writeBuffer.position())) ;
           
            int x = writeBuffer.position() ;
            int y = writeBuffer.limit() ;
           
            int offset = (int)(loc-filesize) ;
            int len = writeBuffer.getInt(offset) ;
            int posn = offset + SizeOfInt ;
            // Slice the data bytes,
            writeBuffer.position(posn) ;
            writeBuffer.limit(posn+len) ;
            ByteBuffer bb = writeBuffer.slice() ;
            writeBuffer.limit(y) ;
            writeBuffer.position(x) ;
            return bb ;
        }
       
        // No - it's in the underlying file storage.
        lengthBuffer.clear() ;
        int x = file.read(lengthBuffer, loc) ;
        if ( x != 4 )
            throw new FileException("ObjectFileStorage.read["+file.getLabel()+"]("+loc+")[filesize="+filesize+"][file.size()="+file.size()+"]: Failed to read the length : got "+x+" bytes") ;
        int len = lengthBuffer.getInt(0) ;
        // Sanity check.
        if ( len > filesize-(loc+SizeOfInt) )
        {
            String msg = "ObjectFileStorage.read["+file.getLabel()+"]("+loc+")[filesize="+filesize+"][file.size()="+file.size()+"]: Impossibly large object : "+len+" bytes > filesize-(loc+SizeOfInt)="+(filesize-(loc+SizeOfInt)) ;
            SystemTDB.errlog.error(msg) ;
            throw new FileException(msg) ;
        }
       
        ByteBuffer bb = ByteBuffer.allocate(len) ;
        if ( len == 0 )
            // Zero bytes.
            return bb ;
        x = file.read(bb, loc+SizeOfInt) ;
        bb.flip() ;
        if ( x != len )
            throw new FileException("ObjectFileStorage.read: Failed to read the object ("+len+" bytes) : got "+x+" bytes") ;
        return bb ;
    }
View Full Code Here

            String s = StrUtils.fromUTF8bytes(p.getRight().array()) ;
           
            long x = base.write(p.getRight()) ;
           
            if ( p.getLeft()+otherAllocOffset != x )
                throw new FileException("Expected id of "+(p.getLeft()+otherAllocOffset)+", got an id of "+x) ;
        }
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.tdb.base.file.FileException

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.