/** * Gets the ID of the left child node to this node. * * @return The ID of the left child node. */ long getLeftId() { return block.getLong(IDX_LEFT); }
/** * Gets the ID of the right child node to this node. * * @return The ID of the right child node. */ long getRightId() { return block.getLong(IDX_RIGHT); }
/** * Gets a long from the AVLNode payload * * @param offset The offset into the payload (in longs). * @return The requested long value. */ public long getPayloadLong(int offset) { assert offset > 0; return block.getLong(IDX_PAYLOAD + offset); }
/** * Constructor to build a transaction phase, initializing its internal * values with a given Block. The enclosing FreeList object is initialized * to use this single phase. * * @param b The Block with the initialization values for the phase, in the * order: phase number; head; tail; nextItem. * @param offset The offset within the block to find the phase data. This offset can be due to a header appearing before the freelist data. * @throws IllegalStateException if the enclosing FreeList already has a * phase, or is in an invalid state. * @throws IOException if an I/O error occurs. */ public Phase(Block b, int offset) throws IOException { this( b.getLong(offset + IDX_HEAD), b.getLong(offset + IDX_TAIL), b.getLong(offset + IDX_NEXT_ITEM), b.getLong(offset + IDX_NR_VALID_ITEMS) ); }
/** * Gets the ChildNode on a given side of the current node. * * @param index The index of the child. Either {@link #IDX_LEFT} * or {@link #IDX_RIGHT} * @return The Child node, or <code>null</code> if there is no * child on the given side. */ private AVLNode getChildNode_N(int index) { assert refCount > 0; long nodeId = block.getLong(index); return nodeId == NULL_NODE ? null : newInstance(phase, objectPool, this, index, nodeId); }
/** * 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; }
if (block.getLong(ci) != NULL_NODE) { throw new IllegalStateException("Non-leaf inserts are illegal.");
blockItem = tailBlock.getLong(offset);
long adjacentNodeChildId = adjacentNode.block.getLong(ci); AVLNode adjacentParent = adjacentNode.parentNode; int adjacentParentChildIndex = adjacentNode.childIndex; adjacentNode.rightChildNode = null; adjacentNode.childIndex = childIndex; adjacentNode.block.putLong(IDX_LEFT, block.getLong(IDX_LEFT)); adjacentNode.block.putLong(IDX_RIGHT, block.getLong(IDX_RIGHT)); adjacentNode.block.putByte(IDX_BALANCE_B, block.getByte(IDX_BALANCE_B));
block.putLong(IDX_RIGHT, nodeR.block.getLong(IDX_LEFT)); nodeR.block.putLong(IDX_LEFT, getId());
block.putLong(IDX_LEFT, nodeL.block.getLong(IDX_RIGHT)); nodeL.block.putLong(IDX_RIGHT, getId());