Mercurial > hg > audiodb
comparison soap.cpp @ 471:add65705e655
added --no_unit_norming to SOAP interface, added this case to tests/0041
author | mas01mc |
---|---|
date | Tue, 06 Jan 2009 07:02:11 +0000 |
parents | 2d5c3f8e8c22 |
children | 342822c2d49a |
comparison
equal
deleted
inserted
replaced
467:51d02229288f | 471:add65705e655 |
---|---|
53 (char *)featureFileName, (char *)trackFileName, | 53 (char *)featureFileName, (char *)trackFileName, |
54 (char *)timesFileName, (char *) powerFileName, | 54 (char *)timesFileName, (char *) powerFileName, |
55 queryType, queryPoint, | 55 queryType, queryPoint, |
56 pointNN, trackNN, sequenceLength, | 56 pointNN, trackNN, sequenceLength, |
57 radius, absolute_threshold, relative_threshold, | 57 radius, absolute_threshold, relative_threshold, |
58 !usingQueryPoint, lsh_exact, | 58 !usingQueryPoint, lsh_exact, no_unit_norming, |
59 adbQueryResponse) | 59 adbQueryResponse) |
60 == SOAP_OK) { | 60 == SOAP_OK) { |
61 if(radius == 0) { | 61 if(radius == 0) { |
62 for(int i=0; i<adbQueryResponse.result.__sizeRlist; i++) { | 62 for(int i=0; i<adbQueryResponse.result.__sizeRlist; i++) { |
63 std::cout << adbQueryResponse.result.Rlist[i] << " " | 63 std::cout << adbQueryResponse.result.Rlist[i] << " " |
113 trackNN, | 113 trackNN, |
114 sequenceLength, | 114 sequenceLength, |
115 radius, | 115 radius, |
116 absolute_threshold, | 116 absolute_threshold, |
117 usingQueryPoint, | 117 usingQueryPoint, |
118 lsh_exact, | 118 lsh_exact, |
119 no_unit_norming, | |
119 adbQueryResponse)==SOAP_OK){ | 120 adbQueryResponse)==SOAP_OK){ |
120 //std::std::cerr << "result list length:" << adbQueryResponse.result.__sizeRlist << std::std::endl; | 121 //std::std::cerr << "result list length:" << adbQueryResponse.result.__sizeRlist << std::std::endl; |
121 for(int i=0; i<adbQueryResponse.result.__sizeRlist; i++) | 122 for(int i=0; i<adbQueryResponse.result.__sizeRlist; i++) |
122 std::cout << adbQueryResponse.result.Rlist[i] << " " << adbQueryResponse.result.Dist[i] | 123 std::cout << adbQueryResponse.result.Rlist[i] << " " << adbQueryResponse.result.Dist[i] |
123 << " " << adbQueryResponse.result.Qpos[i] << " " << adbQueryResponse.result.Spos[i] << std::endl; | 124 << " " << adbQueryResponse.result.Qpos[i] << " " << adbQueryResponse.result.Spos[i] << std::endl; |
178 xsd__int qType, | 179 xsd__int qType, |
179 xsd__int qPos, xsd__int pointNN, xsd__int trackNN, | 180 xsd__int qPos, xsd__int pointNN, xsd__int trackNN, |
180 xsd__int seqLen, | 181 xsd__int seqLen, |
181 xsd__double radius, | 182 xsd__double radius, |
182 xsd__double absolute_threshold, xsd__double relative_threshold, | 183 xsd__double absolute_threshold, xsd__double relative_threshold, |
183 xsd__int exhaustive, xsd__int lsh_exact, | 184 xsd__int exhaustive, xsd__int lsh_exact, xsd__int no_unit_norming, |
184 adb__queryResponse &adbQueryResponse){ | 185 adb__queryResponse &adbQueryResponse){ |
185 char queryType[256]; | 186 char queryType[256]; |
186 | 187 |
187 fprintf(stderr,"Calling fileName query on database %s with featureFile=%s\n", dbName, qKey); | 188 fprintf(stderr,"Calling fileName query on database %s with featureFile=%s\n", dbName, qKey); |
188 | 189 |
232 } | 233 } |
233 if (exhaustive) { | 234 if (exhaustive) { |
234 argc++; | 235 argc++; |
235 } | 236 } |
236 if (lsh_exact) { | 237 if (lsh_exact) { |
238 argc++; | |
239 } | |
240 | |
241 if(no_unit_norming){ | |
237 argc++; | 242 argc++; |
238 } | 243 } |
239 | 244 |
240 const char **argv = new const char*[argc+1]; | 245 const char **argv = new const char*[argc+1]; |
241 argv[0] = "./audioDB"; | 246 argv[0] = "./audioDB"; |
278 argv[argv_counter++] = COM_EXHAUSTIVE; | 283 argv[argv_counter++] = COM_EXHAUSTIVE; |
279 } | 284 } |
280 if (lsh_exact) { | 285 if (lsh_exact) { |
281 argv[argv_counter++] = COM_LSH_EXACT; | 286 argv[argv_counter++] = COM_LSH_EXACT; |
282 } | 287 } |
288 | |
289 if (no_unit_norming) { | |
290 argv[argv_counter++] = COM_NO_UNIT_NORMING; | |
291 } | |
292 | |
283 argv[argv_counter] = NULL; | 293 argv[argv_counter] = NULL; |
284 | 294 |
285 try { | 295 try { |
286 audioDB(argc, argv, &adbQueryResponse); | 296 audioDB(argc, argv, &adbQueryResponse); |
287 delete [] argv; | 297 delete [] argv; |
304 xsd__int trackNN, | 314 xsd__int trackNN, |
305 xsd__int sequenceLength, | 315 xsd__int sequenceLength, |
306 xsd__double radius, | 316 xsd__double radius, |
307 xsd__double absolute_threshold, | 317 xsd__double absolute_threshold, |
308 xsd__int usingQueryPoint, | 318 xsd__int usingQueryPoint, |
309 xsd__int lsh_exact, | 319 xsd__int lsh_exact, xsd__int no_unit_norming, |
310 struct adb__queryResponse& adbQueryResponse){ | 320 struct adb__queryResponse& adbQueryResponse){ |
311 char qtypeStr[256]; | 321 char qtypeStr[256]; |
312 | 322 |
313 fprintf(stderr, "Calling %s query on database %s with %s=%s\n", (trackKey&&strlen(trackKey))?"KEY":"FILENAME", dbName, (trackKey&&strlen(trackKey))?"KEY":"FILENAME",(trackKey&&strlen(trackKey))?trackKey:featureFileName); | 323 fprintf(stderr, "Calling %s query on database %s with %s=%s, distFun:%s\n", (trackKey&&strlen(trackKey))?"KEY":"FILENAME", dbName, (trackKey&&strlen(trackKey))?"KEY":"FILENAME",(trackKey&&strlen(trackKey))?trackKey:featureFileName, no_unit_norming?"Euclidean":"Normed Euclidean"); |
314 | 324 |
315 INTSTRINGIFY(queryPoint, qPosStr); | 325 INTSTRINGIFY(queryPoint, qPosStr); |
316 INTSTRINGIFY(pointNN, pointNNStr); | 326 INTSTRINGIFY(pointNN, pointNNStr); |
317 INTSTRINGIFY(trackNN, trackNNStr); | 327 INTSTRINGIFY(trackNN, trackNNStr); |
318 INTSTRINGIFY(sequenceLength, seqLenStr); | 328 INTSTRINGIFY(sequenceLength, seqLenStr); |
319 DOUBLESTRINGIFY(absolute_threshold, absolute_thresholdStr); | 329 DOUBLESTRINGIFY(absolute_threshold, absolute_thresholdStr); |
320 DOUBLESTRINGIFY(radius, radiusStr); | 330 DOUBLESTRINGIFY(radius, radiusStr); |
321 | 331 |
322 // WS queries only support 1-nearest neighbour point reporting | |
323 // at the moment, until we figure out how to better serve results | |
324 snprintf(qtypeStr, 256, "nsequence"); | 332 snprintf(qtypeStr, 256, "nsequence"); |
325 const char *argv[]={ | 333 const char *argv[]={ |
326 "./audioDB", | 334 "./audioDB", |
327 COM_QUERY, | 335 COM_QUERY, |
328 qtypeStr, | 336 qtypeStr, |
342 radiusStr, | 350 radiusStr, |
343 COM_SEQLEN, | 351 COM_SEQLEN, |
344 seqLenStr, | 352 seqLenStr, |
345 COM_ABSOLUTE_THRESH, | 353 COM_ABSOLUTE_THRESH, |
346 absolute_thresholdStr, | 354 absolute_thresholdStr, |
347 lsh_exact?COM_LSH_EXACT:"" | 355 lsh_exact?COM_LSH_EXACT:"", |
356 no_unit_norming?COM_NO_UNIT_NORMING:"", | |
348 }; | 357 }; |
349 | 358 |
350 const unsigned argc = 22; | 359 const unsigned argc = 23; |
351 | 360 |
352 | 361 |
353 try { | 362 try { |
354 audioDB(argc, argv, &adbQueryResponse); | 363 audioDB(argc, argv, &adbQueryResponse); |
355 return SOAP_OK; | 364 return SOAP_OK; |
358 return SOAP_FAULT; | 367 return SOAP_FAULT; |
359 } | 368 } |
360 } | 369 } |
361 | 370 |
362 // Query an audioDB database by vector (serialized) | 371 // Query an audioDB database by vector (serialized) |
363 int adb__shingleQuery(struct soap* soap, xsd__string dbName, struct adb__queryVector qVector, xsd__string keyList, xsd__string timesFileName, xsd__int queryType, xsd__int queryPos, xsd__int pointNN, xsd__int trackNN, xsd__int sequenceLength, xsd__double radius, xsd__double absolute_threshold, xsd__double relative_threshold, xsd__int exhaustive, xsd__int lsh_exact, struct adb__queryResponse &adbQueryResponse){ | 372 int adb__shingleQuery(struct soap* soap, xsd__string dbName, struct adb__queryVector qVector, xsd__string keyList, xsd__string timesFileName, xsd__int queryType, xsd__int queryPos, xsd__int pointNN, xsd__int trackNN, xsd__int sequenceLength, xsd__double radius, xsd__double absolute_threshold, xsd__double relative_threshold, xsd__int exhaustive, xsd__int lsh_exact, xsd__int no_unit_norming, struct adb__queryResponse &adbQueryResponse){ |
364 | 373 |
365 // open a tmp file on the server, write shingle, query as a file with query point 0 | 374 // open a tmp file on the server, write shingle, query as a file with query point 0 |
366 // and shingle length l/dim | 375 // and shingle length l/dim |
367 char tmpFileName[] = "/tmp/adb_XXXXXX"; | 376 char tmpFileName[] = "/tmp/adb_XXXXXX"; |
368 int tmpFid = mkstemp(tmpFileName); | 377 int tmpFid = mkstemp(tmpFileName); |
420 if(!sequenceLength) | 429 if(!sequenceLength) |
421 sequenceLength = qVector.__sizev/qVector.dim; | 430 sequenceLength = qVector.__sizev/qVector.dim; |
422 | 431 |
423 int retVal = adb__query(soap, dbName, tmpFileName, keyList, timesFileName, qVector.__sizep?tmpFileName2:0, | 432 int retVal = adb__query(soap, dbName, tmpFileName, keyList, timesFileName, qVector.__sizep?tmpFileName2:0, |
424 queryType, queryPos, pointNN, trackNN, sequenceLength, radius, | 433 queryType, queryPos, pointNN, trackNN, sequenceLength, radius, |
425 absolute_threshold, relative_threshold, exhaustive, lsh_exact, adbQueryResponse); | 434 absolute_threshold, relative_threshold, exhaustive, lsh_exact, no_unit_norming, adbQueryResponse); |
426 | 435 |
427 return retVal; | 436 return retVal; |
428 } | 437 } |
429 | 438 |
430 /* Server loop */ | 439 /* Server loop */ |