asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yingyi Bu (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: Avoid always merging old components in prefix policy
Date Thu, 15 Jun 2017 08:03:22 GMT
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 <cluo8@uci.edu>
Gerrit-Reviewer: Ian Maxon <imaxon@apache.org>
Gerrit-Reviewer: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <jianfeng.jia@gmail.com>
Gerrit-Reviewer: Luo Chen <cluo8@uci.edu>
Gerrit-Reviewer: Yingyi Bu <buyingyi@gmail.com>
Gerrit-Reviewer: abdullah alamoudi <bamousaa@gmail.com>
Gerrit-HasComments: Yes

Mime
View raw message