当前位置: 首页>>代码示例>>Java>>正文


Java BytesUtil.writeVInt方法代码示例

本文整理汇总了Java中org.apache.kylin.common.util.BytesUtil.writeVInt方法的典型用法代码示例。如果您正苦于以下问题:Java BytesUtil.writeVInt方法的具体用法?Java BytesUtil.writeVInt怎么用?Java BytesUtil.writeVInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.kylin.common.util.BytesUtil的用法示例。


在下文中一共展示了BytesUtil.writeVInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void serialize(BigDecimal value, ByteBuffer out) {
    if (value.scale() > type.getScale()) {
        if (avoidVerbose++ % 10000 == 0) {
            logger.warn("value's scale has exceeded the " + type.getScale() + ", cut it off, to ensure encoded value do not exceed maxLength " + maxLength + " times:" + (avoidVerbose));
        }
        value = value.setScale(type.getScale(), BigDecimal.ROUND_HALF_EVEN);
    }
    byte[] bytes = value.unscaledValue().toByteArray();
    if (bytes.length + 2 > maxLength) {
        throw new IllegalArgumentException("'" + value + "' exceeds the expected length for type " + type);
    }

    BytesUtil.writeVInt(value.scale(), out);
    BytesUtil.writeVInt(bytes.length, out);
    out.put(bytes);
}
 
开发者ID:apache,项目名称:kylin,代码行数:18,代码来源:BigDecimalSerializer.java

示例2: serializeRawScans

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
private ByteString serializeRawScans(List<RawScan> rawScans) {
    ByteString rawScanByteString;
    int rawScanBufferSize = BytesSerializer.SERIALIZE_BUFFER_SIZE;
    while (true) {
        try {
            ByteBuffer rawScanBuffer = ByteBuffer.allocate(rawScanBufferSize);
            BytesUtil.writeVInt(rawScans.size(), rawScanBuffer);
            for (RawScan rs : rawScans) {
                RawScan.serializer.serialize(rs, rawScanBuffer);
            }
            rawScanBuffer.flip();
            rawScanByteString = HBaseZeroCopyByteString.wrap(rawScanBuffer.array(), rawScanBuffer.position(), rawScanBuffer.limit());
            break;
        } catch (BufferOverflowException boe) {
            logger.info("Buffer size {} cannot hold the raw scans, resizing to 4 times", rawScanBufferSize);
            rawScanBufferSize *= 4;
        }
    }
    return rawScanByteString;
}
 
开发者ID:apache,项目名称:kylin,代码行数:21,代码来源:CubeHBaseEndpointRPC.java

示例3: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void serialize(RawScan value, ByteBuffer out) {
    BytesUtil.writeByteArray(value.startKey, out);
    BytesUtil.writeByteArray(value.endKey, out);
    BytesUtil.writeVInt(value.hbaseColumns.size(), out);
    for (Pair<byte[], byte[]> hbaseColumn : value.hbaseColumns) {
        BytesUtil.writeByteArray(hbaseColumn.getFirst(), out);
        BytesUtil.writeByteArray(hbaseColumn.getSecond(), out);
    }
    BytesUtil.writeVInt(value.fuzzyKeys.size(), out);
    for (Pair<byte[], byte[]> fuzzyKey : value.fuzzyKeys) {
        BytesUtil.writeByteArray(fuzzyKey.getFirst(), out);
        BytesUtil.writeByteArray(fuzzyKey.getSecond(), out);
    }
    BytesUtil.writeVInt(value.hbaseCaching, out);
    BytesUtil.writeVInt(value.hbaseMaxResultSize, out);
}
 
开发者ID:apache,项目名称:kylin,代码行数:18,代码来源:RawScan.java

示例4: writeDimensionEncoding

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
private static void writeDimensionEncoding(DimensionEncoding encoding, ByteBuffer out) {
    try {
        if (encoding == null) {
            BytesUtil.writeVInt(1, out);
        } else {
            BytesUtil.writeVInt(0, out);

            if (encoding instanceof DictionaryDimEnc) {
                encoding = new TrimmedDimEnc(encoding.getLengthOfEncoding());
            }
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(encoding);
            BytesUtil.writeByteArray(baos.toByteArray(), out);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:20,代码来源:TrimmedCubeCodeSystem.java

示例5: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void serialize(IGTCodeSystem ivalue, ByteBuffer out) {
    TrimmedCubeCodeSystem value = (TrimmedCubeCodeSystem) ivalue;
    BytesUtil.writeVInt(value.dependentMetricsMap.size(), out);
    for (Map.Entry<Integer, Integer> x : value.dependentMetricsMap.entrySet()) {
        BytesUtil.writeVInt(x.getKey(), out);
        BytesUtil.writeVInt(x.getValue(), out);
    }

    BytesUtil.writeVInt(value.dimEncs.length, out);
    for (int i = 0; i < value.dimEncs.length; i++) {
        DimensionEncoding enc = value.dimEncs[i];

        writeDimensionEncoding(enc, out);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:17,代码来源:TrimmedCubeCodeSystem.java

示例6: writeRegisters

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
public void writeRegisters(final ByteBuffer out) throws IOException {

        final int indexLen = getRegisterIndexSize();
        int size = size();

        // decide output scheme -- map (3*size bytes) or array (2^p bytes)
        byte scheme;
        if (5 + (indexLen + 1) * size < m) // 5 is max len of vint
            scheme = 0; // map
        else
            scheme = 1; // array
        out.put(scheme);

        if (scheme == 0) { // map scheme
            BytesUtil.writeVInt(size, out);
            if (singleBucket == -1) {
                // no non-zero register
            } else if (singleBucket >= 0) {
                writeUnsigned(singleBucket, indexLen, out);
                out.put(registers[singleBucket]);
            } else {
                for (int i = 0; i < m; i++) {
                    if (registers[i] > 0) {
                        writeUnsigned(i, indexLen, out);
                        out.put(registers[i]);
                    }
                }
            }
        } else if (scheme == 1) { // array scheme
            out.put(registers);
        } else
            throw new IllegalStateException();
    }
 
开发者ID:apache,项目名称:kylin,代码行数:34,代码来源:HLLCounterOld.java

示例7: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void serialize(List<ByteArray> values, ByteBuffer out) {
    if (values == null) {
        BytesUtil.writeVInt(0, out);
    } else {
        BytesUtil.writeVInt(values.size(), out);
        for (ByteArray array : values) {
            if (!out.hasRemaining() || out.remaining() < array.length()) {
                throw new RuntimeException("BufferOverflow! Please use one higher cardinality column for dimension column when build RAW cube!");
            }
            BytesUtil.writeByteArray(BytesUtil.subarray(array.array(), array.offset(), array.offset() + array.length()), out);
        }
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:15,代码来源:RawSerializer.java

示例8: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void serialize(DataType value, ByteBuffer out) {
    BytesUtil.writeUTFString(value.name, out);
    BytesUtil.writeVInt(value.precision, out);
    BytesUtil.writeVInt(value.scale, out);

}
 
开发者ID:apache,项目名称:kylin,代码行数:8,代码来源:DataType.java

示例9: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void serialize(IFilterCodeSystem cs, ByteBuffer buffer) {
    int size = this.constantValues.size();
    BytesUtil.writeVInt(size, buffer);
    for (Object val : this.constantValues) {
        cs.serialize(val, buffer);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:ConstantTupleFilter.java

示例10: serializeFilter

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
private static void serializeFilter(int flag, TupleFilter filter, ByteBuffer buffer, IFilterCodeSystem<?> cs) {
    if (flag < 0) {
        BytesUtil.writeVInt(-1, buffer);
    } else {
        int opVal = filter.getOperator().getValue();
        BytesUtil.writeVInt(opVal, buffer);
        filter.serialize(cs, buffer);
        BytesUtil.writeVInt(flag, buffer);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:11,代码来源:TupleFilterSerializer.java

示例11: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void serialize(IFilterCodeSystem cs, ByteBuffer buffer) {
    int size = this.dynamicVariables.size();
    BytesUtil.writeVInt(size, buffer);
    for (Map.Entry<String, Object> entry : this.dynamicVariables.entrySet()) {
        BytesUtil.writeUTFString(entry.getKey(), buffer);
        cs.serialize(entry.getValue(), buffer);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:11,代码来源:CompareTupleFilter.java

示例12: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void serialize(CoprocessorRowType o, ByteBuffer out) {
    int n = o.columns.length;
    BytesUtil.writeVInt(o.columns.length, out);
    BytesUtil.writeVInt(o.bodyOffset, out);
    for (int i = 0; i < n; i++) {
        BytesUtil.writeAsciiString(o.columns[i].getTable(), out);
        BytesUtil.writeAsciiString(o.columns[i].getName(), out);
        BytesUtil.writeAsciiString(o.columns[i].getDatatype(), out);
        BytesUtil.writeVInt(o.columnSizes[i], out);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:13,代码来源:CoprocessorRowType.java

示例13: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void serialize(GTScanRequest value, ByteBuffer out) {
    final int serialLevel = KylinConfig.getInstanceFromEnv().getGTScanRequestSerializationLevel();

    GTInfo.serializer.serialize(value.info, out);

    BytesUtil.writeVInt(value.ranges.size(), out);
    for (GTScanRange range : value.ranges) {
        serializeGTRecord(range.pkStart, out);
        serializeGTRecord(range.pkEnd, out);
        BytesUtil.writeVInt(range.fuzzyKeys.size(), out);
        for (GTRecord f : range.fuzzyKeys) {
            serializeGTRecord(f, out);
        }
    }

    ImmutableBitSet.serializer.serialize(value.columns, out);
    BytesUtil.writeByteArray(GTUtil.serializeGTFilter(value.filterPushDown, value.info), out);

    if (serialLevel >= SERIAL_1_HAVING_FILTER) {
        BytesUtil.writeByteArray(
                TupleFilterSerializer.serialize(value.havingFilterPushDown, StringCodeSystem.INSTANCE), out);
    }

    ImmutableBitSet.serializer.serialize(value.aggrGroupBy, out);
    ImmutableBitSet.serializer.serialize(value.aggrMetrics, out);
    BytesUtil.writeAsciiStringArray(value.aggrMetricsFuncs, out);
    BytesUtil.writeVInt(value.allowStorageAggregation ? 1 : 0, out);
    out.putDouble(value.aggCacheMemThreshold);
    BytesUtil.writeUTFString(value.getStorageLimitLevel().name(), out);
    BytesUtil.writeVInt(value.storageScanRowNumThreshold, out);
    BytesUtil.writeVInt(value.storagePushDownLimit, out);
    BytesUtil.writeVLong(value.startTime, out);
    BytesUtil.writeVLong(value.timeout, out);
    BytesUtil.writeUTFString(value.storageBehavior, out);
}
 
开发者ID:apache,项目名称:kylin,代码行数:37,代码来源:GTScanRequest.java

示例14: writeRegisters

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
public void writeRegisters(final ByteBuffer out) throws IOException {

        final int indexLen = getRegisterIndexSize();
        int size = register.getSize();

        // decide output scheme -- map (3*size bytes) or array (2^p bytes)
        byte scheme;
        if (register instanceof SingleValueRegister || register instanceof SparseRegister //
                || 5 + (indexLen + 1) * size < m) {
            scheme = 0; // map
        } else {
            scheme = 1; // array
        }
        out.put(scheme);
        if (scheme == 0) { // map scheme
            BytesUtil.writeVInt(size, out);
            if (register.getRegisterType() == RegisterType.SINGLE_VALUE) { //single value register
                if (size > 0) {
                    SingleValueRegister sr = (SingleValueRegister) register;
                    writeUnsigned(sr.getSingleValuePos(), indexLen, out);
                    out.put(sr.getValue());
                }
            } else if (register.getRegisterType() == RegisterType.SPARSE) { //sparse register
                Collection<Map.Entry<Integer, Byte>> allValue = ((SparseRegister) register).getAllValue();
                for (Map.Entry<Integer, Byte> entry : allValue) {
                    writeUnsigned(entry.getKey(), indexLen, out);
                    out.put(entry.getValue());
                }
            } else { //dense register
                byte[] registers = ((DenseRegister) register).getRawRegister();
                for (int i = 0; i < m; i++) {
                    if (registers[i] > 0) {
                        writeUnsigned(i, indexLen, out);
                        out.put(registers[i]);
                    }
                }
            }
        } else if (scheme == 1) { // array scheme
            out.put(((DenseRegister) register).getRawRegister());
        } else
            throw new IllegalStateException();
    }
 
开发者ID:apache,项目名称:kylin,代码行数:43,代码来源:HLLCounter.java

示例15: serialize

import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void serialize(CoprocessorProjector value, ByteBuffer out) {
    BytesUtil.writeByteArray(value.groupByMask, out);
    BytesUtil.writeVInt(value.hasGroupby ? 1 : 0, out);
}
 
开发者ID:apache,项目名称:kylin,代码行数:6,代码来源:CoprocessorProjector.java


注:本文中的org.apache.kylin.common.util.BytesUtil.writeVInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。