@Override public Row<Sample> next() { if (!hasNext()) throw new NoSuchElementException(); Row<Sample> working = m_input.next(); Row<Sample> result = new Row<>(working.getTimestamp(), working.getResource()); for (String metricName : m_metrics) { Sample sample = working.getElement(metricName); if (sample == null) { continue; } // Use rate as result if one of counter types, else pass through as-is. result.addElement(COUNTERS.contains(sample.getType()) ? getRate(sample) : sample); m_prevSamples.put(sample.getName(), sample); } return result; }
public Results<Measurement> process(Iterator<Row<Sample>> samples) { checkNotNull(samples, "samples argument"); // Build chain of iterators to process results as a stream Rate rate = new Rate(samples, m_resultDescriptor.getSourceNames()); PrimaryData primaryData = new PrimaryData(m_resource, m_start.minus(m_resolution), m_end, m_resultDescriptor, rate); Aggregation aggregation = new Aggregation(m_resource, m_start, m_end, m_resultDescriptor, m_resolution, primaryData); Compute compute = new Compute(m_resultDescriptor, aggregation); Export exports = new Export(m_resultDescriptor.getExports(), compute); Results<Measurement> measurements = new Results<>(); for (Row<Measurement> row : exports) { measurements.addRow(row); } return measurements; }