thenetcircle/faiss4j

Is this wrapper working?

Opened this issue · 8 comments

I follow the documentation and got everything right except the "error: method finalize() is already defined in class RangeSearchPartialResult". Then I commented the first finalize() method in com/thenetcircle/services/faiss/RangeSearchPartialResult.java and re-run the Test command, this time is compiles right and throw this error while loading the shared library:


T E S T S

Running com.thenetcircle.services.faiss4j.tests.Examples
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.371 sec <<< FAILURE! - in com.thenetcircle.services.faiss4j.tests.Examples
com.thenetcircle.services.faiss4j.tests.Examples Time elapsed: 0.37 sec <<< ERROR!

java.lang.UnsatisfiedLinkError: /data/zhaohh/soft/faiss4j/swigfaiss4j.so: 
/data/zhaohh/soft/faiss4j/swigfaiss4j.so: undefined symbol: _ZTIN5faiss9IndexFlatE
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.thenetcircle.services.faiss4j.tests.Examples.load(Examples.java:25)

Results :

Tests in error:
Examples.load:25 » UnsatisfiedLink /data/zhaohh/soft/faiss4j/swigfaiss4j.so: /...

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

I can't figure out what went wrong, can somebody help me in here ?

Sorry for the late reply.
I guess I missed one part in test

LD_LIBRARY_PATH=. mvn test -Dtest=com.thenetcircle.services.faiss4j.tests.Examples#testLib

this is run in root path of the project and the faiss so files should also be placed here.

please let me know if this helps.

This is exactly where I ran the test command, the project root, and swigfaiss4j.so is indeed there. I still got this error.
And there is no testLib method in com.thenetcircle.services.faiss4j.tests.Examples.java

libfaiss.a and libfaiss.so, you might find it in /usr/local/lib/, and please cp both to project root.

I also follow the instruction and get this error.
I found generated RangeSearchPartialResult.java file is not the same with original.

diff --git a/src/main/java/com/thenetcircle/services/faiss/RangeSearchPartialResult.java b/src/main/java/com/thenetcircle/services
index b322ae1..ab26209 100644
--- a/src/main/java/com/thenetcircle/services/faiss/RangeSearchPartialResult.java
+++ b/src/main/java/com/thenetcircle/services/faiss/RangeSearchPartialResult.java
@@ -61,9 +61,9 @@ public class RangeSearchPartialResult extends BufferList {
     return new SWIGTYPE_p_faiss__RangeSearchPartialResult__QueryResult(swigfaissJNI.RangeSearchPartialResult_new_result(swigCPtr,
   }

-//  public void finalize() {
-//    swigfaissJNI.RangeSearchPartialResult_finalize(swigCPtr, this);
-//  }
+  public void finalize() {
+    swigfaissJNI.RangeSearchPartialResult_finalize(swigCPtr, this);
+  }

   public void set_lims() {
     swigfaissJNI.RangeSearchPartialResult_set_lims(swigCPtr, this);

Then I roll back this file and this error solved.

I also follow the instruction and get this error.
I found generated RangeSearchPartialResult.java file is not the same with original.

diff --git a/src/main/java/com/thenetcircle/services/faiss/RangeSearchPartialResult.java b/src/main/java/com/thenetcircle/services
index b322ae1..ab26209 100644
--- a/src/main/java/com/thenetcircle/services/faiss/RangeSearchPartialResult.java
+++ b/src/main/java/com/thenetcircle/services/faiss/RangeSearchPartialResult.java
@@ -61,9 +61,9 @@ public class RangeSearchPartialResult extends BufferList {
     return new SWIGTYPE_p_faiss__RangeSearchPartialResult__QueryResult(swigfaissJNI.RangeSearchPartialResult_new_result(swigCPtr,
   }

-//  public void finalize() {
-//    swigfaissJNI.RangeSearchPartialResult_finalize(swigCPtr, this);
-//  }
+  public void finalize() {
+    swigfaissJNI.RangeSearchPartialResult_finalize(swigCPtr, this);
+  }

   public void set_lims() {
     swigfaissJNI.RangeSearchPartialResult_set_lims(swigCPtr, this);

Then I roll back this file and this error solved.

I found two finalize() method in this file.

23 protected void finalize() {
24 delete();
25 }

64 public void finalize() {
65 swigfaissJNI.RangeSearchPartialResult_finalize(swigCPtr, this);
66 }

Maybe this is the reason for that. But I don't know which is the right.

Hi, I follow the documentation and also get flowing error:

java.lang.UnsatisfiedLinkError: /data/zhaohh/soft/faiss4j/swigfaiss4j.so: 
/data/zhaohh/soft/faiss4j/swigfaiss4j.so: undefined symbol: _ZTIN5faiss9IndexFlatE
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.thenetcircle.services.faiss4j.tests.Examples.load(Examples.java:25)

Could you please give me your docker images? @Baineng

Hi, I follow the documentation and also get flowing error:

java.lang.UnsatisfiedLinkError: /data/zhaohh/soft/faiss4j/swigfaiss4j.so: 
/data/zhaohh/soft/faiss4j/swigfaiss4j.so: undefined symbol: _ZTIN5faiss9IndexFlatE
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.thenetcircle.services.faiss4j.tests.Examples.load(Examples.java:25)

Could you please give me your docker images? @Baineng

Hi, Mr Zhang, did you build faiss with source of version 1.5.0?
I haven't tested any other version's source.

libfaiss.a and libfaiss.so, you might find it in /usr/local/lib/, and please cp both to project root.

I done this, but I still got the error too.
"undefined symbol: _ZTIN5faiss9IndexFlatE"