long currentNodeNumber = nodeNumber;
int nodeSize = getBTHeaderRecord().getNodeSize();
ByteBuffer nodeData = ByteBuffer.allocate(nodeSize);
catalogFile.read(fs, (currentNodeNumber * nodeSize), nodeData);
byte[] datas = nodeData.array();
NodeDescriptor nd = new NodeDescriptor(datas, 0);
if (nd.isIndexNode()) {
CatalogIndexNode node = new CatalogIndexNode(datas, nodeSize);
IndexRecord[] records = node.findAll(new CatalogKey(parentID));
List<LeafRecord> lfList = new LinkedList<LeafRecord>();
for (IndexRecord rec : records) {
LeafRecord[] lfr = getRecords(parentID, rec.getIndex());
Collections.addAll(lfList, lfr);
}
return lfList.toArray(new LeafRecord[lfList.size()]);
} else if (nd.isLeafNode()) {
CatalogLeafNode node = new CatalogLeafNode(nodeData.array(), nodeSize);
return node.findAll(new CatalogKey(parentID));
} else {
log.info(
String.format("Node %d wasn't a leaf or index: %s\n%s", nodeNumber, nd, NumberUtils.hex(datas)));