package de.lmu.ifi.dbs.elki.algorithm;

import de.lmu.ifi.dbs.elki.data.NumberVector;
import de.lmu.ifi.dbs.elki.data.type.VectorFieldTypeInformation;
import de.lmu.ifi.dbs.elki.database.Database;
import de.lmu.ifi.dbs.elki.database.ids.DBID;
import de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery;
import de.lmu.ifi.dbs.elki.database.relation.Relation;
import de.lmu.ifi.dbs.elki.distance.distancefunction.EuclideanDistanceFunction;
import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance;
import de.lmu.ifi.dbs.elki.logging.Logging;
import de.lmu.ifi.dbs.elki.result.Result;
import de.lmu.ifi.dbs.elki.utilities.documentation.Description;
import de.lmu.ifi.dbs.elki.utilities.documentation.Title;

/**
 * Dummy Algorithm, which just iterates over all points once, doing a 10NN query
 * each. Useful in testing e.g. index structures and as template for custom
 * algorithms.
 * 
 * @author Erich Schubert
 * @param <V> Vector type
 */
@Title("Dummy Algorithm")
@Description("The algorithm executes a euclidena 10NN query on all data points, and can be used in unit testing")
public class DummyAlgorithm<O extends NumberVector<?, ?>> extends AbstractAlgorithm<O, Result> {
  /**
   * The logger for this class.
   */
  private static final Logging logger = Logging.getLogger(DummyAlgorithm.class);

  /**
   * Constructor, adhering to
   * {@link de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable}
   */
  public DummyAlgorithm() {
    super();
  }

  /**
   * Iterates over all points in the database.
   */
  @Override
  protected Result runInTime(Database database) throws IllegalStateException {
    Relation<O> dataQuery = getRelation(database);
    KNNQuery<O, DoubleDistance> knnQuery = database.getKNNQuery(dataQuery, EuclideanDistanceFunction.STATIC, 10);
    for(DBID id : dataQuery.iterDBIDs()) {
      // Get the actual object from the database (but discard)
      dataQuery.get(id);
      // run a 10NN query for each point (but discard)
      knnQuery.getKNNForDBID(id, 10);
    }
    return null;
  }

  @Override
  public VectorFieldTypeInformation<? super O> getInputTypeRestriction() {
    return EuclideanDistanceFunction.STATIC.getInputTypeRestriction();
  }

  @Override
  protected Logging getLogger() {
    return logger;
  }
}
@@ -236,16 +236,82 @@
 s.DBID;%0A
+import de.lmu.ifi.dbs.elki.database.query.distance.DistanceQuery;%0A
 import d
@@ -1679,16 +1679,44 @@
 ption %7B%0A
+    // Bind to the database%0A
     Rela
@@ -1723,25 +1723,24 @@
 tion%3CO%3E 
-dataQuery
+relation
  = getRe
@@ -1761,19 +1761,24 @@
 e);%0A    
-KNN
+Distance
 Query%3CO,
@@ -1794,19 +1794,20 @@
 stance%3E 
-knn
+dist
 Query = 
@@ -1822,26 +1822,30 @@
 .get
-KNNQuery(dataQuery
+DistanceQuery(relation
 , Eu
@@ -1874,23 +1874,100 @@
 n.STATIC
+);%0A    KNNQuery%3CO, DoubleDistance%3E knnQuery = database.getKNNQuery(distQuery
 , 10);%0A
+%0A
     for(
@@ -1976,25 +1976,24 @@
 ID id : 
-dataQuery
+relation
 .iterDBI
@@ -2073,17 +2073,16 @@
     
-dataQuery
+relation
 .get

Make explicit as example.