/** Returns true if a slot is free */ boolean isFree( int slot ) { return ! isAllocated( slot ); }
/** * Returns first free slot, -1 if no slots are available */ int getFirstFree() { for (int i = 0; i < ELEMS_PER_PAGE; i++) { if (isFree(i)) return i; } return -1; }
/** Allocates a slot */ short alloc(int slot) { setCount((short) (getCount() + 1)); return slotToOffset(slot); }
/** Frees a slot */ void free(int slot) { short pos = slotToOffset(slot); FreePhysicalRowId_setSize(pos, 0); //get(slot).setSize(0); setCount((short) (getCount() - 1)); }
.getFreePhysicalRowIdPageView( recordFile.get( curs.getCurrent() ) ); int slot = fp.getFirstLargerThan( size ); retval = new Location( fp.get( slot ) ); fp.free( slot ); if ( fp.getCount() == 0 )
FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView( curBlock ); int slot = fp.getFirstFree(); free = fp.alloc( slot ); break; FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView( curBlock ); free = fp.alloc( 0 );
FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView(_file.get(curs.getCurrent()), blockSize); int slot = fp.getFirstLargerThan(size); if (slot != -1) { retval = fp.slotToLocation(slot); fp.free(slot); if (fp.getCount() == 0) {
long freePage = curs.getCurrent(); BlockIo curBlock = _file.get(freePage); FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView(curBlock, blockSize); int slot = fp.getFirstFree(); short freePhysRowId = fp.alloc(slot); fp.setLocationBlock(freePhysRowId, Location.getBlock(rowid)); fp.setLocationOffset(freePhysRowId, Location.getOffset(rowid)); fp.FreePhysicalRowId_setSize(freePhysRowId, size); slot = fp.getFirstFree(); FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView(curBlock, blockSize); int slot = fp.getFirstFree(); short freePhysRowId = fp.alloc(slot); fp.setLocationBlock(freePhysRowId, Location.getBlock(rowid)); fp.setLocationOffset(freePhysRowId, Location.getOffset(rowid)); fp.FreePhysicalRowId_setSize(freePhysRowId, size); slot = fp.getFirstFree();
/** * @return first slot with available size >= indicated size, or -1 if no * slots are available. */ int getFirstLargerThan( int size ) { for ( int i = 0; i < ELEMS_PER_PAGE; i++ ) { if ( isAllocated( i ) && get( i ).getSize() >= size ) { return i; } } return -1; }
/** * Factory method to create or return a data page for the indicated block. */ static FreePhysicalRowIdPage getFreePhysicalRowIdPageView(BlockIo block,int pageSize) { BlockView view = block.getView(); if (view != null && view instanceof FreePhysicalRowIdPage) return (FreePhysicalRowIdPage) view; else return new FreePhysicalRowIdPage(block, pageSize); }
sb.append( "count: " ).append( getCount() );
.getFreePhysicalRowIdPageView( file.get( curs.getCurrent() ) ); int slot = fp.getFirstLargerThan( size ); retval = new Location( fp.get( slot ) ); fp.free( slot ); if ( fp.getCount() == 0 )
FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView( curBlock ); int slot = fp.getFirstFree(); free = fp.alloc( slot ); break; FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView( curBlock ); free = fp.alloc( 0 );
/** * Returns first slot with available size >= indicated size, or -1 if no * slots are available. */ int getFirstLargerThan( int size ) { for ( int i = 0; i < ELEMS_PER_PAGE; i++ ) { if ( isAllocated( i ) && get( i ).getSize() >= size ) { return i; } } return -1; } }
/** * Factory method to create or return a data page for the indicated block. */ static FreePhysicalRowIdPage getFreePhysicalRowIdPageView( BlockIo block ) { BlockView view = block.getView(); if ( view != null && view instanceof FreePhysicalRowIdPage ) { return ( FreePhysicalRowIdPage ) view; } else { return new FreePhysicalRowIdPage( block ); } }
.getFreePhysicalRowIdPageView( recordFile.get( curs.getBlockId() ) ); int slot = fp.getFirstLargerThan( size ); retval = new Location( fp.get( slot ) ); fp.free( slot ); if ( fp.getCount() == 0 )
FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView( curBlock ); int slot = fp.getFirstFree(); free = fp.alloc( slot ); break; FreePhysicalRowIdPage fp = FreePhysicalRowIdPage.getFreePhysicalRowIdPageView( curBlock ); free = fp.alloc( 0 );
/** * Returns first slot with available size >= indicated size, or -1 if no * slots are available. */ int getFirstLargerThan( int size ) { for ( int i = 0; i < ELEMS_PER_PAGE; i++ ) { if ( isAllocated( i ) && get( i ).getSize() >= size ) { return i; } } return -1; } }