# HG changeset patch # User mas01mc # Date 1226012259 0 # Node ID a22b18005853f0daa7d26aed38868e44f87fca08 # Parent af3bc78e0f77dcaac19f40eaee85a23d0062b8b6 serialized query now with power. diff -r af3bc78e0f77 -r a22b18005853 QueryADB.py --- 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 @@ %s + %s %s - %s + %s 32 %s @@ -163,15 +164,16 @@ ############### Shingle Query - Show the data closest to one shingle ########### def RunShingleQuery(): global debug, dbName - queryVector='1.00.50.25' featureDim = '3' + queryVector='1.00.50.25' + powerVector='

-1.0

' 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) diff -r af3bc78e0f77 -r a22b18005853 audioDBws.h --- 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 { diff -r af3bc78e0f77 -r a22b18005853 soap.cpp --- 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; }