private double naiveQuerySparse(SparseNumberVector obj,WritableDoubleDataStore scores,HashSetModifiableDBIDs cands){
  double len=0.;
  for (int iter=obj.iter(); obj.iterValid(iter); iter=obj.iterAdvance(iter)) {
    final int dim=obj.iterDim(iter);
    final double val=obj.iterDoubleValue(iter);
    if (val == 0. || val != val) {
      continue;
    }
    len+=val * val;
    if (dim >= index.size()) {
      continue;
    }
    ModifiableDoubleDBIDList column=index.get(dim);
    for (DoubleDBIDListIter n=column.iter(); n.valid(); n.advance()) {
      scores.increment(n,n.doubleValue() * val);
      cands.add(n);
    }
  }
  return Math.sqrt(len);
}

private double naiveQuerySparse ( SparseNumberVector obj , WritableDoubleDataStore scores , HashSetModifiableDBIDs cands ) { double len = 0. ; for ( int iter = obj . iter ( ) ; obj . iterValid ( iter ) ; iter = obj . iterAdvance ( iter ) ) { final int dim = obj . iterDim ( iter ) ; final double val = obj . iterDoubleValue ( iter ) ; if ( val == 0. || val != val ) { continue ; } len += val * val ; if ( dim >= index . size ( ) ) { continue ; } ModifiableDoubleDBIDList column = index . get ( dim ) ; for ( DoubleDBIDListIter n = column . iter ( ) ; n . valid ( ) ; n . advance ( ) ) { scores . increment ( n , n . doubleValue ( ) * val ) ; cands . add ( n ) ; } } return Math . sqrt ( len ) ; }
query the most similar objects , sparse version .
