public static <O>KNNQuery<O> precomputedKNNQuery(Database database,Relation<O> relation,DistanceQuery<O> dq,int k){
  KNNQuery<O> knnq=database.getKNNQuery(dq,k,DatabaseQuery.HINT_HEAVY_USE,DatabaseQuery.HINT_OPTIMIZED_ONLY,DatabaseQuery.HINT_NO_CACHE);
  if (knnq instanceof PreprocessorKNNQuery) {
    return knnq;
  }
  MaterializeKNNPreprocessor<O> preproc=new MaterializeKNNPreprocessor<>(relation,dq.getDistanceFunction(),k);
  preproc.initialize();
  return preproc.getKNNQuery(dq,k);
}

public static < O > KNNQuery < O > precomputedKNNQuery ( Database database , Relation < O > relation , DistanceQuery < O > dq , int k ) { KNNQuery < O > knnq = database . getKNNQuery ( dq , k , DatabaseQuery . HINT_HEAVY_USE , DatabaseQuery . HINT_OPTIMIZED_ONLY , DatabaseQuery . HINT_NO_CACHE ) ; if ( knnq instanceof PreprocessorKNNQuery ) { return knnq ; } MaterializeKNNPreprocessor < O > preproc = new MaterializeKNNPreprocessor < > ( relation , dq . getDistanceFunction ( ) , k ) ; preproc . initialize ( ) ; return preproc . getKNNQuery ( dq , k ) ; }
get ( or create ) a precomputed knn query for the database .
