Mercurial > hg > audiodb
comparison index.cpp @ 431:8632cd387e24 api-inversion
Punishment gluttony.
Continue teasing out vague orthogonalities by beginning the task of
using an adb_query_parameters_t. This does have the benefit of making
the distance calculation clearer, and we begin to see the shape of a
putative audiodb_query() emerging from the shrapnel of audioDB::query.
(Only the general shape; the detail is still a long, long way away).
author | mas01cr |
---|---|
date | Wed, 24 Dec 2008 10:55:40 +0000 |
parents | adaa6a688a04 |
children | 681837f7c903 |
comparison
equal
deleted
inserted
replaced
430:2d14d21f826b | 431:8632cd387e24 |
---|---|
573 exact_evaluation_queue->push(p); | 573 exact_evaluation_queue->push(p); |
574 } | 574 } |
575 | 575 |
576 // return 0: if index does not exist | 576 // return 0: if index does not exist |
577 // return nqv: if index exists | 577 // return nqv: if index exists |
578 int audioDB::index_query_loop(adb_query_refine_t *refine, const char* dbName, Uns32T queryIndex) { | 578 int audioDB::index_query_loop(adb_query_parameters_t *params, adb_query_refine_t *refine, const char* dbName, Uns32T queryIndex) { |
579 | 579 |
580 unsigned int numVectors = 0; | 580 unsigned int numVectors = 0; |
581 double *query = 0, *query_data = 0; | 581 double *query = 0, *query_data = 0; |
582 double *qNorm = 0, *qnPtr = 0, *qPower = 0, *qpPtr = 0; | 582 double *qNorm = 0, *qnPtr = 0, *qPower = 0, *qpPtr = 0; |
583 double meanQdur = 0; | 583 double meanQdur = 0; |
584 void (*add_point_func)(void*,Uns32T,Uns32T,float); | 584 void (*add_point_func)(void*,Uns32T,Uns32T,float); |
585 | 585 |
586 normalizedDistance = (params->distance == ADB_DISTANCE_EUCLIDEAN_NORMED); | |
587 | |
586 // Set the point-reporter callback based on the value of lsh_exact | 588 // Set the point-reporter callback based on the value of lsh_exact |
587 if(lsh_exact){ | 589 if(lsh_exact){ |
588 initialize_exact_evalutation_queue(); | 590 initialize_exact_evalutation_queue(); |
589 add_point_func = &index_add_point_exact; | 591 add_point_func = &index_add_point_exact; |
590 } | 592 } |
601 else | 603 else |
602 set_up_query(&query_data, &query, &qNorm, &qnPtr, &qPower, &qpPtr, &meanQdur, &numVectors); // get query vectors | 604 set_up_query(&query_data, &query, &qNorm, &qnPtr, &qPower, &qpPtr, &meanQdur, &numVectors); // get query vectors |
603 | 605 |
604 VERB_LOG(1, "retrieving tracks..."); | 606 VERB_LOG(1, "retrieving tracks..."); |
605 | 607 |
606 assert(pointNN>0 && pointNN<=O2_MAXNN); | |
607 assert(trackNN>0 && trackNN<=O2_MAXNN); | |
608 | |
609 gettimeofday(&tv1, NULL); | 608 gettimeofday(&tv1, NULL); |
610 // query vector index | 609 // query vector index |
611 Uns32T Nq = (numVectors>O2_MAXTRACKLEN?O2_MAXTRACKLEN:numVectors) - sequenceLength + 1; | 610 Uns32T Nq = (numVectors>O2_MAXTRACKLEN?O2_MAXTRACKLEN:numVectors) - sequenceLength + 1; |
612 vv = index_initialize_shingles(Nq); // allocate memory to copy query vectors to shingles | 611 vv = index_initialize_shingles(Nq); // allocate memory to copy query vectors to shingles |
613 VERB_LOG(1, "Nq=%d", Nq); | 612 VERB_LOG(1, "Nq=%d", Nq); |
638 } | 637 } |
639 } | 638 } |
640 | 639 |
641 if(lsh_exact) | 640 if(lsh_exact) |
642 // Perform exact distance computation on point pairs in exact_evaluation_queue | 641 // Perform exact distance computation on point pairs in exact_evaluation_queue |
643 query_loop_points(query, qnPtr, qpPtr, meanQdur, numVectors, refine); | 642 query_loop_points(query, qnPtr, qpPtr, meanQdur, numVectors, params, refine); |
644 | 643 |
645 gettimeofday(&tv2,NULL); | 644 gettimeofday(&tv2,NULL); |
646 VERB_LOG(1,"elapsed time: %ld msec\n", | 645 VERB_LOG(1,"elapsed time: %ld msec\n", |
647 (tv2.tv_sec*1000 + tv2.tv_usec/1000) - | 646 (tv2.tv_sec*1000 + tv2.tv_usec/1000) - |
648 (tv1.tv_sec*1000 + tv1.tv_usec/1000)) | 647 (tv1.tv_sec*1000 + tv1.tv_usec/1000)) |