annotate libtests/0039/prog1.c @ 548:e18843dc0aea

Implement a rudimentary API for audioDB::liszt The API is rudimentary because we've dropped support for the incremental retrieval of tracks and their number of vectors (at the API level; the SOAP and command-line support is still there -- no changes should be visible). This is potentially bad for the large-scale databases, of course; one million tracks will take of the order of 16MB of RAM, more if I'm unlucky about how std::string.c_str() is implemented. Both this liszt operation and querying (and sampling, forthcoming...) would benefit from a `cursor-like' interface to retrieval results: for an API like that, instead of getting a struct with the data there, you get a cookie with which you can ask the database for successive results. This would be neat for all sorts of reasons. In the meantime, at least this change fixes SOAP memory leaks related to liszt. Make liszt.o part of LIBOBJS rather than ordinary OBJS, so that the liszt functionality is actually compiled into the library. Add a test for this library functionality; also modify the command-line test file to run the SOAP server on its own port.
author mas01cr
date Wed, 11 Feb 2009 12:38:03 +0000
parents
children
rev   line source
mas01cr@548 1 #include "audioDB_API.h"
mas01cr@548 2 #include "test_utils_lib.h"
mas01cr@548 3
mas01cr@548 4 int main(int argc, char *argv[]) {
mas01cr@548 5 adb_t *adb;
mas01cr@548 6 adb_liszt_results_t *liszt;
mas01cr@548 7
mas01cr@548 8 clean_remove_db(TESTDB);
mas01cr@548 9 if(!(adb = audiodb_create(TESTDB, 0, 0, 0)))
mas01cr@548 10 return 1;
mas01cr@548 11 adb_datum_t datum1 = {2, 2, "testfeature01", (double[4]) {0, 1, 1, 0}};
mas01cr@548 12 adb_datum_t datum2 = {2, 2, "testfeature10", (double[4]) {1, 0, 0, 1}};
mas01cr@548 13 if(audiodb_insert_datum(adb, &datum1))
mas01cr@548 14 return 1;
mas01cr@548 15 if(audiodb_insert_datum(adb, &datum2))
mas01cr@548 16 return 1;
mas01cr@548 17
mas01cr@548 18 liszt = audiodb_liszt(adb);
mas01cr@548 19 if(!liszt || liszt->nresults != 2)
mas01cr@548 20 return 1;
mas01cr@548 21 entry_present_or_fail(liszt, "testfeature01", 2);
mas01cr@548 22 entry_present_or_fail(liszt, "testfeature10", 2);
mas01cr@548 23 audiodb_liszt_free_results(adb, liszt);
mas01cr@548 24
mas01cr@548 25 audiodb_close(adb);
mas01cr@548 26
mas01cr@548 27 return 104;
mas01cr@548 28 }