public int compare( BlockIo block1, BlockIo block2 ) { if ( block1.getBlockId() == block2.getBlockId() ) { return 0; } else if ( block1.getBlockId() < block2.getBlockId() ) { return -1; } else { return 1; } }
/** * Decrements transaction count for this block, to signal that this * block has been written from the log to the data file. */ synchronized void decrementTransactionCount() { transactionCount--; if (transactionCount < 0) throw new Error("transaction count on block " + getBlockId() + " below zero!"); }
/** * Discards a block (will not write the block even if it's dirty) * * @param block The block to discard. */ void discard( BlockIo block ) { inUse.remove( block.getBlockId() ); // note: block not added to free list on purpose, because // it's considered invalid }
/** * Discards a block (will not write the block even if it's dirty) * * @param block The block to discard. */ void discard( BlockIo block ) { inUse.remove( block.getBlockId() ); // note: block not added to free list on purpose, because // it's considered invalid }
/** * Discards a block (will not write the block even if it's dirty) * * @param block The block to discard. */ void discard( BlockIo block ) { inUse.remove( block.getBlockId() ); // note: block not added to free list on purpose, because // it's considered invalid }
/** * Releases a node from the transaction list, if it was sitting there. * * @param recycle true if block data can be reused */ void releaseFromTransaction( BlockIo node, boolean recycle ) throws IOException { if ( ( inTxn.remove( node.getBlockId() ) != null ) && recycle ) { free.add( node ); } }
/** * Releases a node from the transaction list, if it was sitting there. * * @param recycle true if block data can be reused */ void releaseFromTransaction( BlockIo node, boolean recycle ) throws IOException { if ( ( inTxn.remove( node.getBlockId() ) != null ) && recycle ) { free.add( node ); } }
/** * Releases a node from the transaction list, if it was sitting there. * * @param recycle true if block data can be reused */ void releaseFromTransaction( BlockIo node, boolean recycle ) throws IOException { if ( ( inTxn.remove( node.getBlockId() ) != null ) && recycle ) { free.add( node ); } }
/** * Decrements transaction count for this block, to signal that this * block has been written from the log to the data file. */ synchronized void decrementTransactionCount() { transactionCount--; if ( transactionCount < 0 ) { throw new Error( I18n.err( I18n.ERR_541, getBlockId() ) ); } }
/** * Discards a block (will not write the block even if it's dirty) * * @param block The block to discard. */ void discard(BlockIo block) { long key = block.getBlockId(); inUse.remove(key); // note: block not added to free list on purpose, because // it's considered invalid }
/** * Decrements transaction count for this block, to signal that this * block has been written from the log to the data recordFile. */ synchronized void decrementTransactionCount() { transactionCount--; if ( transactionCount < 0 ) { throw new Error( I18n.err( I18n.ERR_541, getBlockId() ) ); } }
/** * Constructs a record header from the indicated data starting at the * indicated position. */ RecordHeader( BlockIo block, short pos ) { this.block = block; this.pos = pos; if ( pos > ( RecordFile.BLOCK_SIZE - SIZE ) ) { throw new Error( I18n.err( I18n.ERR_562, block.getBlockId(), pos ) ); } }
/** * Decrements transaction count for this block, to signal that this * block has been written from the log to the data recordFile. */ /*No qualifier*/ void decrementTransactionCount() { if ( transactionCount.decrementAndGet() < 0 ) { throw new Error( I18n.err( I18n.ERR_541, getBlockId() ) ); } }
/** * Constructs a record header from the indicated data starting at the * indicated position. */ RecordHeader( BlockIo block, short pos ) { this.block = block; this.pos = pos; if ( pos > ( RecordFile.BLOCK_SIZE - SIZE ) ) { throw new Error( I18n.err( I18n.ERR_562, block.getBlockId(), pos ) ); } }
/** * Constructs a record header from the indicated data starting at the * indicated position. */ RecordHeader( BlockIo block, short pos ) { this.block = block; this.pos = pos; if ( pos > ( RecordFile.BLOCK_SIZE - SIZE ) ) { throw new Error( I18n.err( I18n.ERR_562, block.getBlockId(), pos ) ); } }
/** * Synchs a node to disk. This is called by the transaction manager's * synchronization code. */ void synch(BlockIo node) throws IOException { byte[] data = node.getData(); if (data != null) { long offset = node.getBlockId() * BLOCK_SIZE; FileChannel file = getChannel(offset); file.position(offset % MAX_FILE_SIZE); file.write(ByteBuffer.wrap(data)); } }
public String toString() { return "RH( " + block.getBlockId() + " : " + pos + ", avl = " + getAvailableSize() + ", cur = " + getCurrentSize() + " )"; } }
public String toString() { return "RH( " + block.getBlockId() + " : " + pos + ", avl = " + getAvailableSize() + ", cur = " + getCurrentSize() + " )"; } }
public String toString() { return "RH( " + block.getBlockId() + " : " + pos + ", avl = " + getAvailableSize() + ", cur = " + getCurrentSize() + " )"; } }
/** * Releases a node from the transaction list, if it was sitting * there. * * @param recycle true if block data can be reused */ void releaseFromTransaction(BlockIo node, boolean recycle) throws IOException { long key = node.getBlockId(); if ((inTxn.remove(key) != null) && recycle) { free.put(key,node); } }