use of org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor in project asterixdb by apache.
the class TreeIndexTestUtils method checkDiskOrderScan.
public void checkDiskOrderScan(IIndexTestContext ctx) throws Exception {
try {
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Testing Disk-Order Scan.");
}
ITreeIndexAccessor treeIndexAccessor = (ITreeIndexAccessor) ctx.getIndexAccessor();
ITreeIndexCursor diskOrderCursor = treeIndexAccessor.createDiskOrderScanCursor();
treeIndexAccessor.diskOrderScan(diskOrderCursor);
int actualCount = 0;
try {
while (diskOrderCursor.hasNext()) {
diskOrderCursor.next();
ITupleReference tuple = diskOrderCursor.getTuple();
CheckTuple checkTuple = createCheckTupleFromTuple(tuple, ctx.getFieldSerdes(), ctx.getKeyFieldCount());
if (!checkDiskOrderScanResult(tuple, checkTuple, ctx)) {
fail("Disk-order scan returned unexpected answer: " + checkTuple.toString());
}
actualCount++;
}
if (actualCount < ctx.getCheckTuples().size()) {
fail("Disk-order scan returned fewer answers than expected.\nExpected: " + ctx.getCheckTuples().size() + "\nActual : " + actualCount);
}
if (actualCount > ctx.getCheckTuples().size()) {
fail("Disk-order scan returned more answers than expected.\nExpected: " + ctx.getCheckTuples().size() + "\nActual : " + actualCount);
}
} finally {
try {
diskOrderCursor.close();
} catch (Exception ex) {
LOGGER.log(Level.WARNING, "Error during scan cursor close", ex);
}
}
} catch (UnsupportedOperationException e) {
// support disk-order scan.
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Ignoring disk-order scan since it's not supported.");
}
} catch (ClassCastException e) {
// an ITreeIndexAccessor, e.g., for the LSMBTree.
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Ignoring disk-order scan since it's not supported.");
}
}
}
Aggregations