These are chat archives for bytedeco/sbt-javacpp

Mar 2017
Michaël Benesty
Mar 19 2017 16:36

I did some test, and it seems most of the function are working, the only thing remaining is this code:

void getNnsByItem(AnnoyIndexInterface<int,float> *ptr, int item, int n,
                  int search_k, int *result, float *distances) {
  vector<int> resultV;
  vector<float> distancesV;
  ptr->get_nns_by_item(item, n, search_k, &resultV, &distancesV);
  std::copy(resultV.begin(), resultV.end(), result);
  std::copy(distancesV.begin(), distancesV.end(), distances);

Basically result and distancesare two float[] I send from Java full of 0s. And they are supposed to be rewritten by the CPP part with the generated result. When I call this function it is not rewritten, like nothing happen. Because all the other functions are working I think there is something to change in the preset. The very same function works in JNA (called in the very same way). Have you any idea how I can fix the preset?

Second question, Annoy is the standard in machine learning to make near neighboor vector search (looking for a similar vector in a very large vector database), I think it would be a great thing to share this preset directly in the repository of JavaCpp, right now I am not using anything other than Build and the preset, is it mandatory to have this build script show in the Wiki? ( Is it just about compiling? Is it possible I do it from Java as I am doing right now (with Build)?
Michaël Benesty
Mar 19 2017 16:43

So to be clear, the sbt-javacpp and sbt-javacv plugins are for projects that use JavaCPP and Presets
Building JavaCPP or writing a JavaCPP preset is a different workflow that requires a bunch of other stuff (see the JavaCPP Preset stuff in the Maven build for details, but it includes for instance writing a build script).

Yep I think I misunderstood what the plugin is doing. Thanks for highlighting this point

Samuel Audet
Mar 19 2017 22:33
If you are mapping int* and float* using IntPointer and FloatPointer, you'll need to call get() on them to get the output.
Sure, contributions are welcome, please send a pull request!
I'm not sure what you mean by "Build". Are you saying you are building this from an IDE? If so, yes please use a script instead.