static long decompressRecid(long recid){ long block = recid >>8; short offset = (short) (((recid & 0xff) ) * 8+TranslationPage.O_TRANS); return Location.toLong(block, offset); }}
public long slotToLocation(int slot) { short pos = slotToOffset(slot); return Location.toLong(getLocationBlock(pos),getLocationOffset(pos)); }
public long slotToLocation(int slot) { short pos = slotToOffset(slot); return Location.toLong(getLocationBlock(pos),getLocationOffset(pos)); }
/** * Inserts a new record using a custom serializer. * * @param obj the object for the new record. * @param serializer a custom serializer * @return the rowid for the new record. * @throws IOException when one of the underlying I/O operations fails. */ public long insert( Object obj, Serializer serializer ) throws IOException { byte[] data; long recid; Location physRowId; checkIfClosed(); data = serializer.serialize( obj ); physRowId = physMgr.insert( data, 0, data.length ); recid = logMgr.insert( physRowId ).toLong(); LOG.debug( "BaseRecordManager.insert() recid {} length {}", recid, data.length ); return recid; }
/** * Creates a new logical rowid pointing to the indicated physical id */ long insert(long loc) throws IOException { // check whether there's a free rowid to reuse long retval = freeman.get(); if (retval == 0) { // 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 < ELEMS_PER_PAGE; i++) { freeman.put(Location.toLong(firstPage, curOffset)); curOffset += PageHeader.PhysicalRowId_SIZE; } retval = freeman.get(); if (retval == 0) { throw new Error("couldn't obtain free translation"); } } // write the translation. update(retval, loc); return retval; }
/** * Inserts a new record using a custom serializer. * * @param obj the object for the new record. * @param serializer a custom serializer * @return the rowid for the new record. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized long insert( Object obj, Serializer serializer ) throws IOException { byte[] data; long recid; Location physRowId; checkIfClosed(); data = serializer.serialize( obj ); physRowId = physMgr.insert( data, 0, data.length ); recid = logMgr.insert( physRowId ).toLong(); if ( DEBUG ) { System.out.println( "BaseRecordManager.insert() recid " + recid + " length " + data.length ) ; } return recid; }
/** * Inserts a new record using a custom serializer. * * @param obj the object for the new record. * @param serializer a custom serializer * @return the rowid for the new record. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized long insert( Object obj, Serializer serializer ) throws IOException { byte[] data; long recid; Location physRowId; checkIfClosed(); data = serializer.serialize( obj ); physRowId = physMgr.insert( data, 0, data.length ); recid = logMgr.insert( physRowId ).toLong(); if ( DEBUG ) { System.out.println( "BaseRecordManager.insert() recid " + recid + " length " + data.length ); } return recid; }
/** * Returns a mapping * * @param rowid * The logical rowid * @return The physical rowid, 0 if does not exist */ long fetch(long rowid) throws IOException { final long block = Location.getBlock(rowid); long last = pageman.getLast(Magic.TRANSLATION_PAGE); if(last+1<block) return 0; final short offset = Location.getOffset(rowid); BlockIo bio = file.get(block); TranslationPage xlatPage = TranslationPage.getTranslationPageView(bio,blockSize); try { long retval = Location.toLong( xlatPage.getLocationBlock(offset), xlatPage.getLocationOffset(offset)); return retval; } finally { file.release(block, false); } }
long retval = Location.toLong(start, pos); int freeHere = BLOCK_SIZE - pos - RecordHeader.SIZE; if (freeHere < size) {