Mercurial > hg > audiodb
comparison soap.cpp @ 314:b671a46873c2
working SIIGRAPH08 version. Fixed powerTable mmap memory leak in WS calls (only showed up in big databases). Implements radius queries over WS with new wsdl file
author | mas01mc |
---|---|
date | Tue, 12 Aug 2008 01:21:44 +0000 |
parents | f9dde18f556a |
children | 25572f1bd37f c93be2f3a674 |
comparison
equal
deleted
inserted
replaced
313:f9dde18f556a | 314:b671a46873c2 |
---|---|
52 | 52 |
53 // WS_QUERY_BY_KEY (CLIENT SIDE) | 53 // WS_QUERY_BY_KEY (CLIENT SIDE) |
54 void audioDB::ws_query_by_key(const char*dbName, const char *trackKey, const char* hostport){ | 54 void audioDB::ws_query_by_key(const char*dbName, const char *trackKey, const char* hostport){ |
55 struct soap soap; | 55 struct soap soap; |
56 adb__queryResponse adbQueryResponse; | 56 adb__queryResponse adbQueryResponse; |
57 adb__sequenceQueryParms asqp; | 57 /* JUST TRY TO USE A DATA STRUCTURE WITH PHP |
58 | 58 adb__sequenceQueryParms asqp; |
59 asqp.keyList = (char*)trackFileName; | 59 asqp.keyList = (char*)trackFileName; |
60 asqp.timesFileName = (char*)timesFileName; | 60 asqp.timesFileName = (char*)timesFileName; |
61 asqp.queryPoint = queryPoint; | 61 asqp.queryPoint = queryPoint; |
62 asqp.pointNN = pointNN; | 62 asqp.pointNN = pointNN; |
63 asqp.trackNN = trackNN; | 63 asqp.trackNN = trackNN; |
64 asqp.sequenceLength = sequenceLength; | 64 asqp.sequenceLength = sequenceLength; |
65 asqp.radius = radius; | 65 asqp.radius = radius; |
66 asqp.relative_threshold = relative_threshold; | 66 asqp.relative_threshold = relative_threshold; |
67 asqp.absolute_threshold = absolute_threshold; | 67 asqp.absolute_threshold = absolute_threshold; |
68 asqp.usingQueryPoint = usingQueryPoint; | 68 asqp.usingQueryPoint = usingQueryPoint; |
69 asqp.lsh_exact = lsh_exact; | 69 asqp.lsh_exact = lsh_exact; |
70 */ | |
70 | 71 |
71 soap_init(&soap); | 72 soap_init(&soap); |
72 if(queryType==O2_SEQUENCE_QUERY || queryType==O2_N_SEQUENCE_QUERY){ | 73 if(queryType==O2_SEQUENCE_QUERY || queryType==O2_N_SEQUENCE_QUERY){ |
73 if(soap_call_adb__sequenceQuery_by_key(&soap,hostport,NULL,(char*)dbName,(char*)trackKey,queryType,&asqp,adbQueryResponse)==SOAP_OK){ | 74 if(soap_call_adb__sequenceQueryByKey(&soap,hostport,NULL, |
75 (char*)dbName, | |
76 (char*)trackKey, | |
77 queryType, | |
78 (char*)trackFileName, | |
79 (char*)timesFileName, | |
80 queryPoint, | |
81 pointNN, | |
82 trackNN, | |
83 sequenceLength, | |
84 radius, | |
85 absolute_threshold, | |
86 usingQueryPoint, | |
87 lsh_exact, | |
88 adbQueryResponse)==SOAP_OK){ | |
74 //std::std::cerr << "result list length:" << adbQueryResponse.result.__sizeRlist << std::std::endl; | 89 //std::std::cerr << "result list length:" << adbQueryResponse.result.__sizeRlist << std::std::endl; |
75 for(int i=0; i<adbQueryResponse.result.__sizeRlist; i++) | 90 for(int i=0; i<adbQueryResponse.result.__sizeRlist; i++) |
76 std::cout << adbQueryResponse.result.Rlist[i] << " " << adbQueryResponse.result.Dist[i] | 91 std::cout << adbQueryResponse.result.Rlist[i] << " " << adbQueryResponse.result.Dist[i] |
77 << " " << adbQueryResponse.result.Qpos[i] << " " << adbQueryResponse.result.Spos[i] << std::endl; | 92 << " " << adbQueryResponse.result.Qpos[i] << " " << adbQueryResponse.result.Spos[i] << std::endl; |
78 } | 93 } |
160 soap_receiver_fault(soap, err, ""); | 175 soap_receiver_fault(soap, err, ""); |
161 return SOAP_FAULT; | 176 return SOAP_FAULT; |
162 } | 177 } |
163 } | 178 } |
164 | 179 |
165 // A sequence query using radius and a query key | 180 int adb__sequenceQueryByKey(struct soap* soap,xsd__string dbName, |
166 int adb__sequenceQuery_by_key(struct soap* soap, xsd__string dbName, xsd__string qKey, int qType, | 181 xsd__string trackKey, |
167 adb__sequenceQueryParms* parms, | 182 xsd__int queryType, |
168 adb__queryResponse& adbQueryResponse) { | 183 xsd__string trackFileName, |
169 | 184 xsd__string timesFileName, |
185 xsd__int queryPoint, | |
186 xsd__int pointNN, | |
187 xsd__int trackNN, | |
188 xsd__int sequenceLength, | |
189 xsd__double radius, | |
190 xsd__double absolute_threshold, | |
191 xsd__int usingQueryPoint, | |
192 xsd__int lsh_exact, | |
193 struct adb__queryResponse& adbQueryResponse){ | |
170 char radiusStr[256]; | 194 char radiusStr[256]; |
171 char qPosStr[256]; | 195 char qPosStr[256]; |
172 char pointNNStr[256]; | 196 char pointNNStr[256]; |
173 char trackNNStr[256]; | 197 char trackNNStr[256]; |
174 char seqLenStr[256]; | 198 char seqLenStr[256]; |
175 char relative_thresholdStr[256]; | |
176 char absolute_thresholdStr[256]; | 199 char absolute_thresholdStr[256]; |
177 char qtypeStr[256]; | 200 char qtypeStr[256]; |
178 | 201 |
179 /* When the branch is merged, move this to a header and use it | 202 /* When the branch is merged, move this to a header and use it |
180 elsewhere */ | 203 elsewhere */ |
181 #define INTSTRINGIFY(val, str) \ | 204 #define INTSTRINGIFY(val, str) \ |
182 snprintf(str, 256, "%d", val); | 205 snprintf(str, 256, "%d", val); |
183 #define DOUBLESTRINGIFY(val, str) \ | 206 #define DOUBLESTRINGIFY(val, str) \ |
184 snprintf(str, 256, "%f", val); | 207 snprintf(str, 256, "%f", val); |
185 | 208 |
186 INTSTRINGIFY(parms->queryPoint, qPosStr); | 209 INTSTRINGIFY(queryPoint, qPosStr); |
187 INTSTRINGIFY(parms->pointNN, pointNNStr); | 210 INTSTRINGIFY(pointNN, pointNNStr); |
188 INTSTRINGIFY(parms->trackNN, trackNNStr); | 211 INTSTRINGIFY(trackNN, trackNNStr); |
189 INTSTRINGIFY(parms->sequenceLength, seqLenStr); | 212 INTSTRINGIFY(sequenceLength, seqLenStr); |
190 | 213 DOUBLESTRINGIFY(absolute_threshold, absolute_thresholdStr); |
191 DOUBLESTRINGIFY(parms->relative_threshold, relative_thresholdStr); | 214 DOUBLESTRINGIFY(radius, radiusStr); |
192 DOUBLESTRINGIFY(parms->absolute_threshold, absolute_thresholdStr); | |
193 DOUBLESTRINGIFY(parms->radius, radiusStr); | |
194 | 215 |
195 // WS queries only support 1-nearest neighbour point reporting | 216 // WS queries only support 1-nearest neighbour point reporting |
196 // at the moment, until we figure out how to better serve results | 217 // at the moment, until we figure out how to better serve results |
197 snprintf(qtypeStr, 256, "nsequence"); | 218 snprintf(qtypeStr, 256, "nsequence"); |
198 | |
199 const char *argv[]={ | 219 const char *argv[]={ |
200 "./audioDB", | 220 "./audioDB", |
201 COM_QUERY, | 221 COM_QUERY, |
202 qtypeStr, | 222 qtypeStr, |
203 COM_DATABASE, | 223 COM_DATABASE, |
204 dbName, | 224 dbName, |
205 COM_QUERYKEY, | 225 COM_QUERYKEY, |
206 ENSURE_STRING(qKey), | 226 ENSURE_STRING(trackKey), |
207 COM_KEYLIST, | 227 COM_KEYLIST, |
208 ENSURE_STRING(parms->keyList), | 228 ENSURE_STRING(trackFileName), |
209 parms->usingQueryPoint?COM_QPOINT:COM_EXHAUSTIVE, | 229 usingQueryPoint?COM_QPOINT:COM_EXHAUSTIVE, |
210 parms->usingQueryPoint?qPosStr:"", | 230 usingQueryPoint?qPosStr:"", |
211 COM_POINTNN, | 231 COM_POINTNN, |
212 pointNNStr, | 232 pointNNStr, |
213 COM_TRACKNN, | 233 COM_TRACKNN, |
214 trackNNStr, | 234 trackNNStr, |
215 COM_RADIUS, | 235 COM_RADIUS, |
216 radiusStr, | 236 radiusStr, |
217 COM_SEQLEN, | 237 COM_SEQLEN, |
218 seqLenStr, | 238 seqLenStr, |
219 COM_ABSOLUTE_THRESH, | 239 COM_ABSOLUTE_THRESH, |
220 absolute_thresholdStr, | 240 absolute_thresholdStr, |
221 parms->lsh_exact?COM_LSH_EXACT:"" | 241 lsh_exact?COM_LSH_EXACT:"" |
222 }; | 242 }; |
223 | 243 |
224 const unsigned argc = 22; | 244 const unsigned argc = 22; |
225 | 245 |
226 | 246 |