/** * Returns first allocated slot, -1 if no slots are available. */ int getFirstAllocated() { for (int i = 0; i < ELEMS_PER_PAGE; i++) { if (isAllocated(i)) return i; } return -1; } }
/** * 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; }
/** Frees a slot */ void free(int slot) { setLocationBlock(slotToOffset(slot), 0); //get(slot).setBlock(0); setCount((short) (getCount() - 1)); // update previousFoundFree if the freed slot is before what we've found in the past if (slot < previousFoundFree) previousFoundFree = slot; }
FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView( blockIo ); int slot = fp.getFirstAllocated(); Location location = new Location( fp.get( slot ) ); fp.free( slot ); boolean hasMore = fp.getCount() != 0;
while (curs.next() != 0) { FreeLogicalRowIdPage fp = FreeLogicalRowIdPage .getFreeLogicalRowIdPageView(file.get(curs.getCurrent()),blockSize); int slot = fp.getFirstAllocated(); if (slot != -1) { retval = fp.slotToLocation(slot); fp.free(slot); if (fp.getCount() == 0) {
BlockIo curBlock = recordFile.get(freePage); FreeLogicalRowIdPage fp = FreeLogicalRowIdPage .getFreeLogicalRowIdPageView(curBlock); int slot = fp.getFirstFree(); if (slot != -1) { free = fp.alloc(slot); break; BlockIo curBlock = recordFile.get(freePage); FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView(curBlock); free = fp.alloc(0);
long freePage = curs.getCurrent(); BlockIo curBlock = file.get(freePage); FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView(curBlock, blockSize); int slot = fp.getFirstFree(); short freePhysRowId = fp.alloc(slot); fp.setLocationBlock(freePhysRowId, Location.getBlock(rowid)); fp.setLocationOffset(freePhysRowId, Location.getOffset(rowid)); slot = fp.getFirstFree(); FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView(curBlock, blockSize); int slot = fp.getFirstFree(); short freePhysRowId = fp.alloc(slot); fp.setLocationBlock(freePhysRowId, Location.getBlock(rowid)); fp.setLocationOffset(freePhysRowId, Location.getOffset(rowid)); slot = fp.getFirstFree();
/** * Factory method to create or return a data page for the * indicated block. */ static FreeLogicalRowIdPage getFreeLogicalRowIdPageView(BlockIo block, int blockSize) { BlockView view = block.getView(); if (view != null && view instanceof FreeLogicalRowIdPage) return (FreeLogicalRowIdPage) view; else return new FreeLogicalRowIdPage(block,blockSize); }
/** * {@inheritDoc} */ public String toString() { StringBuilder sb = new StringBuilder(); sb.append( "FreeLogRowIdPage ( " ); // The blockIO sb.append( super.toString() ).append( ", " ); // The first rowId sb.append( "count: " ).append( getCount() ); // Dump the Physical row id for ( int i = 0; i < ELEMS_PER_PAGE; i++ ) { if ( slots[i] != null ) { sb.append( ", [" ).append( i ).append( "]=<" ).append( slots[i].getBlock() ).append( ", " ).append( slots[i].getOffset() ).append( ">" ); } } sb.append( ")" ); return sb.toString(); } }
while (curs.next() != 0) { FreeLogicalRowIdPage fp = FreeLogicalRowIdPage .getFreeLogicalRowIdPageView(recordFile.get(curs.getCurrent())); int slot = fp.getFirstAllocated(); if (slot != -1) { new Location(fp.get(slot)); fp.free(slot); if (fp.getCount() == 0) {
BlockIo curBlock = file.get(freePage); FreeLogicalRowIdPage fp = FreeLogicalRowIdPage .getFreeLogicalRowIdPageView(curBlock); int slot = fp.getFirstFree(); if (slot != -1) { free = fp.alloc(slot); break; BlockIo curBlock = file.get(freePage); FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView(curBlock); free = fp.alloc(0);
/** Allocates a slot */ short alloc(int slot) { setCount((short) (getCount() + 1)); short pos = slotToOffset(slot); setLocationBlock(pos, -1); //get(slot).setBlock(-1); // update previousFoundAllocated if the newly allocated slot is before what we've found in the past if (slot < previousFoundAllocated) previousFoundAllocated = slot; return pos; }
/** * Factory method to create or return a data page for the indicated block. */ static FreeLogicalRowIdPage getFreeLogicalRowIdPageView( BlockIo block ) { BlockView view = block.getView(); if ( view != null && view instanceof FreeLogicalRowIdPage ) { return ( FreeLogicalRowIdPage ) view; } else { return new FreeLogicalRowIdPage(block); } }
while (curs.next() != 0) { FreeLogicalRowIdPage fp = FreeLogicalRowIdPage .getFreeLogicalRowIdPageView(file.get(curs.getCurrent())); int slot = fp.getFirstAllocated(); if (slot != -1) { new Location(fp.get(slot)); fp.free(slot); if (fp.getCount() == 0) {
FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView( curBlockIo ); int slot = fp.getFirstFree(); free = fp.alloc(slot); break; FreeLogicalRowIdPage fp = FreeLogicalRowIdPage.getFreeLogicalRowIdPageView( curBlockIo ); free = fp.alloc( 0 );
/** Returns true if a slot is free */ boolean isFree(int slot) { return !isAllocated(slot); }
/** * Factory method to create or return a data page for the indicated block. */ static FreeLogicalRowIdPage getFreeLogicalRowIdPageView( BlockIo block ) { BlockView view = block.getView(); if ( view != null && view instanceof FreeLogicalRowIdPage ) { return ( FreeLogicalRowIdPage ) view; } else { return new FreeLogicalRowIdPage(block); } }
/** * 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; }