Package de.lmu.ifi.dbs.elki.utilities.exceptions

Examples of de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException


    int matrixsize = 0;
    for(DBID id : distanceQuery.getRelation().iterDBIDs()) {
      matrixsize = Math.max(matrixsize, id.getIntegerID() + 1);
      if(id.getIntegerID() < 0) {
        throw new AbortException("OnDiskMatrixCache does not allow negative DBIDs.");
      }
    }

    OnDiskUpperTriangleMatrix matrix;
    try {
      matrix = new OnDiskUpperTriangleMatrix(out, DiskCacheBasedFloatDistanceFunction.FLOAT_CACHE_MAGIC, 0, FLOAT_SIZE, matrixsize);
    }
    catch(IOException e) {
      throw new AbortException("Error creating output matrix.", e);
    }

    for(DBID id1 : distanceQuery.getRelation().iterDBIDs()) {
      for(DBID id2 : distanceQuery.getRelation().iterDBIDs()) {
        if(id2.getIntegerID() >= id1.getIntegerID()) {
          float d = distanceQuery.distance(id1, id2).floatValue();
          if(debugExtraCheckSymmetry) {
            float d2 = distanceQuery.distance(id2, id1).floatValue();
            if(Math.abs(d - d2) > 0.0000001) {
              logger.warning("Distance function doesn't appear to be symmetric!");
            }
          }
          try {
            matrix.getRecordBuffer(id1.getIntegerID(), id2.getIntegerID()).putFloat(d);
          }
          catch(IOException e) {
            throw new AbortException("Error writing distance record " + id1 + "," + id2 + " to matrix.", e);
          }
        }
      }
    }
  }
View Full Code Here


    int matrixsize = 0;
    for(DBID id : distanceQuery.getRelation().iterDBIDs()) {
      matrixsize = Math.max(matrixsize, id.getIntegerID() + 1);
      if(id.getIntegerID() < 0) {
        throw new AbortException("OnDiskMatrixCache does not allow negative DBIDs.");
      }
    }

    OnDiskUpperTriangleMatrix matrix;
    try {
      matrix = new OnDiskUpperTriangleMatrix(out, DiskCacheBasedDoubleDistanceFunction.DOUBLE_CACHE_MAGIC, 0, 8, matrixsize);
    }
    catch(IOException e) {
      throw new AbortException("Error creating output matrix.", e);
    }

    for(DBID id1 : distanceQuery.getRelation().iterDBIDs()) {
      for(DBID id2 : distanceQuery.getRelation().iterDBIDs()) {
        if(id2.getIntegerID() >= id1.getIntegerID()) {
          double d = distanceQuery.distance(id1, id2).doubleValue();
          if(debugExtraCheckSymmetry) {
            double d2 = distanceQuery.distance(id2, id1).doubleValue();
            if(Math.abs(d - d2) > 0.0000001) {
              logger.warning("Distance function doesn't appear to be symmetric!");
            }
          }
          try {
            matrix.getRecordBuffer(id1.getIntegerID(), id2.getIntegerID()).putDouble(d);
          }
          catch(IOException e) {
            throw new AbortException("Error writing distance record " + id1 + "," + id2 + " to matrix.", e);
          }
        }
      }
    }
  }
View Full Code Here

      super.setValue(val);
    }
    catch(ParameterException e) {
      // We're pretty sure that any Boolean is okay, so this should never be
      // reached.
      throw new AbortException("Flag did not accept boolean value!", e);
    }
  }
View Full Code Here

   * @param kNNReach the kNN query w.r.t. reachability distance function
   */
  protected LOFResult<O, D> doRunInTime(KNNQuery<O, D> kNNRefer, KNNQuery<O, D> kNNReach, StepProgress stepprog) throws IllegalStateException {
    // Assert we got something
    if(kNNRefer == null) {
      throw new AbortException("No kNN queries supported by database for reference neighborhood distance function.");
    }
    if(kNNReach == null) {
      throw new AbortException("No kNN queries supported by database for reachability distance function.");
    }

    // Compute LRDs
    if(stepprog != null) {
      stepprog.beginStep(2, "Computing LRDs.", logger);
View Full Code Here

            Matcher mi = idpattern.matcher(str);
            Matcher ms = scorepattern.matcher(str);
            final boolean mif = mi.find();
            final boolean msf = ms.find();
            if(mif && msf) {
              throw new AbortException("ID pattern and score pattern both match value: " + str);
            }
            if(mif) {
              if(id != null) {
                throw new AbortException("ID pattern matched twice: previous value " + id + " second value: " + str);
              }
              id = Integer.parseInt(str.substring(mi.end()));
            }
            if(msf) {
              if(score != null) {
                throw new AbortException("Score pattern matched twice: previous value " + score + " second value: " + str);
              }
              score = Double.parseDouble(str.substring(ms.end()));
            }
          }
          if(id != null && score != null) {
            scores.put(DBIDUtil.importInteger(id), score);
            minmax.put(score);
          }
          else if(id == null && score == null) {
            logger.warning("Line did not match either ID nor score nor comment: " + line);
          }
          else {
            throw new AbortException("Line matched only ID or only SCORE patterns: " + line);
          }
        }
      }
    }
    catch(IOException e) {
      throw new AbortException("Could not load outlier scores: " + e.getMessage() + " when loading " + file, e);
    }

    OutlierScoreMeta meta;
    if(inverted) {
      meta = new InvertedOutlierScoreMeta(minmax.getMin(), minmax.getMax());
View Full Code Here

    for(DBID id : or.getScores().iterDBIDs()) {
      scores[pos] = or.getScores().get(id);
      pos++;
    }
    if(pos != or.getScores().size()) {
      throw new AbortException("Database size is incorrect!");
    }
    // sort them
    // TODO: Inverted scores!
    Arrays.sort(scores);
  }
View Full Code Here

   * Init the iterators
   */
  protected void init() {
    this.itr = getParentIterator();
    if (this.itr == null) {
      throw new AbortException("Filtered iterator has 'null' parent.");
    }
  }
View Full Code Here

  }

  @Override
  public void processNewResult(HierarchicalResult baseResult, Result newResult) {
    if(output.isFile()) {
      throw new AbortException("Output folder cannot be an existing file.");
    }
    if(!output.exists()) {
      if(!output.mkdirs()) {
        throw new AbortException("Could not create output directory.");
      }
    }
    if(this.baseResult != baseResult) {
      this.baseResult = baseResult;
      context = null;
View Full Code Here

    // Convert SVG colors into AWT colors for math
    Color[] cols = new Color[colors.length];
    for(int i = 0; i < colors.length; i++) {
      cols[i] = SVGUtil.stringToColor(colors[i]);
      if(cols[i] == null) {
        throw new AbortException("Error parsing color: " + colors[i]);
      }
    }

    // Step size
    double increment = (cols.length - 1.) / shades;
View Full Code Here

  @Override
  public void processNewResult(HierarchicalResult baseResult, Result newResult) {
    ArrayList<OutlierResult> ors = ResultUtil.filterResults(newResult, OutlierResult.class);
    if(ors.size() > 1) {
      throw new AbortException("More than one outlier result found. The KML writer only supports a single outlier result!");
    }
    if(ors.size() == 1) {
      Database database = ResultUtil.findDatabase(baseResult);
      try {
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(filename));
        out.putNextEntry(new ZipEntry("doc.kml"));
        final XMLStreamWriter xmlw = factory.createXMLStreamWriter(out);
        writeKMLData(xmlw, ors.get(0), database);
        xmlw.flush();
        xmlw.close();
        out.closeEntry();
        out.flush();
        out.close();
        if(autoopen) {
          Desktop.getDesktop().open(filename);
        }
      }
      catch(XMLStreamException e) {
        logger.exception(e);
        throw new AbortException("XML error in KML output.", e);
      }
      catch(IOException e) {
        logger.exception(e);
        throw new AbortException("IO error in KML output.", e);
      }
    }
  }
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.