use of org.apache.hyracks.storage.am.common.api.ITreeIndexCursor in project asterixdb by apache.
the class AbstractRTreeExamplesTest method scan.
protected void scan(IIndexAccessor indexAccessor, ISerializerDeserializer[] fieldSerdes) throws Exception {
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Scan:");
}
ITreeIndexCursor scanCursor = (ITreeIndexCursor) indexAccessor.createSearchCursor(false);
SearchPredicate nullPred = new SearchPredicate(null, null);
indexAccessor.search(scanCursor, nullPred);
try {
while (scanCursor.hasNext()) {
scanCursor.next();
ITupleReference frameTuple = scanCursor.getTuple();
String rec = TupleUtils.printTuple(frameTuple, fieldSerdes);
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info(rec);
}
}
} finally {
scanCursor.close();
}
}
use of org.apache.hyracks.storage.am.common.api.ITreeIndexCursor 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.");
}
}
}
use of org.apache.hyracks.storage.am.common.api.ITreeIndexCursor in project asterixdb by apache.
the class TreeIndexTestUtils method checkScan.
@SuppressWarnings("unchecked")
public void checkScan(IIndexTestContext ctx) throws Exception {
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Testing Scan.");
}
ITreeIndexCursor scanCursor = (ITreeIndexCursor) ctx.getIndexAccessor().createSearchCursor(false);
ISearchPredicate nullPred = createNullSearchPredicate();
ctx.getIndexAccessor().search(scanCursor, nullPred);
Iterator<CheckTuple> checkIter = ctx.getCheckTuples().iterator();
checkExpectedResults(scanCursor, ctx.getCheckTuples(), ctx.getFieldSerdes(), ctx.getKeyFieldCount(), checkIter);
}
Aggregations