log.log(Level.INFO, "Search start");
int idx = 0;
while (cursor.hasNext()) {
//log.log(Level.INFO, String.format("Search idx %d", idx));
DBObject dbo = cursor.next();
Match newMatch = Match.fromDBObject(dbo);
ArrayList arr = (ArrayList) dbo.get("hash");
double[][] music = new double[arr.size()][hash[0].length];
for(int i = 0; i < arr.size(); i++) {
ArrayList<Double> arr2 = (ArrayList<Double>)arr.get(i);
for(int j = 0; j < arr2.size(); j++)
music[i][j] = arr2.get(j);
}
int music_len = music.length;
// if(newMatch.getTitle().equals("Tie You Up (The Pain Of Love)")) {
// log.log(Level.INFO, String.format("Music length %d", music_len));
// for(int i = 0; i < music_len; i++) {
// String str = "[";
// for(int j = 0; j < music[i].length; j++)
// str += Double.toString(music[i][j]) + " ";
// str += "]";
// log.log(Level.INFO, str);
// }
// }
double score = Double.MAX_VALUE;
for(int i = 0; i < music_len - hash_len; i++) {
double sum = 0.0;
for(int j = 0; j < hash_len; j++) {
sum += SearchUtils.distance(music[i+j], hash[j], min_max);
}
if(sum < score)
score = sum;
}
newMatch.setScore(score);
newMatch.setClassScore(clresult);
if(newMatch.getTitle().equals("Tie You Up (The Pain Of Love)"))
log.log(Level.INFO, String.format("Tie You Up (The Pain Of Love) match %f", newMatch.getScore()));
if(matches.size() < 10) {
matches.add(newMatch);
Collections.sort(matches, new MatchComparator());
}
else {