/** * Creates a new phase for this AVL tree. * * @throws IOException If and I/O error occurs. */ public Phase() throws IOException { if (currentPhase == null) { rootId = AVLNode.NULL_NODE; nrNodes = 0; } else { rootId = currentPhase.rootId; nrNodes = currentPhase.nrNodes; } avlBlockFilePhase = avlBlockFile.new Phase(); check(); currentPhase = this; }
/** * Constructs a phase, copying another phase. * * @param p The phase to copy. * @throws IOException If an I/O error occurs. */ public Phase(Phase p) throws IOException { assert p != null; rootId = p.rootId; nrNodes = p.nrNodes; avlBlockFilePhase = avlBlockFile.new Phase(p.avlBlockFilePhase); check(); currentPhase = this; }
/** * Construct a phase, copy the phase data found in an existing block. * * @param b The block containing the phase data. * @param offset The offset of the phase data within the block. * @throws IOException If an I/O error occurs. */ public Phase(Block b, int offset) throws IOException { rootId = b.getLong(offset + IDX_ROOT_ID); nrNodes = b.getLong(offset + IDX_NR_NODES); avlBlockFilePhase = avlBlockFile.new Phase(b, offset + HEADER_SIZE); check(); currentPhase = this; }
/** * Writes this PersistableMetaRoot to the specified Block. The ints are * written at the specified offset. * * @param b the Block. * @param offset the offset into the Block to start writing. */ public void writeToBlock(Block b, int offset) { check(); b.putLong(offset + IDX_ROOT_ID, rootId); b.putLong(offset + IDX_NR_NODES, nrNodes); avlBlockFilePhase.writeToBlock(b, offset + HEADER_SIZE); }