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