Search in sources :

Example 6 with ILSMIndexAccessor

use of org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor in project asterixdb by apache.

the class ExternalRTree method scheduleMerge.

// The only change the the schedule merge is the method used to create the
// opCtx. first line <- in schedule merge, we->
@Override
public void scheduleMerge(ILSMIndexOperationContext ctx, ILSMIOOperationCallback callback) throws HyracksDataException {
    ILSMIndexOperationContext rctx = createOpContext(NoOpOperationCallback.INSTANCE, -1);
    rctx.setOperation(IndexOperation.MERGE);
    List<ILSMComponent> mergingComponents = ctx.getComponentHolder();
    ITreeIndexCursor cursor = new LSMRTreeSortedCursor(rctx, linearizer, buddyBTreeFields);
    LSMComponentFileReferences relMergeFileRefs = getMergeFileReferences((ILSMDiskComponent) mergingComponents.get(0), (ILSMDiskComponent) mergingComponents.get(mergingComponents.size() - 1));
    ILSMIndexAccessor accessor = new LSMRTreeAccessor(getLsmHarness(), rctx, buddyBTreeFields);
    // create the merge operation.
    LSMRTreeMergeOperation mergeOp = new LSMRTreeMergeOperation(accessor, mergingComponents, cursor, relMergeFileRefs.getInsertIndexFileReference(), relMergeFileRefs.getDeleteIndexFileReference(), relMergeFileRefs.getBloomFilterFileReference(), callback, fileManager.getBaseDir());
    ioScheduler.scheduleOperation(mergeOp);
}
Also used : ITreeIndexCursor(org.apache.hyracks.storage.am.common.api.ITreeIndexCursor) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) ILSMIndexOperationContext(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext) ILSMIndexAccessor(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor) LSMComponentFileReferences(org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences)

Example 7 with ILSMIndexAccessor

use of org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor in project asterixdb by apache.

the class LSMIndexCompactOperatorNodePushable method initialize.

@Override
public void initialize() throws HyracksDataException {
    indexHelper.open();
    ILSMIndex index = (ILSMIndex) indexHelper.getIndexInstance();
    ILSMIndexAccessor accessor = index.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
    try {
        accessor.scheduleFullMerge(NoOpIOOperationCallbackFactory.INSTANCE.createIoOpCallback());
    } catch (Exception e) {
        indexHelper.close();
        throw new HyracksDataException(e);
    }
}
Also used : ILSMIndex(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex) ILSMIndexAccessor(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 8 with ILSMIndexAccessor

use of org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor in project asterixdb by apache.

the class PrefixMergePolicy method scheduleMerge.

/**
     * schedule a merge operation according to this prefix merge policy
     *
     * @param index
     * @return true if merge is scheduled, false otherwise.
     * @throws HyracksDataException
     * @throws IndexException
     */
private boolean scheduleMerge(final ILSMIndex index) throws HyracksDataException {
    // 1.  Look at the candidate components for merging in oldest-first order.  If one exists, identify the prefix of the sequence of
    // all such components for which the sum of their sizes exceeds MaxMrgCompSz.  Schedule a merge of those components into a new component.
    // 2.  If a merge from 1 doesn't happen, see if the set of candidate components for merging exceeds MaxTolCompCnt.  If so, schedule
    // a merge all of the current candidates into a new single component.
    List<ILSMDiskComponent> immutableComponents = new ArrayList<>(index.getImmutableComponents());
    // Reverse the components order so that we look at components from oldest to newest.
    Collections.reverse(immutableComponents);
    long totalSize = 0;
    int startIndex = -1;
    for (int i = 0; i < immutableComponents.size(); i++) {
        ILSMComponent c = immutableComponents.get(i);
        long componentSize = ((ILSMDiskComponent) c).getComponentSize();
        if (componentSize > maxMergableComponentSize) {
            startIndex = i;
            totalSize = 0;
            continue;
        }
        totalSize += componentSize;
        boolean isLastComponent = i + 1 == immutableComponents.size() ? true : false;
        if (totalSize > maxMergableComponentSize || (isLastComponent && i - startIndex >= maxToleranceComponentCount)) {
            List<ILSMDiskComponent> mergableComponents = new ArrayList<>();
            for (int j = startIndex + 1; j <= i; j++) {
                mergableComponents.add(immutableComponents.get(j));
            }
            // Reverse the components order back to its original order
            Collections.reverse(mergableComponents);
            ILSMIndexAccessor accessor = index.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            accessor.scheduleMerge(index.getIOOperationCallback(), mergableComponents);
            return true;
        }
    }
    return false;
}
Also used : ILSMDiskComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent) ArrayList(java.util.ArrayList) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) ILSMIndexAccessor(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)

Example 9 with ILSMIndexAccessor

use of org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor in project asterixdb by apache.

the class PrefixMergePolicy method diskComponentAdded.

@Override
public void diskComponentAdded(final ILSMIndex index, boolean fullMergeIsRequested) throws HyracksDataException {
    ArrayList<ILSMDiskComponent> immutableComponents = new ArrayList<>(index.getImmutableComponents());
    if (!areComponentsReadableWritableState(immutableComponents)) {
        return;
    }
    if (fullMergeIsRequested) {
        ILSMIndexAccessor accessor = index.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        accessor.scheduleFullMerge(index.getIOOperationCallback());
        return;
    }
    scheduleMerge(index);
}
Also used : ILSMDiskComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent) ArrayList(java.util.ArrayList) ILSMIndexAccessor(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)

Example 10 with ILSMIndexAccessor

use of org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor in project asterixdb by apache.

the class ThreadCountingTracker method completeOperation.

@Override
public void completeOperation(ILSMIndex index, LSMOperationType opType, ISearchOperationCallback searchCallback, IModificationOperationCallback modificationCallback) throws HyracksDataException {
    // Flush will only be handled by last exiting thread.
    if (opType == LSMOperationType.MODIFICATION && threadRefCount.decrementAndGet() == 0 && index.hasFlushRequestForCurrentMutableComponent()) {
        ILSMIndexAccessor accessor = index.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        accessor.scheduleFlush(NoOpIOOperationCallbackFactory.INSTANCE.createIoOpCallback());
    }
}
Also used : ILSMIndexAccessor(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)

Aggregations

ILSMIndexAccessor (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)34 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)9 ILSMDiskComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent)8 ILSMIndex (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex)8 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)6 ArrayList (java.util.ArrayList)5 ILSMComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)4 ACIDException (org.apache.asterix.common.exceptions.ACIDException)3 IntegerSerializerDeserializer (org.apache.hyracks.dataflow.common.data.marshalling.IntegerSerializerDeserializer)3 LSMComponentFileReferences (org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences)3 LSMTreeIndexAccessor (org.apache.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor)3 IModificationOperationCallback (org.apache.hyracks.storage.common.IModificationOperationCallback)3 IOException (java.io.IOException)2 AbstractLSMIOOperationCallback (org.apache.asterix.common.ioopcallbacks.AbstractLSMIOOperationCallback)2 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)2 AMutableString (org.apache.asterix.om.base.AMutableString)2 AString (org.apache.asterix.om.base.AString)2 TransactionContext (org.apache.asterix.transaction.management.service.transaction.TransactionContext)2 UTF8StringSerializerDeserializer (org.apache.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer)2 OrderedIndexTestContext (org.apache.hyracks.storage.am.btree.OrderedIndexTestContext)2