private void outputAndResetAccumulators() { if (aggregatedSampleNumber != 0) { // TODO Assume CSV builder.append(","); } // Output one opcode at a time for (final SampleOpcode opcode : accumulators.keySet()) { aggregatedSampleNumber++; sampleProcessor.processOneSample(lastRoundedTime, opcode, accumulators.get(opcode)); } // This will flush (clear) the sample consumer builder.append(sampleProcessor.toString()); accumulators.clear(); }
/** * Process sampleCount sequential samples with identical values. sampleCount will usually be 1, * but may be larger than 1. Implementors may just loop processing identical values, but some * implementations may optimize adding a bunch of repeated values * * @param timeCursor a TimeCursor instance, which supplies successive int UNIX times * @param sampleCount the count of sequential, identical values * @param opcode the opcode of the sample value, which may not be a REPEAT opcode * @param value the value of this kind of sample over the sampleCount samples */ @Override public void processSamples(final TimelineCursor timeCursor, final int sampleCount, final SampleOpcode opcode, final Object value) { for (int i = 0; i < sampleCount; i++) { // Check if the sample is in the right time range final DateTime sampleTime = timeCursor.getNextTime(); if ((startTime == null || !sampleTime.isBefore(startTime)) && ((endTime == null || !sampleTime.isAfter(endTime)))) { processOneSample(sampleTime, opcode, value); } } }
sampleProcessor.processOneSample(time, opcode, value); } else { sampleProcessor.processOneSample(centerTime, minSample.getSampleOpcode(), minSample.getValue()); } else { sampleProcessor.processOneSample(centerTime, maxSample.getSampleOpcode(), maxSample.getValue()); sampleProcessor.processOneSample(centerTime, SampleOpcode.DOUBLE, average); break; default: