Search in sources :

Example 1 with Operations

use of com.yahoo.container.StatisticsConfig.Values.Operations in project vespa by vespa-engine.

the class ValueTestCase method testReverseHistogram.

public void testReverseHistogram() {
    Logger logger = Logger.getLogger(Value.class.getName());
    boolean initUseParentHandlers = logger.getUseParentHandlers();
    logger.setUseParentHandlers(false);
    CheckHistogram h = new CheckHistogram("(0) < 0.0 (2) < 1.0 (2) < 2.0 (0)", "REGULAR");
    logger.addHandler(h);
    List<Operations.Arguments.Builder> histogram = Arrays.asList(new Operations.Arguments.Builder[] { new Operations.Arguments.Builder().key("limits").value("0, 1, 2") });
    List<Operations.Builder> ops = Arrays.asList(new Operations.Builder[] { new Operations.Builder().name(Operations.Name.Enum.REVERSE_CUMULATIVE).arguments(histogram) });
    StatisticsConfig c = new StatisticsConfig(new StatisticsConfig.Builder().values(new StatisticsConfig.Values.Builder().name(NALLE).operations(ops)));
    MockStatistics m = new MockStatistics();
    m.config = c;
    Value v = Value.buildValue(NALLE, m, null);
    assertEquals(HistogramType.REGULAR.toString(), v.histogramId.toString());
    v.put(.5d);
    v.put(.5d);
    v.put(1.5d);
    v.put(1.5d);
    v.run();
    assertEquals(true, h.gotRecord);
    assertEquals(true, h.gotWarning);
    logger.removeHandler(h);
    logger.setUseParentHandlers(initUseParentHandlers);
}
Also used : Logger(java.util.logging.Logger) StatisticsConfig(com.yahoo.container.StatisticsConfig) Operations(com.yahoo.container.StatisticsConfig.Values.Operations)

Example 2 with Operations

use of com.yahoo.container.StatisticsConfig.Values.Operations in project vespa by vespa-engine.

the class ValueTestCase method testParameterFromConfig.

public void testParameterFromConfig() {
    Logger logger = Logger.getLogger(Value.class.getName());
    boolean initUseParentHandlers = logger.getUseParentHandlers();
    logger.setUseParentHandlers(false);
    CheckHistogram h = new CheckHistogram("(0) < 0.0 (0) < 1.0 (0) < 2.0 (1)", "REGULAR");
    logger.addHandler(h);
    List<Operations.Arguments.Builder> histogram = Arrays.asList(new Operations.Arguments.Builder[] { new Operations.Arguments.Builder().key("limits").value("0, 1, 2") });
    List<Operations.Builder> ops = Arrays.asList(new Operations.Builder[] { new Operations.Builder().name(Operations.Name.Enum.MEAN), new Operations.Builder().name(Operations.Name.Enum.MIN), new Operations.Builder().name(Operations.Name.Enum.MAX), new Operations.Builder().name(Operations.Name.Enum.RAW), new Operations.Builder().name(Operations.Name.Enum.INSERTIONS), new Operations.Builder().name(Operations.Name.Enum.REGULAR).arguments(histogram), new Operations.Builder().name(Operations.Name.Enum.SUM) });
    StatisticsConfig c = new StatisticsConfig(new StatisticsConfig.Builder().values(new StatisticsConfig.Values.Builder().name(NALLE).operations(ops)));
    MockStatistics m = new MockStatistics();
    m.config = c;
    Value v = Value.buildValue(NALLE, m, null);
    final double x = 79.0d;
    v.put(x);
    assertEquals(x, v.getMean());
    v.run();
    assertEquals(true, h.gotRecord);
    logger.removeHandler(h);
    logger.setUseParentHandlers(initUseParentHandlers);
}
Also used : Logger(java.util.logging.Logger) StatisticsConfig(com.yahoo.container.StatisticsConfig) Operations(com.yahoo.container.StatisticsConfig.Values.Operations)

Example 3 with Operations

use of com.yahoo.container.StatisticsConfig.Values.Operations in project vespa by vespa-engine.

the class Value method parametersFromConfig.

private static Parameters parametersFromConfig(List<Operations> o) {
    Parameters p = new Parameters().setNameExtension(true);
    for (Operations operation : o) {
        Operations.Name.Enum opName = operation.name();
        HashMap<String, String> args = new HashMap<>();
        for (int j = 0; j < operation.arguments().size(); j++) {
            args.put(operation.arguments(j).key(), operation.arguments(j).value());
        }
        if (opName == Operations.Name.MEAN) {
            p.setLogMean(true);
        } else if (opName == Operations.Name.MAX) {
            p.setLogMax(true);
        } else if (opName == Operations.Name.MIN) {
            p.setLogMin(true);
        } else if (opName == Operations.Name.RAW) {
            p.setLogRaw(true);
        } else if (opName == Operations.Name.SUM) {
            p.setLogSum(true);
        } else if (opName == Operations.Name.INSERTIONS) {
            p.setLogInsertions(true);
        } else if (opName == Operations.Name.REGULAR) {
            p.setLogHistogram(true);
            p.setHistogramId(HistogramType.REGULAR);
            p.setLimits(initHistogram(args.get("axes"), args.get("limits")));
        } else if (opName == Operations.Name.CUMULATIVE) {
            p.setLogHistogram(true);
            p.setHistogramId(HistogramType.CUMULATIVE);
            p.setLimits(initHistogram(args.get("axes"), args.get("limits")));
        } else if (opName == Operations.Name.REVERSE_CUMULATIVE) {
            p.setLogHistogram(true);
            p.setHistogramId(HistogramType.REVERSE_CUMULATIVE);
            p.setLimits(initHistogram(args.get("axes"), args.get("limits")));
        }
    }
    return p;
}
Also used : HashMap(java.util.HashMap) Operations(com.yahoo.container.StatisticsConfig.Values.Operations)

Example 4 with Operations

use of com.yahoo.container.StatisticsConfig.Values.Operations in project vespa by vespa-engine.

the class ValueTestCase method testCumulativeHistogram.

public void testCumulativeHistogram() {
    Logger logger = Logger.getLogger(Value.class.getName());
    boolean initUseParentHandlers = logger.getUseParentHandlers();
    logger.setUseParentHandlers(false);
    CheckHistogram h = new CheckHistogram("(0) < 0.0 (2) < 1.0 (2) < 2.0 (0)", "REGULAR");
    logger.addHandler(h);
    List<Operations.Arguments.Builder> histogram = Arrays.asList(new Operations.Arguments.Builder[] { new Operations.Arguments.Builder().key("limits").value("0, 1, 2") });
    List<Operations.Builder> ops = Arrays.asList(new Operations.Builder[] { new Operations.Builder().name(Operations.Name.Enum.CUMULATIVE).arguments(histogram) });
    StatisticsConfig c = new StatisticsConfig(new StatisticsConfig.Builder().values(new StatisticsConfig.Values.Builder().name(NALLE).operations(ops)));
    MockStatistics m = new MockStatistics();
    m.config = c;
    Value v = Value.buildValue(NALLE, m, null);
    assertEquals(HistogramType.REGULAR.toString(), v.histogramId.toString());
    v.put(.5d);
    v.put(.5d);
    v.put(1.5d);
    v.put(1.5d);
    v.run();
    assertEquals(true, h.gotRecord);
    assertEquals(true, h.gotWarning);
    logger.removeHandler(h);
    logger.setUseParentHandlers(initUseParentHandlers);
}
Also used : Logger(java.util.logging.Logger) StatisticsConfig(com.yahoo.container.StatisticsConfig) Operations(com.yahoo.container.StatisticsConfig.Values.Operations)

Aggregations

Operations (com.yahoo.container.StatisticsConfig.Values.Operations)4 StatisticsConfig (com.yahoo.container.StatisticsConfig)3 Logger (java.util.logging.Logger)3 HashMap (java.util.HashMap)1