Java Code Examples for org.apache.kylin.common.util.BytesUtil#readVInt()
The following examples show how to use
org.apache.kylin.common.util.BytesUtil#readVInt() .
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: TrimmedCubeCodeSystem.java From kylin with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: TrimmedCubeCodeSystem.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
public 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); } }
Example 3
Source File: CoprocessorRowType.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@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); }
Example 4
Source File: HLLCounterOld.java From kylin with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: CaseTupleExpression.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public void deserialize(IFilterCodeSystem<?> cs, ByteBuffer buffer) { int nWhenEntries = BytesUtil.readVInt(buffer); List<Pair<TupleFilter, TupleExpression>> whenList = Lists.newArrayListWithExpectedSize(nWhenEntries); for (int i = 0; i < nWhenEntries; i++) { TupleFilter tupleFilter = TupleFilterSerializer.deserialize(BytesUtil.readByteArray(buffer), cs); TupleExpression tupleExpression = TupleExpressionSerializer.deserialize(BytesUtil.readByteArray(buffer), cs); whenList.add(new Pair<>(tupleFilter, tupleExpression)); } this.whenList = whenList; int flag = BytesUtil.readVInt(buffer); if (flag == 1) { this.elseExpr = TupleExpressionSerializer.deserialize(BytesUtil.readByteArray(buffer), cs); } }
Example 6
Source File: TrimmedCubeCodeSystem.java From kylin with Apache License 2.0 | 6 votes |
public 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); } }
Example 7
Source File: RawSerializer.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@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; }
Example 8
Source File: CoprocessorRowType.java From Kylin with Apache License 2.0 | 6 votes |
@Override public CoprocessorRowType deserialize(ByteBuffer in) { int n = 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); TableDesc table = new TableDesc(); table.setName(tableName); ColumnDesc col = new ColumnDesc(); col.setTable(table); col.setName(colName); cols[i] = new TblColRef(col); int colSize = BytesUtil.readVInt(in); colSizes[i] = colSize; } return new CoprocessorRowType(cols, colSizes); }
Example 9
Source File: RawSerializer.java From kylin with Apache License 2.0 | 6 votes |
@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; }
Example 10
Source File: TupleExpressionSerializer.java From kylin with Apache License 2.0 | 5 votes |
public static TupleExpression deserialize(byte[] bytes, IFilterCodeSystem<?> cs) { ByteBuffer buffer = ByteBuffer.wrap(bytes); TupleExpression rootTuple = null; Stack<TupleExpression> parentStack = new Stack<>(); while (buffer.hasRemaining()) { int opVal = BytesUtil.readVInt(buffer); if (opVal < 0) { parentStack.pop(); continue; } DataType dataType = DataType.serializer.deserialize(buffer); // deserialize expression TupleExpression tuple = createTupleExpression(dataType, opVal); tuple.deserialize(cs, buffer); if (rootTuple == null) { // push root to stack rootTuple = tuple; parentStack.push(tuple); BytesUtil.readVInt(buffer); continue; } // add expression to parent TupleExpression parentExpression = parentStack.peek(); if (parentExpression != null) { parentExpression.addChild(tuple); } // push expression to stack or not based on having children or not int hasChild = BytesUtil.readVInt(buffer); if (hasChild == 1) { parentStack.push(tuple); } } return rootTuple; }
Example 11
Source File: CompareTupleFilter.java From kylin with Apache License 2.0 | 5 votes |
@Override public void deserialize(IFilterCodeSystem<?> cs, ByteBuffer buffer) { this.dynamicVariables.clear(); int size = BytesUtil.readVInt(buffer); for (int i = 0; i < size; i++) { String name = BytesUtil.readUTFString(buffer); Object value = cs.deserialize(buffer); bindVariable(name, value); } }
Example 12
Source File: GTTwoLayerAggregateParam.java From kylin with Apache License 2.0 | 5 votes |
@Override public GTTwoLayerAggregateParam deserialize(ByteBuffer in) { int ifEnabled = BytesUtil.readVInt(in); if (ifEnabled != 1) { return new GTTwoLayerAggregateParam(); } ImmutableBitSet vDimMask = ImmutableBitSet.serializer.deserialize(in); ImmutableBitSet outLMetrics = ImmutableBitSet.serializer.deserialize(in); String[] outLMetricsFuncs = BytesUtil.readAsciiStringArray(in); int[] inLMetrics = BytesUtil.readIntArray(in); String[] inLMetricsFuncs = BytesUtil.readAsciiStringArray(in); return new GTTwoLayerAggregateParam(vDimMask, outLMetrics, outLMetricsFuncs, inLMetrics, inLMetricsFuncs); }
Example 13
Source File: TupleFilterSerializer.java From Kylin with Apache License 2.0 | 5 votes |
public static TupleFilter deserialize(byte[] bytes) { 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); byte[] filetrBytes = BytesUtil.readByteArray(buffer); filter.deserialize(filetrBytes); 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; }
Example 14
Source File: BigDecimalSerializer.java From Kylin with Apache License 2.0 | 5 votes |
@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); }
Example 15
Source File: TupleFilterSerializer.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
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; }
Example 16
Source File: HLLCounter.java From kylin with Apache License 2.0 | 5 votes |
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(); }
Example 17
Source File: CubeVisitService.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private List<RawScan> deserializeRawScans(ByteBuffer in) { int rawScanCount = BytesUtil.readVInt(in); List<RawScan> ret = Lists.newArrayList(); for (int i = 0; i < rawScanCount; i++) { RawScan temp = RawScan.serializer.deserialize(in); ret.add(temp); } return ret; }
Example 18
Source File: ConstantTupleFilter.java From kylin with Apache License 2.0 | 5 votes |
@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)); } }
Example 19
Source File: GTScanRequest.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public GTScanRequest deserialize(ByteBuffer in) { final int serialLevel = KylinConfig.getInstanceFromEnv().getGTScanRequestSerializationLevel(); GTInfo sInfo = GTInfo.serializer.deserialize(in); List<GTScanRange> sRanges = Lists.newArrayList(); int sRangesCount = BytesUtil.readVInt(in); for (int rangeIdx = 0; rangeIdx < sRangesCount; rangeIdx++) { GTRecord sPkStart = deserializeGTRecord(in, sInfo); GTRecord sPkEnd = deserializeGTRecord(in, sInfo); List<GTRecord> sFuzzyKeys = Lists.newArrayList(); int sFuzzyKeySize = BytesUtil.readVInt(in); for (int i = 0; i < sFuzzyKeySize; i++) { sFuzzyKeys.add(deserializeGTRecord(in, sInfo)); } GTScanRange sRange = new GTScanRange(sPkStart, sPkEnd, sFuzzyKeys); sRanges.add(sRange); } ImmutableBitSet sColumns = ImmutableBitSet.serializer.deserialize(in); TupleFilter sGTFilter = GTUtil.deserializeGTFilter(BytesUtil.readByteArray(in), sInfo); TupleFilter sGTHavingFilter = null; if (serialLevel >= SERIAL_1_HAVING_FILTER) { sGTHavingFilter = TupleFilterSerializer.deserialize(BytesUtil.readByteArray(in), StringCodeSystem.INSTANCE); } ImmutableBitSet sAggGroupBy = ImmutableBitSet.serializer.deserialize(in); ImmutableBitSet sAggrMetrics = ImmutableBitSet.serializer.deserialize(in); String[] sAggrMetricFuncs = BytesUtil.readAsciiStringArray(in); boolean sAllowPreAggr = (BytesUtil.readVInt(in) == 1); double sAggrCacheGB = in.getDouble(); StorageLimitLevel storageLimitLevel = StorageLimitLevel.valueOf(BytesUtil.readUTFString(in)); int storageScanRowNumThreshold = BytesUtil.readVInt(in); int storagePushDownLimit = BytesUtil.readVInt(in); long startTime = BytesUtil.readVLong(in); long timeout = BytesUtil.readVLong(in); String storageBehavior = BytesUtil.readUTFString(in); ImmutableBitSet aDynCols = ImmutableBitSet.serializer.deserialize(in); int nTupleExprs = BytesUtil.readVInt(in); Map<Integer, TupleExpression> sTupleExpressionMap = Maps.newHashMapWithExpectedSize(nTupleExprs); for (int i = 0; i < nTupleExprs; i++) { int sC = BytesUtil.readVInt(in); TupleExpression sTupleExpr = TupleExpressionSerializer.deserialize(BytesUtil.readByteArray(in), GTUtil.wrap(sInfo.codeSystem.getComparator())); sTupleExpressionMap.put(sC, sTupleExpr); } ImmutableBitSet aRuntimeAggrMetrics = ImmutableBitSet.serializer.deserialize(in); return new GTScanRequestBuilder().setInfo(sInfo).setRanges(sRanges).setDimensions(sColumns) .setAggrGroupBy(sAggGroupBy).setAggrMetrics(sAggrMetrics).setAggrMetricsFuncs(sAggrMetricFuncs) .setRtAggrMetrics(aRuntimeAggrMetrics).setDynamicColumns(aDynCols) .setExprsPushDown(sTupleExpressionMap) .setFilterPushDown(sGTFilter).setHavingFilterPushDown(sGTHavingFilter) .setAllowStorageAggregation(sAllowPreAggr).setAggCacheMemThreshold(sAggrCacheGB) .setStorageScanRowNumThreshold(storageScanRowNumThreshold) .setStoragePushDownLimit(storagePushDownLimit).setStorageLimitLevel(storageLimitLevel) .setStartTime(startTime).setTimeout(timeout).setStorageBehavior(storageBehavior) .createGTScanRequest(); }
Example 20
Source File: CoprocessorProjector.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public CoprocessorProjector deserialize(ByteBuffer in) { byte[] mask = BytesUtil.readByteArray(in); boolean hasGroupBy = BytesUtil.readVInt(in) == 1; return new CoprocessorProjector(mask, hasGroupBy); }