Yingyi Bu has posted comments on this change. Change subject: Avoid always merging old components in prefix policy ......................................................................
Patch Set 7: (3 comments) https://asterix-gerrit.ics.uci.edu/#/c/1818/7/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/PrefixMergePolicy.java File hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/PrefixMergePolicy.java: PS7, Line 285: if (startComponentSize == 0) { : startComponentSize = componentSize; : } pull this to the beginning of the loop? PS7, Line 302: else if (isLastComponent) { : // we already reach the last component : if (j - i + 1 >= maxToleranceComponentCount) { : // we find a candidate sequence based on tolerance count : if (mergable) { : // if the ratio check passes, we return this sequence : return Pair.of(i, j); : } : // otherwise, we can check the i+1 th component : : } else { : // if we reach the last component, but there are not enough components to merge, : // then we don't need to check i+1 th component : return null; : } : } pull this out of the loop? PS7, Line 321: return null; A shorter & less nesting version as follows? private Pair<Integer, Integer> getMergableComponentsIndex(List<ILSMDiskComponent> immutableComponents) { int numComponents = immutableComponents.size(); for (int i = 0; i < numComponents; i++) { long startComponentSize = immutableComponents.get(i).getComponentSize(); if (immutableComponents.get(i).getComponentSize() > maxMergableComponentSize || immutableComponents.get(i).getState() != ComponentState.READABLE_UNWRITABLE) { continue; } long totalSize = startComponentSize; int j = i + 1; boolean mergeable = true; for (; j < numComponents; j++) { long componentSize = immutableComponents.get(j).getComponentSize(); if (componentSize > maxMergableComponentSize || immutableComponents.get(j).getState() != ComponentState.READABLE_UNWRITABLE) { // skip unmergeable components if any break; } totalSize += componentSize; mergeable = startComponentSize < MAX_MERGABLE_COMPONENT_SIZE_RATIO * (totalSize - startComponentSize); if (totalSize > maxMergableComponentSize && mergeable) { // If the ratio check passes and total size exceeds the threshold, we return this sequence return Pair.of(i, j); } } if (numComponents - i >= maxToleranceComponentCount && mergeable) { // If it's the last component, component count exceeds the threshold, the ratio check passes, // then we return this sequence. return Pair.of(i, numComponents - 1); } // if we reach the last component, but there are not enough components to merge, // then we don't need to check i+1 th component if (numComponents - i <= maxToleranceComponentCount) { return null; } } return null; } -- To view, visit https://asterix-gerrit.ics.uci.edu/1818 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: comment Gerrit-Change-Id: I464da3fed38cded0aee7b319a35664eae069a2ba Gerrit-PatchSet: 7 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Luo Chen <[email protected]> Gerrit-Reviewer: Ian Maxon <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Jianfeng Jia <[email protected]> Gerrit-Reviewer: Luo Chen <[email protected]> Gerrit-Reviewer: Yingyi Bu <[email protected]> Gerrit-Reviewer: abdullah alamoudi <[email protected]> Gerrit-HasComments: Yes
