本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}