use of com.linkedin.thirdeye.hadoop.config.MetricType in project pinot by linkedin.
the class DerivedColumnTransformationPhaseConfig method fromThirdEyeConfig.
public static DerivedColumnTransformationPhaseConfig fromThirdEyeConfig(ThirdEyeConfig config) {
// metrics
List<String> metricNames = new ArrayList<String>(config.getMetrics().size());
List<MetricType> metricTypes = new ArrayList<MetricType>(config.getMetrics().size());
for (MetricSpec spec : config.getMetrics()) {
metricNames.add(spec.getName());
metricTypes.add(spec.getType());
}
// dimensions
List<String> dimensionNames = new ArrayList<String>(config.getDimensions().size());
for (DimensionSpec dimensionSpec : config.getDimensions()) {
dimensionNames.add(dimensionSpec.getName());
}
// time
String timeColumnName = config.getTime().getColumnName();
TopkWhitelistSpec topKWhitelist = config.getTopKWhitelist();
Map<String, Set<String>> whitelist = new HashMap<>();
// topkwhitelist
if (topKWhitelist != null && topKWhitelist.getWhitelist() != null) {
for (Entry<String, String> entry : topKWhitelist.getWhitelist().entrySet()) {
String[] whitelistValues = entry.getValue().split(FIELD_SEPARATOR);
whitelist.put(entry.getKey(), new HashSet<String>(Arrays.asList(whitelistValues)));
}
}
return new DerivedColumnTransformationPhaseConfig(dimensionNames, metricNames, metricTypes, timeColumnName, whitelist);
}
use of com.linkedin.thirdeye.hadoop.config.MetricType in project pinot by linkedin.
the class AggregationPhaseMapOutputValue method fromBytes.
public static AggregationPhaseMapOutputValue fromBytes(byte[] buffer, List<MetricType> metricTypes) throws IOException {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buffer));
int length;
// metric values
length = dis.readInt();
Number[] metricValues = new Number[length];
for (int i = 0; i < length; i++) {
MetricType metricType = metricTypes.get(i);
switch(metricType) {
case SHORT:
metricValues[i] = dis.readShort();
break;
case LONG:
metricValues[i] = dis.readLong();
break;
case INT:
metricValues[i] = dis.readInt();
break;
case FLOAT:
metricValues[i] = dis.readFloat();
break;
case DOUBLE:
metricValues[i] = dis.readDouble();
break;
}
}
AggregationPhaseMapOutputValue wrapper;
wrapper = new AggregationPhaseMapOutputValue(metricValues, metricTypes);
return wrapper;
}
use of com.linkedin.thirdeye.hadoop.config.MetricType in project pinot by linkedin.
the class TopKPhaseMapOutputValue method toBytes.
public byte[] toBytes() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
// metric values
dos.writeInt(metricValues.length);
for (int i = 0; i < metricValues.length; i++) {
Number number = metricValues[i];
MetricType metricType = metricTypes.get(i);
switch(metricType) {
case SHORT:
dos.writeShort(number.intValue());
break;
case LONG:
dos.writeLong(number.longValue());
break;
case INT:
dos.writeInt(number.intValue());
break;
case FLOAT:
dos.writeFloat(number.floatValue());
break;
case DOUBLE:
dos.writeDouble(number.doubleValue());
break;
}
}
baos.close();
dos.close();
return baos.toByteArray();
}
use of com.linkedin.thirdeye.hadoop.config.MetricType in project pinot by linkedin.
the class TopKPhaseMapOutputValue method fromBytes.
public static TopKPhaseMapOutputValue fromBytes(byte[] buffer, List<MetricType> metricTypes) throws IOException {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buffer));
int length;
// metric values
length = dis.readInt();
Number[] metricValues = new Number[length];
for (int i = 0; i < length; i++) {
MetricType metricType = metricTypes.get(i);
switch(metricType) {
case SHORT:
metricValues[i] = dis.readShort();
break;
case LONG:
metricValues[i] = dis.readLong();
break;
case INT:
metricValues[i] = dis.readInt();
break;
case FLOAT:
metricValues[i] = dis.readFloat();
break;
case DOUBLE:
metricValues[i] = dis.readDouble();
break;
}
}
TopKPhaseMapOutputValue wrapper;
wrapper = new TopKPhaseMapOutputValue(metricValues, metricTypes);
return wrapper;
}
use of com.linkedin.thirdeye.hadoop.config.MetricType in project pinot by linkedin.
the class AggregationPhaseConfig method fromThirdEyeConfig.
public static AggregationPhaseConfig fromThirdEyeConfig(ThirdEyeConfig config) {
// metrics
List<String> metricNames = new ArrayList<String>(config.getMetrics().size());
List<MetricType> metricTypes = new ArrayList<MetricType>(config.getMetrics().size());
for (MetricSpec spec : config.getMetrics()) {
metricNames.add(spec.getName());
metricTypes.add(spec.getType());
}
// dimensions
List<String> dimensionNames = new ArrayList<String>(config.getDimensions().size());
for (DimensionSpec dimensionSpec : config.getDimensions()) {
dimensionNames.add(dimensionSpec.getName());
}
// time
TimeSpec time = config.getTime();
// input time
TimeSpec inputTime = config.getInputTime();
if (inputTime == null) {
throw new IllegalStateException("Must provide input time configs for aggregation job");
}
return new AggregationPhaseConfig(dimensionNames, metricNames, metricTypes, time, inputTime);
}
Aggregations