Mercurial > hg > audiodb
comparison audioDB.cpp @ 538:02e0a9ecfd0f multiprobeLSH
Added back single-query point I/O behaviour from pre API-inversion. Thus only those query vectors required are loaded when using query-from-file. Tests 0006 and 0007 fail silently with this change.
author | mas01mc |
---|---|
date | Fri, 06 Feb 2009 21:08:35 +0000 |
parents | c7bdb7913762 |
children | 283b412083db |
comparison
equal
deleted
inserted
replaced
533:eb5dd50dd7d1 | 538:02e0a9ecfd0f |
---|---|
735 if(audiodb_insert(adb, &insert)) { | 735 if(audiodb_insert(adb, &insert)) { |
736 error("insertion failure", thisFile); | 736 error("insertion failure", thisFile); |
737 } | 737 } |
738 } while(!filesIn->eof()); | 738 } while(!filesIn->eof()); |
739 | 739 |
740 VERB_LOG(0, "%s %s %u vectors %ju bytes.\n", COM_BATCHINSERT, dbName, totalVectors, (intmax_t) (totalVectors * dbH->dim * sizeof(double))); | 740 VERB_LOG(0, "%s %s %u vectors %ju bytes.\n", COM_BATCHINSERT, dbName, totalVectors, (intmax_t) (totalVectors * adb->header->dim * sizeof(double))); |
741 | 741 |
742 delete [] thisPowerFileName; | 742 delete [] thisPowerFileName; |
743 if(key && (key != inFile)) { | 743 if(key && (key != inFile)) { |
744 delete [] thisKey; | 744 delete [] thisKey; |
745 } | 745 } |
829 if(fd < 0) { | 829 if(fd < 0) { |
830 error("failed to open feature file", inFile); | 830 error("failed to open feature file", inFile); |
831 } | 831 } |
832 fstat(fd, &st); | 832 fstat(fd, &st); |
833 read(fd, &datum.dim, sizeof(uint32_t)); | 833 read(fd, &datum.dim, sizeof(uint32_t)); |
834 datum.nvectors = (st.st_size - sizeof(uint32_t)) / (datum.dim * sizeof(double)); | 834 if(usingQueryPoint){ |
835 datum.data = (double *) malloc(st.st_size - sizeof(uint32_t)); | 835 datum.nvectors = sequenceLength; |
836 read(fd, datum.data, st.st_size - sizeof(uint32_t)); | 836 datum.data = (double *) malloc(datum.nvectors*datum.dim*sizeof(double)); |
837 close(fd); | 837 lseek(fd, queryPoint*sizeof(double)*datum.dim, SEEK_CUR); |
838 read(fd, datum.data, datum.nvectors*datum.dim*sizeof(double)); | |
839 close(fd); | |
840 } | |
841 else{ | |
842 datum.nvectors = (st.st_size - sizeof(uint32_t)) / (datum.dim * sizeof(double)); | |
843 datum.data = (double *) malloc(st.st_size - sizeof(uint32_t)); | |
844 read(fd, datum.data, st.st_size - sizeof(uint32_t)); | |
845 close(fd); | |
846 } | |
838 if(usingPower) { | 847 if(usingPower) { |
839 uint32_t one; | 848 uint32_t one; |
840 fd = open(powerFileName, O_RDONLY); | 849 fd = open(powerFileName, O_RDONLY); |
841 if(fd < 0) { | 850 if(fd < 0) { |
842 error("failed to open power file", powerFileName); | 851 error("failed to open power file", powerFileName); |
844 read(fd, &one, sizeof(uint32_t)); | 853 read(fd, &one, sizeof(uint32_t)); |
845 if(one != 1) { | 854 if(one != 1) { |
846 error("malformed power file dimensionality", powerFileName); | 855 error("malformed power file dimensionality", powerFileName); |
847 } | 856 } |
848 datum.power = (double *) malloc(datum.nvectors * sizeof(double)); | 857 datum.power = (double *) malloc(datum.nvectors * sizeof(double)); |
858 if(usingQueryPoint) | |
859 lseek(fd, queryPoint*sizeof(double), SEEK_CUR); | |
849 if(read(fd, datum.power, datum.nvectors * sizeof(double)) != (ssize_t) (datum.nvectors * sizeof(double))) { | 860 if(read(fd, datum.power, datum.nvectors * sizeof(double)) != (ssize_t) (datum.nvectors * sizeof(double))) { |
850 error("malformed power file", powerFileName); | 861 error("malformed power file", powerFileName); |
851 } | 862 } |
852 close(fd); | 863 close(fd); |
853 } | 864 } |
854 if(usingTimes) { | 865 if(usingTimes) { |
855 datum.times = (double *) malloc(2 * datum.nvectors * sizeof(double)); | 866 datum.times = (double *) malloc(2 * datum.nvectors * sizeof(double)); |
860 qspec.qid.datum = &datum; | 871 qspec.qid.datum = &datum; |
861 qspec.qid.sequence_length = sequenceLength; | 872 qspec.qid.sequence_length = sequenceLength; |
862 qspec.qid.flags = 0; | 873 qspec.qid.flags = 0; |
863 qspec.qid.flags |= usingQueryPoint ? 0 : ADB_QID_FLAG_EXHAUSTIVE; | 874 qspec.qid.flags |= usingQueryPoint ? 0 : ADB_QID_FLAG_EXHAUSTIVE; |
864 qspec.qid.flags |= lsh_exact ? 0 : ADB_QID_FLAG_ALLOW_FALSE_POSITIVES; | 875 qspec.qid.flags |= lsh_exact ? 0 : ADB_QID_FLAG_ALLOW_FALSE_POSITIVES; |
865 qspec.qid.sequence_start = queryPoint; | 876 if(usingQueryPoint) |
877 qspec.qid.sequence_start = 0; | |
878 else | |
879 qspec.qid.sequence_start = queryPoint; | |
866 | 880 |
867 switch(queryType) { | 881 switch(queryType) { |
868 case O2_POINT_QUERY: | 882 case O2_POINT_QUERY: |
869 qspec.qid.sequence_length = 1; | 883 qspec.qid.sequence_length = 1; |
870 qspec.params.accumulation = ADB_ACCUMULATION_DB; | 884 qspec.params.accumulation = ADB_ACCUMULATION_DB; |
910 qspec.params.npoints = 0; | 924 qspec.params.npoints = 0; |
911 qspec.params.ntracks = 0; | 925 qspec.params.ntracks = 0; |
912 if(!(qspec.refine.flags & ADB_REFINE_RADIUS)) { | 926 if(!(qspec.refine.flags & ADB_REFINE_RADIUS)) { |
913 error("query-type not yet supported"); | 927 error("query-type not yet supported"); |
914 } else { | 928 } else { |
915 reporter = new trackSequenceQueryRadNNReporterOneToOne(pointNN,trackNN, dbH->numFiles); | 929 reporter = new trackSequenceQueryRadNNReporterOneToOne(pointNN,trackNN, adb->header->numFiles); |
916 } | 930 } |
917 break; | 931 break; |
918 default: | 932 default: |
919 error("unrecognized queryType"); | 933 error("unrecognized queryType"); |
920 } | 934 } |