# HG changeset patch # User Sascha L. Teichmann # Date 1347115336 0 # Node ID 487a8cb4a222e388433e4ceacbc5511ac36a18a8 # Parent e727e3ebdf8522b83de0525ebab5dbcbfe74bdf0 FixA: Improved robustness and performance in facet generation for dates. flys-artifacts/trunk@5403 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e727e3ebdf85 -r 487a8cb4a222 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Sat Sep 08 14:19:40 2012 +0000 +++ b/flys-artifacts/ChangeLog Sat Sep 08 14:42:16 2012 +0000 @@ -1,3 +1,12 @@ +2012-09-08 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/states/fixation/FixAnalysisCompute.java: + Simplified code. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisResult.java: + Improved robustness and performance. + Only expose date events as Collections not TreeSets. + 2012-09-08 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/QW.java: diff -r e727e3ebdf85 -r 487a8cb4a222 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisResult.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisResult.java Sat Sep 08 14:19:40 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisResult.java Sat Sep 08 14:42:16 2012 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts.model.fixings; +import java.util.Collection; import java.util.Date; import java.util.TreeSet; @@ -40,24 +41,26 @@ return result; } - public TreeSet getReferenceEventsDates() { + public Collection getReferenceEventsDates() { TreeSet dates = new TreeSet(); for (KMIndex.Entry entry: referenced) { - for (int i = 0; i < entry.getValue().length; i++) { - QWD qwd = entry.getValue()[i]; - dates.add(qwd.date); + QWD [] values = entry.getValue(); + for (int i = 0; i < values.length; i++) { + dates.add(values[i].date); } } return dates; } - public TreeSet getAnalysisEventsDates(int analysisPeriod) { + public Collection getAnalysisEventsDates(int analysisPeriod) { TreeSet dates = new TreeSet(); for (KMIndex.Entry entry: analysisPeriods) { - AnalysisPeriod period = entry.getValue()[analysisPeriod]; - for (int i = 0; i < period.qwds.length; i++) { - QWD qwd = period.qwds[i]; - dates.add(qwd.date); + QWD [] qwds = entry.getValue()[analysisPeriod].getQWDs(); + if (qwds == null) { + continue; + } + for (int i = 0; i < qwds.length; i++) { + dates.add(qwds[i].date); } } return dates; diff -r e727e3ebdf85 -r 487a8cb4a222 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixAnalysisCompute.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixAnalysisCompute.java Sat Sep 08 14:19:40 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixAnalysisCompute.java Sat Sep 08 14:42:16 2012 +0000 @@ -2,9 +2,7 @@ import java.text.DateFormat; import java.util.Date; -import java.util.Iterator; import java.util.List; -import java.util.TreeSet; import org.apache.log4j.Logger; @@ -209,11 +207,8 @@ I18N_REFERENCEDEVIATION, I18N_REFERENCEDEVIATION); - TreeSet dates = fr.getReferenceEventsDates(); - Iterator iter = dates.iterator(); int i = 0; - while (iter.hasNext()) { - Date d = iter.next(); + for (Date d: fr.getReferenceEventsDates()) { int refNdx = idg.next() << 8; refNdx |= i; facets.add(new FixReferenceEventsFacet(refNdx,