changeset 3119:238803b2cb8b

Create a compound index for SQOutlierFacets based on result index and iteration number. flys-artifacts/trunk@4720 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 20 Jun 2012 11:04:24 +0000
parents 6fb211753674
children e52a3b62fc20
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQOutlierFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java
diffstat 4 files changed, 72 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jun 20 10:56:08 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jun 20 11:04:24 2012 +0000
@@ -1,3 +1,18 @@
+2012-06-20  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/SQRelation.java:
+	  Create a compound index value for SQOutlierFacets. This index is based
+	  on the index of the result object (to get the correct data) and the
+	  iteration of the outliers. This compound index is used to make
+	  SQOutlierFacets unique to FLYSCollection's DESCRIBE document.
+
+	* src/main/java/de/intevation/flys/artifacts/model/sq/SQOutlierFacet.java:
+	  Parse the index of the result object and the iteration number from index
+	  property.
+
+	* src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java:
+	  Added some more debug output.
+
 2012-06-20  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQOutlierFacet.java	Wed Jun 20 10:56:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQOutlierFacet.java	Wed Jun 20 11:04:24 2012 +0000
@@ -22,8 +22,9 @@
 
     private static final Logger log = Logger.getLogger(SQOutlierFacet.class);
 
+    public static final int BITMASK_ITERATION = (1 << 16) - 1;
 
-    private int iteration;
+
     private int fractionIdx;
 
 
@@ -34,7 +35,6 @@
     public SQOutlierFacet(
         int    idx,
         int    fractionIdx,
-        int    iteration,
         String name,
         String description,
         String hash,
@@ -55,10 +55,30 @@
             CalculationResult res = (CalculationResult) flys.compute(
                 context, ComputeType.ADVANCE, false);
 
+            int idx  = this.index >> 16;
+            int iter = this.index & BITMASK_ITERATION;
+
+            if (log.isDebugEnabled()) {
+                log.debug("Fetch data for index : " + this.index);
+                log.debug("  > index:       " + idx);
+                log.debug("  > fraction:    " + fractionIdx);
+                log.debug("  > iteration:   " + iter);
+            }
+
             SQResult[]       result  = (SQResult[]) res.getData();
-            SQFractionResult fResult = result[index].getFraction(fractionIdx);
+            SQFractionResult fResult = result[idx].getFraction(fractionIdx);
 
-            return fResult.getOutliers(iteration);
+            if (fResult == null) {
+                log.warn("No SQFractionResult at " + idx + "|" + fractionIdx);
+            }
+            else if (log.isDebugEnabled()) {
+                SQ[] outliers = fResult.getOutliers(iter);
+                int  num      = outliers != null ? outliers.length : 0;
+
+                log.debug("Found " + num + " outliers for iteration " + iter);
+            }
+
+            return fResult.getOutliers(iter);
         }
 
         return null;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java	Wed Jun 20 10:56:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java	Wed Jun 20 11:04:24 2012 +0000
@@ -134,10 +134,20 @@
                 ));
 
                 for (int j = 0, C = result.getOutliersCount(); j < C; j++) {
+                    int index = res;
+                    index     = index << 16;
+                    index     = index + j;
+
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("new outliers facet (index=" +index+ ")");
+                        logger.debug("   result index = " + res);
+                        logger.debug("   fraction idx = " + i);
+                        logger.debug("   iteration    = " + j);
+                    }
+
                     container.add(new SQOutlierFacet(
-                        res,
+                        index,
                         i,
-                        j,
                         getFractionFacetname(2, i),
                         Resources.getMsg(
                             meta,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java	Wed Jun 20 10:56:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java	Wed Jun 20 11:04:24 2012 +0000
@@ -139,11 +139,21 @@
         XYSeries series = JFreeUtil.sampleFunction2D(
             func.getFunction(),
             attr,
-            "SQ Curve",
+            f.getDescription(),
             10,
             func.getMinQ(),
             func.getMaxQ());
 
+        if (logger.isDebugEnabled()) {
+            logger.debug("Series '" + f.getDescription() + "' has "
+                + series.getItemCount() + " items.");
+
+            logger.debug("   -> min x = " + series.getMinX());
+            logger.debug("   -> max x = " + series.getMaxX());
+            logger.debug("   -> min y = " + series.getMinY());
+            logger.debug("   -> max y = " + series.getMaxY());
+        }
+
         addAxisSeries(series, YAXIS.S.idx, visible);
     }
 
@@ -163,6 +173,16 @@
             series.add(sq.getQ(), sq.getS());
         }
 
+        if (logger.isDebugEnabled()) {
+            logger.debug("Series '" + f.getDescription() + "' has "
+                + series.getItemCount() + " items.");
+
+            logger.debug("   -> min x = " + series.getMinX());
+            logger.debug("   -> max x = " + series.getMaxX());
+            logger.debug("   -> min y = " + series.getMinY());
+            logger.debug("   -> max y = " + series.getMaxY());
+        }
+
         addAxisSeries(series, YAXIS.S.idx, visible);
     }
 }

http://dive4elements.wald.intevation.org