Mercurial > hg > audiodb
changeset 352:a22b18005853 serializedQuery
serialized query now with power.
author | mas01mc |
---|---|
date | Thu, 06 Nov 2008 22:57:39 +0000 |
parents | af3bc78e0f77 |
children | 1662745233d9 |
files | QueryADB.py audioDBws.h soap.cpp |
diffstat | 3 files changed, 47 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/QueryADB.py Thu Nov 06 16:07:57 2008 +0000 +++ b/QueryADB.py Thu Nov 06 22:57:39 2008 +0000 @@ -96,8 +96,9 @@ <adb:shingleQuery> <dbName>%s</dbName> <qVector> + <dim>%s</dim> %s - <dim>%s</dim> + %s </qVector> <queryType>32</queryType> <pointNN>%s</pointNN> @@ -163,15 +164,16 @@ ############### Shingle Query - Show the data closest to one shingle ########### def RunShingleQuery(): global debug, dbName - queryVector='<Qvector>1.0</Qvector><Qvector>0.5</Qvector><Qvector>0.25</Qvector>' featureDim = '3' + queryVector='<v>1.0</v><v>0.5</v><v>0.25</v>' + powerVector='<p>-1.0</p>' pointNN = '10' trackNN = '5' queryRadius = '0.5' absoluteThreshold = '-4.5' lshExact = '0' message = SHINGLE_QUERY_TEMPLATE - message = SHINGLE_QUERY_TEMPLATE%(dbName, queryVector, featureDim, pointNN, trackNN, queryRadius, absoluteThreshold, lshExact); + message = SHINGLE_QUERY_TEMPLATE%(dbName, featureDim, queryVector, powerVector, pointNN, trackNN, queryRadius, absoluteThreshold, lshExact); # print message print message response = SendXMLCommand(message)
--- a/audioDBws.h Thu Nov 06 16:07:57 2008 +0000 +++ b/audioDBws.h Thu Nov 06 22:57:39 2008 +0000 @@ -48,9 +48,11 @@ }; struct adb__queryVector { - int __sizeQvector; // l x d : - double *Qvector; // pointer to query data int dim; // dimensionality of the feature (d) + int __sizev; // l x d : + double *v; // pointer to query data + int __sizep; + double *p; }; struct adb__lisztResponse {
--- a/soap.cpp Thu Nov 06 16:07:57 2008 +0000 +++ b/soap.cpp Thu Nov 06 22:57:39 2008 +0000 @@ -361,9 +361,9 @@ // Query an audioDB database by vector (serialized) int adb__shingleQuery(struct soap* soap, xsd__string dbName, struct adb__queryVector qVector, xsd__int queryType,xsd__int pointNN,xsd__int trackNN,xsd__int sequenceLength,xsd__double radius,xsd__double absolute_threshold,xsd__int lsh_exact,struct adb__queryResponse &adbQueryResponse){ - cout << "qvector[" << qVector.dim << " x " << qVector.__sizeQvector/qVector.dim << "]: "; - for(int k=0; k < qVector.__sizeQvector ; k++) - cout << qVector.Qvector[k] << " "; + cout << "qvector[" << qVector.dim << " x " << qVector.__sizev/qVector.dim << "]: "; + for(int k=0; k < qVector.__sizev ; k++) + cout << qVector.v[k] << " "; cout << endl; cout.flush(); @@ -376,7 +376,7 @@ return SOAP_FAULT; } - FILE* tmpFile = fdopen(tmpFid, "wb"); + FILE* tmpFile = fdopen(tmpFid, "r+b"); if(!tmpFile){ cerr << "error opening <" << tmpFileName << "> for write" << endl; return SOAP_FAULT; @@ -387,17 +387,47 @@ return SOAP_FAULT; } - if(fwrite(qVector.Qvector, sizeof(double), qVector.__sizeQvector, tmpFile)!=(size_t)qVector.__sizeQvector){ + if(fwrite(qVector.v, sizeof(double), qVector.__sizev, tmpFile)!=(size_t)qVector.__sizev){ cerr << "error writing tmp file doubles <" << tmpFileName << ">" << endl; return SOAP_FAULT; } + + // Close the file so that a new FD can be opened + fclose(tmpFile); + + char tmpFileName2[] = "/tmp/adbP_XXXXXX"; + int tmpFid2 = 0; + FILE* tmpFile2 = NULL; + + // Check if powers have been passed and write accordingly + if(qVector.__sizep){ + tmpFid2 = mkstemp(tmpFileName2); + tmpFile2 = fdopen(tmpFid2, "r+b"); + if(!tmpFile2){ + cerr << "error opening power file <" << tmpFileName2 << "> for write" << endl; + return SOAP_FAULT; + } + int pSize=1; + if(fwrite(&pSize, sizeof(int), 1, tmpFile2)!=1){ + cerr << "error writing tmp power file dim <"<< tmpFileName2 << ">" << endl; + return SOAP_FAULT; + } + if(fwrite(qVector.p, sizeof(double), qVector.__sizep, tmpFile2)!=(size_t)qVector.__sizep){ + cerr << "error writing tmp power file doubles <" << tmpFileName2 << ">" << endl; + return SOAP_FAULT; + } + fclose(tmpFile2); + } + // fix up sequenceLength if it isn't provided, we know what the caller wants by the size of the shingle // and the feature dimensionality if(!sequenceLength) - sequenceLength = qVector.__sizeQvector/qVector.dim; - int retVal = adb__sequenceQueryByKey(soap, dbName, "", tmpFileName, queryType,"","",0,pointNN,trackNN,sequenceLength,radius,absolute_threshold,1,lsh_exact,adbQueryResponse); - fclose(tmpFile); + sequenceLength = qVector.__sizev/qVector.dim; + // int retVal = adb__sequenceQueryByKey(soap, dbName, "", tmpFileName, queryType,"","",0,pointNN,trackNN,sequenceLength,radius,absolute_threshold,1,lsh_exact,adbQueryResponse); + +int retVal = adb__query(soap, dbName, tmpFileName, "", "", qVector.__sizep?tmpFileName2:0, queryType, 0, pointNN, trackNN, sequenceLength,radius, absolute_threshold, 0,0, lsh_exact,adbQueryResponse); + return retVal; }