Mercurial > hg > audiodb
comparison audioDB.cpp @ 76:f6cc39635877
Make the status request Web Services enabled.
author | mas01cr |
---|---|
date | Mon, 01 Oct 2007 13:54:22 +0000 |
parents | a7b7a1ca68b8 |
children | c4389e8f4461 |
comparison
equal
deleted
inserted
replaced
75:a7b7a1ca68b8 | 76:f6cc39635877 |
---|---|
8 perror(sysFunc); | 8 perror(sysFunc); |
9 } | 9 } |
10 exit(1); | 10 exit(1); |
11 } | 11 } |
12 | 12 |
13 audioDB::audioDB(const unsigned argc, char* const argv[], adb__queryResult *adbQueryResult): | 13 #define O2_AUDIODB_INITIALIZERS \ |
14 dim(0), | 14 dim(0), \ |
15 dbName(0), | 15 dbName(0), \ |
16 inFile(0), | 16 inFile(0), \ |
17 key(0), | 17 key(0), \ |
18 trackFileName(0), | 18 trackFileName(0), \ |
19 trackFile(0), | 19 trackFile(0), \ |
20 command(0), | 20 command(0), \ |
21 timesFileName(0), | 21 timesFileName(0), \ |
22 timesFile(0), | 22 timesFile(0), \ |
23 dbfid(0), | 23 dbfid(0), \ |
24 infid(0), | 24 infid(0), \ |
25 db(0), | 25 db(0), \ |
26 indata(0), | 26 indata(0), \ |
27 dbH(0), | 27 dbH(0), \ |
28 fileTable(0), | 28 fileTable(0), \ |
29 trackTable(0), | 29 trackTable(0), \ |
30 dataBuf(0), | 30 dataBuf(0), \ |
31 l2normTable(0), | 31 l2normTable(0), \ |
32 qNorm(0), | 32 qNorm(0), \ |
33 timesTable(0), | 33 timesTable(0), \ |
34 verbosity(1), | 34 verbosity(1), \ |
35 queryType(O2_FLAG_POINT_QUERY), | 35 queryType(O2_FLAG_POINT_QUERY), \ |
36 pointNN(O2_DEFAULT_POINTNN), | 36 pointNN(O2_DEFAULT_POINTNN), \ |
37 trackNN(O2_DEFAULT_TRACKNN), | 37 trackNN(O2_DEFAULT_TRACKNN), \ |
38 sequenceLength(16), | 38 sequenceLength(16), \ |
39 sequenceHop(1), | 39 sequenceHop(1), \ |
40 queryPoint(0), | 40 queryPoint(0), \ |
41 usingQueryPoint(0), | 41 usingQueryPoint(0), \ |
42 usingTimes(0), | 42 usingTimes(0), \ |
43 isClient(0), | 43 isClient(0), \ |
44 isServer(0), | 44 isServer(0), \ |
45 port(0), | 45 port(0), \ |
46 timesTol(0.1), | 46 timesTol(0.1), \ |
47 radius(0){ | 47 radius(0) |
48 | 48 |
49 audioDB::audioDB(const unsigned argc, char* const argv[]): O2_AUDIODB_INITIALIZERS | |
50 { | |
49 if(processArgs(argc, argv)<0){ | 51 if(processArgs(argc, argv)<0){ |
50 printf("No command found.\n"); | 52 printf("No command found.\n"); |
51 cmdline_parser_print_version (); | 53 cmdline_parser_print_version (); |
52 if (strlen(gengetopt_args_info_purpose) > 0) | 54 if (strlen(gengetopt_args_info_purpose) > 0) |
53 printf("%s\n", gengetopt_args_info_purpose); | 55 printf("%s\n", gengetopt_args_info_purpose); |
72 | 74 |
73 else if(O2_ACTION(COM_QUERY)) | 75 else if(O2_ACTION(COM_QUERY)) |
74 if(isClient) | 76 if(isClient) |
75 ws_query(dbName, inFile, (char*)hostport); | 77 ws_query(dbName, inFile, (char*)hostport); |
76 else | 78 else |
77 query(dbName, inFile, adbQueryResult); | 79 query(dbName, inFile); |
78 | 80 |
79 else if(O2_ACTION(COM_STATUS)) | 81 else if(O2_ACTION(COM_STATUS)) |
80 if(isClient) | 82 if(isClient) |
81 ws_status(dbName,(char*)hostport); | 83 ws_status(dbName,(char*)hostport); |
82 else | 84 else |
88 else if(O2_ACTION(COM_DUMP)) | 90 else if(O2_ACTION(COM_DUMP)) |
89 dump(dbName); | 91 dump(dbName); |
90 | 92 |
91 else | 93 else |
92 error("Unrecognized command",command); | 94 error("Unrecognized command",command); |
95 } | |
96 | |
97 audioDB::audioDB(const unsigned argc, char* const argv[], adb__queryResult *adbQueryResult): O2_AUDIODB_INITIALIZERS | |
98 { | |
99 processArgs(argc, argv); | |
100 assert(O2_ACTION(COM_QUERY)); | |
101 query(dbName, inFile, adbQueryResult); | |
102 } | |
103 | |
104 audioDB::audioDB(const unsigned argc, char* const argv[], adb__statusResult *adbStatusResult): O2_AUDIODB_INITIALIZERS | |
105 { | |
106 processArgs(argc, argv); | |
107 assert(O2_ACTION(COM_STATUS)); | |
108 status(dbName, adbStatusResult); | |
93 } | 109 } |
94 | 110 |
95 audioDB::~audioDB(){ | 111 audioDB::~audioDB(){ |
96 // Clean up | 112 // Clean up |
97 if(indata) | 113 if(indata) |
802 status(dbName); | 818 status(dbName); |
803 | 819 |
804 munmap(db,O2_DEFAULTDBSIZE); | 820 munmap(db,O2_DEFAULTDBSIZE); |
805 } | 821 } |
806 | 822 |
823 // FIXME: this can't propagate the sequence length argument (used for | |
824 // dudCount). See adb__status() definition for the other half of | |
825 // this. -- CSR, 2007-10-01 | |
807 void audioDB::ws_status(const char*dbName, char* hostport){ | 826 void audioDB::ws_status(const char*dbName, char* hostport){ |
808 struct soap soap; | 827 struct soap soap; |
809 int adbStatusResult; | 828 adb__statusResult adbStatusResult; |
810 | 829 |
811 // Query an existing adb database | 830 // Query an existing adb database |
812 soap_init(&soap); | 831 soap_init(&soap); |
813 if(soap_call_adb__status(&soap,hostport,NULL,(char*)dbName,adbStatusResult)==SOAP_OK) | 832 if(soap_call_adb__status(&soap,hostport,NULL,(char*)dbName,adbStatusResult)==SOAP_OK) { |
814 std::cout << "result = " << adbStatusResult << std::endl; | 833 cout << "numFiles = " << adbStatusResult.numFiles << endl; |
815 else | 834 cout << "dim = " << adbStatusResult.dim << endl; |
835 cout << "length = " << adbStatusResult.length << endl; | |
836 cout << "dudCount = " << adbStatusResult.dudCount << endl; | |
837 cout << "nullCount = " << adbStatusResult.nullCount << endl; | |
838 cout << "flags = " << adbStatusResult.flags << endl; | |
839 } else { | |
816 soap_print_fault(&soap,stderr); | 840 soap_print_fault(&soap,stderr); |
841 } | |
817 | 842 |
818 soap_destroy(&soap); | 843 soap_destroy(&soap); |
819 soap_end(&soap); | 844 soap_end(&soap); |
820 soap_done(&soap); | 845 soap_done(&soap); |
821 } | 846 } |
841 soap_done(&soap); | 866 soap_done(&soap); |
842 | 867 |
843 } | 868 } |
844 | 869 |
845 | 870 |
846 void audioDB::status(const char* dbName){ | 871 void audioDB::status(const char* dbName, adb__statusResult *adbStatusResult){ |
847 if(!dbH) | 872 if(!dbH) |
848 initTables(dbName, 0, 0); | 873 initTables(dbName, 0, 0); |
849 | |
850 // Update Header information | |
851 cout << "num files:" << dbH->numFiles << endl; | |
852 cout << "data dim:" << dbH->dim <<endl; | |
853 if(dbH->dim>0){ | |
854 cout << "total vectors:" << dbH->length/(sizeof(double)*dbH->dim)<<endl; | |
855 cout << "vectors available:" << (timesTableOffset-(dataoffset+dbH->length))/(sizeof(double)*dbH->dim) << endl; | |
856 } | |
857 cout << "total bytes:" << dbH->length << " (" << (100.0*dbH->length)/(timesTableOffset-dataoffset) << "%)" << endl; | |
858 cout << "bytes available:" << timesTableOffset-(dataoffset+dbH->length) << " (" << | |
859 (100.0*(timesTableOffset-(dataoffset+dbH->length)))/(timesTableOffset-dataoffset) << "%)" << endl; | |
860 cout << "flags:" << dbH->flags << endl; | |
861 | 874 |
862 unsigned dudCount=0; | 875 unsigned dudCount=0; |
863 unsigned nullCount=0; | 876 unsigned nullCount=0; |
864 for(unsigned k=0; k<dbH->numFiles; k++){ | 877 for(unsigned k=0; k<dbH->numFiles; k++){ |
865 if(trackTable[k]<sequenceLength){ | 878 if(trackTable[k]<sequenceLength){ |
866 dudCount++; | 879 dudCount++; |
867 if(!trackTable[k]) | 880 if(!trackTable[k]) |
868 nullCount++; | 881 nullCount++; |
869 } | 882 } |
870 } | 883 } |
871 cout << "null count: " << nullCount << " small sequence count " << dudCount-nullCount << endl; | 884 |
872 } | 885 if(adbStatusResult == 0) { |
873 | 886 |
887 // Update Header information | |
888 cout << "num files:" << dbH->numFiles << endl; | |
889 cout << "data dim:" << dbH->dim <<endl; | |
890 if(dbH->dim>0){ | |
891 cout << "total vectors:" << dbH->length/(sizeof(double)*dbH->dim)<<endl; | |
892 cout << "vectors available:" << (timesTableOffset-(dataoffset+dbH->length))/(sizeof(double)*dbH->dim) << endl; | |
893 } | |
894 cout << "total bytes:" << dbH->length << " (" << (100.0*dbH->length)/(timesTableOffset-dataoffset) << "%)" << endl; | |
895 cout << "bytes available:" << timesTableOffset-(dataoffset+dbH->length) << " (" << | |
896 (100.0*(timesTableOffset-(dataoffset+dbH->length)))/(timesTableOffset-dataoffset) << "%)" << endl; | |
897 cout << "flags:" << dbH->flags << endl; | |
898 | |
899 cout << "null count: " << nullCount << " small sequence count " << dudCount-nullCount << endl; | |
900 } else { | |
901 adbStatusResult->numFiles = dbH->numFiles; | |
902 adbStatusResult->dim = dbH->dim; | |
903 adbStatusResult->length = dbH->length; | |
904 adbStatusResult->dudCount = dudCount; | |
905 adbStatusResult->nullCount = nullCount; | |
906 adbStatusResult->flags = dbH->flags; | |
907 } | |
908 } | |
874 | 909 |
875 void audioDB::dump(const char* dbName){ | 910 void audioDB::dump(const char* dbName){ |
876 if(!dbH) | 911 if(!dbH) |
877 initTables(dbName, 0, 0); | 912 initTables(dbName, 0, 0); |
878 | 913 |
2450 | 2485 |
2451 | 2486 |
2452 // web services | 2487 // web services |
2453 | 2488 |
2454 // SERVER SIDE | 2489 // SERVER SIDE |
2455 int adb__status(struct soap* soap, xsd__string dbName, xsd__int &adbCreateResult){ | 2490 int adb__status(struct soap* soap, xsd__string dbName, adb__statusResult &adbStatusResult){ |
2456 char* const argv[]={"audioDB",COM_STATUS,"-d",dbName}; | 2491 char* const argv[]={"audioDB",COM_STATUS,"-d",dbName}; |
2457 const unsigned argc = 4; | 2492 const unsigned argc = 4; |
2458 audioDB(argc,argv); | 2493 audioDB(argc, argv, &adbStatusResult); |
2459 adbCreateResult=100; | |
2460 return SOAP_OK; | 2494 return SOAP_OK; |
2461 } | 2495 } |
2462 | 2496 |
2463 // Literal translation of command line to web service | 2497 // Literal translation of command line to web service |
2464 | 2498 |