changeset 522:dad3d252462a multiprobeLSH

Fixed upper-limit (T) boundary error in MultiProbe::generatePerturbationSets(x, T). Setting this too high spins algorithm1 into infinite heap allocations without possiblity of terminating. This is now silently capped at --lsh_k * 2; the algorithm halts up to this threshold.
author mas01mc
date Tue, 27 Jan 2009 14:52:28 +0000
parents 237d5a03d317
children 83e37b76b483
files Makefile lshlib.cpp multiprobe.cpp
diffstat 3 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Jan 27 03:49:19 2009 +0000
+++ b/Makefile	Tue Jan 27 14:52:28 2009 +0000
@@ -22,6 +22,9 @@
 # set to DUMP hashtables on QUERY load
 #override CFLAGS+=-DLSH_DUMP_CORE_TABLES
 
+# set to increase multiple probes in LSH QUERY (allowable range = 1 ... lsh_k*2)
+#override CFLAGS+=-DLSH_MULTI_PROBE_COUNT=10
+
 ifeq ($(shell uname),Linux)
 override CFLAGS+=-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
 endif
--- a/lshlib.cpp	Tue Jan 27 03:49:19 2009 +0000
+++ b/lshlib.cpp	Tue Jan 27 14:52:28 2009 +0000
@@ -558,14 +558,14 @@
 
 // point retrieval routine
 void G::retrieve_point(vector<float>& v, Uns32T qpos, ReporterCallbackPtr add_point, void* caller){
-  assert(LSH_MULTI_PROBE_COUNT);
+  //  assert(LSH_MULTI_PROBE_COUNT);
   calling_instance = caller;
   add_point_callback = add_point;
   H::compute_hash_functions( v );
   for(Uns32T j = 0 ; j < H::L ; j++ ){
     // MultiProbe loop    
     multiProbePtr->generatePerturbationSets( *( H::boundaryDistances + j ) , 2*H::k, (unsigned)LSH_MULTI_PROBE_COUNT);
-    for(Uns32T multiProbeIdx = 0 ; multiProbeIdx < LSH_MULTI_PROBE_COUNT+1 ; multiProbeIdx++ ){
+    for(Uns32T multiProbeIdx = 0 ; multiProbeIdx < multiProbePtr->size()+1 ; multiProbeIdx++ ){
       if(!multiProbeIdx)	
 	H::generate_hash_keys( *( H::g + j ), *( H::r1 + j ), *( H::r2 + j ) ); 
       else
--- a/multiprobe.cpp	Tue Jan 27 03:49:19 2009 +0000
+++ b/multiprobe.cpp	Tue Jan 27 14:52:28 2009 +0000
@@ -116,10 +116,10 @@
 
   min_heap_element mhe = minHeap->top();
 
+  if(T>distFuns->size())
+    T = distFuns->size();
   for(unsigned i = 0 ; i != T ; i++ ){
     do{
-      if(minHeap->empty())
-	break;
       mhe = minHeap->top();
       ai = mhe.perturbs;
       ai_score = mhe.score;