Class DataContainer
java.lang.Object
net.simplace.sim.wrapper.DataContainer
Delivers data to wrapper clients (R, Python, ...) as simple types: parallel arrays of column names, units, data
type names and values. Built either from a variable map (one value per variable, see
SimplaceWrapper.step()) or from result caches of MEMORY outputs (one array of values per column, see
SimplaceWrapper.getResult(String, String)). Dates of result caches are returned as ISO strings.- Author:
- Andreas Enders
-
Constructor Summary
ConstructorsConstructorDescriptionDataContainer(Collection<FWSimResultCache> aResultCaches) Creates the container from several result caches with the same fields (e.g.DataContainer(FWSimResultCache aResultCache) Creates the container from a result cache.DataContainer(FWSimVarMap aVarMap) Creates the container from all variables of a variable map.DataContainer(FWSimVarMap aVarMap, String[] aFieldNameFilter) Creates the container from the given variables of a variable map. -
Method Summary
Modifier and TypeMethodDescriptionvoidfill(FWSimResultCache aResultCache, int aStartIndex, int aSize) Copies the rows of a result cache into the column arrays.Object[]Object[]getDataObjects(int from, int to) Returns a range of rows: each column array is copied withArrays.copyOfRange(Object[], int, int), so the result is padded withnulliftoexceeds the number of rows.String[]String[]String[]booleanisLast()voidsetLast(boolean aLast)
-
Constructor Details
-
DataContainer
Creates the container from all variables of a variable map.- Parameters:
aVarMap- the variable map
-
DataContainer
Creates the container from the given variables of a variable map. An unknown name is logged and returned with typeNULL.- Parameters:
aVarMap- the variable mapaFieldNameFilter- names of the variables (not changed, the header is a copy)
-
DataContainer
Creates the container from several result caches with the same fields (e.g. of several simulations); their rows are concatenated.- Parameters:
aResultCaches- the result caches, must not be empty
-
DataContainer
Creates the container from a result cache.- Parameters:
aResultCache- the result cache
-
-
Method Details
-
fill
Copies the rows of a result cache into the column arrays. With start index 0 header, units, types and the column arrays are created first.- Parameters:
aResultCache- the result cacheaStartIndex- row index of the first row of this cacheaSize- total number of rows (only used when creating the arrays)
-
getHeaderStrings
- Returns:
- the column (variable) names
-
getHeaderUnits
- Returns:
- the units of the columns
-
getTypeStrings
- Returns:
- the data type names of the columns
-
getDataObjects
- Returns:
- the values per column: single values (variable map) or arrays of values (result cache)
-
getDataObjects
Returns a range of rows: each column array is copied withArrays.copyOfRange(Object[], int, int), so the result is padded withnulliftoexceeds the number of rows. Only for containers created from result caches.- Parameters:
from- first row (inclusive)to- last row (exclusive)- Returns:
- the column arrays of the range
- Throws:
ArrayIndexOutOfBoundsException- iffrom < 0orfromis greater than the number of rowsIllegalArgumentException- iffrom > to
-
isLast
public boolean isLast()- Returns:
trueif this is the last result of a simulation (the simulation has ended)
-
setLast
public void setLast(boolean aLast) - Parameters:
aLast-trueif this is the last result of a simulation
-