public byte[] getBlockBytes(int blockAddress, int blockCount) { byte[] dataBytes = new byte[blockCount * lobBlockSize]; int dataBlockOffset = 0; while (blockCount > 0) { int largeBlockIndex = blockAddress / blocksInLargeBlock; byte[] largeBlock = (byte[]) byteStoreList.get(largeBlockIndex); int blockOffset = blockAddress % blocksInLargeBlock; int currentBlockCount = blockCount; if ((blockOffset + currentBlockCount) > blocksInLargeBlock) { currentBlockCount = blocksInLargeBlock - blockOffset; } System.arraycopy( largeBlock, blockOffset * lobBlockSize, dataBytes, dataBlockOffset * lobBlockSize, currentBlockCount * lobBlockSize); blockAddress += currentBlockCount; dataBlockOffset += currentBlockCount; blockCount -= currentBlockCount; } return dataBytes; }
/** Add all columns to a list of expressions */ void addTableColumns(HsqlArrayList exprList) { if (namedJoinColumns != null) { int count = exprList.size(); int position = 0; for (int i = 0; i < count; i++) { Expression e = (Expression) exprList.get(i); String columnName = e.getColumnName(); if (namedJoinColumns.contains(columnName)) { if (position != i) { exprList.remove(i); exprList.add(position, e); } e = getColumnExpression(columnName); exprList.set(position, e); position++; } } } addTableColumns(exprList, exprList.size(), namedJoinColumns); }
public void setBlockBytes(byte[] dataBytes, int blockAddress, int blockCount) { int dataBlockOffset = 0; while (blockCount > 0) { int largeBlockIndex = blockAddress / blocksInLargeBlock; int largeBlockLimit = (blockAddress + blockCount) / blocksInLargeBlock; if ((blockAddress + blockCount) % blocksInLargeBlock != 0) { largeBlockLimit++; } if (largeBlockIndex >= byteStoreList.size()) { byteStoreList.add(new byte[largeBlockSize]); } byte[] largeBlock = (byte[]) byteStoreList.get(largeBlockIndex); int blockOffset = blockAddress % blocksInLargeBlock; int currentBlockCount = blockCount; if ((blockOffset + currentBlockCount) > blocksInLargeBlock) { currentBlockCount = blocksInLargeBlock - blockOffset; } System.arraycopy( dataBytes, dataBlockOffset * lobBlockSize, largeBlock, blockOffset * lobBlockSize, currentBlockCount * lobBlockSize); blockAddress += currentBlockCount; dataBlockOffset += currentBlockCount; blockCount -= currentBlockCount; } }