Search in sources :

Example 16 with ITreeIndexAccessor

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.");
        }
    }
}
Also used : ITreeIndexCursor(org.apache.hyracks.storage.am.common.api.ITreeIndexCursor) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ITreeIndexAccessor(org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

ITreeIndexAccessor (org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor)16 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)9 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)8 IBTreeLeafFrame (org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame)8 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)8 ArrayList (java.util.ArrayList)7 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)7 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)7 RangePredicate (org.apache.hyracks.storage.am.btree.impls.RangePredicate)7 BTreeRangeSearchCursor (org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor)6 IMetadataPageManager (org.apache.hyracks.storage.am.common.api.IMetadataPageManager)6 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)6 ITreeIndexFrameFactory (org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory)6 LinkedMetaDataPageManager (org.apache.hyracks.storage.am.common.freepage.LinkedMetaDataPageManager)6 IBufferCache (org.apache.hyracks.storage.common.buffercache.IBufferCache)6 Test (org.junit.Test)6 ArrayTupleReference (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference)5 BTreeNSMInteriorFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory)5 BTreeNSMLeafFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory)5 AbstractBTreeTest (org.apache.hyracks.storage.am.btree.util.AbstractBTreeTest)5