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


Java BytesUtil.readVInt方法代碼示例

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


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

示例1: peekLength

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
public int peekLength(ByteBuffer in) {
    int mark = in.position();
    int len;

    byte scheme = in.get();
    if (scheme == 0) { // map scheme
        int size = BytesUtil.readVInt(in);
        int indexLen = getRegisterIndexSize();
        len = in.position() - mark + (indexLen + 1) * size;
    } else {
        len = in.position() - mark + m;
    }

    in.position(mark);
    return len;
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:17,代碼來源:HLLCounterOld.java

示例2: peekLength

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public int peekLength(ByteBuffer in) {
    int mark = in.position();
    int len = 0;
    if (in.hasRemaining()) {
        int size = BytesUtil.readVInt(in);
        len = in.position() - mark;
        for (int i = 0; i < size; i++) {
            int length = BytesUtil.peekByteArrayLength(in);
            in.position(in.position() + length);
            len += length;
        }
    }
    in.position(mark);
    return len;
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:17,代碼來源:RawSerializer.java

示例3: deserialize

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public List<ByteArray> deserialize(ByteBuffer in) {
    List<ByteArray> values = new ArrayList<>();
    int size = BytesUtil.readVInt(in);
    if (size >= 0) {
        for (int i = 0; i < size; i++) {
            ByteArray ba = new ByteArray(BytesUtil.readByteArray(in));
            if (ba.length() != 0) {
                values.add(ba);
            }
        }
    } else {
        throw new RuntimeException("Read error data size:" + size);
    }
    return values;
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:17,代碼來源:RawSerializer.java

示例4: deserialize

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public CoprocessorRowType deserialize(ByteBuffer in) {
    int n = BytesUtil.readVInt(in);
    int bodyOffset = BytesUtil.readVInt(in);
    TblColRef[] cols = new TblColRef[n];
    int[] colSizes = new int[n];
    for (int i = 0; i < n; i++) {
        String tableName = BytesUtil.readAsciiString(in);
        String colName = BytesUtil.readAsciiString(in);
        String datatype = BytesUtil.readAsciiString(in);
        TableDesc table = new TableDesc();
        table.setName(tableName);
        ColumnDesc col = new ColumnDesc();
        col.setTable(table);
        col.setName(colName);
        col.setDatatype(datatype);
        col.init(table);
        cols[i] = col.getRef();

        int colSize = BytesUtil.readVInt(in);
        colSizes[i] = colSize;
    }
    return new CoprocessorRowType(cols, colSizes, bodyOffset);
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:25,代碼來源:CoprocessorRowType.java

示例5: readDimensionEncoding

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
private static DimensionEncoding readDimensionEncoding(ByteBuffer in) {
    try {
        int isNull = BytesUtil.readVInt(in);
        if (isNull == 1) {
            return null;
        }

        byte[] bytes = BytesUtil.readByteArray(in);
        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        ObjectInputStream ois = new ObjectInputStream(bais);
        DimensionEncoding ret = (DimensionEncoding) ois.readObject();
        return ret;
    } catch (IOException | ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:17,代碼來源:TrimmedCubeCodeSystem.java

示例6: deserialize

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public IGTCodeSystem deserialize(ByteBuffer in) {
    Map<Integer, Integer> dependentMetricsMap = Maps.newHashMap();

    int size = BytesUtil.readVInt(in);
    for (int i = 0; i < size; ++i) {
        int key = BytesUtil.readVInt(in);
        int value = BytesUtil.readVInt(in);
        dependentMetricsMap.put(key, value);
    }

    DimensionEncoding[] dimEncs = new DimensionEncoding[BytesUtil.readVInt(in)];
    for (int i = 0; i < dimEncs.length; i++) {
        dimEncs[i] = readDimensionEncoding(in);
    }

    return new TrimmedCubeCodeSystem(dimEncs, dependentMetricsMap);
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:19,代碼來源:TrimmedCubeCodeSystem.java

示例7: readRegisters

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
public void readRegisters(ByteBuffer in) throws IOException {
    byte scheme = in.get();
    if (scheme == 0) { // map scheme
        clear();
        int size = BytesUtil.readVInt(in);
        if (size > m)
            throw new IllegalArgumentException("register size (" + size + ") cannot be larger than m (" + m + ")");
        if (isDense(size)) {
            register = new DenseRegister(p);
        } else if (size <= 1) {
            register = new SingleValueRegister();
        } else {
            register = new SparseRegister();
        }
        int indexLen = getRegisterIndexSize();
        int key = 0;
        for (int i = 0; i < size; i++) {
            key = readUnsigned(in, indexLen);
            register.set(key, in.get());
        }
    } else if (scheme == 1) { // array scheme
        if (register.getRegisterType() != RegisterType.DENSE) {
            register = new DenseRegister(p);
        }
        in.get(((DenseRegister) register).getRawRegister());
    } else
        throw new IllegalStateException();
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:29,代碼來源:HLLCounter.java

示例8: peekLength

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
public int peekLength(ByteBuffer in) {
    int mark = in.position();
    int len;
    byte scheme = in.get();
    if (scheme == 0) { // map scheme
        int size = BytesUtil.readVInt(in);
        int indexLen = getRegisterIndexSize();
        len = in.position() - mark + (indexLen + 1) * size;
    } else {
        len = in.position() - mark + m;
    }

    in.position(mark);
    return len;
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:16,代碼來源:HLLCounter.java

示例9: readRegisters

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
public void readRegisters(ByteBuffer in) throws IOException {
    byte scheme = in.get();

    if (scheme == 0) { // map scheme
        clear();
        int size = BytesUtil.readVInt(in);
        if (size > m)
            throw new IllegalArgumentException("register size (" + size + ") cannot be larger than m (" + m + ")");
        int indexLen = getRegisterIndexSize();
        int key = 0;
        for (int i = 0; i < size; i++) {
            key = readUnsigned(in, indexLen);
            registers[key] = in.get();
        }

        if (size == 0)
            singleBucket = -1;
        else if (size == 1)
            singleBucket = key;
        else
            singleBucket = Integer.MIN_VALUE;

    } else if (scheme == 1) { // array scheme
        in.get(registers);
        singleBucket = Integer.MIN_VALUE;
    } else
        throw new IllegalStateException();
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:29,代碼來源:HLLCounterOld.java

示例10: peekLength

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public int peekLength(ByteBuffer in) {
    int mark = in.position();
    int size = BytesUtil.readVInt(in);
    int total = in.position() - mark;
    if (size >= 0) {
        //size <0 is the null case
        total += size;
    }
    in.position(mark);
    return total;
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:13,代碼來源:ExtendedColumnSerializer.java

示例11: deserialize

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public BigDecimal deserialize(ByteBuffer in) {
    int scale = BytesUtil.readVInt(in);
    int n = BytesUtil.readVInt(in);

    byte[] bytes = new byte[n];
    in.get(bytes);

    return new BigDecimal(new BigInteger(bytes), scale);
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:11,代碼來源:BigDecimalSerializer.java

示例12: peekLength

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public int peekLength(ByteBuffer in) {
    int mark = in.position();

    @SuppressWarnings("unused")
    int scale = BytesUtil.readVInt(in);
    int n = BytesUtil.readVInt(in);
    int len = in.position() - mark + n;

    in.position(mark);
    return len;
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:13,代碼來源:BigDecimalSerializer.java

示例13: deserialize

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public DataType deserialize(ByteBuffer in) {
    String name = BytesUtil.readUTFString(in);
    int precision = BytesUtil.readVInt(in);
    int scale = BytesUtil.readVInt(in);

    return new DataType(name, precision, scale);
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:9,代碼來源:DataType.java

示例14: deserialize

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
@Override
public void deserialize(IFilterCodeSystem<?> cs, ByteBuffer buffer) {

    this.constantValues.clear();
    int size = BytesUtil.readVInt(buffer);
    for (int i = 0; i < size; i++) {
        this.constantValues.add(cs.deserialize(buffer));
    }
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:10,代碼來源:ConstantTupleFilter.java

示例15: deserialize

import org.apache.kylin.common.util.BytesUtil; //導入方法依賴的package包/類
public static TupleFilter deserialize(byte[] bytes, IFilterCodeSystem<?> cs) {
    ByteBuffer buffer = ByteBuffer.wrap(bytes);
    TupleFilter rootFilter = null;
    Stack<TupleFilter> parentStack = new Stack<TupleFilter>();
    while (buffer.hasRemaining()) {
        int opVal = BytesUtil.readVInt(buffer);
        if (opVal < 0) {
            parentStack.pop();
            continue;
        }

        // deserialize filter
        TupleFilter filter = createTupleFilter(opVal);
        filter.deserialize(cs, buffer);

        if (rootFilter == null) {
            // push root to stack
            rootFilter = filter;
            parentStack.push(filter);
            BytesUtil.readVInt(buffer);
            continue;
        }

        // add filter to parent
        TupleFilter parentFilter = parentStack.peek();
        if (parentFilter != null) {
            parentFilter.addChild(filter);
        }

        // push filter to stack or not based on having children or not
        int hasChild = BytesUtil.readVInt(buffer);
        if (hasChild == 1) {
            parentStack.push(filter);
        }
    }
    return rootFilter;
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:38,代碼來源:TupleFilterSerializer.java


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