Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Annoy Presets
// Targeted by JavaCPP version 1.2: DO NOT EDIT THIS FILE
package org.bytedeco.javacpp;
import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
public class annoy extends org.bytedeco.javacpp.presets.annoy {
static { Loader.load(); }
// Parsed from annoylib.h
// Copyright (c) 2013 Spotify AB
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
// #ifndef ANNOYLIB_H
// #define ANNOYLIB_H
// #include <stdio.h>
// #include <string>
// #include <sys/stat.h>
// #include <unistd.h>
// #include <stdio.h>
// #include <stdlib.h>
// #include <sys/types.h>
// #include <fcntl.h>
// #include <stddef.h>
// #include <stdint.h>
// #ifdef __MINGW32__
// #include "mman.h"
// #include <windows.h>
// #else
// #include <sys/mman.h>
// #endif
// #include <string.h>
// #include <math.h>
// #include <vector>
// #include <algorithm>
// #include <queue>
// #include <limits>
// This allows others to supply their own logger / error printer without
// requiring Annoy to import their headers. See RcppAnnoy for a use case.
// #ifndef __ERROR_PRINTER_OVERRIDE__
// #define showUpdate(...) { fprintf(stderr, __VA_ARGS__ ); }
// #else
// #define showUpdate(...) { __ERROR_PRINTER_OVERRIDE__( __VA_ARGS__ ); }
// #endif
// #ifndef ANNOY_NODE_ATTRIBUTE
// #define ANNOY_NODE_ATTRIBUTE __attribute__((__packed__))
// #define ANNOY_NODE_ATTRIBUTE
// TODO: this is turned on by default, but may not work for all architectures! Need to investigate.
// #endif
public static class RandRandom extends Pointer {
static { Loader.load(); }
/** Default native constructor. */
public RandRandom() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public RandRandom(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public RandRandom(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public RandRandom position(long position) {
return (RandRandom)super.position(position);
}
// Default implementation of annoy-specific random number generator that uses rand() from standard library.
// Owned by the AnnoyIndex, passed around to the distance metrics
public native int flip();
public native @Cast("size_t") long index(@Cast("size_t") long n);
}
public static class Angular extends Pointer {
static { Loader.load(); }
/** Default native constructor. */
public Angular() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public Angular(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public Angular(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public Angular position(long position) {
return (Angular)super.position(position);
}
public static native @Cast("const char*") BytePointer name();
}
public static class Euclidean extends Pointer {
static { Loader.load(); }
/** Default native constructor. */
public Euclidean() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public Euclidean(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public Euclidean(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public Euclidean position(long position) {
return (Euclidean)super.position(position);
}
public static native @Cast("const char*") BytePointer name();
}
public static class AnnoyIndexInterface extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public AnnoyIndexInterface(Pointer p) { super(p); }
public native void add_item(int item, @Const FloatPointer w);
public native void add_item(int item, @Const FloatBuffer w);
public native void add_item(int item, @Const float[] w);
public native void build(int q);
public native @Cast("bool") boolean save(@Cast("const char*") BytePointer filename);
public native @Cast("bool") boolean save(String filename);
public native void unload();
public native @Cast("bool") boolean load(@Cast("const char*") BytePointer filename);
public native @Cast("bool") boolean load(String filename);
public native float get_distance(int i, int j);
public native void get_nns_by_item(int item, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector IntPointer result, @StdVector FloatPointer distances);
public native void get_nns_by_item(int item, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector IntBuffer result, @StdVector FloatBuffer distances);
public native void get_nns_by_item(int item, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector int[] result, @StdVector float[] distances);
public native void get_nns_by_vector(@Const FloatPointer w, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector IntPointer result, @StdVector FloatPointer distances);
public native void get_nns_by_vector(@Const FloatBuffer w, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector IntBuffer result, @StdVector FloatBuffer distances);
public native void get_nns_by_vector(@Const float[] w, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector int[] result, @StdVector float[] distances);
public native int get_n_items();
public native void verbose(@Cast("bool") boolean v);
public native void get_item(int item, FloatPointer v);
public native void get_item(int item, FloatBuffer v);
public native void get_item(int item, float[] v);
}
@NoOffset public static class AnnoyIndex extends AnnoyIndexInterface {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public AnnoyIndex(Pointer p) { super(p); }
public AnnoyIndex(int f) { super((Pointer)null); allocate(f); }
private native void allocate(int f);
public native int get_f();
public native void add_item(int item, @Const FloatPointer w);
public native void add_item(int item, @Const FloatBuffer w);
public native void add_item(int item, @Const float[] w);
public native void build(int q);
public native @Cast("bool") boolean save(@Cast("const char*") BytePointer filename);
public native @Cast("bool") boolean save(String filename);
public native void reinitialize();
public native void unload();
public native @Cast("bool") boolean load(@Cast("const char*") BytePointer filename);
public native @Cast("bool") boolean load(String filename);
public native float get_distance(int i, int j);
public native void get_nns_by_item(int item, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector IntPointer result, @StdVector FloatPointer distances);
public native void get_nns_by_item(int item, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector IntBuffer result, @StdVector FloatBuffer distances);
public native void get_nns_by_item(int item, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector int[] result, @StdVector float[] distances);
public native void get_nns_by_vector(@Const FloatPointer w, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector IntPointer result, @StdVector FloatPointer distances);
public native void get_nns_by_vector(@Const FloatBuffer w, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector IntBuffer result, @StdVector FloatBuffer distances);
public native void get_nns_by_vector(@Const float[] w, @Cast("size_t") long n, @Cast("size_t") long search_k, @StdVector int[] result, @StdVector float[] distances);
public native int get_n_items();
public native void verbose(@Cast("bool") boolean v);
public native void get_item(int item, FloatPointer v);
public native void get_item(int item, FloatBuffer v);
public native void get_item(int item, float[] v);
}
// #endif
// vim: tabstop=2 shiftwidth=2
}
package org.bytedeco.javacpp.presets;
import org.bytedeco.javacpp.annotation.*;
import org.bytedeco.javacpp.tools.*;
@Properties(target="org.bytedeco.javacpp.annoy", value={@Platform(include="annoylib.h", link="z@.1")})
public class annoy implements InfoMapper {
public void map(InfoMap infoMap) {
infoMap
.put(new Info("AnnoyIndexInterface<int, float>").pointerTypes("AnnoyIndexInterface").define())
.put(new Info("AnnoyIndex<int, float, Euclidean, Kiss64Random>").pointerTypes("AnnoyIndex").base("AnnoyIndexInterface").define())
;
}
}
// Copyright (c) 2013 Spotify AB
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#ifndef ANNOYLIB_H
#define ANNOYLIB_H
#include <stdio.h>
#include <string>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __MINGW32__
#include "mman.h"
#include <windows.h>
#else
#include <sys/mman.h>
#endif
#include <string.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <limits>
// This allows others to supply their own logger / error printer without
// requiring Annoy to import their headers. See RcppAnnoy for a use case.
#ifndef __ERROR_PRINTER_OVERRIDE__
#define showUpdate(...) { fprintf(stderr, __VA_ARGS__ ); }
#else
#define showUpdate(...) { __ERROR_PRINTER_OVERRIDE__( __VA_ARGS__ ); }
#endif
#ifndef ANNOY_NODE_ATTRIBUTE
// #define ANNOY_NODE_ATTRIBUTE __attribute__((__packed__))
#define ANNOY_NODE_ATTRIBUTE
// TODO: this is turned on by default, but may not work for all architectures! Need to investigate.
#endif
using std::vector;
using std::string;
using std::pair;
using std::numeric_limits;
using std::make_pair;
struct RandRandom {
// Default implementation of annoy-specific random number generator that uses rand() from standard library.
// Owned by the AnnoyIndex, passed around to the distance metrics
inline int flip() {
// Draw random 0 or 1
return rand() & 1;
}
inline size_t index(size_t n) {
// Draw random integer between 0 and n-1 where n is at most the number of data points you have
return rand() % n;
}
};
template<typename T>
inline T get_norm(T* v, int f) {
T sq_norm = 0;
for (int z = 0; z < f; z++)
sq_norm += v[z] * v[z];
return sqrt(sq_norm);
}
template<typename T>
inline void normalize(T* v, int f) {
T norm = get_norm(v, f);
for (int z = 0; z < f; z++)
v[z] /= norm;
}
template<typename T, typename Random, typename Distance, typename Node>
inline void two_means(const vector<Node*>& nodes, int f, Random& random, bool cosine, T* iv, T* jv) {
/*
This algorithm is a huge heuristic. Empirically it works really well, but I
can't motivate it well. The basic idea is to keep two centroids and assign
points to either one of them. We weight each centroid by the number of points
assigned to it, so to balance it.
*/
static int iteration_steps = 200;
size_t count = nodes.size();
size_t i = random.index(count);
size_t j = random.index(count-1);
j += (j >= i); // ensure that i != j
std::copy(&nodes[i]->v[0], &nodes[i]->v[f], &iv[0]);
std::copy(&nodes[j]->v[0], &nodes[j]->v[f], &jv[0]);
if (cosine) { normalize(&iv[0], f); normalize(&jv[0], f); }
int ic = 1, jc = 1;
for (int l = 0; l < iteration_steps; l++) {
size_t k = random.index(count);
T di = ic * Distance::distance(&iv[0], nodes[k]->v, f),
dj = jc * Distance::distance(&jv[0], nodes[k]->v, f);
T norm = cosine ? get_norm(nodes[k]->v, f) : 1.0;
if (di < dj) {
for (int z = 0; z < f; z++)
iv[z] = (iv[z] * ic + nodes[k]->v[z] / norm) / (ic + 1);
ic++;
} else if (dj < di) {
for (int z = 0; z < f; z++)
jv[z] = (jv[z] * jc + nodes[k]->v[z] / norm) / (jc + 1);
jc++;
}
}
}
struct Angular {
template<typename S, typename T>
struct ANNOY_NODE_ATTRIBUTE Node {
/*
* We store a binary tree where each node has two things
* - A vector associated with it
* - Two children
* All nodes occupy the same amount of memory
* All nodes with n_descendants == 1 are leaf nodes.
* A memory optimization is that for nodes with 2 <= n_descendants <= K,
* we skip the vector. Instead we store a list of all descendants. K is
* determined by the number of items that fits in the space of the vector.
* For nodes with n_descendants == 1 the vector is a data point.
* For nodes with n_descendants > K the vector is the normal of the split plane.
* Note that we can't really do sizeof(node<T>) because we cheat and allocate
* more memory to be able to fit the vector outside
*/
S n_descendants;
S children[2]; // Will possibly store more than 2
T v[1]; // We let this one overflow intentionally. Need to allocate at least 1 to make GCC happy
};
template<typename T>
static inline T distance(const T* x, const T* y, int f) {
// want to calculate (a/|a| - b/|b|)^2
// = a^2 / a^2 + b^2 / b^2 - 2ab/|a||b|
// = 2 - 2cos
T pp = 0, qq = 0, pq = 0;
for (int z = 0; z < f; z++, x++, y++) {
pp += (*x) * (*x);
qq += (*y) * (*y);
pq += (*x) * (*y);
}
T ppqq = pp * qq;
if (ppqq > 0) return 2.0 - 2.0 * pq / sqrt(ppqq);
else return 2.0; // cos is 0
}
template<typename S, typename T>
static inline T margin(const Node<S, T>* n, const T* y, int f) {
T dot = 0;
for (int z = 0; z < f; z++)
dot += n->v[z] * y[z];
return dot;
}
template<typename S, typename T, typename Random>
static inline bool side(const Node<S, T>* n, const T* y, int f, Random& random) {
T dot = margin(n, y, f);
if (dot != 0)
return (dot > 0);
else
return random.flip();
}
template<typename S, typename T, typename Random>
static inline void create_split(const vector<Node<S, T>*>& nodes, int f, Random& random, Node<S, T>* n) {
vector<T> best_iv(f, 0), best_jv(f, 0); // TODO: avoid allocation
two_means<T, Random, Angular, Node<S, T> >(nodes, f, random, true, &best_iv[0], &best_jv[0]);
for (int z = 0; z < f; z++)
n->v[z] = best_iv[z] - best_jv[z];
normalize(n->v, f);
}
template<typename T>
static inline T normalized_distance(T distance) {
// Used when requesting distances from Python layer
// Turns out sometimes the squared distance is -0.0
// so we have to make sure it's a positive number.
return sqrt(std::max(distance, T(0)));
}
static const char* name() {
return "angular";
}
};
struct Euclidean {
template<typename S, typename T>
struct ANNOY_NODE_ATTRIBUTE Node {
S n_descendants;
T a; // need an extra constant term to determine the offset of the plane
S children[2];
T v[1];
};
template<typename T>
static inline T distance(const T* x, const T* y, int f) {
T d = 0.0;
for (int i = 0; i < f; i++, x++, y++)
d += ((*x) - (*y)) * ((*x) - (*y));
return d;
}
template<typename S, typename T>
static inline T margin(const Node<S, T>* n, const T* y, int f) {
T dot = n->a;
for (int z = 0; z < f; z++)
dot += n->v[z] * y[z];
return dot;
}
template<typename S, typename T, typename Random>
static inline bool side(const Node<S, T>* n, const T* y, int f, Random& random) {
T dot = margin(n, y, f);
if (dot != 0)
return (dot > 0);
else
return random.flip();
}
template<typename S, typename T, typename Random>
static inline void create_split(const vector<Node<S, T>*>& nodes, int f, Random& random, Node<S, T>* n) {
vector<T> best_iv(f, 0), best_jv(f, 0);
two_means<T, Random, Euclidean, Node<S, T> >(nodes, f, random, false, &best_iv[0], &best_jv[0]);
for (int z = 0; z < f; z++)
n->v[z] = best_iv[z] - best_jv[z];
normalize(n->v, f);
n->a = 0.0;
for (int z = 0; z < f; z++)
n->a += -n->v[z] * (best_iv[z] + best_jv[z]) / 2;
}
template<typename T>
static inline T normalized_distance(T distance) {
return sqrt(std::max(distance, T(0)));
}
static const char* name() {
return "euclidean";
}
};
template<typename S, typename T>
class AnnoyIndexInterface {
public:
virtual ~AnnoyIndexInterface() {};
virtual void add_item(S item, const T* w) = 0;
virtual void build(int q) = 0;
virtual bool save(const char* filename) = 0;
virtual void unload() = 0;
virtual bool load(const char* filename) = 0;
virtual T get_distance(S i, S j) = 0;
virtual void get_nns_by_item(S item, size_t n, size_t search_k, vector<S>* result, vector<T>* distances) = 0;
virtual void get_nns_by_vector(const T* w, size_t n, size_t search_k, vector<S>* result, vector<T>* distances) = 0;
virtual S get_n_items() = 0;
virtual void verbose(bool v) = 0;
virtual void get_item(S item, T* v) = 0;
};
template<typename S, typename T, typename Distance, typename Random>
class AnnoyIndex : public AnnoyIndexInterface<S, T> {
/*
* We use random projection to build a forest of binary trees of all items.
* Basically just split the hyperspace into two sides by a hyperplane,
* then recursively split each of those subtrees etc.
* We create a tree like this q times. The default q is determined automatically
* in such a way that we at most use 2x as much memory as the vectors take.
*/
public:
typedef Distance D;
typedef typename D::template Node<S, T> Node;
protected:
const int _f;
size_t _s;
S _n_items;
Random _random;
void* _nodes; // Could either be mmapped, or point to a memory buffer that we reallocate
S _n_nodes;
S _nodes_size;
vector<S> _roots;
S _K;
bool _loaded;
bool _verbose;
int _fd;
public:
AnnoyIndex(int f) : _f(f), _random() {
_s = offsetof(Node, v) + f * sizeof(T); // Size of each node
_verbose = false;
_K = (_s - offsetof(Node, children)) / sizeof(S); // Max number of descendants to fit into node
reinitialize(); // Reset everything
}
~AnnoyIndex() {
unload();
}
int get_f() const {
return _f;
}
void add_item(S item, const T* w) {
add_item_impl(item, w);
}
template<typename W>
void add_item_impl(S item, const W& w) {
_allocate_size(item + 1);
Node* n = _get(item);
n->children[0] = 0;
n->children[1] = 0;
n->n_descendants = 1;
for (int z = 0; z < _f; z++)
n->v[z] = w[z];
if (item >= _n_items)
_n_items = item + 1;
}
void build(int q) {
if (_loaded) {
// TODO: throw exception
showUpdate("You can't build a loaded index\n");
return;
}
_n_nodes = _n_items;
while (1) {
if (q == -1 && _n_nodes >= _n_items * 2)
break;
if (q != -1 && _roots.size() >= (size_t)q)
break;
if (_verbose) showUpdate("pass %zd...\n", _roots.size());
vector<S> indices;
for (S i = 0; i < _n_items; i++)
indices.push_back(i);
_roots.push_back(_make_tree(indices));
}
// Also, copy the roots into the last segment of the array
// This way we can load them faster without reading the whole file
_allocate_size(_n_nodes + (S)_roots.size());
for (size_t i = 0; i < _roots.size(); i++)
memcpy(_get(_n_nodes + (S)i), _get(_roots[i]), _s);
_n_nodes += _roots.size();
if (_verbose) showUpdate("has %d nodes\n", _n_nodes);
}
bool save(const char* filename) {
FILE *f = fopen(filename, "wb");
if (f == NULL)
return false;
fwrite(_nodes, _s, _n_nodes, f);
fclose(f);
unload();
return load(filename);
}
void reinitialize() {
_fd = 0;
_nodes = NULL;
_loaded = false;
_n_items = 0;
_n_nodes = 0;
_nodes_size = 0;
_roots.clear();
}
void unload() {
if (_fd) {
// we have mmapped data
close(_fd);
off_t size = _n_nodes * _s;
munmap(_nodes, size);
} else if (_nodes) {
// We have heap allocated data
free(_nodes);
}
reinitialize();
if (_verbose) showUpdate("unloaded\n");
}
bool load(const char* filename) {
_fd = open(filename, O_RDONLY, (mode_t)0400);
if (_fd == -1)
return false;
off_t size = lseek(_fd, 0, SEEK_END);
#ifdef MAP_POPULATE
_nodes = (Node*)mmap(
0, size, PROT_READ, MAP_SHARED | MAP_POPULATE, _fd, 0);
#else
_nodes = (Node*)mmap(
0, size, PROT_READ, MAP_SHARED, _fd, 0);
#endif
_n_nodes = (S)(size / _s);
// Find the roots by scanning the end of the file and taking the nodes with most descendants
S m = -1;
for (S i = _n_nodes - 1; i >= 0; i--) {
S k = _get(i)->n_descendants;
if (m == -1 || k == m) {
_roots.push_back(i);
m = k;
} else {
break;
}
}
// hacky fix: since the last root precedes the copy of all roots, delete it
if (_roots.size() > 1 && _get(_roots.front())->children[0] == _get(_roots.back())->children[0])
_roots.pop_back();
_loaded = true;
_n_items = m;
if (_verbose) showUpdate("found %lu roots with degree %d\n", _roots.size(), m);
return true;
}
T get_distance(S i, S j) {
const T* x = _get(i)->v;
const T* y = _get(j)->v;
return D::distance(x, y, _f);
}
void get_nns_by_item(S item, size_t n, size_t search_k, vector<S>* result, vector<T>* distances) {
const Node* m = _get(item);
_get_all_nns(m->v, n, search_k, result, distances);
}
void get_nns_by_vector(const T* w, size_t n, size_t search_k, vector<S>* result, vector<T>* distances) {
_get_all_nns(w, n, search_k, result, distances);
}
S get_n_items() {
return _n_items;
}
void verbose(bool v) {
_verbose = v;
}
void get_item(S item, T* v) {
Node* m = _get(item);
std::copy(&m->v[0], &m->v[_f], v);
}
protected:
void _allocate_size(S n) {
if (n > _nodes_size) {
const double reallocation_factor = 1.3;
S new_nodes_size = std::max(n,
(S)((_nodes_size + 1) * reallocation_factor));
if (_verbose) showUpdate("Reallocating to %d nodes\n", new_nodes_size);
_nodes = realloc(_nodes, _s * new_nodes_size);
memset((char *)_nodes + (_nodes_size * _s)/sizeof(char), 0, (new_nodes_size - _nodes_size) * _s);
_nodes_size = new_nodes_size;
}
}
inline Node* _get(S i) {
return (Node*)((uint8_t *)_nodes + (_s * i));
}
S _make_tree(const vector<S >& indices) {
if (indices.size() == 1)
return indices[0];
if (indices.size() <= (size_t)_K) {
_allocate_size(_n_nodes + 1);
S item = _n_nodes++;
Node* m = _get(item);
m->n_descendants = (S)indices.size();
// Using std::copy instead of a loop seems to resolve issues #3 and #13,
// probably because gcc 4.8 goes overboard with optimizations.
std::copy(indices.begin(), indices.end(), m->children);
return item;
}
vector<Node*> children;
for (size_t i = 0; i < indices.size(); i++) {
S j = indices[i];
Node* n = _get(j);
if (n)
children.push_back(n);
}
vector<S> children_indices[2];
Node* m = (Node*)malloc(_s); // TODO: avoid
D::create_split(children, _f, _random, m);
for (size_t i = 0; i < indices.size(); i++) {
S j = indices[i];
Node* n = _get(j);
if (n) {
bool side = D::side(m, n->v, _f, _random);
children_indices[side].push_back(j);
}
}
// If we didn't find a hyperplane, just randomize sides as a last option
while (children_indices[0].size() == 0 || children_indices[1].size() == 0) {
if (_verbose && indices.size() > 100000)
showUpdate("Failed splitting %lu items\n", indices.size());
children_indices[0].clear();
children_indices[1].clear();
// Set the vector to 0.0
for (int z = 0; z < _f; z++)
m->v[z] = 0.0;
for (size_t i = 0; i < indices.size(); i++) {
S j = indices[i];
// Just randomize...
children_indices[_random.flip()].push_back(j);
}
}
int flip = (children_indices[0].size() > children_indices[1].size());
m->n_descendants = (S)indices.size();
for (int side = 0; side < 2; side++)
// run _make_tree for the smallest child first (for cache locality)
m->children[side^flip] = _make_tree(children_indices[side^flip]);
_allocate_size(_n_nodes + 1);
S item = _n_nodes++;
memcpy(_get(item), m, _s);
free(m);
return item;
}
void _get_all_nns(const T* v, size_t n, size_t search_k, vector<S>* result, vector<T>* distances) {
std::priority_queue<pair<T, S> > q;
if (search_k == (size_t)-1)
search_k = n * _roots.size(); // slightly arbitrary default value
for (size_t i = 0; i < _roots.size(); i++) {
q.push(make_pair(numeric_limits<T>::infinity(), _roots[i]));
}
vector<S> nns;
while (nns.size() < search_k && !q.empty()) {
const pair<T, S>& top = q.top();
T d = top.first;
S i = top.second;
Node* nd = _get(i);
q.pop();
if (nd->n_descendants == 1) {
nns.push_back(i);
} else if (nd->n_descendants <= _K) {
const S* dst = nd->children;
nns.insert(nns.end(), dst, &dst[nd->n_descendants]);
} else {
T margin = D::margin(nd, v, _f);
q.push(make_pair(std::min(d, +margin), nd->children[1]));
q.push(make_pair(std::min(d, -margin), nd->children[0]));
}
}
// Get distances for all items
// To avoid calculating distance multiple times for any items, sort by id
sort(nns.begin(), nns.end());
vector<pair<T, S> > nns_dist;
S last = -1;
for (size_t i = 0; i < nns.size(); i++) {
S j = nns[i];
if (j == last)
continue;
last = j;
nns_dist.push_back(make_pair(D::distance(v, _get(j)->v, _f), j));
}
size_t m = nns_dist.size();
size_t p = n < m ? n : m; // Return this many items
std::partial_sort(&nns_dist[0], &nns_dist[p], &nns_dist[m]);
for (size_t i = 0; i < p; i++) {
if (distances)
distances->push_back(D::normalized_distance(nns_dist[i].first));
result->push_back(nns_dist[i].second);
}
}
};
#endif
// vim: tabstop=2 shiftwidth=2
// Generated by JavaCPP version 1.2: DO NOT EDIT THIS FILE
#ifdef _WIN32
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT __declspec(dllexport)
#define JNIIMPORT __declspec(dllimport)
#define JNICALL __stdcall
typedef int jint;
typedef long long jlong;
typedef signed char jbyte;
#elif defined(__GNUC__)
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT __attribute__((visibility("default")))
#define JNIIMPORT
#define JNICALL
typedef int jint;
typedef long long jlong;
typedef signed char jbyte;
#endif
#include <jni.h>
#ifdef ANDROID
#include <android/log.h>
#elif defined(__APPLE__) && defined(__OBJC__)
#include <TargetConditionals.h>
#include <Foundation/Foundation.h>
#endif
#if defined(ANDROID) || TARGET_OS_IPHONE
#define NewWeakGlobalRef(obj) NewGlobalRef(obj)
#define DeleteWeakGlobalRef(obj) DeleteGlobalRef(obj)
#endif
#include <limits.h>
#include <stddef.h>
#ifndef _WIN32
#include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <exception>
#include <memory>
#include <new>
#if defined(NATIVE_ALLOCATOR) && defined(NATIVE_DEALLOCATOR)
void* operator new(std::size_t size, const std::nothrow_t&) throw() {
return NATIVE_ALLOCATOR(size);
}
void* operator new[](std::size_t size, const std::nothrow_t&) throw() {
return NATIVE_ALLOCATOR(size);
}
void* operator new(std::size_t size) throw(std::bad_alloc) {
return NATIVE_ALLOCATOR(size);
}
void* operator new[](std::size_t size) throw(std::bad_alloc) {
return NATIVE_ALLOCATOR(size);
}
void operator delete(void* ptr) throw() {
NATIVE_DEALLOCATOR(ptr);
}
void operator delete[](void* ptr) throw() {
NATIVE_DEALLOCATOR(ptr);
}
#endif
#define jlong_to_ptr(a) ((void*)(uintptr_t)(a))
#define ptr_to_jlong(a) ((jlong)(uintptr_t)(a))
#if defined(_MSC_VER)
#define JavaCPP_noinline __declspec(noinline)
#define JavaCPP_hidden /* hidden by default */
#elif defined(__GNUC__)
#define JavaCPP_noinline __attribute__((noinline))
#define JavaCPP_hidden __attribute__((visibility("hidden")))
#else
#define JavaCPP_noinline
#define JavaCPP_hidden
#endif
#include "annoylib.h"
static JavaVM* JavaCPP_vm = NULL;
static bool JavaCPP_haveAllocObject = false;
static bool JavaCPP_haveNonvirtual = false;
static const char* JavaCPP_classNames[24] = {
"org/bytedeco/javacpp/Pointer",
"org/bytedeco/javacpp/BytePointer",
"org/bytedeco/javacpp/ShortPointer",
"org/bytedeco/javacpp/IntPointer",
"org/bytedeco/javacpp/LongPointer",
"org/bytedeco/javacpp/FloatPointer",
"org/bytedeco/javacpp/DoublePointer",
"org/bytedeco/javacpp/CharPointer",
"org/bytedeco/javacpp/PointerPointer",
"org/bytedeco/javacpp/BoolPointer",
"org/bytedeco/javacpp/CLongPointer",
"org/bytedeco/javacpp/SizeTPointer",
"java/lang/String",
"org/bytedeco/javacpp/Pointer$NativeDeallocator",
"org/bytedeco/javacpp/Loader",
"java/nio/Buffer",
"java/lang/Object",
"java/lang/NullPointerException",
"java/lang/RuntimeException",
"org/bytedeco/javacpp/annoy$AnnoyIndex",
"org/bytedeco/javacpp/annoy$AnnoyIndexInterface",
"org/bytedeco/javacpp/annoy$Euclidean",
"org/bytedeco/javacpp/annoy$Angular",
"org/bytedeco/javacpp/annoy$RandRandom" };
static jclass JavaCPP_classes[24] = { NULL };
static jfieldID JavaCPP_addressFID = NULL;
static jfieldID JavaCPP_positionFID = NULL;
static jfieldID JavaCPP_limitFID = NULL;
static jfieldID JavaCPP_capacityFID = NULL;
static jfieldID JavaCPP_deallocatorFID = NULL;
static jfieldID JavaCPP_ownerAddressFID = NULL;
static jmethodID JavaCPP_initMID = NULL;
static jmethodID JavaCPP_arrayMID = NULL;
static jmethodID JavaCPP_stringMID = NULL;
static jmethodID JavaCPP_getBytesMID = NULL;
static jmethodID JavaCPP_toStringMID = NULL;
static inline void JavaCPP_log(const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
#ifdef ANDROID
__android_log_vprint(ANDROID_LOG_ERROR, "javacpp", fmt, ap);
#elif defined(__APPLE__) && defined(__OBJC__)
NSLogv([NSString stringWithUTF8String:fmt], ap);
#else
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
#endif
va_end(ap);
}
static JavaCPP_noinline jclass JavaCPP_getClass(JNIEnv* env, int i) {
if (JavaCPP_classes[i] == NULL && env->PushLocalFrame(1) == 0) {
jclass cls = env->FindClass(JavaCPP_classNames[i]);
if (cls == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error loading class %s.", JavaCPP_classNames[i]);
return NULL;
}
JavaCPP_classes[i] = (jclass)env->NewWeakGlobalRef(cls);
if (JavaCPP_classes[i] == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error creating global reference of class %s.", JavaCPP_classNames[i]);
return NULL;
}
env->PopLocalFrame(NULL);
}
return JavaCPP_classes[i];
}
static JavaCPP_noinline jfieldID JavaCPP_getFieldID(JNIEnv* env, int i, const char* name, const char* sig) {
jclass cls = JavaCPP_getClass(env, i);
if (cls == NULL) {
return NULL;
}
jfieldID fid = env->GetFieldID(cls, name, sig);
if (fid == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error getting field ID of %s/%s", JavaCPP_classNames[i], name);
return NULL;
}
return fid;
}
static JavaCPP_noinline jmethodID JavaCPP_getMethodID(JNIEnv* env, int i, const char* name, const char* sig) {
jclass cls = JavaCPP_getClass(env, i);
if (cls == NULL) {
return NULL;
}
jmethodID mid = env->GetMethodID(cls, name, sig);
if (mid == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error getting method ID of %s/%s", JavaCPP_classNames[i], name);
return NULL;
}
return mid;
}
static JavaCPP_noinline jmethodID JavaCPP_getStaticMethodID(JNIEnv* env, int i, const char* name, const char* sig) {
jclass cls = JavaCPP_getClass(env, i);
if (cls == NULL) {
return NULL;
}
jmethodID mid = env->GetStaticMethodID(cls, name, sig);
if (mid == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error getting static method ID of %s/%s", JavaCPP_classNames[i], name);
return NULL;
}
return mid;
}
static JavaCPP_noinline jobject JavaCPP_createPointer(JNIEnv* env, int i, jclass cls = NULL) {
if (cls == NULL && (cls = JavaCPP_getClass(env, i)) == NULL) {
return NULL;
}
if (JavaCPP_haveAllocObject) {
return env->AllocObject(cls);
} else {
jmethodID mid = env->GetMethodID(cls, "<init>", "(Lorg/bytedeco/javacpp/Pointer;)V");
if (mid == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error getting Pointer constructor of %s, while VM does not support AllocObject()", JavaCPP_classNames[i]);
return NULL;
}
return env->NewObject(cls, mid, NULL);
}
}
static JavaCPP_noinline void JavaCPP_initPointer(JNIEnv* env, jobject obj, const void* ptr, long long size, void* owner, void (*deallocator)(void*)) {
if (deallocator != NULL) {
jvalue args[4];
args[0].j = ptr_to_jlong(ptr);
args[1].j = (jlong)size;
args[2].j = ptr_to_jlong(owner);
args[3].j = ptr_to_jlong(deallocator);
if (JavaCPP_haveNonvirtual) {
env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 0), JavaCPP_initMID, args);
} else {
env->CallVoidMethodA(obj, JavaCPP_initMID, args);
}
} else {
env->SetLongField(obj, JavaCPP_addressFID, ptr_to_jlong(ptr));
env->SetLongField(obj, JavaCPP_limitFID, (jlong)size);
env->SetLongField(obj, JavaCPP_capacityFID, (jlong)size);
}
}
static JavaCPP_noinline jstring JavaCPP_createString(JNIEnv* env, const char* ptr) {
if (ptr == NULL) {
return NULL;
}
#ifdef MODIFIED_UTF8_STRING
return env->NewStringUTF(ptr);
#else
size_t length = strlen(ptr);
jbyteArray bytes = env->NewByteArray(length < INT_MAX ? length : INT_MAX);
env->SetByteArrayRegion(bytes, 0, length < INT_MAX ? length : INT_MAX, (signed char*)ptr);
return (jstring)env->NewObject(JavaCPP_getClass(env, 12), JavaCPP_stringMID, bytes);
#endif
}
static JavaCPP_noinline const char* JavaCPP_getStringBytes(JNIEnv* env, jstring str) {
if (str == NULL) {
return NULL;
}
#ifdef MODIFIED_UTF8_STRING
return env->GetStringUTFChars(str, NULL);
#else
jbyteArray bytes = (jbyteArray)env->CallObjectMethod(str, JavaCPP_getBytesMID);
if (bytes == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error getting bytes from string.");
return NULL;
}
jsize length = env->GetArrayLength(bytes);
signed char* ptr = new (std::nothrow) signed char[length + 1];
if (ptr != NULL) {
env->GetByteArrayRegion(bytes, 0, length, ptr);
ptr[length] = 0;
}
return (const char*)ptr;
#endif
}
static JavaCPP_noinline void JavaCPP_releaseStringBytes(JNIEnv* env, jstring str, const char* ptr) {
#ifdef MODIFIED_UTF8_STRING
if (str != NULL) {
env->ReleaseStringUTFChars(str, ptr);
}
#else
delete[] ptr;
#endif
}
class JavaCPP_hidden JavaCPP_exception : public std::exception {
public:
JavaCPP_exception(const char* str) throw() {
if (str == NULL) {
strcpy(msg, "Unknown exception.");
} else {
strncpy(msg, str, sizeof(msg));
msg[sizeof(msg) - 1] = 0;
}
}
virtual const char* what() const throw() { return msg; }
char msg[1024];
};
#ifndef GENERIC_EXCEPTION_CLASS
#define GENERIC_EXCEPTION_CLASS std::exception
#endif
static JavaCPP_noinline jthrowable JavaCPP_handleException(JNIEnv* env, int i) {
jstring str = NULL;
try {
throw;
} catch (GENERIC_EXCEPTION_CLASS& e) {
str = JavaCPP_createString(env, e.what());
} catch (...) {
str = JavaCPP_createString(env, "Unknown exception.");
}
jmethodID mid = JavaCPP_getMethodID(env, i, "<init>", "(Ljava/lang/String;)V");
if (mid == NULL) {
return NULL;
}
return (jthrowable)env->NewObject(JavaCPP_getClass(env, i), mid, str);
}
static JavaCPP_noinline void* JavaCPP_getPointerOwner(JNIEnv* env, jobject obj) {
if (obj != NULL) {
jobject deallocator = env->GetObjectField(obj, JavaCPP_deallocatorFID);
if (deallocator != NULL && env->IsInstanceOf(deallocator, JavaCPP_getClass(env, 13))) {
return jlong_to_ptr(env->GetLongField(deallocator, JavaCPP_ownerAddressFID));
}
}
return NULL;
}
#include <vector>
template<typename P, typename T = P> class JavaCPP_hidden VectorAdapter {
public:
VectorAdapter(const P* ptr, typename std::vector<T>::size_type size, void* owner) : ptr((P*)ptr), size(size), owner(owner),
vec2(ptr ? std::vector<T>((P*)ptr, (P*)ptr + size) : std::vector<T>()), vec(vec2) { }
VectorAdapter(const std::vector<T>& vec) : ptr(0), size(0), owner(0), vec2(vec), vec(vec2) { }
VectorAdapter( std::vector<T>& vec) : ptr(0), size(0), owner(0), vec(vec) { }
VectorAdapter(const std::vector<T>* vec) : ptr(0), size(0), owner(0), vec(*(std::vector<T>*)vec) { }
void assign(P* ptr, typename std::vector<T>::size_type size, void* owner) {
this->ptr = ptr;
this->size = size;
this->owner = owner;
vec.assign(ptr, ptr + size);
}
static void deallocate(void* owner) { operator delete(owner); }
operator P*() {
if (vec.size() > size) {
ptr = (P*)(operator new(sizeof(P) * vec.size(), std::nothrow_t()));
}
if (ptr) {
std::copy(vec.begin(), vec.end(), ptr);
}
size = vec.size();
owner = ptr;
return ptr;
}
operator const P*() { return &vec[0]; }
operator std::vector<T>&() { return vec; }
operator std::vector<T>*() { return ptr ? &vec : 0; }
P* ptr;
typename std::vector<T>::size_type size;
void* owner;
std::vector<T> vec2;
std::vector<T>& vec;
};
#include <string>
class JavaCPP_hidden StringAdapter {
public:
StringAdapter(const char* ptr, size_t size, void* owner) : ptr((char*)ptr), size(size), owner(owner),
str2(ptr ? (char*)ptr : "", ptr ? (size > 0 ? size : strlen((char*)ptr)) : 0), str(str2) { }
StringAdapter(const signed char* ptr, size_t size, void* owner) : ptr((char*)ptr), size(size), owner(owner),
str2(ptr ? (char*)ptr : "", ptr ? (size > 0 ? size : strlen((char*)ptr)) : 0), str(str2) { }
StringAdapter(const unsigned char* ptr, size_t size, void* owner) : ptr((char*)ptr), size(size), owner(owner),
str2(ptr ? (char*)ptr : "", ptr ? (size > 0 ? size : strlen((char*)ptr)) : 0), str(str2) { }
StringAdapter(const std::string& str) : ptr(0), size(0), owner(0), str2(str), str(str2) { }
StringAdapter( std::string& str) : ptr(0), size(0), owner(0), str(str) { }
StringAdapter(const std::string* str) : ptr(0), size(0), owner(0), str(*(std::string*)str) { }
void assign(char* ptr, size_t size, void* owner) {
this->ptr = ptr;
this->size = size;
this->owner = owner;
str.assign(ptr ? ptr : "", ptr ? (size > 0 ? size : strlen((char*)ptr)) : 0);
}
void assign(const char* ptr, size_t size, void* owner) { assign((char*)ptr, size, owner); }
void assign(const signed char* ptr, size_t size, void* owner) { assign((char*)ptr, size, owner); }
void assign(const unsigned char* ptr, size_t size, void* owner) { assign((char*)ptr, size, owner); }
static void deallocate(void* owner) { delete[] (char*)owner; }
operator char*() {
const char* data = str.data();
if (str.size() > size) {
ptr = new (std::nothrow) char[str.size()+1];
if (ptr) memset(ptr, 0, str.size()+1);
}
if (ptr && memcmp(ptr, data, str.size()) != 0) {
memcpy(ptr, data, str.size());
if (size > str.size()) ptr[str.size()] = 0;
}
size = str.size();
owner = ptr;
return ptr;
}
operator signed char*() { return (signed char*)(operator char*)(); }
operator unsigned char*() { return (unsigned char*)(operator char*)(); }
operator const char*() { return str.c_str(); }
operator const signed char*() { return (signed char*)str.c_str(); }
operator const unsigned char*() { return (unsigned char*)str.c_str(); }
operator std::string&() { return str; }
operator std::string*() { return ptr ? &str : 0; }
char* ptr;
size_t size;
void* owner;
std::string str2;
std::string& str;
};
#ifdef SHARED_PTR_NAMESPACE
template<class T> class SharedPtrAdapter {
public:
typedef SHARED_PTR_NAMESPACE::shared_ptr<T> S;
SharedPtrAdapter(const T* ptr, size_t size, void* owner) : ptr((T*)ptr), size(size), owner(owner),
sharedPtr2(owner != NULL && owner != ptr ? *(S*)owner : S((T*)ptr)), sharedPtr(sharedPtr2) { }
SharedPtrAdapter(const S& sharedPtr) : ptr(0), size(0), owner(0), sharedPtr2(sharedPtr), sharedPtr(sharedPtr2) { }
SharedPtrAdapter( S& sharedPtr) : ptr(0), size(0), owner(0), sharedPtr(sharedPtr) { }
void assign(T* ptr, size_t size, S* owner) {
this->ptr = ptr;
this->size = size;
this->owner = owner;
this->sharedPtr = owner != NULL && owner != ptr ? *(S*)owner : S((T*)ptr);
}
static void deallocate(void* owner) { delete (S*)owner; }
operator T*() {
ptr = sharedPtr.get();
if (owner == NULL || owner == ptr) {
owner = new S(sharedPtr);
}
return ptr;
}
operator const T*() { return sharedPtr.get(); }
operator S&() { return sharedPtr; }
operator S*() { return ptr ? &sharedPtr : 0; }
T* ptr;
size_t size;
void* owner;
S sharedPtr2;
S& sharedPtr;
};
#endif
static JavaCPP_noinline void JavaCPP_detach(bool detach) {
if (detach && JavaCPP_vm->DetachCurrentThread() != JNI_OK) {
JavaCPP_log("Could not detach the JavaVM from the current thread.");
}
}
static JavaCPP_noinline bool JavaCPP_getEnv(JNIEnv** env) {
bool attached = false;
JavaVM *vm = JavaCPP_vm;
if (vm == NULL) {
JavaCPP_log("Could not get any created JavaVM.");
*env = NULL;
return false;
}
if (vm->GetEnv((void**)env, JNI_VERSION_1_4) != JNI_OK) {
struct {
JNIEnv **env;
operator JNIEnv**() { return env; } // Android JNI
operator void**() { return (void**)env; } // standard JNI
} env2 = { env };
if (vm->AttachCurrentThread(env2, NULL) != JNI_OK) {
JavaCPP_log("Could not attach the JavaVM to the current thread.");
*env = NULL;
return false;
}
attached = true;
}
if (JavaCPP_vm == NULL) {
if (JNI_OnLoad(vm, NULL) < 0) {
JavaCPP_detach(attached);
*env = NULL;
return false;
}
}
return attached;
}
class JavaCPP_hidden JavaCPP__0003a_0003aAnnoyIndexInterface : public ::AnnoyIndexInterface {
public:
jobject obj;
static jmethodID verbose__Z;
static jmethodID build__I;
static jmethodID get_1distance__II;
static jmethodID get_1nns_1by_1item__IJJLorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_FloatPointer_2;
static jmethodID get_1nns_1by_1vector__Lorg_bytedeco_javacpp_FloatPointer_2JJLorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_FloatPointer_2;
static jmethodID get_1n_1items__;
static jmethodID get_1item__ILorg_bytedeco_javacpp_FloatPointer_2;
static jmethodID add_1item__ILorg_bytedeco_javacpp_FloatPointer_2;
static jmethodID load__Lorg_bytedeco_javacpp_BytePointer_2;
static jmethodID save__Lorg_bytedeco_javacpp_BytePointer_2;
static jmethodID unload__;
using ::AnnoyIndexInterface::verbose;
virtual void verbose(bool arg0);
void super_verbose(bool arg0) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::build;
virtual void build(int arg0);
void super_build(int arg0) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::get_distance;
virtual float get_distance(int arg0, int arg1);
float super_get_distance(int arg0, int arg1) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::get_nns_by_item;
virtual void get_nns_by_item(int arg0, size_t arg1, size_t arg2, std::vector<int>* arg3, std::vector<float>* arg4);
void super_get_nns_by_item(int arg0, size_t arg1, size_t arg2, std::vector<int>* arg3, std::vector<float>* arg4) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::get_nns_by_vector;
virtual void get_nns_by_vector(const float* arg0, size_t arg1, size_t arg2, std::vector<int>* arg3, std::vector<float>* arg4);
void super_get_nns_by_vector(const float* arg0, size_t arg1, size_t arg2, std::vector<int>* arg3, std::vector<float>* arg4) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::get_n_items;
virtual int get_n_items();
int super_get_n_items() { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::get_item;
virtual void get_item(int arg0, float* arg1);
void super_get_item(int arg0, float* arg1) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::add_item;
virtual void add_item(int arg0, const float* arg1);
void super_add_item(int arg0, const float* arg1) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::load;
virtual bool load(const char* arg0);
bool super_load(const char* arg0) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
using ::AnnoyIndexInterface::save;
virtual bool save(const char* arg0);
bool super_save(const char* arg0) { throw JavaCPP_exception("Cannot call a pure virtual function."); }
JavaCPP__0003a_0003aAnnoyIndexInterface() : ::AnnoyIndexInterface(), obj(NULL) { }
using ::AnnoyIndexInterface::unload;
virtual void unload();
void super_unload() { throw JavaCPP_exception("Cannot call a pure virtual function."); }
};
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::verbose__Z = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::build__I = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::get_1distance__II = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::get_1nns_1by_1item__IJJLorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_FloatPointer_2 = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::get_1nns_1by_1vector__Lorg_bytedeco_javacpp_FloatPointer_2JJLorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_FloatPointer_2 = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::get_1n_1items__ = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::get_1item__ILorg_bytedeco_javacpp_FloatPointer_2 = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::add_1item__ILorg_bytedeco_javacpp_FloatPointer_2 = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::load__Lorg_bytedeco_javacpp_BytePointer_2 = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::save__Lorg_bytedeco_javacpp_BytePointer_2 = NULL;
jmethodID JavaCPP__0003a_0003aAnnoyIndexInterface::unload__ = NULL;
static void JavaCPP_org_bytedeco_javacpp_annoy_00024AnnoyIndex_deallocate(void *p) { delete (::AnnoyIndex*)p; }
static void JavaCPP_org_bytedeco_javacpp_annoy_00024AnnoyIndexInterface_deallocate(void *p) { JNIEnv *e; bool a = JavaCPP_getEnv(&e); if (e != NULL) e->DeleteWeakGlobalRef((jweak)((JavaCPP__0003a_0003aAnnoyIndexInterface*)p)->obj); delete (JavaCPP__0003a_0003aAnnoyIndexInterface*)p; JavaCPP_detach(a); }
static void JavaCPP_org_bytedeco_javacpp_annoy_00024Euclidean_deallocate(void *p) { delete (::Euclidean*)p; }
static void JavaCPP_org_bytedeco_javacpp_annoy_00024Angular_deallocate(void *p) { delete (::Angular*)p; }
static void JavaCPP_org_bytedeco_javacpp_annoy_00024RandRandom_deallocate(void *p) { delete (::RandRandom*)p; }
static void JavaCPP_org_bytedeco_javacpp_BytePointer_deallocateArray(void* p) { delete[] (signed char*)p; }
static void JavaCPP_org_bytedeco_javacpp_ShortPointer_deallocateArray(void* p) { delete[] (short*)p; }
static void JavaCPP_org_bytedeco_javacpp_IntPointer_deallocateArray(void* p) { delete[] (int*)p; }
static void JavaCPP_org_bytedeco_javacpp_LongPointer_deallocateArray(void* p) { delete[] (jlong*)p; }
static void JavaCPP_org_bytedeco_javacpp_FloatPointer_deallocateArray(void* p) { delete[] (float*)p; }
static void JavaCPP_org_bytedeco_javacpp_DoublePointer_deallocateArray(void* p) { delete[] (double*)p; }
static void JavaCPP_org_bytedeco_javacpp_CharPointer_deallocateArray(void* p) { delete[] (unsigned short*)p; }
static void JavaCPP_org_bytedeco_javacpp_PointerPointer_deallocateArray(void* p) { delete[] (void**)p; }
static void JavaCPP_org_bytedeco_javacpp_BoolPointer_deallocateArray(void* p) { delete[] (bool*)p; }
static void JavaCPP_org_bytedeco_javacpp_CLongPointer_deallocateArray(void* p) { delete[] (long*)p; }
static void JavaCPP_org_bytedeco_javacpp_SizeTPointer_deallocateArray(void* p) { delete[] (size_t*)p; }
static void JavaCPP_org_bytedeco_javacpp_annoy_00024AnnoyIndexInterface_deallocateArray(void* p) { delete[] (::AnnoyIndexInterface*)p; }
static void JavaCPP_org_bytedeco_javacpp_annoy_00024Euclidean_deallocateArray(void* p) { delete[] (::Euclidean*)p; }
static void JavaCPP_org_bytedeco_javacpp_annoy_00024Angular_deallocateArray(void* p) { delete[] (::Angular*)p; }
static void JavaCPP_org_bytedeco_javacpp_annoy_00024RandRandom_deallocateArray(void* p) { delete[] (::RandRandom*)p; }
extern "C" {
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
JNIEnv* env;
if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) {
JavaCPP_log("Could not get JNIEnv for JNI_VERSION_1_4 inside JNI_OnLoad().");
return JNI_ERR;
}
if (JavaCPP_vm == vm) {
return env->GetVersion();
}
JavaCPP_vm = vm;
JavaCPP_haveAllocObject = env->functions->AllocObject != NULL;
JavaCPP_haveNonvirtual = env->functions->CallNonvirtualVoidMethodA != NULL;
const char* members[24][1] = {
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" },
{ "sizeof" } };
int offsets[24][1] = {
{ sizeof(void*) },
{ sizeof(signed char) },
{ sizeof(short) },
{ sizeof(int) },
{ sizeof(jlong) },
{ sizeof(float) },
{ sizeof(double) },
{ sizeof(unsigned short) },
{ sizeof(void*) },
{ sizeof(bool) },
{ sizeof(long) },
{ sizeof(size_t) },
{ -1 },
{ -1 },
{ -1 },
{ -1 },
{ -1 },
{ -1 },
{ -1 },
{ sizeof(::AnnoyIndex) },
{ sizeof(::AnnoyIndexInterface) },
{ sizeof(::Euclidean) },
{ sizeof(::Angular) },
{ sizeof(::RandRandom) } };
int memberOffsetSizes[24] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
jmethodID putMemberOffsetMID = JavaCPP_getStaticMethodID(env, 14, "putMemberOffset", "(Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/Class;");
if (putMemberOffsetMID == NULL) {
return JNI_ERR;
}
for (int i = 0; i < 24 && !env->ExceptionCheck(); i++) {
for (int j = 0; j < memberOffsetSizes[i] && !env->ExceptionCheck(); j++) {
if (env->PushLocalFrame(3) == 0) {
jvalue args[3];
args[0].l = env->NewStringUTF(JavaCPP_classNames[i]);
args[1].l = members[i][j] == NULL ? NULL : env->NewStringUTF(members[i][j]);
args[2].i = offsets[i][j];
jclass cls = (jclass)env->CallStaticObjectMethodA(JavaCPP_getClass(env, 14), putMemberOffsetMID, args);
if (cls == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error putting member offsets for class %s.", JavaCPP_classNames[i]);
return JNI_ERR;
}
JavaCPP_classes[i] = (jclass)env->NewWeakGlobalRef(cls);
if (JavaCPP_classes[i] == NULL || env->ExceptionCheck()) {
JavaCPP_log("Error creating global reference of class %s.", JavaCPP_classNames[i]);
return JNI_ERR;
}
env->PopLocalFrame(NULL);
}
}
}
JavaCPP_addressFID = JavaCPP_getFieldID(env, 0, "address", "J");
if (JavaCPP_addressFID == NULL) {
return JNI_ERR;
}
JavaCPP_positionFID = JavaCPP_getFieldID(env, 0, "position", "J");
if (JavaCPP_positionFID == NULL) {
return JNI_ERR;
}
JavaCPP_limitFID = JavaCPP_getFieldID(env, 0, "limit", "J");
if (JavaCPP_limitFID == NULL) {
return JNI_ERR;
}
JavaCPP_capacityFID = JavaCPP_getFieldID(env, 0, "capacity", "J");
if (JavaCPP_capacityFID == NULL) {
return JNI_ERR;
}
JavaCPP_deallocatorFID = JavaCPP_getFieldID(env, 0, "deallocator", "Lorg/bytedeco/javacpp/Pointer$Deallocator;");
if (JavaCPP_deallocatorFID == NULL) {
return JNI_ERR;
}
JavaCPP_ownerAddressFID = JavaCPP_getFieldID(env, 13, "ownerAddress", "J");
if (JavaCPP_ownerAddressFID == NULL) {
return JNI_ERR;
}
JavaCPP_initMID = JavaCPP_getMethodID(env, 0, "init", "(JJJJ)V");
if (JavaCPP_initMID == NULL) {
return JNI_ERR;
}
JavaCPP_arrayMID = JavaCPP_getMethodID(env, 15, "array", "()Ljava/lang/Object;");
if (JavaCPP_arrayMID == NULL) {
return JNI_ERR;
}
JavaCPP_stringMID = JavaCPP_getMethodID(env, 12, "<init>", "([B)V");
if (JavaCPP_stringMID == NULL) {
return JNI_ERR;
}
JavaCPP_getBytesMID = JavaCPP_getMethodID(env, 12, "getBytes", "()[B");
if (JavaCPP_getBytesMID == NULL) {
return JNI_ERR;
}
JavaCPP_toStringMID = JavaCPP_getMethodID(env, 16, "toString", "()Ljava/lang/String;");
if (JavaCPP_toStringMID == NULL) {
return JNI_ERR;
}
return env->GetVersion();
}
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) {
JNIEnv* env;
if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) {
JavaCPP_log("Could not get JNIEnv for JNI_VERSION_1_4 inside JNI_OnUnLoad().");
return;
}
for (int i = 0; i < 24; i++) {
env->DeleteWeakGlobalRef((jweak)JavaCPP_classes[i]);
JavaCPP_classes[i] = NULL;
}
JavaCPP_vm = NULL;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_Pointer_00024NativeDeallocator_deallocate(JNIEnv* env, jobject obj, jlong arg0, jlong arg1) {
void* allocatedAddress = jlong_to_ptr(arg0);
void (*deallocatorAddress)(void*) = (void(*)(void*))jlong_to_ptr(arg1);
if (deallocatorAddress != NULL && allocatedAddress != NULL) {
(*deallocatorAddress)(allocatedAddress);
}
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_Pointer_asDirectBuffer(JNIEnv* env, jobject obj) {
char* ptr = (char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jlong size = env->GetLongField(obj, JavaCPP_limitFID);
size -= position;
jobject rarg = NULL;
char* rptr;
rptr = ptr;
jlong rcapacity = size;
if (rptr != NULL) {
jlong rcapacityptr = rcapacity * sizeof(rptr[0]);
rarg = env->NewDirectByteBuffer((void*)rptr, rcapacityptr < INT_MAX ? rcapacityptr : INT_MAX);
}
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_Pointer_memchr(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jlong arg2) {
char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jobject rarg = NULL;
void* rptr;
rptr = memchr(ptr0, arg1, arg2);
if (rptr == ptr0) {
rarg = arg0;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 0);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_Pointer_memcmp(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) {
char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
char* ptr1 = arg1 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jint rarg = 0;
int rvalue = memcmp(ptr0, ptr1, arg2);
rarg = (jint)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_Pointer_memcpy(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) {
char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
char* ptr1 = arg1 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
void* rptr;
rptr = memcpy(ptr0, ptr1, arg2);
if (rptr == ptr0) {
rarg = arg0;
} else if (rptr == ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 0);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_Pointer_memmove(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) {
char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
char* ptr1 = arg1 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
void* rptr;
rptr = memmove(ptr0, ptr1, arg2);
if (rptr == ptr0) {
rarg = arg0;
} else if (rptr == ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 0);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_Pointer_memset(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jlong arg2) {
char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jobject rarg = NULL;
void* rptr;
rptr = memset(ptr0, arg1, arg2);
if (rptr == ptr0) {
rarg = arg0;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 0);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_Pointer_allocate(JNIEnv* env, jobject obj, jobject arg0) {
char* ptr0 = arg0 == NULL ? NULL : (char*)env->GetDirectBufferAddress(arg0);
void* rptr = ptr0;
jlong rcapacity = 1;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, NULL);
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_BytePointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
signed char* rptr = new (std::nothrow) signed char[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_BytePointer_deallocateArray);
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strchr(JNIEnv* env, jclass cls, jobject arg0, jint arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strchr((char*)ptr0, arg1);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_BytePointer_strcmp(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jint rarg = 0;
int rvalue = strcmp((char*)ptr0, (char*)ptr1);
rarg = (jint)rvalue;
return rarg;
}
JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_BytePointer_strcoll(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jint rarg = 0;
int rvalue = strcoll((char*)ptr0, (char*)ptr1);
rarg = (jint)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strcpy(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strcpy((char*)ptr0, (char*)ptr1);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr == (char*)ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jlong JNICALL Java_org_bytedeco_javacpp_BytePointer_strcspn(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jlong rarg = 0;
size_t rvalue = (size_t)strcspn((char*)ptr0, (char*)ptr1);
rarg = (jlong)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strerror(JNIEnv* env, jclass cls, jint arg0) {
jobject rarg = NULL;
char* rptr;
rptr = (char*)strerror(arg0);
if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strcat(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strcat((char*)ptr0, (char*)ptr1);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr == (char*)ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jlong JNICALL Java_org_bytedeco_javacpp_BytePointer_strlen(JNIEnv* env, jclass cls, jobject arg0) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jlong rarg = 0;
size_t rvalue = (size_t)strlen((char*)ptr0);
rarg = (jlong)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strncat(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strncat((char*)ptr0, (char*)ptr1, (size_t)arg2);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr == (char*)ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_BytePointer_strncmp(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jint rarg = 0;
int rvalue = strncmp((char*)ptr0, (char*)ptr1, (size_t)arg2);
rarg = (jint)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strncpy(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strncpy((char*)ptr0, (char*)ptr1, (size_t)arg2);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr == (char*)ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strpbrk(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strpbrk((char*)ptr0, (char*)ptr1);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr == (char*)ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strrchr(JNIEnv* env, jclass cls, jobject arg0, jint arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strrchr((char*)ptr0, arg1);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jlong JNICALL Java_org_bytedeco_javacpp_BytePointer_strspn(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jlong rarg = 0;
size_t rvalue = (size_t)strspn((char*)ptr0, (char*)ptr1);
rarg = (jlong)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strstr(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strstr((char*)ptr0, (char*)ptr1);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr == (char*)ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_strtok(JNIEnv* env, jclass cls, jobject arg0, jobject arg1) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = NULL;
char* rptr;
rptr = (char*)strtok((char*)ptr0, (char*)ptr1);
if (rptr == (char*)ptr0) {
rarg = arg0;
} else if (rptr == (char*)ptr1) {
rarg = arg1;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 1);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jlong JNICALL Java_org_bytedeco_javacpp_BytePointer_strxfrm(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) {
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jlong rarg = 0;
size_t rvalue = (size_t)strxfrm((char*)ptr0, (char*)ptr1, (size_t)arg2);
rarg = (jlong)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_get___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) {
signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jbyte JNICALL Java_org_bytedeco_javacpp_BytePointer_get__J(JNIEnv* env, jobject obj, jlong arg0) {
signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jbyte rarg = 0;
signed char rvalue = ptr[arg0];
rarg = (jbyte)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_put__JB(JNIEnv* env, jobject obj, jlong arg0, jbyte arg1) {
signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = arg1;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BytePointer_put___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) {
signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_ShortPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
short* rptr = new (std::nothrow) short[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_ShortPointer_deallocateArray);
}
JNIEXPORT jshort JNICALL Java_org_bytedeco_javacpp_ShortPointer_get__J(JNIEnv* env, jobject obj, jlong arg0) {
short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jshort rarg = 0;
short rvalue = ptr[arg0];
rarg = (jshort)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_ShortPointer_get___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) {
short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_ShortPointer_put___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) {
short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_ShortPointer_put__JS(JNIEnv* env, jobject obj, jlong arg0, jshort arg1) {
short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_IntPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
int* rptr = new (std::nothrow) int[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_IntPointer_deallocateArray);
}
JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_IntPointer_get__J(JNIEnv* env, jobject obj, jlong arg0) {
int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jint rarg = 0;
int rvalue = ptr[arg0];
rarg = (jint)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_IntPointer_get___3III(JNIEnv* env, jobject obj, jintArray arg0, jint arg1, jint arg2) {
int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
int* ptr0 = arg0 == NULL ? NULL : (jint*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_IntPointer_put___3III(JNIEnv* env, jobject obj, jintArray arg0, jint arg1, jint arg2) {
int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
int* ptr0 = arg0 == NULL ? NULL : (jint*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_IntPointer_put__JI(JNIEnv* env, jobject obj, jlong arg0, jint arg1) {
int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_LongPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
jlong* rptr = new (std::nothrow) jlong[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_LongPointer_deallocateArray);
}
JNIEXPORT jlong JNICALL Java_org_bytedeco_javacpp_LongPointer_get__J(JNIEnv* env, jobject obj, jlong arg0) {
jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jlong rarg = 0;
jlong rvalue = ptr[arg0];
rarg = (jlong)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_LongPointer_get___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) {
jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_LongPointer_put___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) {
jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_LongPointer_put__JJ(JNIEnv* env, jobject obj, jlong arg0, jlong arg1) {
jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_FloatPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
float* rptr = new (std::nothrow) float[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_FloatPointer_deallocateArray);
}
JNIEXPORT jfloat JNICALL Java_org_bytedeco_javacpp_FloatPointer_get__J(JNIEnv* env, jobject obj, jlong arg0) {
float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jfloat rarg = 0;
float rvalue = ptr[arg0];
rarg = (jfloat)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_FloatPointer_get___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) {
float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_FloatPointer_put___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) {
float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_FloatPointer_put__JF(JNIEnv* env, jobject obj, jlong arg0, jfloat arg1) {
float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_DoublePointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
double* rptr = new (std::nothrow) double[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_DoublePointer_deallocateArray);
}
JNIEXPORT jdouble JNICALL Java_org_bytedeco_javacpp_DoublePointer_get__J(JNIEnv* env, jobject obj, jlong arg0) {
double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jdouble rarg = 0;
double rvalue = ptr[arg0];
rarg = (jdouble)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_DoublePointer_get___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) {
double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_DoublePointer_put___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) {
double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_DoublePointer_put__JD(JNIEnv* env, jobject obj, jlong arg0, jdouble arg1) {
double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_CharPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
unsigned short* rptr = new (std::nothrow) unsigned short[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_CharPointer_deallocateArray);
}
JNIEXPORT jchar JNICALL Java_org_bytedeco_javacpp_CharPointer_get__J(JNIEnv* env, jobject obj, jlong arg0) {
unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jchar rarg = 0;
unsigned short rvalue = ptr[arg0];
rarg = (jchar)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_CharPointer_get___3CII(JNIEnv* env, jobject obj, jcharArray arg0, jint arg1, jint arg2) {
unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
unsigned short* ptr0 = arg0 == NULL ? NULL : (jchar*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_CharPointer_put___3CII(JNIEnv* env, jobject obj, jcharArray arg0, jint arg1, jint arg2) {
unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
unsigned short* ptr0 = arg0 == NULL ? NULL : (jchar*)env->GetPrimitiveArrayCritical(arg0, NULL);
jobject rarg = obj;
memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0));
if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0);
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_CharPointer_put__JC(JNIEnv* env, jobject obj, jlong arg0, jchar arg1) {
unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_PointerPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
void** rptr = new (std::nothrow) void*[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_PointerPointer_deallocateArray);
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_PointerPointer_get(JNIEnv* env, jobject obj, jclass arg0, jlong arg1) {
void** ptr = (void**)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = NULL;
void* rptr;
rptr = ptr[arg1];
if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 0, arg0);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_PointerPointer_put(JNIEnv* env, jobject obj, jlong arg0, jobject arg1) {
void** ptr = (void**)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
char* ptr1 = arg1 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jobject rarg = obj;
ptr[arg0] = ptr1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_BoolPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
bool* rptr = new (std::nothrow) bool[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_BoolPointer_deallocateArray);
}
JNIEXPORT jboolean JNICALL Java_org_bytedeco_javacpp_BoolPointer_get(JNIEnv* env, jobject obj, jlong arg0) {
bool* ptr = (bool*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jboolean rarg = 0;
bool rvalue = (bool)ptr[arg0];
rarg = (jboolean)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_BoolPointer_put(JNIEnv* env, jobject obj, jlong arg0, jboolean arg1) {
bool* ptr = (bool*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = (bool)arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_CLongPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
long* rptr = new (std::nothrow) long[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_CLongPointer_deallocateArray);
}
JNIEXPORT jlong JNICALL Java_org_bytedeco_javacpp_CLongPointer_get(JNIEnv* env, jobject obj, jlong arg0) {
long* ptr = (long*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jlong rarg = 0;
long rvalue = (long)ptr[arg0];
rarg = (jlong)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_CLongPointer_put(JNIEnv* env, jobject obj, jlong arg0, jlong arg1) {
long* ptr = (long*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = (long)arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_SizeTPointer_allocateArray(JNIEnv* env, jobject obj, jlong arg0) {
size_t* rptr = new (std::nothrow) size_t[arg0];
jlong rcapacity = arg0;
JavaCPP_initPointer(env, obj, rptr, rcapacity, rptr, &JavaCPP_org_bytedeco_javacpp_SizeTPointer_deallocateArray);
}
JNIEXPORT jlong JNICALL Java_org_bytedeco_javacpp_SizeTPointer_get(JNIEnv* env, jobject obj, jlong arg0) {
size_t* ptr = (size_t*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jlong rarg = 0;
size_t rvalue = (size_t)ptr[arg0];
rarg = (jlong)rvalue;
return rarg;
}
JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_SizeTPointer_put(JNIEnv* env, jobject obj, jlong arg0, jlong arg1) {
size_t* ptr = (size_t*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = obj;
ptr[arg0] = (size_t)arg1;
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_verbose(JNIEnv* env, jobject obj, jboolean arg0) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jthrowable exc = NULL;
try {
ptr->verbose((bool)arg0);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_build(JNIEnv* env, jobject obj, jint arg0) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jthrowable exc = NULL;
try {
ptr->build(arg0);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT jfloat JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1distance(JNIEnv* env, jobject obj, jint arg0, jint arg1) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jfloat rarg = 0;
jthrowable exc = NULL;
try {
float rvalue = ptr->get_distance(arg0, arg1);
rarg = (jfloat)rvalue;
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (exc != NULL) {
env->Throw(exc);
}
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1nns_1by_1item__IJJLorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_FloatPointer_2(JNIEnv* env, jobject obj, jint arg0, jlong arg1, jlong arg2, jobject arg3, jobject arg4) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
int* ptr3 = arg3 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID));
jlong size3 = arg3 == NULL ? 0 : env->GetLongField(arg3, JavaCPP_limitFID);
void* owner3 = JavaCPP_getPointerOwner(env, arg3);
jlong position3 = arg3 == NULL ? 0 : env->GetLongField(arg3, JavaCPP_positionFID);
ptr3 += position3;
size3 -= position3;
VectorAdapter< int > adapter3(ptr3, size3, owner3);
float* ptr4 = arg4 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg4, JavaCPP_addressFID));
jlong size4 = arg4 == NULL ? 0 : env->GetLongField(arg4, JavaCPP_limitFID);
void* owner4 = JavaCPP_getPointerOwner(env, arg4);
jlong position4 = arg4 == NULL ? 0 : env->GetLongField(arg4, JavaCPP_positionFID);
ptr4 += position4;
size4 -= position4;
VectorAdapter< float > adapter4(ptr4, size4, owner4);
jthrowable exc = NULL;
try {
ptr->get_nns_by_item(arg0, (size_t)arg1, (size_t)arg2, adapter3, adapter4);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
int* rptr3 = adapter3;
jlong rsize3 = (jlong)adapter3.size;
void* rowner3 = adapter3.owner;
if (rptr3 != ptr3) {
JavaCPP_initPointer(env, arg3, rptr3, rsize3, rowner3, &VectorAdapter< int >::deallocate);
} else {
env->SetLongField(arg3, JavaCPP_limitFID, rsize3 + position3);
}
float* rptr4 = adapter4;
jlong rsize4 = (jlong)adapter4.size;
void* rowner4 = adapter4.owner;
if (rptr4 != ptr4) {
JavaCPP_initPointer(env, arg4, rptr4, rsize4, rowner4, &VectorAdapter< float >::deallocate);
} else {
env->SetLongField(arg4, JavaCPP_limitFID, rsize4 + position4);
}
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1nns_1by_1item__IJJLjava_nio_IntBuffer_2Ljava_nio_FloatBuffer_2(JNIEnv* env, jobject obj, jint arg0, jlong arg1, jlong arg2, jobject arg3, jobject arg4) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
int* ptr3 = arg3 == NULL ? NULL : (int*)env->GetDirectBufferAddress(arg3);
jlong size3 = arg3 == NULL ? 0 : env->GetDirectBufferCapacity(arg3);
void* owner3 = (void*)ptr3;
jintArray arr3 = NULL;
if (arg3 != NULL && ptr3 == NULL) {
arr3 = (jintArray)env->CallObjectMethod(arg3, JavaCPP_arrayMID);
if (env->ExceptionOccurred() != NULL) {
env->ExceptionClear();
} else {
ptr3 = arr3 == NULL ? NULL : env->GetIntArrayElements(arr3, NULL);
size3 = env->GetArrayLength(arr3);
}
}
VectorAdapter< int > adapter3(ptr3, size3, owner3);
float* ptr4 = arg4 == NULL ? NULL : (float*)env->GetDirectBufferAddress(arg4);
jlong size4 = arg4 == NULL ? 0 : env->GetDirectBufferCapacity(arg4);
void* owner4 = (void*)ptr4;
jfloatArray arr4 = NULL;
if (arg4 != NULL && ptr4 == NULL) {
arr4 = (jfloatArray)env->CallObjectMethod(arg4, JavaCPP_arrayMID);
if (env->ExceptionOccurred() != NULL) {
env->ExceptionClear();
} else {
ptr4 = arr4 == NULL ? NULL : env->GetFloatArrayElements(arr4, NULL);
size4 = env->GetArrayLength(arr4);
}
}
VectorAdapter< float > adapter4(ptr4, size4, owner4);
jthrowable exc = NULL;
try {
ptr->get_nns_by_item(arg0, (size_t)arg1, (size_t)arg2, adapter3, adapter4);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
int* rptr3 = adapter3;
void* rowner3 = adapter3.owner;
if (rptr3 != ptr3) {
VectorAdapter< int >::deallocate(rowner3);
}
if (arr3 != NULL) env->ReleaseIntArrayElements(arr3, (jint*)ptr3, 0);
float* rptr4 = adapter4;
void* rowner4 = adapter4.owner;
if (rptr4 != ptr4) {
VectorAdapter< float >::deallocate(rowner4);
}
if (arr4 != NULL) env->ReleaseFloatArrayElements(arr4, (jfloat*)ptr4, 0);
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1nns_1by_1item__IJJ_3I_3F(JNIEnv* env, jobject obj, jint arg0, jlong arg1, jlong arg2, jintArray arg3, jfloatArray arg4) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
int* ptr3 = arg3 == NULL ? NULL : env->GetIntArrayElements(arg3, NULL);
jlong size3 = arg3 == NULL ? 0 : env->GetArrayLength(arg3);
void* owner3 = (void*)ptr3;
VectorAdapter< int > adapter3(ptr3, size3, owner3);
float* ptr4 = arg4 == NULL ? NULL : env->GetFloatArrayElements(arg4, NULL);
jlong size4 = arg4 == NULL ? 0 : env->GetArrayLength(arg4);
void* owner4 = (void*)ptr4;
VectorAdapter< float > adapter4(ptr4, size4, owner4);
jthrowable exc = NULL;
try {
ptr->get_nns_by_item(arg0, (size_t)arg1, (size_t)arg2, adapter3, adapter4);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
int* rptr3 = adapter3;
void* rowner3 = adapter3.owner;
if (rptr3 != ptr3) {
VectorAdapter< int >::deallocate(rowner3);
}
if (arg3 != NULL) env->ReleaseIntArrayElements(arg3, (jint*)ptr3, 0);
float* rptr4 = adapter4;
void* rowner4 = adapter4.owner;
if (rptr4 != ptr4) {
VectorAdapter< float >::deallocate(rowner4);
}
if (arg4 != NULL) env->ReleaseFloatArrayElements(arg4, (jfloat*)ptr4, 0);
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1nns_1by_1vector__Lorg_bytedeco_javacpp_FloatPointer_2JJLorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_FloatPointer_2(JNIEnv* env, jobject obj, jobject arg0, jlong arg1, jlong arg2, jobject arg3, jobject arg4) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr0 = arg0 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
int* ptr3 = arg3 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID));
jlong size3 = arg3 == NULL ? 0 : env->GetLongField(arg3, JavaCPP_limitFID);
void* owner3 = JavaCPP_getPointerOwner(env, arg3);
jlong position3 = arg3 == NULL ? 0 : env->GetLongField(arg3, JavaCPP_positionFID);
ptr3 += position3;
size3 -= position3;
VectorAdapter< int > adapter3(ptr3, size3, owner3);
float* ptr4 = arg4 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg4, JavaCPP_addressFID));
jlong size4 = arg4 == NULL ? 0 : env->GetLongField(arg4, JavaCPP_limitFID);
void* owner4 = JavaCPP_getPointerOwner(env, arg4);
jlong position4 = arg4 == NULL ? 0 : env->GetLongField(arg4, JavaCPP_positionFID);
ptr4 += position4;
size4 -= position4;
VectorAdapter< float > adapter4(ptr4, size4, owner4);
jthrowable exc = NULL;
try {
ptr->get_nns_by_vector((const float*)ptr0, (size_t)arg1, (size_t)arg2, adapter3, adapter4);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
int* rptr3 = adapter3;
jlong rsize3 = (jlong)adapter3.size;
void* rowner3 = adapter3.owner;
if (rptr3 != ptr3) {
JavaCPP_initPointer(env, arg3, rptr3, rsize3, rowner3, &VectorAdapter< int >::deallocate);
} else {
env->SetLongField(arg3, JavaCPP_limitFID, rsize3 + position3);
}
float* rptr4 = adapter4;
jlong rsize4 = (jlong)adapter4.size;
void* rowner4 = adapter4.owner;
if (rptr4 != ptr4) {
JavaCPP_initPointer(env, arg4, rptr4, rsize4, rowner4, &VectorAdapter< float >::deallocate);
} else {
env->SetLongField(arg4, JavaCPP_limitFID, rsize4 + position4);
}
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1nns_1by_1vector___3FJJ_3I_3F(JNIEnv* env, jobject obj, jfloatArray arg0, jlong arg1, jlong arg2, jintArray arg3, jfloatArray arg4) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr0 = arg0 == NULL ? NULL : env->GetFloatArrayElements(arg0, NULL);
int* ptr3 = arg3 == NULL ? NULL : env->GetIntArrayElements(arg3, NULL);
jlong size3 = arg3 == NULL ? 0 : env->GetArrayLength(arg3);
void* owner3 = (void*)ptr3;
VectorAdapter< int > adapter3(ptr3, size3, owner3);
float* ptr4 = arg4 == NULL ? NULL : env->GetFloatArrayElements(arg4, NULL);
jlong size4 = arg4 == NULL ? 0 : env->GetArrayLength(arg4);
void* owner4 = (void*)ptr4;
VectorAdapter< float > adapter4(ptr4, size4, owner4);
jthrowable exc = NULL;
try {
ptr->get_nns_by_vector((const float*)ptr0, (size_t)arg1, (size_t)arg2, adapter3, adapter4);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (arg0 != NULL) env->ReleaseFloatArrayElements(arg0, (jfloat*)ptr0, JNI_ABORT);
int* rptr3 = adapter3;
void* rowner3 = adapter3.owner;
if (rptr3 != ptr3) {
VectorAdapter< int >::deallocate(rowner3);
}
if (arg3 != NULL) env->ReleaseIntArrayElements(arg3, (jint*)ptr3, 0);
float* rptr4 = adapter4;
void* rowner4 = adapter4.owner;
if (rptr4 != ptr4) {
VectorAdapter< float >::deallocate(rowner4);
}
if (arg4 != NULL) env->ReleaseFloatArrayElements(arg4, (jfloat*)ptr4, 0);
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1nns_1by_1vector__Ljava_nio_FloatBuffer_2JJLjava_nio_IntBuffer_2Ljava_nio_FloatBuffer_2(JNIEnv* env, jobject obj, jobject arg0, jlong arg1, jlong arg2, jobject arg3, jobject arg4) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr0 = arg0 == NULL ? NULL : (float*)env->GetDirectBufferAddress(arg0);
jfloatArray arr0 = NULL;
if (arg0 != NULL && ptr0 == NULL) {
arr0 = (jfloatArray)env->CallObjectMethod(arg0, JavaCPP_arrayMID);
if (env->ExceptionOccurred() != NULL) {
env->ExceptionClear();
} else {
ptr0 = arr0 == NULL ? NULL : env->GetFloatArrayElements(arr0, NULL);
}
}
int* ptr3 = arg3 == NULL ? NULL : (int*)env->GetDirectBufferAddress(arg3);
jlong size3 = arg3 == NULL ? 0 : env->GetDirectBufferCapacity(arg3);
void* owner3 = (void*)ptr3;
jintArray arr3 = NULL;
if (arg3 != NULL && ptr3 == NULL) {
arr3 = (jintArray)env->CallObjectMethod(arg3, JavaCPP_arrayMID);
if (env->ExceptionOccurred() != NULL) {
env->ExceptionClear();
} else {
ptr3 = arr3 == NULL ? NULL : env->GetIntArrayElements(arr3, NULL);
size3 = env->GetArrayLength(arr3);
}
}
VectorAdapter< int > adapter3(ptr3, size3, owner3);
float* ptr4 = arg4 == NULL ? NULL : (float*)env->GetDirectBufferAddress(arg4);
jlong size4 = arg4 == NULL ? 0 : env->GetDirectBufferCapacity(arg4);
void* owner4 = (void*)ptr4;
jfloatArray arr4 = NULL;
if (arg4 != NULL && ptr4 == NULL) {
arr4 = (jfloatArray)env->CallObjectMethod(arg4, JavaCPP_arrayMID);
if (env->ExceptionOccurred() != NULL) {
env->ExceptionClear();
} else {
ptr4 = arr4 == NULL ? NULL : env->GetFloatArrayElements(arr4, NULL);
size4 = env->GetArrayLength(arr4);
}
}
VectorAdapter< float > adapter4(ptr4, size4, owner4);
jthrowable exc = NULL;
try {
ptr->get_nns_by_vector((const float*)ptr0, (size_t)arg1, (size_t)arg2, adapter3, adapter4);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (arr0 != NULL) env->ReleaseFloatArrayElements(arr0, (jfloat*)ptr0, JNI_ABORT);
int* rptr3 = adapter3;
void* rowner3 = adapter3.owner;
if (rptr3 != ptr3) {
VectorAdapter< int >::deallocate(rowner3);
}
if (arr3 != NULL) env->ReleaseIntArrayElements(arr3, (jint*)ptr3, 0);
float* rptr4 = adapter4;
void* rowner4 = adapter4.owner;
if (rptr4 != ptr4) {
VectorAdapter< float >::deallocate(rowner4);
}
if (arr4 != NULL) env->ReleaseFloatArrayElements(arr4, (jfloat*)ptr4, 0);
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1n_1items(JNIEnv* env, jobject obj) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jint rarg = 0;
jthrowable exc = NULL;
try {
int rvalue = ptr->get_n_items();
rarg = (jint)rvalue;
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (exc != NULL) {
env->Throw(exc);
}
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1item__I_3F(JNIEnv* env, jobject obj, jint arg0, jfloatArray arg1) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr1 = arg1 == NULL ? NULL : env->GetFloatArrayElements(arg1, NULL);
jthrowable exc = NULL;
try {
ptr->get_item(arg0, ptr1);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (arg1 != NULL) env->ReleaseFloatArrayElements(arg1, (jfloat*)ptr1, 0);
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1item__ILjava_nio_FloatBuffer_2(JNIEnv* env, jobject obj, jint arg0, jobject arg1) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr1 = arg1 == NULL ? NULL : (float*)env->GetDirectBufferAddress(arg1);
jfloatArray arr1 = NULL;
if (arg1 != NULL && ptr1 == NULL) {
arr1 = (jfloatArray)env->CallObjectMethod(arg1, JavaCPP_arrayMID);
if (env->ExceptionOccurred() != NULL) {
env->ExceptionClear();
} else {
ptr1 = arr1 == NULL ? NULL : env->GetFloatArrayElements(arr1, NULL);
}
}
jthrowable exc = NULL;
try {
ptr->get_item(arg0, ptr1);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (arr1 != NULL) env->ReleaseFloatArrayElements(arr1, (jfloat*)ptr1, 0);
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1item__ILorg_bytedeco_javacpp_FloatPointer_2(JNIEnv* env, jobject obj, jint arg0, jobject arg1) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr1 = arg1 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jthrowable exc = NULL;
try {
ptr->get_item(arg0, ptr1);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_get_1f(JNIEnv* env, jobject obj) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jint rarg = 0;
jthrowable exc = NULL;
try {
int rvalue = ptr->get_f();
rarg = (jint)rvalue;
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (exc != NULL) {
env->Throw(exc);
}
return rarg;
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_add_1item__ILorg_bytedeco_javacpp_FloatPointer_2(JNIEnv* env, jobject obj, jint arg0, jobject arg1) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr1 = arg1 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID));
jlong position1 = arg1 == NULL ? 0 : env->GetLongField(arg1, JavaCPP_positionFID);
ptr1 += position1;
jthrowable exc = NULL;
try {
ptr->add_item(arg0, (const float*)ptr1);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_add_1item__ILjava_nio_FloatBuffer_2(JNIEnv* env, jobject obj, jint arg0, jobject arg1) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr1 = arg1 == NULL ? NULL : (float*)env->GetDirectBufferAddress(arg1);
jfloatArray arr1 = NULL;
if (arg1 != NULL && ptr1 == NULL) {
arr1 = (jfloatArray)env->CallObjectMethod(arg1, JavaCPP_arrayMID);
if (env->ExceptionOccurred() != NULL) {
env->ExceptionClear();
} else {
ptr1 = arr1 == NULL ? NULL : env->GetFloatArrayElements(arr1, NULL);
}
}
jthrowable exc = NULL;
try {
ptr->add_item(arg0, (const float*)ptr1);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (arr1 != NULL) env->ReleaseFloatArrayElements(arr1, (jfloat*)ptr1, JNI_ABORT);
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT void JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_add_1item__I_3F(JNIEnv* env, jobject obj, jint arg0, jfloatArray arg1) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
float* ptr1 = arg1 == NULL ? NULL : env->GetFloatArrayElements(arg1, NULL);
jthrowable exc = NULL;
try {
ptr->add_item(arg0, (const float*)ptr1);
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (arg1 != NULL) env->ReleaseFloatArrayElements(arg1, (jfloat*)ptr1, JNI_ABORT);
if (exc != NULL) {
env->Throw(exc);
}
}
JNIEXPORT jboolean JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_load__Ljava_lang_String_2(JNIEnv* env, jobject obj, jstring arg0) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
const char* ptr0 = JavaCPP_getStringBytes(env, arg0);
jboolean rarg = 0;
jthrowable exc = NULL;
try {
bool rvalue = (bool)ptr->load(ptr0);
rarg = (jboolean)rvalue;
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
JavaCPP_releaseStringBytes(env, arg0, ptr0);
if (exc != NULL) {
env->Throw(exc);
}
return rarg;
}
JNIEXPORT jboolean JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_load__Lorg_bytedeco_javacpp_BytePointer_2(JNIEnv* env, jobject obj, jobject arg0) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jboolean rarg = 0;
jthrowable exc = NULL;
try {
bool rvalue = (bool)ptr->load((const char*)ptr0);
rarg = (jboolean)rvalue;
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
if (exc != NULL) {
env->Throw(exc);
}
return rarg;
}
JNIEXPORT jboolean JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_save__Ljava_lang_String_2(JNIEnv* env, jobject obj, jstring arg0) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
const char* ptr0 = JavaCPP_getStringBytes(env, arg0);
jboolean rarg = 0;
jthrowable exc = NULL;
try {
bool rvalue = (bool)ptr->save(ptr0);
rarg = (jboolean)rvalue;
} catch (...) {
exc = JavaCPP_handleException(env, 18);
}
JavaCPP_releaseStringBytes(env, arg0, ptr0);
if (exc != NULL) {
env->Throw(exc);
}
return rarg;
}
JNIEXPORT jboolean JNICALL Java_org_bytedeco_javacpp_annoy_00024AnnoyIndex_save__Lorg_bytedeco_javacpp_BytePointer_2(JNIEnv* env, jobject obj, jobject arg0) {
::AnnoyIndex* ptr = (::AnnoyIndex*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 17), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jboolean rarg = 0;
jthrowable exc = NULL;
try {
bool rvalue = (bool)ptr->save((const char*)ptr0);
</