Search in sources :

Example 11 with ILSMComponent

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

the class AbstractLSMIOOperationCallback method getComponentId.

private ILSMDiskComponentId getComponentId(List<ILSMComponent> oldComponents) throws HyracksDataException {
    if (oldComponents == null) {
        //if oldComponents == null, then getComponentLSN would treat it as a flush operation,
        //and return the LSN for the flushed component
        long id = getComponentLSN(null);
        if (id == 0) {
            logger.log(Level.WARNING, "Flushing a memory component without setting the LSN");
            id = ILSMDiskComponentId.NOT_FOUND;
        }
        return new LSMDiskComponentId(id, id);
    } else {
        long minId = Long.MAX_VALUE;
        long maxId = Long.MIN_VALUE;
        for (ILSMComponent oldComponent : oldComponents) {
            ILSMDiskComponentId oldComponentId = ((ILSMDiskComponent) oldComponent).getComponentId();
            if (oldComponentId.getMinId() < minId) {
                minId = oldComponentId.getMinId();
            }
            if (oldComponentId.getMaxId() > maxId) {
                maxId = oldComponentId.getMaxId();
            }
        }
        return new LSMDiskComponentId(minId, maxId);
    }
}
Also used : ILSMDiskComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent) LSMDiskComponentId(org.apache.hyracks.storage.am.lsm.common.impls.LSMDiskComponentId) ILSMDiskComponentId(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId) ILSMDiskComponentId(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)

Example 12 with ILSMComponent

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

the class AbstractLSMIOOperationCallback method getComponentLSN.

public long getComponentLSN(List<? extends ILSMComponent> diskComponents) throws HyracksDataException {
    if (diskComponents == null) {
        // Flush operation of an LSM index are executed sequentially.
        synchronized (this) {
            long lsn = mutableLastLSNs[readIndex];
            return lsn;
        }
    }
    // Get max LSN from the diskComponents. Implies a merge IO operation or Recovery operation.
    long maxLSN = -1L;
    for (ILSMComponent c : diskComponents) {
        DiskComponentMetadata md = ((ILSMDiskComponent) c).getMetadata();
        maxLSN = Math.max(getTreeIndexLSN(md), maxLSN);
    }
    return maxLSN;
}
Also used : ILSMDiskComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) DiskComponentMetadata(org.apache.hyracks.storage.am.lsm.common.impls.DiskComponentMetadata)

Example 13 with ILSMComponent

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

the class LSMRTreeWithAntiMatterTuplesSearchCursor method open.

@Override
public void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMRTreeCursorInitialState lsmInitialState = (LSMRTreeCursorInitialState) initialState;
    cmp = lsmInitialState.getHilbertCmp();
    btreeCmp = lsmInitialState.getBTreeCmp();
    lsmHarness = lsmInitialState.getLSMHarness();
    comparatorFields = lsmInitialState.getComparatorFields();
    operationalComponents = lsmInitialState.getOperationalComponents();
    rtreeSearchPredicate = (SearchPredicate) searchPred;
    searchCallback = lsmInitialState.getSearchOperationCallback();
    includeMutableComponent = false;
    numMutableComponents = 0;
    int numImmutableComponents = 0;
    for (ILSMComponent component : operationalComponents) {
        if (component.getType() == LSMComponentType.MEMORY) {
            includeMutableComponent = true;
            numMutableComponents++;
        } else {
            numImmutableComponents++;
        }
    }
    if (includeMutableComponent) {
        btreeRangePredicate = new RangePredicate(null, null, true, true, btreeCmp, btreeCmp);
    }
    mutableRTreeCursors = new RTreeSearchCursor[numMutableComponents];
    mutableRTreeAccessors = new ITreeIndexAccessor[numMutableComponents];
    btreeCursors = new BTreeRangeSearchCursor[numMutableComponents];
    btreeAccessors = new ITreeIndexAccessor[numMutableComponents];
    for (int i = 0; i < numMutableComponents; i++) {
        ILSMComponent component = operationalComponents.get(i);
        RTree rtree = ((LSMRTreeMemoryComponent) component).getRTree();
        BTree btree = ((LSMRTreeMemoryComponent) component).getBTree();
        mutableRTreeCursors[i] = new RTreeSearchCursor((IRTreeInteriorFrame) lsmInitialState.getRTreeInteriorFrameFactory().createFrame(), (IRTreeLeafFrame) lsmInitialState.getRTreeLeafFrameFactory().createFrame());
        btreeCursors[i] = new BTreeRangeSearchCursor((IBTreeLeafFrame) lsmInitialState.getBTreeLeafFrameFactory().createFrame(), false);
        btreeAccessors[i] = btree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        mutableRTreeAccessors[i] = rtree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
    }
    rangeCursors = new RTreeSearchCursor[numImmutableComponents];
    ITreeIndexAccessor[] immutableRTreeAccessors = new ITreeIndexAccessor[numImmutableComponents];
    int j = 0;
    for (int i = numMutableComponents; i < operationalComponents.size(); i++) {
        ILSMComponent component = operationalComponents.get(i);
        rangeCursors[j] = new RTreeSearchCursor((IRTreeInteriorFrame) lsmInitialState.getRTreeInteriorFrameFactory().createFrame(), (IRTreeLeafFrame) lsmInitialState.getRTreeLeafFrameFactory().createFrame());
        RTree rtree = ((LSMRTreeDiskComponent) component).getRTree();
        immutableRTreeAccessors[j] = rtree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        immutableRTreeAccessors[j].search(rangeCursors[j], searchPred);
        j++;
    }
    searchNextCursor();
    setPriorityQueueComparator();
    initPriorityQueue();
    open = true;
}
Also used : RangePredicate(org.apache.hyracks.storage.am.btree.impls.RangePredicate) IRTreeLeafFrame(org.apache.hyracks.storage.am.rtree.api.IRTreeLeafFrame) BTreeRangeSearchCursor(org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) RTreeSearchCursor(org.apache.hyracks.storage.am.rtree.impls.RTreeSearchCursor) ITreeIndexAccessor(org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor) IRTreeInteriorFrame(org.apache.hyracks.storage.am.rtree.api.IRTreeInteriorFrame) IBTreeLeafFrame(org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) RTree(org.apache.hyracks.storage.am.rtree.impls.RTree)

Example 14 with ILSMComponent

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

the class ExternalRTree method clear.

// The clear method is not used anywhere in AsterixDB! we override it anyway
// to exit components first and clear the two lists
@Override
public void clear() throws HyracksDataException {
    if (!isActive) {
        throw new HyracksDataException("Failed to clear the index since it is not activated.");
    }
    getLsmHarness().indexClear();
    for (ILSMComponent c : diskComponents) {
        LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
        component.getRTree().deactivate();
        component.getBloomFilter().deactivate();
        component.getBTree().deactivate();
        component.getRTree().destroy();
        component.getBloomFilter().destroy();
        component.getBTree().destroy();
        // Remove from second list to avoid destroying twice
        secondDiskComponents.remove(c);
    }
    for (ILSMComponent c : secondDiskComponents) {
        LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
        component.getRTree().deactivate();
        component.getBloomFilter().deactivate();
        component.getBTree().deactivate();
        component.getRTree().destroy();
        component.getBloomFilter().destroy();
        component.getBTree().destroy();
    }
    diskComponents.clear();
    secondDiskComponents.clear();
    version = 0;
}
Also used : ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 15 with ILSMComponent

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

the class ExternalRTree method activate.

@Override
public synchronized void activate() throws HyracksDataException {
    if (isActive) {
        throw new HyracksDataException("Failed to activate the index since it is already activated.");
    }
    if (diskComponents.size() == 0 && secondDiskComponents.size() == 0) {
        //First time activation
        List<LSMComponentFileReferences> validFileReferences;
        validFileReferences = fileManager.cleanupAndGetValidFiles();
        for (LSMComponentFileReferences lsmComonentFileReference : validFileReferences) {
            LSMRTreeDiskComponent component;
            component = createDiskComponent(componentFactory, lsmComonentFileReference.getInsertIndexFileReference(), lsmComonentFileReference.getDeleteIndexFileReference(), lsmComonentFileReference.getBloomFilterFileReference(), false);
            diskComponents.add(component);
            secondDiskComponents.add(component);
        }
        getLsmHarness().indexFirstTimeActivated();
    } else {
        // components. It should also maintain the version pointer
        for (ILSMComponent c : diskComponents) {
            LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
            RTree rtree = component.getRTree();
            BTree btree = component.getBTree();
            BloomFilter bloomFilter = component.getBloomFilter();
            rtree.activate();
            btree.activate();
            bloomFilter.activate();
        }
        for (ILSMComponent c : secondDiskComponents) {
            // Only activate non shared components
            if (!diskComponents.contains(c)) {
                LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
                RTree rtree = component.getRTree();
                BTree btree = component.getBTree();
                BloomFilter bloomFilter = component.getBloomFilter();
                rtree.activate();
                btree.activate();
                bloomFilter.activate();
            }
        }
    }
    isActive = true;
}
Also used : ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) RTree(org.apache.hyracks.storage.am.rtree.impls.RTree) LSMComponentFileReferences(org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) BloomFilter(org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilter)

Aggregations

ILSMComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)38 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)13 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)10 ILSMDiskComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent)10 IBTreeLeafFrame (org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame)9 BTreeRangeSearchCursor (org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor)7 RangePredicate (org.apache.hyracks.storage.am.btree.impls.RangePredicate)7 LSMComponentFileReferences (org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences)6 BloomFilter (org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilter)5 BloomFilterAwareBTreePointSearchCursor (org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)5 ArrayList (java.util.ArrayList)4 ILSMIndexAccessor (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)4 RTree (org.apache.hyracks.storage.am.rtree.impls.RTree)4 ITreeIndexAccessor (org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor)3 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)3 ILSMIndexOperationContext (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext)3 IIndexAccessor (org.apache.hyracks.storage.common.IIndexAccessor)3 ILSMDiskComponentId (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId)2 BlockingIOOperationCallbackWrapper (org.apache.hyracks.storage.am.lsm.common.impls.BlockingIOOperationCallbackWrapper)2 LSMTreeIndexAccessor (org.apache.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor)2