当前位置: 首页>>代码示例>>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;未经允许,请勿转载。