Search in sources :

Example 1 with MetricType

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);
}
Also used : DimensionSpec(com.linkedin.thirdeye.hadoop.config.DimensionSpec) Set(java.util.Set) HashSet(java.util.HashSet) TopkWhitelistSpec(com.linkedin.thirdeye.hadoop.config.TopkWhitelistSpec) HashMap(java.util.HashMap) MetricType(com.linkedin.thirdeye.hadoop.config.MetricType) MetricSpec(com.linkedin.thirdeye.hadoop.config.MetricSpec) ArrayList(java.util.ArrayList)

Example 2 with MetricType

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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) MetricType(com.linkedin.thirdeye.hadoop.config.MetricType) DataInputStream(java.io.DataInputStream)

Example 3 with MetricType

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();
}
Also used : DataOutputStream(java.io.DataOutputStream) MetricType(com.linkedin.thirdeye.hadoop.config.MetricType) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 4 with MetricType

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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) MetricType(com.linkedin.thirdeye.hadoop.config.MetricType) DataInputStream(java.io.DataInputStream)

Example 5 with MetricType

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);
}
Also used : DimensionSpec(com.linkedin.thirdeye.hadoop.config.DimensionSpec) MetricType(com.linkedin.thirdeye.hadoop.config.MetricType) MetricSpec(com.linkedin.thirdeye.hadoop.config.MetricSpec) ArrayList(java.util.ArrayList) TimeSpec(com.linkedin.thirdeye.hadoop.config.TimeSpec)

Aggregations

MetricType (com.linkedin.thirdeye.hadoop.config.MetricType)8 MetricSpec (com.linkedin.thirdeye.hadoop.config.MetricSpec)4 DimensionSpec (com.linkedin.thirdeye.hadoop.config.DimensionSpec)3 TopkWhitelistSpec (com.linkedin.thirdeye.hadoop.config.TopkWhitelistSpec)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 TopKDimensionToMetricsSpec (com.linkedin.thirdeye.hadoop.config.TopKDimensionToMetricsSpec)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataInputStream (java.io.DataInputStream)2 DataOutputStream (java.io.DataOutputStream)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2 TimeSpec (com.linkedin.thirdeye.hadoop.config.TimeSpec)1 Schema (org.apache.avro.Schema)1