org.android.activityminer.logic.util
Class SequenceTimeGapResampler<T extends Enum<T> & Dimensions>

Package class diagram package SequenceTimeGapResampler
java.lang.Object
  extended by org.android.activityminer.logic.util.SequenceTimeGapResampler<T>
Type Parameters:
T - the enumeration type for the dimensions

public class SequenceTimeGapResampler<T extends Enum<T> & Dimensions>
extends Object

Resampler for the occasional gaps in older stored time series sequences.


Field Summary
private  SensorObservationCache<T,Double> cache
          The sensor observation cache.
private  long maxFrameSize
          The maximum frame size of stored recordings.
private  long sampleRate
          The sample rate of the recordings.
 
Constructor Summary
SequenceTimeGapResampler(long sampleRate)
          Constructor
 
Method Summary
private  void fillWithRequiredObservationsFromNextRecording(LabeledRecording<T> nextRecording, List<SensorObservation<T,Double>> observations, long endTs)
          Does add required samples from next recording to full fill end time requirement.
 void finishSequence()
          Does stop a sequence processing.
 long getMaxFrameSize()
          Getter for the maximum frame size
 long getSampleRate()
          Getter for the sample rate
 SensorObservationCutout<T,Double> resample(LabeledRecording<T> recording, LabeledRecording<T> nextRecording, AtomicLong nextSampleTs)
          Does re-sample the cut-out for the database frequency to fix the known gaps in older time series.
 SensorObservationCutout<T,Double> resampleFromCache(AtomicLong nextSampleTs, long minDuration)
          Test for remaining observations in the cache for further cut-outs
 void startSequence()
          Does start sequence processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sampleRate

private final long sampleRate
The sample rate of the recordings.


cache

private final SensorObservationCache<T extends Enum<T> & Dimensions,Double> cache
The sensor observation cache.


maxFrameSize

private final long maxFrameSize
The maximum frame size of stored recordings.

Constructor Detail

SequenceTimeGapResampler

public SequenceTimeGapResampler(long sampleRate)
Constructor

Parameters:
sampleRate - the sample rate
Method Detail

getMaxFrameSize

public long getMaxFrameSize()
Getter for the maximum frame size

Returns:
the maximum frame size

getSampleRate

public long getSampleRate()
Getter for the sample rate

Returns:
the sample rate

startSequence

public final void startSequence()
Does start sequence processing.


finishSequence

public final void finishSequence()
Does stop a sequence processing.


resample

public final SensorObservationCutout<T,Double> resample(LabeledRecording<T> recording,
                                                        LabeledRecording<T> nextRecording,
                                                        AtomicLong nextSampleTs)
Does re-sample the cut-out for the database frequency to fix the known gaps in older time series.

Parameters:
recording - the cut-out
nextRecording - the last observation (null if record is the first in the sequence)
nextSampleTs - the time stamp of the next sample to take
Returns:
the remaining sensor observations from the current recording if a split is required or an empty list

fillWithRequiredObservationsFromNextRecording

private void fillWithRequiredObservationsFromNextRecording(LabeledRecording<T> nextRecording,
                                                           List<SensorObservation<T,Double>> observations,
                                                           long endTs)
Does add required samples from next recording to full fill end time requirement.

Parameters:
nextRecording - the next recording
observations - the current observation list to add required observations to
endTs - the end time stamp

resampleFromCache

public final SensorObservationCutout<T,Double> resampleFromCache(AtomicLong nextSampleTs,
                                                                 long minDuration)
Test for remaining observations in the cache for further cut-outs

Parameters:
nextSampleTs - the next Sample time stamp
minDuration - the minimum duration
Returns:
next cut-out with minimum duration from cache