/** * Convenience method. */ public Map<String, double[]> columnsWithLabels() { final Map<String, double[]> mappedValues = Maps.newHashMap(); for (int i = 0; i < labels.length; i++) { mappedValues.put(labels[i], columns[i].getList()); } return mappedValues; }
/** * Convenience method. */ public Map<String, double[]> columnsWithLabels() { final Map<String, double[]> mappedValues = Maps.newHashMap(); for (int i = 0; i < labels.length; i++) { mappedValues.put(labels[i], columns[i].getList()); } return mappedValues; }
public double getLastValue(final String resource, final String attribute, final String aggregation, boolean relaxed) throws MeasurementException { long end = System.currentTimeMillis(); long start = end - (15 * 60 * 1000); QueryResponse.WrappedPrimitive[] columns = queryInt(resource, attribute, start, end, 300000, aggregation, relaxed).getColumns(); if (columns.length > 0) { double[] values = columns[0].getList(); if (values.length > 0) { for(int i = values.length-1; i >= 0; i--) { if (!Double.isNaN(values[i])) { return values[i]; } } } } return Double.NaN; }
/** * A method to query the Measurements Api for a given resource/attribute. * * @param resource the resource to be used * @param attribute the attribute to query for * @param start the start timestamp * @param end the end timestamp * @param step the step size * @param aggregation the aggregation method * @return the list of double values */ public List<Double> query(final String resource, final String attribute, final long start, final long end, final long step, final String aggregation, final boolean relaxed) throws MeasurementException { QueryResponse.WrappedPrimitive[] columns = queryInt(resource, attribute, start, end, step, aggregation, relaxed).getColumns(); if (columns.length > 0) { return Doubles.asList(columns[0].getList()); } return Collections.emptyList(); }
/** * A method to query the Measurements Api for a given resource/attribute. * * @param resource the resource to be used * @param attribute the attribute to query for * @param start the start timestamp * @param end the end timestamp * @param step the step size * @param aggregation the aggregation method * @return the list of double values */ public List<Double> query(final String resource, final String attribute, final long start, final long end, final long step, final String aggregation, final boolean relaxed) throws MeasurementException { QueryResponse.WrappedPrimitive[] columns = queryInt(resource, attribute, start, end, step, aggregation, relaxed).getColumns(); if (columns.length > 0) { return Doubles.asList(columns[0].getList()); } return Collections.emptyList(); }
public double getLastValue(final String resource, final String attribute, final String aggregation, boolean relaxed) throws MeasurementException { long end = System.currentTimeMillis(); long start = end - (15 * 60 * 1000); QueryResponse.WrappedPrimitive[] columns = queryInt(resource, attribute, start, end, 300000, aggregation, relaxed).getColumns(); if (columns.length > 0) { double[] values = columns[0].getList(); if (values.length > 0) { for(int i = values.length-1; i >= 0; i--) { if (!Double.isNaN(values[i])) { return values[i]; } } } } return Double.NaN; }