/** * Perform an comparison between two unsigned integers. * * @param a The first value to compare. * @param b The second value to compare. * @return 1, 0 or -1 if a is greater than, equal to, or less than b. */ public static int compareUInt(int a, int b) { if (a == b) { return 0; } long ua = ui(a); long ub = ui(b); return (ua < ub) ? (-1) : 1; }
if (blockSize != (1 << XAUtils.log2(blockSize))) {
/** * Reads data from the specified block into the ByteBuffer starting at the * current position. The number of bytes read is the number of remaining * bytes in the ByteBuffer. */ private ByteBuffer retrieveRemainingBytes( ObjectPool objectPool, ByteBuffer data, long blockId ) throws IOException { int dataSize = data.remaining(); if (dataSize > 0) { // Determine the block file to use. int fileIndex = XAUtils.log2( (dataSize - 1) >> (LOG2_MIN_BLOCK_SIZE - 1) ); ManagedBlockFile.Phase blockFilePhase = blockFilePhases[fileIndex]; Block block = blockFilePhase.readBlock(objectPool, blockId); try { block.get(0, data); } finally { block.release(); } } return data; }
private void freeBlock(AVLNode avlNode) throws IOException { int dataSize = avlNode.getPayloadInt(IDX_DATA_SIZE_I); // Check if a block has been allocated. if (dataSize > MAX_DIRECT_DATA_BYTES) { // The number of SPObject data bytes in the AVLNode. int directDataSize = MAX_DIRECT_DATA_BYTES - Constants.SIZEOF_LONG; // Free the block. long blockId = avlNode.getPayloadLong(IDX_BLOCK_ID); // Determine the block file to use. int fileIndex = XAUtils.log2( (dataSize - directDataSize - 1) >> (LOG2_MIN_BLOCK_SIZE - 1) ); ManagedBlockFile.Phase blockFilePhase = blockFilePhases[fileIndex]; blockFilePhase.freeBlock(blockId); } }
int fileIndex = XAUtils.log2( (data.remaining() - 1) >> (LOG2_MIN_BLOCK_SIZE - 1) );