use of org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent in project asterixdb by apache.
the class CorrelatedPrefixMergePolicy method triggerScheduledMerge.
/**
* Submit merge requests for all disk components within [minID, maxID]
* of all indexes of a given dataset in the given partition
*
* @param minID
* @param maxID
* @param partition
* @param indexInfos
* @throws HyracksDataException
*/
private void triggerScheduledMerge(long minID, long maxID, Set<IndexInfo> indexInfos) throws HyracksDataException {
for (IndexInfo info : indexInfos) {
ILSMIndex lsmIndex = info.getIndex();
List<ILSMDiskComponent> immutableComponents = new ArrayList<>(lsmIndex.getImmutableComponents());
if (isMergeOngoing(immutableComponents)) {
continue;
}
List<ILSMDiskComponent> mergableComponents = new ArrayList<>();
for (ILSMDiskComponent component : immutableComponents) {
ILSMDiskComponentId id = component.getComponentId();
if (!id.notFound()) {
if (id.getMinId() >= minID && id.getMaxId() <= maxID) {
mergableComponents.add(component);
}
if (id.getMaxId() < minID) {
//if the component.maxID < minID, we can safely skip the rest disk components in the list
break;
}
}
}
ILSMIndexAccessor accessor = lsmIndex.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
accessor.scheduleMerge(lsmIndex.getIOOperationCallback(), mergableComponents);
}
}
use of org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent 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);
}
}
use of org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent 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;
}
use of org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent 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.api.ILSMDiskComponent in project asterixdb by apache.
the class ExternalIndexHarness method addTransactionComponents.
// Three differences from addBulkLoadedComponent
// 1. this needs synchronization since others might be accessing the index (specifically merge operations that might change the lists of components)
// 2. the actions taken by the index itself are different
// 3. the component has already been marked valid by the bulk update operation
public void addTransactionComponents(ILSMDiskComponent newComponent) throws HyracksDataException {
ITwoPCIndex index = (ITwoPCIndex) lsmIndex;
synchronized (opTracker) {
List<ILSMDiskComponent> newerList;
List<ILSMDiskComponent> olderList;
if (index.getCurrentVersion() == 0) {
newerList = index.getFirstComponentList();
olderList = index.getSecondComponentList();
} else {
newerList = index.getSecondComponentList();
olderList = index.getFirstComponentList();
}
// deleted if they are not needed anymore
for (ILSMDiskComponent c : olderList) {
exitComponent(c);
}
// Enter components in the newer list
for (ILSMDiskComponent c : newerList) {
enterComponent(c);
}
if (newComponent != null) {
// Enter new component
enterComponent(newComponent);
}
index.commitTransactionDiskComponent(newComponent);
mergePolicy.diskComponentAdded(lsmIndex, fullMergeIsRequested.get());
}
}
Aggregations