org.garret.perst
Interface TimeSeries<T extends TimeSeries.Tick>

All Superinterfaces:
java.util.Collection, java.io.Externalizable, IPersistent, IResource, ITable, java.lang.Iterable, java.io.Serializable

public interface TimeSeries<T extends TimeSeries.Tick>
extends IPersistent, IResource, ITable<T>

Time series interface. Time series class is used for efficient handling of time series data. Ussually time series contains a very large number if relatively small elements which are ussually acessed in sucessive order. To avoid overhead of loading from the disk each particular time series element, this class group several subsequent time series elements together and store them as single object (block).

As far as Java currently has no templates and Perst need to know format of block class, it is responsibity of prgorammer to create block implementation derived from TimeSeries.Block class and containing array of time series elements. Size of this array specifies the size of the block.


Nested Class Summary
static class TimeSeries.Block
          Abstract base class for time series block.
static interface TimeSeries.Tick
          Interface for timeseries element.
 
Method Summary
 boolean add(T tick)
          Add new tick to time series
 long countTicks()
          Get number of elements in time series
 java.util.ArrayList<T> elements()
          Get list of alements in the time series (in ascending order)
 java.util.Date getFirstTime()
          Get timestamp of first time series element
 java.util.Date getLastTime()
          Get timestamp of last time series element
 T getTick(java.util.Date timestamp)
          Get tick for specified data
 boolean has(java.util.Date timestamp)
          Check if data is available in time series for the specified time
 java.util.Iterator<T> iterator()
          Get forward iterator through all time series elements This iterator doesn't support remove() method.
 IterableIterator<T> iterator(boolean ascent)
          Get iterator through all time series elements This iterator doesn't support remove() method.
 IterableIterator<T> iterator(java.util.Date from, java.util.Date till)
          Get forward iterator for time series elements belonging to the specified range This iterator doesn't support remove() method.
 IterableIterator<T> iterator(java.util.Date from, java.util.Date till, boolean ascent)
          Get forward iterator for time series elements belonging to the specified range This iterator doesn't support remove() method.
 int remove(java.util.Date from, java.util.Date till)
          Remove timeseries elements belonging to the specified range
 int size()
          Get number of elements in time series
 
Methods inherited from interface org.garret.perst.IPersistent
assignOid, deallocate, getOid, getStorage, invalidate, isDeleted, isModified, isPersistent, isRaw, load, loadAndModify, makePersistent, modify, onLoad, onStore, recursiveLoading, store
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface org.garret.perst.IResource
exclusiveLock, exclusiveLock, reset, sharedLock, sharedLock, unlock
 
Methods inherited from interface org.garret.perst.ITable
select
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

add

boolean add(T tick)
Add new tick to time series

Parameters:
tick - new time series element

countTicks

long countTicks()
Get number of elements in time series

Returns:
number of elements in time series

elements

java.util.ArrayList<T> elements()
Get list of alements in the time series (in ascending order)

Returns:
list of all elements

getFirstTime

java.util.Date getFirstTime()
Get timestamp of first time series element

Returns:
time of time series start

getLastTime

java.util.Date getLastTime()
Get timestamp of last time series element

Returns:
time of time series end

getTick

T getTick(java.util.Date timestamp)
Get tick for specified data

Parameters:
timestamp - time series element timestamp return time series element for the specified timestamp or null if no such element was found

has

boolean has(java.util.Date timestamp)
Check if data is available in time series for the specified time

Parameters:
timestamp - time series element timestamp
Returns:
true if there is element in time series with such timestamp, false otherwise

iterator

java.util.Iterator<T> iterator()
Get forward iterator through all time series elements This iterator doesn't support remove() method. It is not possible to modify time series during iteration.

Specified by:
iterator in interface java.util.Collection
Returns:
forward iterator

iterator

IterableIterator<T> iterator(boolean ascent)
Get iterator through all time series elements This iterator doesn't support remove() method. It is not possible to modify time series during iteration.

Parameters:
ascent - direction of iteration
Returns:
iterator in specified direction

iterator

IterableIterator<T> iterator(java.util.Date from,
                             java.util.Date till)
Get forward iterator for time series elements belonging to the specified range This iterator doesn't support remove() method. It is not possible to modify time series during iteration.

Parameters:
from - inclusive time of the begging of interval, if null then take all elements from the beginning of time series
till - inclusive time of the ending of interval, if null then take all elements till the end of time series
Returns:
forward iterator within specified range.

iterator

IterableIterator<T> iterator(java.util.Date from,
                             java.util.Date till,
                             boolean ascent)
Get forward iterator for time series elements belonging to the specified range This iterator doesn't support remove() method. It is not possible to modify time series during iteration.

Parameters:
from - inclusive time of the begging of interval, if null then take all elements from the beginning of time series
till - inclusive time of the ending of interval, if null then take all elements till the end of time series
ascent - direction of iteration
Returns:
iterator within specified range in specified direction

remove

int remove(java.util.Date from,
           java.util.Date till)
Remove timeseries elements belonging to the specified range

Parameters:
from - inclusive time of the begging of interval, if null then remove all elements from the beginning of time series
till - inclusive time of the ending of interval, if null then remove all elements till the end of time series
Returns:
number of removed elements

size

int size()
Get number of elements in time series

Specified by:
size in interface java.util.Collection
Returns:
number of elements in time series