/** * Deletes a record. * * @param recid the rowid for the record that should be deleted. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized void delete( long recid ) throws IOException { checkIfClosed(); if ( recid <= 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } if ( DEBUG ) { System.out.println( "BaseRecordManager.delete() recid " + recid ); } Location logRowId = new Location( recid ); Location physRowId = logMgr.fetch( logRowId ); physMgr.delete( physRowId ); logMgr.delete( logRowId ); }
/** * Deletes a record. * * @param recid the rowid for the record that should be deleted. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized void delete( long recid ) throws IOException { checkIfClosed(); if ( recid <= 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } if ( DEBUG ) { System.out.println( "BaseRecordManager.delete() recid " + recid ) ; } Location logRowId = new Location( recid ); Location physRowId = logMgr.fetch( logRowId ); physMgr.delete( physRowId ); logMgr.delete( logRowId ); }
/** * Fetches a record using a custom serializer. * * @param recid the recid for the record that must be fetched. * @param serializer a custom serializer * @return the object contained in the record. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized Object fetch( long recid, Serializer serializer ) throws IOException { byte[] data; checkIfClosed(); if ( recid <= 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } data = physMgr.fetch( logMgr.fetch( new Location( recid ) ) ); if ( DEBUG ) { System.out.println( "BaseRecordManager.fetch() recid " + recid + " length " + data.length ) ; } return serializer.deserialize( data ); }
/** * Fetches a record using a custom serializer. * * @param recid the recid for the record that must be fetched. * @param serializer a custom serializer * @return the object contained in the record. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized Object fetch( long recid, Serializer serializer ) throws IOException { byte[] data; checkIfClosed(); if ( recid <= 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } data = physMgr.fetch( logMgr.fetch( new Location( recid ) ) ); if ( DEBUG ) { System.out.println( "BaseRecordManager.fetch() recid " + recid + " length " + data.length ); } return serializer.deserialize( data ); }
/** * Creates a new logical rowid pointing to the indicated physical * id */ Location insert( Location loc ) throws IOException { // check whether there's a free rowid to reuse Location retval = freeman.get(); if ( retval == null ) { // no. This means that we bootstrap things by allocating // a new translation page and freeing all the rowids on it. long firstPage = pageManager.allocate( Magic.TRANSLATION_PAGE ); short curOffset = TranslationPage.O_TRANS; for ( int i = 0; i < TranslationPage.ELEMS_PER_PAGE; i++ ) { freeman.put( new Location( firstPage, curOffset ) ); curOffset += PhysicalRowId.SIZE; } retval = freeman.get(); if ( retval == null ) { throw new Error( I18n.err( I18n.ERR_545 ) ); } } // write the translation. update( retval, loc ); return retval; }
/** * Creates a new logical rowid pointing to the indicated physical * id */ Location insert( Location loc ) throws IOException { // check whether there's a free rowid to reuse Location retval = freeman.get(); if ( retval == null ) { // no. This means that we bootstrap things by allocating // a new translation page and freeing all the rowids on it. long firstPage = pageManager.allocate( Magic.TRANSLATION_PAGE ); short curOffset = TranslationPage.O_TRANS; for ( int i = 0; i < TranslationPage.ELEMS_PER_PAGE; i++ ) { freeman.put( new Location( firstPage, curOffset ) ); curOffset += PhysicalRowId.SIZE; } retval = freeman.get(); if ( retval == null ) { throw new Error( I18n.err( I18n.ERR_545 ) ); } } // write the translation. update( retval, loc ); return retval; }
/** * Deletes a record. * * @param recid the rowid for the record that should be deleted. * @throws IOException when one of the underlying I/O operations fails. */ public void delete( long recid ) throws IOException { LockElement element; checkIfClosed(); if ( recid <= 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } LOG.debug( "BaseRecordManager.delete() recid {}", recid ); element = beginIO( recid, IOType.WRITE_IO ); try { Location logRowId = new Location( recid ); Location physRowId = logMgr.fetch( logRowId ); physMgr.delete( physRowId ); logMgr.delete( logRowId ); } finally { this.endIO( recid, element, IOType.WRITE_IO ); } }
Location location = logMgr.fetch( new Location( recid ) ); data = physMgr.fetch( location );
/** * Creates a new logical rowid pointing to the indicated physical * id */ Location insert(Location loc) throws IOException { // check whether there's a free rowid to reuse Location retval = freeman.get(); if (retval == null) { // no. This means that we bootstrap things by allocating // a new translation page and freeing all the rowids on it. long firstPage = pageman.allocate(Magic.TRANSLATION_PAGE); short curOffset = TranslationPage.O_TRANS; for (int i = 0; i < TranslationPage.ELEMS_PER_PAGE; i++) { freeman.put(new Location(firstPage, curOffset)); curOffset += PhysicalRowId.SIZE; } retval = freeman.get(); if (retval == null) { throw new Error( I18n.err( I18n.ERR_545 ) ); } } // write the translation. update(retval, loc); return retval; }
Location logRecid = new Location( recid ); Location physRecid = logMgr.fetch( logRecid );
/** * Updates a record using a custom serializer. * * @param recid the recid for the record that is to be updated. * @param obj the new object for the record. * @param serializer a custom serializer * @throws IOException when one of the underlying I/O operations fails. */ public synchronized void update( long recid, Object obj, Serializer serializer ) throws IOException { checkIfClosed(); if ( recid <= 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } Location logRecid = new Location( recid ); Location physRecid = logMgr.fetch( logRecid ); byte[] data = serializer.serialize( obj ); if ( DEBUG ) { System.out.println( "BaseRecordManager.update() recid " + recid + " length " + data.length ); } Location newRecid = physMgr.update( physRecid, data, 0, data.length ); if ( !newRecid.equals( physRecid ) ) { logMgr.update( logRecid, newRecid ); } }
Location logRecid = new Location( recid ); Location physRecid = logMgr.fetch( logRecid );
/** * Returns a mapping * * @param rowid The logical rowid * @return The physical rowid */ Location fetch( Location rowid ) throws IOException { TranslationPage xlatPage = TranslationPage.getTranslationPageView( recordFile.get( rowid.getBlock() ) ); try { Location retval = new Location( xlatPage.get( rowid.getOffset() ) ); return retval; } finally { recordFile.release( rowid.getBlock(), false ); } }
/** * Returns a mapping * * @param rowid The logical rowid * @return The physical rowid */ Location fetch(Location rowid) throws IOException { TranslationPage xlatPage = TranslationPage.getTranslationPageView( file.get(rowid.getBlock())); try { Location retval = new Location(xlatPage.get(rowid.getOffset())); return retval; } finally { file.release(rowid.getBlock(), false); } }
/** * Returns a mapping * * @param rowid The logical rowid * @return The physical rowid */ Location fetch( Location rowid ) throws IOException { TranslationPage xlatPage = TranslationPage.getTranslationPageView( recordFile.get( rowid.getBlock() ) ); try { Location retval = new Location( xlatPage.get( rowid.getOffset() ) ); return retval; } finally { recordFile.release( rowid.getBlock(), false ); } }
Location location = new Location( fp.get( slot ) );
new Location(fp.get(slot)); fp.free(slot); if (fp.getCount() == 0) {
new Location(fp.get(slot)); fp.free(slot); if (fp.getCount() == 0) {
retval = new Location( fp.get( slot ) );
retval = new Location( fp.get( slot ) );