/** * Inserts a new record. Returns the new physical rowid. */ long insert(byte[] data, int start, int length) throws IOException { if (length < 1) throw new IllegalArgumentException("Lenght is <1"); if (start < 0) throw new IllegalArgumentException("negative start"); long retval = alloc(length); write(retval, data, start, length); return retval; }
/** * Inserts a new record. Returns the new physical rowid. */ Location insert( byte[] data, int start, int length ) throws IOException { Location retval = alloc( length ); write( retval, data, start, length ); return retval; }
/** * Inserts a new record. Returns the new physical rowid. */ Location insert( byte[] data, int start, int length ) throws IOException { // Find the location for the added data Location retval = alloc( length ); // And write it write( retval, data, start, length ); return retval; }
/** * Inserts a new record. Returns the new physical rowid. */ Location insert( byte[] data, int start, int length ) throws IOException { Location retval = alloc( length ); write( retval, data, start, length ); return retval; }
/** * Updates an existing record. Returns the possibly changed physical rowid. */ long update(long rowid, byte[] data, int start, int length) throws IOException { // fetch the record header BlockIo block = file.get(Location.getBlock(rowid)); short head = Location.getOffset(rowid); int availSize = RecordHeader.getAvailableSize(block, head); if (length > availSize || //difference between free and available space can be only 64KB. //if bigger, need to realocate and free block availSize - length > RecordHeader.MAX_SIZE_SPACE ) { // not enough space - we need to copy to a new rowid. file.release(block); free(rowid); rowid = alloc(length); } else { file.release(block); } // 'nuff space, write it in and return the rowid. write(rowid, data, start, length); return rowid; }
/** * Updates an existing record. Returns the possibly changed * physical rowid. */ Location update( Location rowid, byte[] data, int start, int length ) throws IOException { // fetch the record header BlockIo block = file.get( rowid.getBlock() ); RecordHeader head = new RecordHeader( block, rowid.getOffset() ); if ( length > head.getAvailableSize() ) { // not enough space - we need to copy to a new rowid. file.release( block ); free( rowid ); rowid = alloc( length ); } else { file.release( block ); } // 'nuff space, write it in and return the rowid. write( rowid, data, start, length ); return rowid; }
/** * Updates an existing record. Returns the possibly changed * physical rowid. */ Location update( Location rowid, byte[] data, int start, int length ) throws IOException { // fetch the record header BlockIo block = pageManager.getRecordFile().get( rowid.getBlock() ); RecordHeader head = new RecordHeader( block, rowid.getOffset() ); if ( length > head.getAvailableSize() ) { // not enough space - we need to copy to a new rowid. pageManager.getRecordFile().release( block ); free( rowid ); rowid = alloc( length ); } else { pageManager.getRecordFile().release( block ); } // 'nuff space, write it in and return the rowid. write( rowid, data, start, length ); return rowid; }
/** * Updates an existing record. Returns the possibly changed * physical rowid. */ Location update( Location rowid, byte[] data, int start, int length ) throws IOException { // fetch the record header BlockIo block = pageManager.getRecordFile().get( rowid.getBlock() ); RecordHeader head = new RecordHeader( block, rowid.getOffset() ); if ( length > head.getAvailableSize() ) { // not enough space - we need to copy to a new rowid. pageManager.getRecordFile().release( block ); free( rowid ); rowid = alloc( length ); } else { pageManager.getRecordFile().release( block ); } // 'nuff space, write it in and return the rowid. write( rowid, data, start, length ); return rowid; }