@Override protected int offsetForId( long id ) { Integer override = nextPageOffset.poll(); return override != null ? override : super.offsetForId( id ); } }
private void throwOutOfBoundsException( long recordId ) { RECORD record = newRecord(); record.setId( recordId ); long pageId = pageIdForRecord( recordId ); int offset = offsetForId( recordId ); throw new UnderlyingStorageException( buildOutOfBoundsExceptionMessage( record, pageId, offset, recordSize, pagedFile.pageSize(), storageFile.getAbsolutePath() ) ); }
private void readIntoRecord( long id, RECORD record, RecordLoad mode, PageCursor cursor ) throws IOException { // Mark the record with this id regardless of whether or not we load the contents of it. // This is done in this method since there are multiple call sites and they all want the id // on that record, so it's to ensure it isn't forgotten. record.setId( id ); long pageId = pageIdForRecord( id ); int offset = offsetForId( id ); if ( cursor.next( pageId ) ) { cursor.setOffset( offset ); readRecordFromPage( id, record, mode, cursor ); } else { verifyAfterNotRead( record, mode ); } }
public byte[] getRawRecordData( long id ) throws IOException { byte[] data = new byte[recordSize]; long pageId = pageIdForRecord( id ); int offset = offsetForId( id ); try ( PageCursor cursor = pagedFile.io( pageId, PagedFile.PF_SHARED_READ_LOCK ) ) { if ( cursor.next() ) { cursor.setOffset( offset ); cursor.mark(); do { cursor.setOffsetToMark(); cursor.getBytes( data ); } while ( cursor.shouldRetry() ); checkForDecodingErrors( cursor, id, CHECK ); } } return data; }
public boolean isInUse( long id ) { long pageId = pageIdForRecord( id ); int offset = offsetForId( id ); try ( PageCursor cursor = pagedFile.io( pageId, PF_SHARED_READ_LOCK ) ) { boolean recordIsInUse = false; if ( cursor.next() ) { cursor.setOffset( offset ); cursor.mark(); do { cursor.setOffsetToMark(); recordIsInUse = isInUse( cursor ); } while ( cursor.shouldRetry() ); checkForDecodingErrors( cursor, id, NORMAL ); } return recordIsInUse; } catch ( IOException e ) { throw new UnderlyingStorageException( e ); } }
int offset = offsetForId( id ); try ( PageCursor cursor = pagedFile.io( pageId, PF_SHARED_WRITE_LOCK ) )
private void throwOutOfBoundsException( long recordId ) { RECORD record = newRecord(); record.setId( recordId ); long pageId = pageIdForRecord( recordId ); int offset = offsetForId( recordId ); throw new UnderlyingStorageException( buildOutOfBoundsExceptionMessage( record, pageId, offset, recordSize, pagedFile.pageSize(), storageFile.getAbsolutePath() ) ); }
private void readIntoRecord( long id, RECORD record, RecordLoad mode, PageCursor cursor ) throws IOException { // Mark the record with this id regardless of whether or not we load the contents of it. // This is done in this method since there are multiple call sites and they all want the id // on that record, so it's to ensure it isn't forgotten. record.setId( id ); long pageId = pageIdForRecord( id ); int offset = offsetForId( id ); if ( cursor.next( pageId ) ) { cursor.setOffset( offset ); readRecordFromPage( id, record, mode, cursor ); } else { verifyAfterNotRead( record, mode ); } }
public byte[] getRawRecordData( long id ) throws IOException { byte[] data = new byte[recordSize]; long pageId = pageIdForRecord( id ); int offset = offsetForId( id ); try ( PageCursor cursor = pagedFile.io( pageId, PagedFile.PF_SHARED_READ_LOCK ) ) { if ( cursor.next() ) { cursor.setOffset( offset ); cursor.mark(); do { cursor.setOffsetToMark(); cursor.getBytes( data ); } while ( cursor.shouldRetry() ); checkForDecodingErrors( cursor, id, CHECK ); } } return data; }
public boolean isInUse( long id ) { long pageId = pageIdForRecord( id ); int offset = offsetForId( id ); try ( PageCursor cursor = pagedFile.io( pageId, PF_SHARED_READ_LOCK ) ) { boolean recordIsInUse = false; if ( cursor.next() ) { cursor.setOffset( offset ); cursor.mark(); do { cursor.setOffsetToMark(); recordIsInUse = isInUse( cursor ); } while ( cursor.shouldRetry() ); checkForDecodingErrors( cursor, id, NORMAL ); } return recordIsInUse; } catch ( IOException e ) { throw new UnderlyingStorageException( e ); } }
int offset = offsetForId( id ); try ( PageCursor cursor = pagedFile.io( pageId, PF_SHARED_WRITE_LOCK ) )