simtools.data.merge
Class SynchronousMergeDSCollection

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by simtools.data.DataSourceCollection
                  extended by simtools.data.merge.SynchronousMergeDSCollection
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess, MergeDSCollection
Direct Known Subclasses:
JSSynchronousMergeDSCollection

public class SynchronousMergeDSCollection
extends DataSourceCollection
implements MergeDSCollection

Synchronize data sources according to a frequency and a time range. This class provides a 0 and and 1-order interpolation of data

Following steps have to be performed to synchronize data together:
  1. Create a SynchronousMergeDSCollection
  2. Add data using MergeDSCollection methods
  3. Call mergeData method to allocate and initialize data buffers

Author:
zxpletran007
See Also:
Serialized Form

Nested Class Summary
 class SynchronousMergeDSCollection.DirectSynchronousMergedDataSource
          A data source dedicated to manage aperiodical data sources.
 class SynchronousMergeDSCollection.IndirectParameter
          This optimization is no longer used at the moment.
 class SynchronousMergeDSCollection.IndirectSynchronousMergedDataSource
          This optimization is no longer used at the moment.
 class SynchronousMergeDSCollection.MergedCollectionContainer
           
 class SynchronousMergeDSCollection.TimeSource
           
 
Nested classes/interfaces inherited from class simtools.data.DataSourceCollection
DataSourceCollection.Container
 
Field Summary
protected  java.lang.String collectionName
           
protected  SynchronousMergeDSCollection.MergedCollectionContainer collectionRoot
           
protected static int HUGEREPERTORYSIZE
           
static java.lang.String ID_MARKER
           
protected  int interpolationOrder
          Interpolation order can be 0 or 1
static double MAX_T_DRIFT
          We do accept this drift when checking a data source period
protected  java.nio.DoubleBuffer mergedTimeBuffer
           
protected  DataSource mergedTimeDs
           
protected  double mergedTimeFreq
          Merged time frequency
protected  long mergedTimeLength
          The number of merged time values
protected  double mergedTimeStart
          The first merged time value
protected  boolean timeRefIsRelative
          If true mergedTime is a number of seconds, otherwise this is a number of milliseconds since 01/01/1970 00:00:00:
 
Fields inherited from class simtools.data.DataSourceCollection
buffers, endNotificationListeners, lastIndex, listeners, map, startIndex
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SynchronousMergeDSCollection(java.lang.String collectionName, int interpolationOrder, boolean timeRefIsRelative, DataSource mergedTimeReferenceDs, boolean mergedTimeReferenceDsIsRelative, double mergedTimeReferenceDsOffset, double mergedTimeReferenceDsInitData)
           
 
Method Summary
 void add(DataSourceCollection dsc, DataSource timeDs, boolean isRelative, double offset, double initialDate)
          Merge a synchronous collection to the mergeDSCollection.
 void add(DataSource ds, DataSource timeDs, boolean isRelative, double offset, double initialDate)
          Merge a synchronous data to the mergeDSCollection.
 void add(java.util.List dataList)
           
 void add(TimeStampedDataSourceCollection tsdsc, double offset, double initialDate)
          Merge a time stamped collection to the mergeDSCollection
 void add(TimeStampedDataSource ds, double offset, double initialDate)
          Merge a time stamped data to the mergeDSCollection
protected  void addToCollectionArborescence(java.lang.String name, DataSource d)
           
 java.lang.Object computeMax(int i)
           
protected  void computeMergedTimeFrequency(DataSource timeDs, boolean isRelative, double offset, double initialDate)
          Compute merged time frequency
 java.lang.Object computeMin(int i)
           
 java.util.Collection getCollectionContainers()
          If the data source collection is compound return the first level collection of containers used to organize the data sources
 java.lang.String getCollectionName()
           
 double getDoubleValue(int i, long index)
          Optimized accessor for double values.
 DataInfo getInformation()
           
 DataInfo getInformation(int i)
           
 java.lang.Object getMax(int i)
           
 java.lang.Object getMin(int i)
           
 java.lang.Object getValue(int i, long index)
          Methods for subclasses to specialize
 boolean isCompound()
          Checks if a data source collection is compound, i.e. if it provides containers to organize the data source hierarchically
 void mergeData()
          Apply merge on all collection elements.
protected  void sortHugeRepertories()
           
protected  void sortHugeRepertory(SynchronousMergeDSCollection.MergedCollectionContainer repertory, int proof)
           
protected  void updateMergedTimeBounds(DataSource timeDs, boolean isRelative, double offset, double initialDate)
          Update merged time bounds
 java.lang.Class valueClass(int i)
          Returns the more specialized superclass of all objects returned by the i-th data source.
 
Methods inherited from class simtools.data.DataSourceCollection
addEndNotificationListener, addListener, attachBuffer, bufferize, bufferize, bufferize, computeLastIndex, computeLastIndex, computeStartIndex, computeStartIndex, get, getByteMax, getByteMin, getByteValue, getDoubleMax, getDoubleMin, getFloatMax, getFloatMin, getFloatValue, getIntegerMax, getIntegerMin, getIntegerValue, getKind, getLastIndex, getLastIndex, getLongMax, getLongMin, getLongValue, getShortMax, getShortMin, getShortValue, getStartIndex, getStartIndex, hashCode, isComparable, notifyEndNotificationListeners, notifyListenersForCollectionRemoved, notifyListenersForDataSourceAdded, notifyListenersForDataSourceRemoved, notifyListenersForInfoChange, removeAllElements, removeEndNotificationListener, removeListener, setSlice, sortedOrder
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

ID_MARKER

public static final java.lang.String ID_MARKER
See Also:
Constant Field Values

HUGEREPERTORYSIZE

protected static final int HUGEREPERTORYSIZE
See Also:
Constant Field Values

collectionRoot

protected SynchronousMergeDSCollection.MergedCollectionContainer collectionRoot

collectionName

protected java.lang.String collectionName

mergedTimeBuffer

protected java.nio.DoubleBuffer mergedTimeBuffer

mergedTimeDs

protected DataSource mergedTimeDs

mergedTimeStart

protected double mergedTimeStart
The first merged time value


mergedTimeLength

protected long mergedTimeLength
The number of merged time values


mergedTimeFreq

protected double mergedTimeFreq
Merged time frequency


timeRefIsRelative

protected boolean timeRefIsRelative
If true mergedTime is a number of seconds, otherwise this is a number of milliseconds since 01/01/1970 00:00:00:


interpolationOrder

protected int interpolationOrder
Interpolation order can be 0 or 1


MAX_T_DRIFT

public static final double MAX_T_DRIFT
We do accept this drift when checking a data source period

See Also:
Constant Field Values
Constructor Detail

SynchronousMergeDSCollection

public SynchronousMergeDSCollection(java.lang.String collectionName,
                                    int interpolationOrder,
                                    boolean timeRefIsRelative,
                                    DataSource mergedTimeReferenceDs,
                                    boolean mergedTimeReferenceDsIsRelative,
                                    double mergedTimeReferenceDsOffset,
                                    double mergedTimeReferenceDsInitData)
                             throws MergeDataException
Throws:
MergeDataException
Method Detail

computeMergedTimeFrequency

protected void computeMergedTimeFrequency(DataSource timeDs,
                                          boolean isRelative,
                                          double offset,
                                          double initialDate)
                                   throws MergeDataException
Compute merged time frequency

Parameters:
timeDs -
isRelative -
offset -
initialDate -
Throws:
DataException
MergeDataException

updateMergedTimeBounds

protected void updateMergedTimeBounds(DataSource timeDs,
                                      boolean isRelative,
                                      double offset,
                                      double initialDate)
                               throws MergeDataException
Update merged time bounds

Parameters:
timeDs -
isRelative -
offset -
initialDate -
Throws:
DataException
MergeDataException

add

public void add(java.util.List dataList)
         throws MergeDataException
Parameters:
dataList -
Throws:
MergeDataException

add

public void add(TimeStampedDataSourceCollection tsdsc,
                double offset,
                double initialDate)
         throws MergeDataException
Description copied from interface: MergeDSCollection
Merge a time stamped collection to the mergeDSCollection

Specified by:
add in interface MergeDSCollection
initialDate - An initial absolute date for relative <-> absolute consersion
Throws:
MergeDataException

add

public void add(DataSourceCollection dsc,
                DataSource timeDs,
                boolean isRelative,
                double offset,
                double initialDate)
         throws MergeDataException
Description copied from interface: MergeDSCollection
Merge a synchronous collection to the mergeDSCollection.

Specified by:
add in interface MergeDSCollection
timeDs - true is timeRef is expressed with relative time.
initialDate - An initial absolute date for relative <-> absolute consersion
Throws:
MergeDataException

add

public void add(DataSource ds,
                DataSource timeDs,
                boolean isRelative,
                double offset,
                double initialDate)
         throws MergeDataException
Description copied from interface: MergeDSCollection
Merge a synchronous data to the mergeDSCollection.

Specified by:
add in interface MergeDSCollection
isRelative - true is timeRef is expressed with relative time.
initialDate - An initial absolute date for relative <-> absolute consersion
Throws:
MergeDataException

add

public void add(TimeStampedDataSource ds,
                double offset,
                double initialDate)
         throws MergeDataException
Description copied from interface: MergeDSCollection
Merge a time stamped data to the mergeDSCollection

Specified by:
add in interface MergeDSCollection
initialDate - An initial absolute date for relative <-> absolute consersion
Throws:
MergeDataException

mergeData

public void mergeData()
               throws MergeDataException
Apply merge on all collection elements.

Throws:
MergeDataException

isCompound

public boolean isCompound()
Description copied from class: DataSourceCollection
Checks if a data source collection is compound, i.e. if it provides containers to organize the data source hierarchically

Overrides:
isCompound in class DataSourceCollection
Returns:
true if it is compound

getCollectionContainers

public java.util.Collection getCollectionContainers()
Description copied from class: DataSourceCollection
If the data source collection is compound return the first level collection of containers used to organize the data sources

Overrides:
getCollectionContainers in class DataSourceCollection
Returns:
the first level collection of containers or null

addToCollectionArborescence

protected void addToCollectionArborescence(java.lang.String name,
                                           DataSource d)

sortHugeRepertories

protected void sortHugeRepertories()

sortHugeRepertory

protected void sortHugeRepertory(SynchronousMergeDSCollection.MergedCollectionContainer repertory,
                                 int proof)
Parameters:
repertory - , where data source have to be structured
proof, - number of prefixes to remove from all data sources names, in order to compute the new structure. Ex : if PL.TM.variable -> proof = 2

getMax

public java.lang.Object getMax(int i)
                        throws UnsupportedOperation
Overrides:
getMax in class DataSourceCollection
Throws:
UnsupportedOperation

getMin

public java.lang.Object getMin(int i)
                        throws UnsupportedOperation
Overrides:
getMin in class DataSourceCollection
Throws:
UnsupportedOperation

computeMax

public java.lang.Object computeMax(int i)
                            throws UnsupportedOperation
Overrides:
computeMax in class DataSourceCollection
Throws:
UnsupportedOperation

computeMin

public java.lang.Object computeMin(int i)
                            throws UnsupportedOperation
Overrides:
computeMin in class DataSourceCollection
Throws:
UnsupportedOperation

getValue

public java.lang.Object getValue(int i,
                                 long index)
                          throws DataException
Description copied from class: DataSourceCollection
Methods for subclasses to specialize

Specified by:
getValue in class DataSourceCollection
Throws:
DataException

getDoubleValue

public double getDoubleValue(int i,
                             long index)
                      throws DataException
Description copied from class: DataSourceCollection
Optimized accessor for double values. Works the same way as provider functions.

Overrides:
getDoubleValue in class DataSourceCollection
Throws:
DataException

getInformation

public DataInfo getInformation(int i)
Overrides:
getInformation in class DataSourceCollection

valueClass

public java.lang.Class valueClass(int i)
Description copied from class: DataSourceCollection
Returns the more specialized superclass of all objects returned by the i-th data source. Returns Object by default in the base implementation, subclass should specialize if possible.

Overrides:
valueClass in class DataSourceCollection

getInformation

public DataInfo getInformation()
Overrides:
getInformation in class DataSourceCollection

getCollectionName

public java.lang.String getCollectionName()