Java Code Examples for org.apache.kylin.common.util.ByteArray#compareTo()

The following examples show how to use org.apache.kylin.common.util.ByteArray#compareTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrieDictionaryForest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
protected int getIdFromValueBytesWithoutCache(byte[] value, int offset, int len, int roundingFlag) throws IllegalArgumentException {
    int index;
    if (trees.size() == 1) {
        index = 0;
    } else {
        ByteArray search = new ByteArray(value, offset, len);
        index = findIndexByValue(search);
        if (index < 0) {
            if (roundingFlag > 0) {
                return getMinId(); //searching value smaller than the smallest value in dict
            } else {
                throw new IllegalArgumentException("Value '" + Bytes.toString(value, offset, len) + "' (" + Bytes.toStringBinary(value, offset, len) + ") not exists!");
            }
        }

        if (roundingFlag > 0) {
            ByteArray maxValueOfTree = maxValue.get(index);
            if (search.compareTo(maxValueOfTree) > 0)
                index++;
            if (index >= trees.size())
                throw new IllegalArgumentException("Value '" + Bytes.toString(value, offset, len) + "' (" + Bytes.toStringBinary(value, offset, len) + ") not exists!");
        }
    }
    TrieDictionary<T> tree = trees.get(index);
    int id = tree.getIdFromValueBytesWithoutCache(value, offset, len, roundingFlag);
    if (id == -1)
        throw new IllegalArgumentException("Value '" + Bytes.toString(value, offset, len) + "' (" + Bytes.toStringBinary(value, offset, len) + ") not exists!");
    id = id + accuOffset.get(index);
    id += baseId;
    return id;
}
 
Example 2
Source File: ByteComparator.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(T o1, T o2) {
    //return BytesUtil.safeCompareBytes(converter.convertToBytes(o1),converter.convertToBytes(o2));
    byte[] b1 = converter.convertToBytes(o1);
    byte[] b2 = converter.convertToBytes(o2);
    ByteArray ba1 = new ByteArray(b1, 0, b1.length);
    ByteArray ba2 = new ByteArray(b2, 0, b2.length);
    return ba1.compareTo(ba2);
}
 
Example 3
Source File: TrieDictionaryForest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
protected int getIdFromValueBytesWithoutCache(byte[] value, int offset, int len, int roundingFlag) throws IllegalArgumentException {
    int index;
    if (trees.size() == 1) {
        index = 0;
    } else {
        ByteArray search = new ByteArray(value, offset, len);
        index = findIndexByValue(search);
        if (index < 0) {
            if (roundingFlag > 0) {
                return getMinId(); //searching value smaller than the smallest value in dict
            } else {
                throw new IllegalArgumentException("Value '" + Bytes.toString(value, offset, len) + "' (" + Bytes.toStringBinary(value, offset, len) + ") not exists!");
            }
        }

        if (roundingFlag > 0) {
            ByteArray maxValueOfTree = maxValue.get(index);
            if (search.compareTo(maxValueOfTree) > 0)
                index++;
            if (index >= trees.size())
                throw new IllegalArgumentException("Value '" + Bytes.toString(value, offset, len) + "' (" + Bytes.toStringBinary(value, offset, len) + ") not exists!");
        }
    }
    TrieDictionary<T> tree = trees.get(index);
    int id = tree.getIdFromValueBytesWithoutCache(value, offset, len, roundingFlag);
    if (id == -1)
        throw new IllegalArgumentException("Value '" + Bytes.toString(value, offset, len) + "' (" + Bytes.toStringBinary(value, offset, len) + ") not exists!");
    id = id + accuOffset.get(index);
    id += baseId;
    return id;
}
 
Example 4
Source File: ByteComparator.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(T o1, T o2) {
    //return BytesUtil.safeCompareBytes(converter.convertToBytes(o1),converter.convertToBytes(o2));
    byte[] b1 = converter.convertToBytes(o1);
    byte[] b2 = converter.convertToBytes(o2);
    ByteArray ba1 = new ByteArray(b1, 0, b1.length);
    ByteArray ba2 = new ByteArray(b2, 0, b2.length);
    return ba1.compareTo(ba2);
}
 
Example 5
Source File: DefaultGTComparator.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(ByteArray code1, ByteArray code2) {
    return code1.compareTo(code2);
}
 
Example 6
Source File: DefaultGTComparator.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(ByteArray code1, ByteArray code2) {
    return code1.compareTo(code2);
}