# HG changeset patch # User mas01mc # Date 1225961680 0 # Node ID 8ff9d4d83222c7acd9e72f04f60c19007a80ff8a # Parent d1afecc7178186a7a8ad872a50c03875570b42cb serialized shingle query added to WS, compiles but not tested diff -r d1afecc71781 -r 8ff9d4d83222 audioDBws.h --- a/audioDBws.h Mon Oct 27 11:09:34 2008 +0000 +++ b/audioDBws.h Thu Nov 06 08:54:40 2008 +0000 @@ -48,8 +48,9 @@ }; struct adb__queryVector { - int __sizeQvector; - double *Qvector; + int __sizeQvector; // l x d : + double *Qvector; // pointer to query data + int dim; // dimensionality of the feature (d) }; struct adb__lisztResponse { diff -r d1afecc71781 -r 8ff9d4d83222 soap.cpp --- a/soap.cpp Mon Oct 27 11:09:34 2008 +0000 +++ b/soap.cpp Thu Nov 06 08:54:40 2008 +0000 @@ -360,11 +360,87 @@ // 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.__sizeQvector << "]: "; + + cout << "qvector[" << qVector.dim << " x " << qVector.__sizeQvector/qVector.dim << "]: "; for(int k=0; k < qVector.__sizeQvector ; k++) cout << qVector.Qvector[k] << " "; cout.flush(); - return SOAP_OK; + + // open a tmp file on the server, write shingle, query as a file with query point 0 + // and shingle length l/dim + char tmpFileName[] = "adbXXXXXX"; + int fid = mkstemp(tmpFileName); + if(fid==-1){ + cerr << "Cannot open tmpfile on server"; + return SOAP_FAULT; + } + + FILE* tmpFile = fdopen(fid, "r+b"); + + if(fwrite(&qVector.dim, 1, sizeof(int), tmpFile)!=1){ + cerr << "error writing tmp file dim"; + return SOAP_FAULT; + } + + if(fwrite(qVector.Qvector, qVector.__sizeQvector,sizeof(double), tmpFile)!=(size_t)qVector.__sizeQvector){ + cerr << "error writing tmp file doubles"; + return SOAP_FAULT; + } + + // Call adb query with tmpQueryFile name as a the query file parameter + char qtypeStr[256]; + + fprintf(stderr, "Calling %s query on database %s with %s=%s\n", "FILENAME", dbName, "FILENAME",tmpFileName); + + // 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; + + INTSTRINGIFY(0, qPosStr); // query position is 0 + INTSTRINGIFY(pointNN, pointNNStr); + INTSTRINGIFY(trackNN, trackNNStr); + INTSTRINGIFY(sequenceLength, seqLenStr); + DOUBLESTRINGIFY(absolute_threshold, absolute_thresholdStr); + DOUBLESTRINGIFY(radius, radiusStr); + + snprintf(qtypeStr, 256, "nsequence"); + const char *argv[]={ + "./audioDB", + COM_QUERY, + qtypeStr, + COM_DATABASE, + dbName, + COM_FEATURES, + ENSURE_STRING(tmpFileName), + COM_KEYLIST, + ENSURE_STRING(""), + COM_QPOINT, + qPosStr, + COM_POINTNN, + pointNNStr, + COM_TRACKNN, + trackNNStr, + COM_RADIUS, + radiusStr, + COM_SEQLEN, + seqLenStr, + COM_ABSOLUTE_THRESH, + absolute_thresholdStr, + lsh_exact?COM_LSH_EXACT:"" + }; + + const unsigned argc = 22; + + try { + audioDB(argc, (char* const*)argv, &adbQueryResponse); + fclose(tmpFile); + return SOAP_OK; + } catch (char *err) { + soap_receiver_fault(soap, err, ""); + fclose(tmpFile); + return SOAP_FAULT; + } } /* Server loop */