diff soap.cpp @ 308:896679d8cc39

Added server-side loading of persistent index (LSH hashtables) via --load_index -d dbName -R radius -l sequenceLength. Queries using these parameters will lookup the memory-resident hashtable instead of loading one from disk.
author mas01mc
date Thu, 07 Aug 2008 01:53:38 +0000
parents d1b8b2dec37e
children 435ffdaecae9
line wrap: on
line diff
--- a/soap.cpp	Wed Aug 06 21:23:14 2008 +0000
+++ b/soap.cpp	Thu Aug 07 01:53:38 2008 +0000
@@ -28,6 +28,7 @@
   soap_done(&soap);
 }
 
+// WS_QUERY (CLIENT SIDE)
 void audioDB::ws_query(const char*dbName, const char *featureFileName, const char* hostport){
   struct soap soap;
   adb__queryResponse adbQueryResponse;  
@@ -49,6 +50,7 @@
   soap_done(&soap);
 }
 
+// WS_QUERY_BY_KEY (CLIENT SIDE)
 void audioDB::ws_query_by_key(const char*dbName, const char *trackKey, const char* hostport){
   struct soap soap;
   adb__queryResponse adbQueryResponse;  
@@ -95,9 +97,8 @@
     return SOAP_FAULT;
   }
 }
-
+ 
 // Literal translation of command line to web service
-
 int adb__query(struct soap* soap, xsd__string dbName, xsd__string qKey, xsd__string keyList, xsd__string timesFileName, xsd__int qType, xsd__int qPos, xsd__int pointNN, xsd__int trackNN, xsd__int seqLen, adb__queryResponse &adbQueryResponse){
   char queryType[256];
   for(int k=0; k<256; k++)
@@ -246,6 +247,18 @@
   else
     {
       fprintf(stderr, "Socket connection successful: master socket = %d\n", m);
+      // Make a global Web Services LSH Index (SINGLETON)
+      if(WS_load_index && dbName && index_exists(dbName, radius, sequenceLength)){
+	char* indexName = index_get_name(dbName, radius, sequenceLength);
+	fprintf(stderr, "Loading LSH hashtables: %s...\n", indexName);
+	lsh = new LSH(indexName, true);
+	assert(lsh);
+	SERVER_LSH_INDEX_SINGLETON = lsh;
+	fprintf(stderr, "LSH INDEX READY\n");
+	fflush(stderr);
+	delete[] indexName;
+      }
+
       for (int i = 1; ; i++)
 	{
 	  s = soap_accept(&soap);