/** * Adopts the similar logic to decide merge lagging based on {@link PrefixMergePolicy} * * @throws HyracksDataException */ @Override public boolean isMergeLagging(ILSMIndex index) throws HyracksDataException { if (index.isPrimaryIndex()) { return super.isMergeLagging(index); } else { return false; } }
@Override public void diskComponentAdded(final ILSMIndex index, boolean fullMergeIsRequested) throws HyracksDataException { // This merge policy will only look at primary indexes in order to evaluate if a merge operation is needed. If it decides that // a merge operation is needed, then it will merge *all* the indexes that belong to the dataset. The criteria to decide if a merge // is needed is the same as the one that is used in the prefix merge policy: // 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. if (fullMergeIsRequested || index.isPrimaryIndex()) { super.diskComponentAdded(index, fullMergeIsRequested); } }
private Predicate<ILSMIndex> newIdleDatasetPredicate() { final long currentTime = System.nanoTime(); return lsmIndex -> { if (lsmIndex.isPrimaryIndex()) { PrimaryIndexOperationTracker opTracker = (PrimaryIndexOperationTracker) lsmIndex.getOperationTracker(); return currentTime - opTracker.getLastFlushTime() >= datasetCheckpointInterval; } return false; }; }
@Override public void scanDiskComponents(ILSMIndexOperationContext ctx, IIndexCursor cursor) throws HyracksDataException { if (!lsmIndex.isPrimaryIndex()) { throw HyracksDataException.create(ErrorCode.DISK_COMPONENT_SCAN_NOT_ALLOWED_FOR_SECONDARY_INDEX); } LSMOperationType opType = LSMOperationType.DISK_COMPONENT_SCAN; getAndEnterComponents(ctx, opType, false); try { ctx.getSearchOperationCallback().before(null); lsmIndex.scanDiskComponents(ctx, cursor); } catch (Exception e) { exitComponents(ctx, opType, null, true); throw e; } }
Mockito.when(index.isPrimaryIndex()).thenReturn(isPrimary); if (isPrimary) { PrimaryIndexOperationTracker opTracker = Mockito.mock(PrimaryIndexOperationTracker.class);
if (lsmIndex.isPrimaryIndex()) { if (lsmIndex.isCurrentMutableComponentEmpty()) { LOGGER.info("Primary index on dataset {} and partition {} is empty... skipping flush", memComponent.setUnwritable(); if (lsmIndex.isPrimaryIndex()) { primaryId = (LSMComponentId) memComponent.getId();