Class FWSimOutputCache
- All Implemented Interfaces:
Serializable, Cloneable, Map<FWSimVariable<?>, Object>
Aggregation cache of one output for one simulation. For each header variable it stores the values of the steps
since the last output line (or only the current value for DAILY and CAL outputs) and, when a line is due, reduces
them according to the mode of the variable (SUM, AVG, MIN, MAX, COUNT, FIRST, LAST).
- Author:
- Andreas Enders
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorsConstructorDescriptionFWSimOutputCache(FWSimVarMap aVarMap, LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables) Creates the cache: for each header variable with a simple rule (a variable name) the referenced model variable is looked up once; complex rules are evaluated in each step. -
Method Summary
Modifier and TypeMethodDescriptionvoidfill(FWSimVarMap aVarMap, FWSimIOAdapter.FREQUENCE aFrequence) Stores the current value of each header variable: the value of the referenced variable or the evaluated rule, converted to the data type of the header variable.generate(FWSimVarMap aVarMap, LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables, boolean aArrayMode, FWSimIOAdapter.FREQUENCE aFrequence) Creates the output line of the current step.voidreset()Discards the collected values of all header variables.Methods inherited from class HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class AbstractMap
equals, hashCode, toString
-
Constructor Details
-
FWSimOutputCache
public FWSimOutputCache(FWSimVarMap aVarMap, LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables) Creates the cache: for each header variable with a simple rule (a variable name) the referenced model variable is looked up once; complex rules are evaluated in each step.- Parameters:
aVarMap- variable map of the simulationaHeaderVariables- header variables of the output
-
-
Method Details
-
fill
Stores the current value of each header variable: the value of the referenced variable or the evaluated rule, converted to the data type of the header variable. Arrays are copied; for a single index (count) only that element is taken (99998 or 99999 mean the last element, from count99999resp.last). DAILY and CAL outputs keep only the current value, other outputs collect the values.- Parameters:
aVarMap- variable map of the simulationaFrequence- frequency of the output- Throws:
org.apache.commons.jexl3.JexlException- if a rule cannot be evaluated (logged and rethrown)
-
reset
public void reset()Discards the collected values of all header variables. -
generate
public FWSimQueueObjectMap generate(FWSimVarMap aVarMap, LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables, boolean aArrayMode, FWSimIOAdapter.FREQUENCE aFrequence) Creates the output line of the current step. For DAILY and CAL outputs the current values are taken; in array mode array variables are reduced to the elements given by theircount(all elements if empty). For other frequencies the collected values are aggregated by the mode of each variable and then discarded.- Parameters:
aVarMap- variable map of the simulation (simulation id and current date of the line)aHeaderVariables- header variables of the output, in column orderaArrayMode-trueif the adapter writes array elements as separate valuesaFrequence- frequency of the output- Returns:
- the output line
-