Java Code Examples for org.apache.kylin.common.util.BytesUtil#writeByteArray()
The following examples show how to use
org.apache.kylin.common.util.BytesUtil#writeByteArray() .
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: CaseTupleExpression.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public void serialize(IFilterCodeSystem<?> cs, ByteBuffer buffer) { BytesUtil.writeVInt(whenList.size(), buffer); for (Pair<TupleFilter, TupleExpression> whenEntry : whenList) { byte[] whenBytes = TupleFilterSerializer.serialize(whenEntry.getFirst(), cs); BytesUtil.writeByteArray(whenBytes, buffer); byte[] thenBytes = TupleExpressionSerializer.serialize(whenEntry.getSecond(), cs); BytesUtil.writeByteArray(thenBytes, buffer); } if (elseExpr != null) { BytesUtil.writeVInt(1, buffer); byte[] elseBytes = TupleExpressionSerializer.serialize(elseExpr, cs); BytesUtil.writeByteArray(elseBytes, buffer); } else { BytesUtil.writeVInt(-1, buffer); } }
Example 2
Source File: RawScan.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@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); }
Example 3
Source File: TrimmedCubeCodeSystem.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
public 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); } }
Example 4
Source File: TrimmedCubeCodeSystem.java From kylin with Apache License 2.0 | 6 votes |
public 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); } }
Example 5
Source File: RawScan.java From kylin with Apache License 2.0 | 6 votes |
@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); }
Example 6
Source File: CaseTupleExpression.java From kylin with Apache License 2.0 | 6 votes |
@Override public void serialize(IFilterCodeSystem<?> cs, ByteBuffer buffer) { BytesUtil.writeVInt(whenList.size(), buffer); for (Pair<TupleFilter, TupleExpression> whenEntry : whenList) { byte[] whenBytes = TupleFilterSerializer.serialize(whenEntry.getFirst(), cs); BytesUtil.writeByteArray(whenBytes, buffer); byte[] thenBytes = TupleExpressionSerializer.serialize(whenEntry.getSecond(), cs); BytesUtil.writeByteArray(thenBytes, buffer); } if (elseExpr != null) { BytesUtil.writeVInt(1, buffer); byte[] elseBytes = TupleExpressionSerializer.serialize(elseExpr, cs); BytesUtil.writeByteArray(elseBytes, buffer); } else { BytesUtil.writeVInt(-1, buffer); } }
Example 7
Source File: EndpointAggregators.java From Kylin with Apache License 2.0 | 5 votes |
@Override public void serialize(EndpointAggregators value, ByteBuffer out) { BytesUtil.writeAsciiStringArray(value.funcNames, out); BytesUtil.writeAsciiStringArray(value.dataTypes, out); BytesUtil.writeVInt(value.metricInfos.length, out); for (int i = 0; i < value.metricInfos.length; ++i) { MetricInfo metricInfo = value.metricInfos[i]; BytesUtil.writeAsciiString(metricInfo.type.toString(), out); BytesUtil.writeVInt(metricInfo.refIndex, out); BytesUtil.writeVInt(metricInfo.precision, out); } BytesUtil.writeByteArray(TableRecordInfoDigest.serialize(value.tableRecordInfoDigest), out); }
Example 8
Source File: ExtendedColumnSerializer.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteArray value, ByteBuffer out) { if (value != null && value.array() != null) { BytesUtil.writeByteArray(value.array(), value.offset(), value.length(), out); } else { BytesUtil.writeByteArray(null, out); } }
Example 9
Source File: ObserverAggregators.java From Kylin with Apache License 2.0 | 5 votes |
@Override public void serialize(ObserverAggregators value, ByteBuffer out) { BytesUtil.writeVInt(value.nHCols, out); for (int i = 0; i < value.nHCols; i++) { HCol col = value.hcols[i]; BytesUtil.writeByteArray(col.family, out); BytesUtil.writeByteArray(col.qualifier, out); BytesUtil.writeAsciiStringArray(col.funcNames, out); BytesUtil.writeAsciiStringArray(col.dataTypes, out); } }
Example 10
Source File: TupleFilterSerializer.java From Kylin with Apache License 2.0 | 5 votes |
private static void serializeFilter(int flag, TupleFilter filter, Decorator decorator, ByteBuffer buffer) { if (flag < 0) { BytesUtil.writeVInt(-1, buffer); } else { byte[] bytes = filter.serialize(); int opVal = filter.getOperator().getValue(); BytesUtil.writeVInt(opVal, buffer); BytesUtil.writeByteArray(bytes, buffer); BytesUtil.writeVInt(flag, buffer); } }
Example 11
Source File: CubeHBaseEndpointRPC.java From kylin with Apache License 2.0 | 5 votes |
private String getScanRequestString(GTScanRequest scanRequest) { int scanRequestBufferSize = BytesSerializer.SERIALIZE_BUFFER_SIZE; while (true) { try { ByteBuffer out = ByteBuffer.allocate(scanRequestBufferSize); GTInfo.serializer.serialize(scanRequest.getInfo(), out); BytesUtil.writeVInt(scanRequest.getGTScanRanges().size(), out); for (GTScanRange range : scanRequest.getGTScanRanges()) { 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(scanRequest.getColumns(), out); BytesUtil.writeByteArray( GTUtil.serializeGTFilter(scanRequest.getFilterPushDown(), scanRequest.getInfo()), out); ImmutableBitSet.serializer.serialize(scanRequest.getAggrGroupBy(), out); ImmutableBitSet.serializer.serialize(scanRequest.getAggrMetrics(), out); BytesUtil.writeAsciiStringArray(scanRequest.getAggrMetricsFuncs(), out); BytesUtil.writeVInt(scanRequest.isAllowStorageAggregation() ? 1 : 0, out); BytesUtil.writeUTFString(scanRequest.getStorageLimitLevel().name(), out); BytesUtil.writeVInt(scanRequest.getStorageScanRowNumThreshold(), out); BytesUtil.writeVInt(scanRequest.getStoragePushDownLimit(), out); BytesUtil.writeUTFString(scanRequest.getStorageBehavior(), out); BytesUtil.writeBooleanArray(new boolean[]{storageContext.isExactAggregation()}, out); out.flip(); return Bytes.toStringBinary(out.array(), out.position(), out.limit()); } catch (BufferOverflowException boe) { logger.info("Buffer size {} cannot hold the scan request, resizing to 4 times", scanRequestBufferSize); scanRequestBufferSize *= 4; } } }
Example 12
Source File: RawSerializer.java From kylin with Apache License 2.0 | 5 votes |
@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); } } }
Example 13
Source File: ExtendedColumnSerializer.java From kylin with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteArray value, ByteBuffer out) { if (value != null && value.array() != null) { BytesUtil.writeByteArray(value.array(), value.offset(), value.length(), out); } else { BytesUtil.writeByteArray(null, out); } }
Example 14
Source File: CubeHBaseEndpointRPC.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private String getScanRequestString(GTScanRequest scanRequest) { int scanRequestBufferSize = BytesSerializer.SERIALIZE_BUFFER_SIZE; while (true) { try { ByteBuffer out = ByteBuffer.allocate(scanRequestBufferSize); GTInfo.serializer.serialize(scanRequest.getInfo(), out); BytesUtil.writeVInt(scanRequest.getGTScanRanges().size(), out); for (GTScanRange range : scanRequest.getGTScanRanges()) { 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(scanRequest.getColumns(), out); BytesUtil.writeByteArray( GTUtil.serializeGTFilter(scanRequest.getFilterPushDown(), scanRequest.getInfo()), out); ImmutableBitSet.serializer.serialize(scanRequest.getAggrGroupBy(), out); ImmutableBitSet.serializer.serialize(scanRequest.getAggrMetrics(), out); BytesUtil.writeAsciiStringArray(scanRequest.getAggrMetricsFuncs(), out); BytesUtil.writeVInt(scanRequest.isAllowStorageAggregation() ? 1 : 0, out); BytesUtil.writeUTFString(scanRequest.getStorageLimitLevel().name(), out); BytesUtil.writeVInt(scanRequest.getStorageScanRowNumThreshold(), out); BytesUtil.writeVInt(scanRequest.getStoragePushDownLimit(), out); BytesUtil.writeUTFString(scanRequest.getStorageBehavior(), out); BytesUtil.writeBooleanArray(new boolean[]{storageContext.isExactAggregation()}, out); out.flip(); return Bytes.toStringBinary(out.array(), out.position(), out.limit()); } catch (BufferOverflowException boe) { logger.info("Buffer size {} cannot hold the scan request, resizing to 4 times", scanRequestBufferSize); scanRequestBufferSize *= 4; } } }
Example 15
Source File: RawSerializer.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@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); } } }
Example 16
Source File: CoprocessorProjector.java From kylin with Apache License 2.0 | 4 votes |
@Override public void serialize(CoprocessorProjector value, ByteBuffer out) { BytesUtil.writeByteArray(value.groupByMask, out); BytesUtil.writeVInt(value.hasGroupby ? 1 : 0, out); }
Example 17
Source File: GTScanRequest.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@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); // for dynamic related info ImmutableBitSet.serializer.serialize(value.dynamicCols, out); BytesUtil.writeVInt(value.tupleExpressionMap.size(), out); for (int c : value.tupleExpressionMap.keySet()) { TupleExpression tupleExpr = value.tupleExpressionMap.get(c); BytesUtil.writeVInt(c, out); BytesUtil.writeByteArray(TupleExpressionSerializer.serialize(tupleExpr, GTUtil.wrap(value.info.codeSystem.getComparator())), out); } ImmutableBitSet.serializer.serialize(value.rtAggrMetrics, out); }
Example 18
Source File: GTScanRequest.java From kylin with Apache License 2.0 | 4 votes |
@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); // for dynamic related info ImmutableBitSet.serializer.serialize(value.dynamicCols, out); BytesUtil.writeVInt(value.tupleExpressionMap.size(), out); for (int c : value.tupleExpressionMap.keySet()) { TupleExpression tupleExpr = value.tupleExpressionMap.get(c); BytesUtil.writeVInt(c, out); BytesUtil.writeByteArray(TupleExpressionSerializer.serialize(tupleExpr, GTUtil.wrap(value.info.codeSystem.getComparator())), out); } ImmutableBitSet.serializer.serialize(value.rtAggrMetrics, out); GTTwoLayerAggregateParam.serializer.serialize(value.twoLayerAggParam, out); }
Example 19
Source File: CoprocessorProjector.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public void serialize(CoprocessorProjector value, ByteBuffer out) { BytesUtil.writeByteArray(value.groupByMask, out); BytesUtil.writeVInt(value.hasGroupby ? 1 : 0, out); }
Example 20
Source File: CoprocessorProjector.java From Kylin with Apache License 2.0 | 4 votes |
@Override public void serialize(CoprocessorProjector value, ByteBuffer out) { BytesUtil.writeByteArray(value.groupByMask, out); }