@Override public MeasureAggregator<?>[] newMetricsAggregators(ImmutableBitSet columns, String[] aggrFunctions) { assert columns.trueBitCount() == aggrFunctions.length; MeasureAggregator<?>[] result = new MeasureAggregator[aggrFunctions.length]; for (int i = 0; i < result.length; i++) { int col = columns.trueBitAt(i); result[i] = MeasureAggregator.create(aggrFunctions[i], info.getColumnType(col)); } return result; }
@Override public MeasureAggregator<?>[] newMetricsAggregators(ImmutableBitSet columns, String[] aggrFunctions) { assert columns.trueBitCount() == aggrFunctions.length; MeasureAggregator<?>[] result = new MeasureAggregator[aggrFunctions.length]; for (int i = 0; i < result.length; i++) { int col = columns.trueBitAt(i); result[i] = MeasureAggregator.create(aggrFunctions[i], info.getColumnType(col)); } // deal with holistic distinct count if (dependentMetricsMap != null) { for (Map.Entry<Integer, Integer> childEntry : dependentMetricsMap.entrySet()) { if (columns.get(childEntry.getKey())) { Integer parent = childEntry.getValue(); if (columns.get(parent) == false) throw new IllegalStateException(); int childIdx = columns.trueBitIndexOf(childEntry.getKey()); int parentIdx = columns.trueBitIndexOf(parent); result[childIdx].setDependentAggregator(result[parentIdx]); } } } return result; }
public BufferedMeasureCodec createMeasureCodec() { DataType[] metricTypes = new DataType[aggrMetrics.trueBitCount()]; for (int i = 0; i < metricTypes.length; i++) { metricTypes[i] = info.getColumnType(aggrMetrics.trueBitAt(i)); } BufferedMeasureCodec codec = new BufferedMeasureCodec(metricTypes); codec.setBufferSize(info.getMaxColumnLength(aggrMetrics)); return codec; }
private ByteArray encodeTime(long ts, int index, int roundingFlag) { String value; DataType partitionColType = info.getColumnType(index); if (partitionColType.isDate()) { value = DateFormat.formatToDateStr(ts); } else if (partitionColType.isTimeFamily()) { value = DateFormat.formatToTimeWithoutMilliStr(ts); } else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101 String partitionDateFormat = segment.getModel().getPartitionDesc().getPartitionDateFormat(); if (StringUtils.isEmpty(partitionDateFormat)) { value = "" + ts; } else { value = DateFormat.formatToDateStr(ts, partitionDateFormat); } } else { throw new RuntimeException("Type " + partitionColType + " is not valid partition column type"); } ByteBuffer buffer = ByteBuffer.allocate(info.getMaxColumnLength()); info.getCodeSystem().encodeColumnValue(index, value, roundingFlag, buffer); return ByteArray.copyOf(buffer.array(), 0, buffer.position()); } }
@Override public void init(GTInfo info) { this.info = info; ImmutableBitSet dDims = info.getDynamicDims(); this.serializers = new DataTypeSerializer[info.getColumnCount()]; for (int i = 0; i < serializers.length; i++) { DimensionEncoding dimEnc = i < dimEncs.length ? dimEncs[i] : null; if (dimEnc != null) { // for dimensions serializers[i] = dimEnc.asDataTypeSerializer(); } else { DataTypeSerializer dSerializer = DataTypeSerializer.create(info.getColumnType(i)); if (dDims != null && dDims.get(i)) { // for dynamic dimensions dSerializer = new DynamicDimSerializer(dSerializer); } else { // for measures } serializers[i] = dSerializer; } } }
@Override public MeasureAggregator<?>[] newMetricsAggregators(ImmutableBitSet columns, String[] aggrFunctions) { assert columns.trueBitCount() == aggrFunctions.length; MeasureAggregator<?>[] result = new MeasureAggregator[aggrFunctions.length]; for (int i = 0; i < result.length; i++) { int col = columns.trueBitAt(i); result[i] = MeasureAggregator.create(aggrFunctions[i], info.getColumnType(col)); } return result; }
@Override public MeasureAggregator<?>[] newMetricsAggregators(ImmutableBitSet columns, String[] aggrFunctions) { assert columns.trueBitCount() == aggrFunctions.length; MeasureAggregator<?>[] result = new MeasureAggregator[aggrFunctions.length]; for (int i = 0; i < result.length; i++) { int col = columns.trueBitAt(i); result[i] = MeasureAggregator.create(aggrFunctions[i], info.getColumnType(col)); } // deal with holistic distinct count if (dependentMetricsMap != null) { for (Map.Entry<Integer, Integer> childEntry : dependentMetricsMap.entrySet()) { if (columns.get(childEntry.getKey())) { Integer parent = childEntry.getValue(); if (columns.get(parent) == false) throw new IllegalStateException(); int childIdx = columns.trueBitIndexOf(childEntry.getKey()); int parentIdx = columns.trueBitIndexOf(parent); result[childIdx].setDependentAggregator(result[parentIdx]); } } } return result; }
public BufferedMeasureCodec createMeasureCodec() { DataType[] metricTypes = new DataType[aggrMetrics.trueBitCount()]; for (int i = 0; i < metricTypes.length; i++) { metricTypes[i] = info.getColumnType(aggrMetrics.trueBitAt(i)); } BufferedMeasureCodec codec = new BufferedMeasureCodec(metricTypes); codec.setBufferSize(info.getMaxColumnLength(aggrMetrics)); return codec; }
private ByteArray encodeTime(long ts, int index, int roundingFlag) { String value; DataType partitionColType = info.getColumnType(index); if (partitionColType.isDate()) { value = DateFormat.formatToDateStr(ts); } else if (partitionColType.isTimeFamily()) { value = DateFormat.formatToTimeWithoutMilliStr(ts); } else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101 String partitionDateFormat = segment.getModel().getPartitionDesc().getPartitionDateFormat(); if (StringUtils.isEmpty(partitionDateFormat)) { value = "" + ts; } else { value = DateFormat.formatToDateStr(ts, partitionDateFormat); } } else { throw new RuntimeException("Type " + partitionColType + " is not valid partition column type"); } ByteBuffer buffer = ByteBuffer.allocate(info.getMaxColumnLength()); info.getCodeSystem().encodeColumnValue(index, value, roundingFlag, buffer); return ByteArray.copyOf(buffer.array(), 0, buffer.position()); } }
@Override public void init(GTInfo info) { this.info = info; ImmutableBitSet dDims = info.getDynamicDims(); this.serializers = new DataTypeSerializer[info.getColumnCount()]; for (int i = 0; i < serializers.length; i++) { DimensionEncoding dimEnc = i < dimEncs.length ? dimEncs[i] : null; if (dimEnc != null) { // for dimensions serializers[i] = dimEnc.asDataTypeSerializer(); } else { DataTypeSerializer dSerializer = DataTypeSerializer.create(info.getColumnType(i)); if (dDims != null && dDims.get(i)) { // for dynamic dimensions dSerializer = new DynamicDimSerializer(dSerializer); } else { // for measures } serializers[i] = dSerializer; } } }