Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java @ 3609:a16837d73130
FixA: Using trove to map int->int instead of bloated generics.
flys-artifacts/trunk@5238 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 22 Aug 2012 14:51:19 +0000 |
parents | e0f54fab55d3 |
children |
comparison
equal
deleted
inserted
replaced
3608:53aa395a29e0 | 3609:a16837d73130 |
---|---|
22 import de.intevation.flys.artifacts.model.Range; | 22 import de.intevation.flys.artifacts.model.Range; |
23 | 23 |
24 import de.intevation.flys.utils.DateAverager; | 24 import de.intevation.flys.utils.DateAverager; |
25 import de.intevation.flys.utils.KMIndex; | 25 import de.intevation.flys.utils.KMIndex; |
26 | 26 |
27 import gnu.trove.TIntIntHashMap; | |
28 | |
27 import java.util.ArrayList; | 29 import java.util.ArrayList; |
28 import java.util.Date; | 30 import java.util.Date; |
29 import java.util.HashMap; | |
30 import java.util.List; | 31 import java.util.List; |
31 | 32 |
32 import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; | 33 import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; |
33 | 34 |
34 import org.apache.log4j.Logger; | 35 import org.apache.log4j.Logger; |
127 KMIndex<AnalysisPeriod []> results = | 128 KMIndex<AnalysisPeriod []> results = |
128 new KMIndex<AnalysisPeriod []>(parameters.size()); | 129 new KMIndex<AnalysisPeriod []>(parameters.size()); |
129 | 130 |
130 IdsFilter idsFilter = new IdsFilter(events); | 131 IdsFilter idsFilter = new IdsFilter(events); |
131 | 132 |
132 ArrayList<HashMap<Integer, Integer>> col2indices = | 133 TIntIntHashMap [] col2indices = |
133 new ArrayList<HashMap<Integer, Integer>>(analysisPeriods.length); | 134 new TIntIntHashMap[analysisPeriods.length]; |
134 | 135 |
135 for (int i = 0; i < analysisPeriods.length; ++i) { | 136 for (int i = 0; i < analysisPeriods.length; ++i) { |
136 col2indices.add(new HashMap<Integer, Integer>()); | 137 col2indices[i] = new TIntIntHashMap(); |
137 } | 138 } |
138 | 139 |
139 for (int row = 0, R = parameters.size(); row < R; ++row) { | 140 for (int row = 0, R = parameters.size(); row < R; ++row) { |
140 double km = parameters.get(row, kmIndex); | 141 double km = parameters.get(row, kmIndex); |
141 parameters.get(row, parameterIndices, parameterValues); | 142 parameters.get(row, parameterIndices, parameterValues); |
149 ArrayList<AnalysisPeriod> periodResults = | 150 ArrayList<AnalysisPeriod> periodResults = |
150 new ArrayList<AnalysisPeriod>(analysisPeriods.length); | 151 new ArrayList<AnalysisPeriod>(analysisPeriods.length); |
151 | 152 |
152 for (int ap = 0; ap < analysisPeriods.length; ++ap) { | 153 for (int ap = 0; ap < analysisPeriods.length; ++ap) { |
153 DateRange analysisPeriod = analysisPeriods[ap]; | 154 DateRange analysisPeriod = analysisPeriods[ap]; |
154 HashMap<Integer, Integer> col2index = col2indices.get(ap); | 155 TIntIntHashMap col2index = col2indices[ap]; |
155 | 156 |
156 DateRangeFilter drf = new DateRangeFilter( | 157 DateRangeFilter drf = new DateRangeFilter( |
157 analysisPeriod.getFrom(), | 158 analysisPeriod.getFrom(), |
158 analysisPeriod.getTo()); | 159 analysisPeriod.getTo()); |
159 | 160 |
208 stdDev.increment(dw); | 209 stdDev.increment(dw); |
209 | 210 |
210 Date date = column.getDate(); | 211 Date date = column.getDate(); |
211 String description = column.getDescription(); | 212 String description = column.getDescription(); |
212 | 213 |
213 Integer colIdx = column.getIndex(); | |
214 Integer index = col2index.get(colIdx); | |
215 if (index == null) { | |
216 index = col2index.size(); | |
217 col2index.put(colIdx, index); | |
218 } | |
219 | |
220 QWD qwd = new QWD( | 214 QWD qwd = new QWD( |
221 wq[1], wq[0], | 215 wq[1], wq[0], |
222 description, | 216 description, |
223 date, true, | 217 date, true, |
224 dw, index); | 218 dw, getIndex(col2index, column.getIndex())); |
225 | 219 |
226 qwds.add(qwd); | 220 qwds.add(qwd); |
227 | 221 |
228 sumW += wq[0]; | 222 sumW += wq[0]; |
229 sumQ += wq[1]; | 223 sumQ += wq[1]; |
284 new AnalysisPeriod[periodResults.size()])); | 278 new AnalysisPeriod[periodResults.size()])); |
285 } | 279 } |
286 | 280 |
287 return results; | 281 return results; |
288 } | 282 } |
283 | |
284 private static final int getIndex(TIntIntHashMap map, int colIdx) { | |
285 if (map.containsKey(colIdx)) { | |
286 return map.get(colIdx); | |
287 } | |
288 int index = map.size(); | |
289 map.put(colIdx, index); | |
290 return index; | |
291 } | |
289 } | 292 } |
290 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 293 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |