Search in sources :

Example 1 with ExternalIndexHarness

use of org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness in project asterixdb by apache.

the class ExternalBTreeWithBuddy method activate.

@Override
public 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) {
            LSMBTreeWithBuddyDiskComponent component;
            component = createDiskComponent(componentFactory, lsmComonentFileReference.getInsertIndexFileReference(), lsmComonentFileReference.getDeleteIndexFileReference(), lsmComonentFileReference.getBloomFilterFileReference(), false);
            diskComponents.add(component);
            secondDiskComponents.add(component);
        }
        ((ExternalIndexHarness) getLsmHarness()).indexFirstTimeActivated();
    } else {
        // components. It should also maintain the version pointer
        for (ILSMComponent c : diskComponents) {
            LSMBTreeWithBuddyDiskComponent component = (LSMBTreeWithBuddyDiskComponent) c;
            BTree btree = component.getBTree();
            BTree buddyBtree = component.getBuddyBTree();
            BloomFilter bloomFilter = component.getBloomFilter();
            btree.activate();
            buddyBtree.activate();
            bloomFilter.activate();
        }
        for (ILSMComponent c : secondDiskComponents) {
            // Only activate non shared components
            if (!diskComponents.contains(c)) {
                LSMBTreeWithBuddyDiskComponent component = (LSMBTreeWithBuddyDiskComponent) c;
                BTree btree = component.getBTree();
                BTree buddyBtree = component.getBuddyBTree();
                BloomFilter bloomFilter = component.getBloomFilter();
                btree.activate();
                buddyBtree.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) ExternalIndexHarness(org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness) 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)

Example 2 with ExternalIndexHarness

use of org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness in project asterixdb by apache.

the class ExternalBTreeWithBuddy method clear.

@Override
public void clear() throws HyracksDataException {
    if (!isActive) {
        throw new HyracksDataException("Failed to clear the index since it is not activated.");
    }
    ((ExternalIndexHarness) getLsmHarness()).indexClear();
    for (ILSMDiskComponent c : diskComponents) {
        clearDiskComponent(c);
        // Remove from second list to avoid destroying twice
        secondDiskComponents.remove(c);
    }
    for (ILSMDiskComponent c : secondDiskComponents) {
        clearDiskComponent(c);
    }
    diskComponents.clear();
    secondDiskComponents.clear();
    version = 0;
}
Also used : ILSMDiskComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent) ExternalIndexHarness(org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 3 with ExternalIndexHarness

use of org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness in project asterixdb by apache.

the class ExternalBTreeWithBuddy method commitTransaction.

@Override
public void commitTransaction() throws HyracksDataException {
    LSMComponentFileReferences componentFileRefrences = fileManager.getTransactionFileReferenceForCommit();
    LSMBTreeWithBuddyDiskComponent component = null;
    if (componentFileRefrences != null) {
        component = createDiskComponent(componentFactory, componentFileRefrences.getInsertIndexFileReference(), componentFileRefrences.getDeleteIndexFileReference(), componentFileRefrences.getBloomFilterFileReference(), false);
    }
    ((ExternalIndexHarness) getLsmHarness()).addTransactionComponents(component);
}
Also used : ExternalIndexHarness(org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness) LSMComponentFileReferences(org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences)

Aggregations

ExternalIndexHarness (org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness)3 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)2 LSMComponentFileReferences (org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences)2 BloomFilter (org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilter)1 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)1 ILSMComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)1 ILSMDiskComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent)1