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 ); } }
@Override public void nextRecordByCursor( RECORD record, RecordLoad mode, PageCursor cursor ) throws UnderlyingStorageException { if ( cursor.getCurrentPageId() < -1 ) { throw new IllegalArgumentException( "Pages are assumed to be positive or -1 if not initialized" ); } try { int offset = cursor.getOffset(); long id = record.getId() + 1; record.setId( id ); long pageId = cursor.getCurrentPageId(); if ( offset >= pagedFile.pageSize() || pageId < 0 ) { if ( !cursor.next() ) { verifyAfterNotRead( record, mode ); return; } cursor.setOffset( 0 ); } readRecordFromPage( id, record, mode, cursor ); } catch ( IOException e ) { throw new UnderlyingStorageException( e ); } }
private <RECORD extends AbstractBaseRecord> void createRecordIn( RecordStore<RECORD> store ) { RECORD record = store.newRecord(); record.setId( store.nextId() ); record.setInUse( true ); if ( record instanceof PropertyRecord ) { // Special hack for property store, since it's not enough to simply set a record as in use there PropertyBlock block = new PropertyBlock(); ((PropertyStore)store).encodeValue( block, 0, Values.of( 10 ) ); ((PropertyRecord) record).addPropertyBlock( block ); } store.updateRecord( record ); }
read.setId( written.getId() );
public static <R extends AbstractBaseRecord> long loadRecords(long[] submitted, R record, RecordStore<R> recordStore, TerminationGuard guard) { if (Util.transactionIsTerminated(guard)) return 0; for (long recordId : submitted) { record.setId(recordId); record.clear(); try { recordStore.getRecord(recordId, record, RecordLoad.NORMAL); } catch (Exception ignore) { // ignore } } return submitted.length; }
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 ); } }
@Override public void nextRecordByCursor( RECORD record, RecordLoad mode, PageCursor cursor ) throws UnderlyingStorageException { if ( cursor.getCurrentPageId() < -1 ) { throw new IllegalArgumentException( "Pages are assumed to be positive or -1 if not initialized" ); } try { int offset = cursor.getOffset(); long id = record.getId() + 1; record.setId( id ); long pageId = cursor.getCurrentPageId(); if ( offset >= pagedFile.pageSize() || pageId < 0 ) { if ( !cursor.next() ) { verifyAfterNotRead( record, mode ); return; } cursor.setOffset( 0 ); } readRecordFromPage( id, record, mode, cursor ); } catch ( IOException e ) { throw new UnderlyingStorageException( e ); } }