當前位置: 首頁>>代碼示例>>Java>>正文


Java BytesUtil.compareByteUnsigned方法代碼示例

本文整理匯總了Java中org.apache.kylin.common.util.BytesUtil.compareByteUnsigned方法的典型用法代碼示例。如果您正苦於以下問題:Java BytesUtil.compareByteUnsigned方法的具體用法?Java BytesUtil.compareByteUnsigned怎麽用?Java BytesUtil.compareByteUnsigned使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.kylin.common.util.BytesUtil的用法示例。


在下文中一共展示了BytesUtil.compareByteUnsigned方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: lookupSeqNoFromValue

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
/**
 * returns a code point from [0, nValues), preserving order of value
 *
 * @param n            -- the offset of current node
 * @param inp          -- input value bytes to lookup
 * @param o            -- offset in the input value bytes matched so far
 * @param inpEnd       -- end of input
 * @param roundingFlag -- =0: return -1 if not found
 *                     -- <0: return closest smaller if not found, return -1
 *                     -- >0: return closest bigger if not found, return nValues
 */
private int lookupSeqNoFromValue(int n, byte[] inp, int o, int inpEnd, int roundingFlag) {
    while (true) {
        // match the current node
        int p = n + firstByteOffset; // start of node's value
        int end = p + BytesUtil.readUnsigned(trieBytes, p - 1, 1); // end of node's value
        for (; p < end && o < inpEnd; p++, o++) { // note matching start from [0]
            if (trieBytes[p] != inp[o]) {
                return -1; // mismatch
            }
        }

        // node completely matched, is input all consumed?
        boolean isEndOfValue = checkFlag(n, BIT_IS_END_OF_VALUE);
        if (o == inpEnd) {
            return p == end && isEndOfValue ? BytesUtil.readUnsigned(trieBytes, end, sizeOfId) : -1;
        }

        // find a child to continue
        int c = headSize + (int) (BytesUtil.readLong(trieBytes, n, sizeChildOffset) & childOffsetMask);
        if (c == headSize) // has no children
            return -1;
        byte inpByte = inp[o];
        int comp;
        while (true) {
            p = c + firstByteOffset;
            comp = BytesUtil.compareByteUnsigned(trieBytes[p], inpByte);
            if (comp == 0) { // continue in the matching child, reset n and loop again
                n = c;
                break;
            } else if (comp < 0) { // try next child
                if (checkFlag(c, BIT_IS_LAST_CHILD))
                    return -1;
                c = p + BytesUtil.readUnsigned(trieBytes, p - 1, 1) + (checkFlag(c, BIT_IS_END_OF_VALUE) ? sizeOfId : 0);
            } else { // children are ordered by their first value byte
                return -1;
            }
        }
    }
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:51,代碼來源:AppendDictSlice.java

示例2: compareTo

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public int compareTo(AggrKey o) {
    int comp = this.length() - o.length();
    if (comp != 0)
        return comp;

    for (int i = 0; i < groupByMaskSet.length; i++) {
        comp = BytesUtil.compareByteUnsigned(this.data[this.offset + groupByMaskSet[i]], o.data[o.offset + groupByMaskSet[i]]);
        if (comp != 0)
            return comp;
    }
    return 0;
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:14,代碼來源:AggrKey.java


注:本文中的org.apache.kylin.common.util.BytesUtil.compareByteUnsigned方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。