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;
}
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;
}
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);
}
Aggregations