Search in sources :

Example 1 with IIndex

use of org.apache.hyracks.storage.common.IIndex in project asterixdb by apache.

the class OrderedIndexMultiThreadTest method runTest.

protected void runTest(ISerializerDeserializer[] fieldSerdes, int numKeys, int numThreads, TestWorkloadConf conf, String dataMsg) throws InterruptedException, HyracksDataException {
    setUp();
    if (LOGGER.isLoggable(Level.INFO)) {
        String indexTypeName = getIndexTypeName();
        LOGGER.info(indexTypeName + " MultiThread Test:\nData: " + dataMsg + "; Threads: " + numThreads + "; Workload: " + conf.toString() + ".");
    }
    ITypeTraits[] typeTraits = SerdeUtils.serdesToTypeTraits(fieldSerdes);
    IBinaryComparatorFactory[] cmpFactories = SerdeUtils.serdesToComparatorFactories(fieldSerdes, numKeys);
    // This is only used for the LSM-BTree.
    int[] bloomFilterKeyFields = new int[numKeys];
    for (int i = 0; i < numKeys; ++i) {
        bloomFilterKeyFields[i] = i;
    }
    IIndex index = createIndex(typeTraits, cmpFactories, bloomFilterKeyFields);
    IIndexTestWorkerFactory workerFactory = getWorkerFactory();
    // 4 batches per thread.
    int batchSize = (NUM_OPERATIONS / numThreads) / 4;
    IndexMultiThreadTestDriver driver = new IndexMultiThreadTestDriver(index, workerFactory, fieldSerdes, conf.ops, conf.opProbs);
    driver.init();
    long[] times = driver.run(numThreads, 1, NUM_OPERATIONS, batchSize);
    index.validate();
    driver.deinit();
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("BTree MultiThread Test Time: " + times[0] + "ms");
    }
    tearDown();
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) ITypeTraits(org.apache.hyracks.api.dataflow.value.ITypeTraits) IBinaryComparatorFactory(org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory) IIndexTestWorkerFactory(org.apache.hyracks.storage.am.common.IIndexTestWorkerFactory) IndexMultiThreadTestDriver(org.apache.hyracks.storage.am.common.IndexMultiThreadTestDriver)

Example 2 with IIndex

use of org.apache.hyracks.storage.common.IIndex in project asterixdb by apache.

the class ExternalDatasetIndexesCommitOperatorDescriptor method performOpOnIndex.

@Override
protected void performOpOnIndex(IIndexDataflowHelper indexHelper, IHyracksTaskContext ctx) throws HyracksDataException {
    String path = indexHelper.getResource().getPath();
    IIOManager ioManager = ctx.getIoManager();
    FileReference file = ioManager.resolve(path);
    LOGGER.warn("performing the operation on " + file.getFile().getAbsolutePath());
    // Get index
    IIndex index = indexHelper.getIndexInstance();
    // commit transaction
    ((ITwoPCIndex) index).commitTransaction();
    LOGGER.warn("operation on " + file.getFile().getAbsolutePath() + " Succeded");
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) FileReference(org.apache.hyracks.api.io.FileReference) IIOManager(org.apache.hyracks.api.io.IIOManager) ITwoPCIndex(org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex)

Example 3 with IIndex

use of org.apache.hyracks.storage.common.IIndex in project asterixdb by apache.

the class AbstractInvertedIndexTest method validateAndCheckIndex.

/**
     * Validates the index, and compares it against the expected index.
     * This test is only for verifying the integrity and correctness of the index,
     * it does not ensure the correctness of index searches.
     */
protected void validateAndCheckIndex(LSMInvertedIndexTestContext testCtx) throws HyracksDataException {
    IIndex invIndex = testCtx.getIndex();
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Validating index: " + invIndex);
    }
    // Validate index and compare against expected index.
    invIndex.validate();
    if (invIndexType == InvertedIndexType.INMEMORY || invIndexType == InvertedIndexType.ONDISK) {
        // This comparison method exercises different features of these types of inverted indexes.
        LSMInvertedIndexTestUtils.compareActualAndExpectedIndexes(testCtx);
    }
    LSMInvertedIndexTestUtils.compareActualAndExpectedIndexesRangeSearch(testCtx);
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex)

Example 4 with IIndex

use of org.apache.hyracks.storage.common.IIndex in project asterixdb by apache.

the class LSMInvertedIndexMergeTest method runTest.

@Override
protected void runTest(LSMInvertedIndexTestContext testCtx, TupleGenerator tupleGen) throws IOException {
    IIndex invIndex = testCtx.getIndex();
    invIndex.create();
    invIndex.activate();
    ILSMIndexAccessor invIndexAccessor = (ILSMIndexAccessor) invIndex.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
    for (int i = 0; i < maxTreesToMerge; i++) {
        for (int j = 0; j < i; j++) {
            LSMInvertedIndexTestUtils.insertIntoInvIndex(testCtx, tupleGen, NUM_DOCS_TO_INSERT);
            // Deactivate and the re-activate the index to force it flush its in memory component
            invIndex.deactivate();
            invIndex.activate();
        }
        // Perform merge.
        invIndexAccessor.scheduleMerge(NoOpIOOperationCallbackFactory.INSTANCE.createIoOpCallback(), ((LSMInvertedIndex) invIndex).getImmutableComponents());
        validateAndCheckIndex(testCtx);
        runTinySearchWorkload(testCtx, tupleGen);
    }
    invIndex.deactivate();
    invIndex.destroy();
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) ILSMIndexAccessor(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)

Example 5 with IIndex

use of org.apache.hyracks.storage.common.IIndex in project asterixdb by apache.

the class PartitionedLSMInvertedIndexMergeTest method runTest.

@Override
protected void runTest(LSMInvertedIndexTestContext testCtx, TupleGenerator tupleGen) throws IOException, HyracksDataException {
    IIndex invIndex = testCtx.getIndex();
    invIndex.create();
    invIndex.activate();
    ILSMIndexAccessor invIndexAccessor = (ILSMIndexAccessor) invIndex.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
    for (int i = 0; i < maxTreesToMerge; i++) {
        for (int j = 0; j < i; j++) {
            LSMInvertedIndexTestUtils.insertIntoInvIndex(testCtx, tupleGen, NUM_DOCS_TO_INSERT);
            // Deactivate and the re-activate the index to force it flush its in memory component
            invIndex.deactivate();
            invIndex.activate();
        }
        // Perform merge.
        invIndexAccessor.scheduleMerge(NoOpIOOperationCallbackFactory.INSTANCE.createIoOpCallback(), ((LSMInvertedIndex) invIndex).getImmutableComponents());
        validateAndCheckIndex(testCtx);
        runTinySearchWorkload(testCtx, tupleGen);
    }
    invIndex.deactivate();
    invIndex.destroy();
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) ILSMIndexAccessor(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)

Aggregations

IIndex (org.apache.hyracks.storage.common.IIndex)17 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)5 ACIDException (org.apache.asterix.common.exceptions.ACIDException)3 AMutableString (org.apache.asterix.om.base.AMutableString)3 AString (org.apache.asterix.om.base.AString)3 RangePredicate (org.apache.hyracks.storage.am.btree.impls.RangePredicate)3 IIndexAccessor (org.apache.hyracks.storage.common.IIndexAccessor)3 DatasetLocalResource (org.apache.asterix.common.dataflow.DatasetLocalResource)2 DatasetId (org.apache.asterix.common.transactions.DatasetId)2 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)2 ITransactionSubsystem (org.apache.asterix.common.transactions.ITransactionSubsystem)2 ExternalFile (org.apache.asterix.external.indexing.ExternalFile)2 FileIndexTupleTranslator (org.apache.asterix.external.indexing.FileIndexTupleTranslator)2 IFrameWriter (org.apache.hyracks.api.comm.IFrameWriter)2 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)2 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)2 AbstractOperatorNodePushable (org.apache.hyracks.dataflow.std.base.AbstractOperatorNodePushable)2 IIndexDataflowHelper (org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper)2 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)2 ILSMIndex (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex)2