mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
More work towards binding FTS5 customization to JNI. Add Fts*.java files missing from previous checkin.
FossilOrigin-Name: 91263178f463ca4623dd0203696eff6bcfd68abde5d2471be3f5a3edd791c52a
This commit is contained in:
@ -65,6 +65,7 @@ JAVA_FILES := $(patsubst %,$(dir.src.jni)/%,\
|
|||||||
)
|
)
|
||||||
ifeq (1,$(enable.fts5))
|
ifeq (1,$(enable.fts5))
|
||||||
JAVA_FILES += $(patsubst %,$(dir.src.jni)/%,\
|
JAVA_FILES += $(patsubst %,$(dir.src.jni)/%,\
|
||||||
|
fts5_api.java \
|
||||||
Fts5Context.java \
|
Fts5Context.java \
|
||||||
Fts5ExtensionApi.java \
|
Fts5ExtensionApi.java \
|
||||||
Fts5Function.java \
|
Fts5Function.java \
|
||||||
@ -147,6 +148,9 @@ endif
|
|||||||
sqlite3-jni.c := $(dir.src.c)/sqlite3-jni.c
|
sqlite3-jni.c := $(dir.src.c)/sqlite3-jni.c
|
||||||
sqlite3-jni.o := $(dir.bld.c)/sqlite3-jni.o
|
sqlite3-jni.o := $(dir.bld.c)/sqlite3-jni.o
|
||||||
sqlite3-jni.h.in := $(dir.bld.c)/org_sqlite_jni_SQLite3Jni.h
|
sqlite3-jni.h.in := $(dir.bld.c)/org_sqlite_jni_SQLite3Jni.h
|
||||||
|
ifeq (1,$(enable.fts5))
|
||||||
|
sqlite3-jni.h.in += $(dir.bld.c)/org_sqlite_jni_Fts5ExtensionApi.h
|
||||||
|
endif
|
||||||
sqlite3-jni.h := $(dir.src.c)/sqlite3-jni.h
|
sqlite3-jni.h := $(dir.src.c)/sqlite3-jni.h
|
||||||
sqlite3-jni.dll := $(dir.bld.c)/libsqlite3-jni.so
|
sqlite3-jni.dll := $(dir.bld.c)/libsqlite3-jni.so
|
||||||
# ------------------------------^^^ lib prefix is requires
|
# ------------------------------^^^ lib prefix is requires
|
||||||
|
@ -186,9 +186,6 @@
|
|||||||
#define PtrGet_sqlite3_stmt(OBJ) getNativePointer(env,OBJ,S3ClassNames.sqlite3_stmt)
|
#define PtrGet_sqlite3_stmt(OBJ) getNativePointer(env,OBJ,S3ClassNames.sqlite3_stmt)
|
||||||
#define PtrGet_sqlite3_value(OBJ) getNativePointer(env,OBJ,S3ClassNames.sqlite3_value)
|
#define PtrGet_sqlite3_value(OBJ) getNativePointer(env,OBJ,S3ClassNames.sqlite3_value)
|
||||||
#define PtrGet_sqlite3_context(OBJ) getNativePointer(env,OBJ,S3ClassNames.sqlite3_context)
|
#define PtrGet_sqlite3_context(OBJ) getNativePointer(env,OBJ,S3ClassNames.sqlite3_context)
|
||||||
#ifdef SQLITE_ENABLE_FTS5
|
|
||||||
#define PtrGet_Fts5Context(OBJ) getNativePointer(env,OBJ,S3ClassNames.Fts5Context)
|
|
||||||
#endif
|
|
||||||
/* Helpers for Java value reference management. */
|
/* Helpers for Java value reference management. */
|
||||||
#define REF_G(VAR) (*env)->NewGlobalRef(env, VAR)
|
#define REF_G(VAR) (*env)->NewGlobalRef(env, VAR)
|
||||||
#define REF_L(VAR) (*env)->NewLocalRef(env, VAR)
|
#define REF_L(VAR) (*env)->NewLocalRef(env, VAR)
|
||||||
@ -205,6 +202,7 @@ static const struct {
|
|||||||
const char * const sqlite3_context;
|
const char * const sqlite3_context;
|
||||||
const char * const sqlite3_value;
|
const char * const sqlite3_value;
|
||||||
const char * const OutputPointer_Int32;
|
const char * const OutputPointer_Int32;
|
||||||
|
const char * const OutputPointer_Int64;
|
||||||
#ifdef SQLITE_ENABLE_FTS5
|
#ifdef SQLITE_ENABLE_FTS5
|
||||||
const char * const Fts5Context;
|
const char * const Fts5Context;
|
||||||
const char * const Fts5ExtensionApi;
|
const char * const Fts5ExtensionApi;
|
||||||
@ -215,9 +213,11 @@ static const struct {
|
|||||||
"org/sqlite/jni/sqlite3_context",
|
"org/sqlite/jni/sqlite3_context",
|
||||||
"org/sqlite/jni/sqlite3_value",
|
"org/sqlite/jni/sqlite3_value",
|
||||||
"org/sqlite/jni/OutputPointer$Int32",
|
"org/sqlite/jni/OutputPointer$Int32",
|
||||||
|
"org/sqlite/jni/OutputPointer$Int64",
|
||||||
#ifdef SQLITE_ENABLE_FTS5
|
#ifdef SQLITE_ENABLE_FTS5
|
||||||
"org/sqlite/jni/Fts5Context",
|
"org/sqlite/jni/Fts5Context",
|
||||||
"org/sqlite/jni/Fts5ExtensionApi"
|
"org/sqlite/jni/Fts5ExtensionApi"
|
||||||
|
"org/sqlite/jni/fts5_api"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -335,13 +335,12 @@ struct JNIEnvCacheLine {
|
|||||||
sqlite3_stmt wrapper object for every
|
sqlite3_stmt wrapper object for every
|
||||||
tracing call which needs a stmt
|
tracing call which needs a stmt
|
||||||
object. This approach is rather invasive,
|
object. This approach is rather invasive,
|
||||||
however, and there may well be places
|
however, requiring code in all stmt
|
||||||
tracing may trigger which we have no
|
operations which can lead through the
|
||||||
accounted for, so it may be best to
|
tracing API. */;
|
||||||
redefine the tracing API rather than
|
|
||||||
passing through the statement handles. */;
|
|
||||||
#ifdef SQLITE_ENABLE_FTS5
|
#ifdef SQLITE_ENABLE_FTS5
|
||||||
jobject jFts5Ext /* Java singleton for the Fts5ExtensionApi instance. */;
|
jobject jFtsExt /* Global ref to Java singleton for the
|
||||||
|
Fts5ExtensionApi instance. */;
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
/* TODO: refactor this cache as a linked list with malloc()'d entries,
|
/* TODO: refactor this cache as a linked list with malloc()'d entries,
|
||||||
@ -368,6 +367,9 @@ static void JNIEnvCacheLine_clear(JNIEnvCacheLine * const p){
|
|||||||
if(env){
|
if(env){
|
||||||
UNREF_G(p->globalClassObj);
|
UNREF_G(p->globalClassObj);
|
||||||
UNREF_G(p->globalClassLong);
|
UNREF_G(p->globalClassLong);
|
||||||
|
#ifdef SQLITE_ENABLE_FTS5
|
||||||
|
UNREF_G(p->jFtsExt);
|
||||||
|
#endif
|
||||||
i = 0;
|
i = 0;
|
||||||
for( ; i < NphCache_SIZE; ++i){
|
for( ; i < NphCache_SIZE; ++i){
|
||||||
NphCacheLine_clear(env, &p->nph[i]);
|
NphCacheLine_clear(env, &p->nph[i]);
|
||||||
@ -412,8 +414,9 @@ struct PerDbStateJni {
|
|||||||
it would be a different instance (and maybe even a
|
it would be a different instance (and maybe even a
|
||||||
different class) than the one the user may expect
|
different class) than the one the user may expect
|
||||||
to receive. */;
|
to receive. */;
|
||||||
PerDbStateJni * pNext /* Next entry in the available/free list */;
|
#ifdef SQLITE_ENABLE_FTS5
|
||||||
PerDbStateJni * pPrev /* Previous entry in the available/free list */;
|
jobject jFtsApi /* global ref to fts5_api object for the db. */;
|
||||||
|
#endif
|
||||||
JniHookState busyHandler;
|
JniHookState busyHandler;
|
||||||
JniHookState collation;
|
JniHookState collation;
|
||||||
JniHookState collationNeeded;
|
JniHookState collationNeeded;
|
||||||
@ -422,6 +425,8 @@ struct PerDbStateJni {
|
|||||||
JniHookState rollbackHook;
|
JniHookState rollbackHook;
|
||||||
JniHookState trace;
|
JniHookState trace;
|
||||||
JniHookState updateHook;
|
JniHookState updateHook;
|
||||||
|
PerDbStateJni * pNext /* Next entry in the available/free list */;
|
||||||
|
PerDbStateJni * pPrev /* Previous entry in the available/free list */;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@ -795,6 +800,9 @@ static void PerDbStateJni_set_aside(PerDbStateJni * const s){
|
|||||||
UNHOOK(busyHandler, 1);
|
UNHOOK(busyHandler, 1);
|
||||||
#undef UNHOOK
|
#undef UNHOOK
|
||||||
UNREF_G(s->jDb);
|
UNREF_G(s->jDb);
|
||||||
|
#ifdef SQLITE_ENABLE_FTS5
|
||||||
|
UNREF_G(s->jFtsApi);
|
||||||
|
#endif
|
||||||
memset(s, 0, sizeof(PerDbStateJni));
|
memset(s, 0, sizeof(PerDbStateJni));
|
||||||
s->pNext = S3Global.perDb.aFree;
|
s->pNext = S3Global.perDb.aFree;
|
||||||
if(s->pNext) s->pNext->pPrev = s;
|
if(s->pNext) s->pNext->pPrev = s;
|
||||||
@ -951,6 +959,25 @@ static void setOutputInt32(JNIEnv * env, jobject jOut, int v){
|
|||||||
EXCEPTION_IS_FATAL("Cannot set OutputPointer.Int32.value");
|
EXCEPTION_IS_FATAL("Cannot set OutputPointer.Int32.value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sets a native int64 value in OutputPointer.Int64 object jOut. */
|
||||||
|
static void setOutputInt64(JNIEnv * env, jobject jOut, jlong v){
|
||||||
|
jfieldID setter = 0;
|
||||||
|
struct NphCacheLine * const cacheLine =
|
||||||
|
S3Global_nph_cache(env, S3ClassNames.OutputPointer_Int64);
|
||||||
|
if(cacheLine && cacheLine->klazz && cacheLine->fidValue){
|
||||||
|
setter = cacheLine->fidValue;
|
||||||
|
}else{
|
||||||
|
const jclass klazz = (*env)->GetObjectClass(env, jOut);
|
||||||
|
setter = (*env)->GetFieldID(env, klazz, "value", "I");
|
||||||
|
if(cacheLine){
|
||||||
|
assert(!cacheLine->fidValue);
|
||||||
|
cacheLine->fidValue = setter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(*env)->SetIntField(env, jOut, setter, (jint)v);
|
||||||
|
EXCEPTION_IS_FATAL("Cannot set OutputPointer.Int64.value");
|
||||||
|
}
|
||||||
|
|
||||||
static int encodingTypeIsValid(int eTextRep){
|
static int encodingTypeIsValid(int eTextRep){
|
||||||
switch(eTextRep){
|
switch(eTextRep){
|
||||||
case SQLITE_UTF8: case SQLITE_UTF16:
|
case SQLITE_UTF8: case SQLITE_UTF16:
|
||||||
@ -1114,26 +1141,6 @@ static jobject new_sqlite3_stmt_wrapper(JNIEnv * const env, sqlite3_stmt *sv){
|
|||||||
return new_NativePointerHolder_object(env, S3ClassNames.sqlite3_stmt, sv);
|
return new_NativePointerHolder_object(env, S3ClassNames.sqlite3_stmt, sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
#ifdef SQLITE_ENABLE_FTS5
|
|
||||||
static jobject new_Fts5Context_wrapper(JNIEnv * const env, Fts5Context *sv){
|
|
||||||
return new_NativePointerHolder_object(env, S3ClassNames.Fts5Context, sv);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SQLITE_ENABLE_FTS5
|
|
||||||
/*static*/ jobject s3jni_getFts5ExensionApi(JNIEnv * const env){
|
|
||||||
JNIEnvCacheLine * const row = S3Global_env_cache(env);
|
|
||||||
if( !row->jFts5Ext ){
|
|
||||||
row->jFts5Ext = new_NativePointerHolder_object(env, S3ClassNames.Fts5ExtensionApi,
|
|
||||||
&sFts5Api/*from sqlite3.c*/);
|
|
||||||
if(row->jFts5Ext) row->jFts5Ext = REF_G(row->jFts5Ext);
|
|
||||||
}
|
|
||||||
return row->jFts5Ext;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum UDFType {
|
enum UDFType {
|
||||||
UDF_SCALAR = 1,
|
UDF_SCALAR = 1,
|
||||||
UDF_AGGREGATE,
|
UDF_AGGREGATE,
|
||||||
@ -2582,11 +2589,83 @@ JDECL(void,1do_1something_1for_1developer)(JENV_JSELF){
|
|||||||
#undef SO
|
#undef SO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// End of the sqlite3_... API bindings. Next up, FTS5...
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifdef SQLITE_ENABLE_FTS5
|
||||||
|
|
||||||
|
/* Creates a verbose JNI Fts5 function name. */
|
||||||
|
#define JFuncNameFts5Ext(Suffix) \
|
||||||
|
Java_org_sqlite_jni_Fts5ExtensionApi_ ## Suffix
|
||||||
|
|
||||||
|
#define JDECLFts(ReturnType,Suffix) \
|
||||||
|
JNIEXPORT ReturnType JNICALL \
|
||||||
|
JFuncNameFts5Ext(Suffix)
|
||||||
|
|
||||||
|
#define PtrGet_Fts5Context(OBJ) getNativePointer(env,OBJ,S3ClassNames.Fts5Context)
|
||||||
|
static inline Fts5ExtensionApi const * s3jni_ftsext(void){
|
||||||
|
return &sFts5Api/*singleton from sqlite3.c*/;
|
||||||
|
}
|
||||||
|
#define Fts5ExtDecl Fts5ExtensionApi const * const fext = s3jni_ftsext()
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static jobject new_Fts5Context_wrapper(JNIEnv * const env, Fts5Context *sv){
|
||||||
|
return new_NativePointerHolder_object(env, S3ClassNames.Fts5Context, sv);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static jobject s3jni_getFts5ExensionApi(JNIEnv * const env){
|
||||||
|
JNIEnvCacheLine * const row = S3Global_env_cache(env);
|
||||||
|
if( !row->jFtsExt ){
|
||||||
|
row->jFtsExt = new_NativePointerHolder_object(env, S3ClassNames.Fts5ExtensionApi,
|
||||||
|
s3jni_ftsext());
|
||||||
|
if(row->jFtsExt) row->jFtsExt = REF_G(row->jFtsExt);
|
||||||
|
}
|
||||||
|
return row->jFtsExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
JDECLFts(jobject,getInstance)(JENV_JSELF){
|
||||||
|
return s3jni_getFts5ExensionApi(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
JDECLFts(jint,xColumnCount)(JENV_JSELF,jobject jCtx){
|
||||||
|
Fts5ExtDecl;
|
||||||
|
return (jint)fext->xColumnCount(PtrGet_Fts5Context(jCtx));
|
||||||
|
}
|
||||||
|
|
||||||
|
JDECLFts(jint,xColumnTotalSize)(JENV_JSELF,jobject jCtx, jint iCol, jobject jOut64){
|
||||||
|
Fts5ExtDecl;
|
||||||
|
sqlite3_int64 nOut = 0;
|
||||||
|
int const rc = fext->xColumnTotalSize(PtrGet_Fts5Context(jCtx), (int)iCol, &nOut);
|
||||||
|
if( 0==rc && jOut64 ) setOutputInt64(env, jOut64, (jlong)nOut);
|
||||||
|
return (jint)rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
JDECLFts(jint,xPhraseCount)(JENV_JSELF,jobject jCtx){
|
||||||
|
Fts5ExtDecl;
|
||||||
|
return (jint)fext->xPhraseCount(PtrGet_Fts5Context(jCtx));
|
||||||
|
}
|
||||||
|
|
||||||
|
JDECLFts(jint,xPhraseSize)(JENV_JSELF,jobject jCtx, jint iPhrase){
|
||||||
|
Fts5ExtDecl;
|
||||||
|
return (jint)fext->xPhraseSize(PtrGet_Fts5Context(jCtx), (int)iPhrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
JDECLFts(jint,xRowCount)(JENV_JSELF,jobject jCtx, jobject jOut64){
|
||||||
|
Fts5ExtDecl;
|
||||||
|
sqlite3_int64 nOut = 0;
|
||||||
|
int const rc = fext->xRowCount(PtrGet_Fts5Context(jCtx), &nOut);
|
||||||
|
if( 0==rc && jOut64 ) setOutputInt64(env, jOut64, (jlong)nOut);
|
||||||
|
return (jint)rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SQLITE_ENABLE_FTS5 */
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// End of the main API bindings. What follows are internal utilities.
|
// End of the main API bindings. What follows are internal utilities.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Called during static init of the SQLite3Jni class to sync certain
|
Called during static init of the SQLite3Jni class to sync certain
|
||||||
compile-time constants to Java-space.
|
compile-time constants to Java-space.
|
||||||
|
@ -1615,3 +1615,64 @@ JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1do_1something_1fo
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class org_sqlite_jni_Fts5ExtensionApi */
|
||||||
|
|
||||||
|
#ifndef _Included_org_sqlite_jni_Fts5ExtensionApi
|
||||||
|
#define _Included_org_sqlite_jni_Fts5ExtensionApi
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: org_sqlite_jni_Fts5ExtensionApi
|
||||||
|
* Method: getInstance
|
||||||
|
* Signature: ()Lorg/sqlite/jni/Fts5ExtensionApi;
|
||||||
|
*/
|
||||||
|
JNIEXPORT jobject JNICALL Java_org_sqlite_jni_Fts5ExtensionApi_getInstance
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_sqlite_jni_Fts5ExtensionApi
|
||||||
|
* Method: xColumnCount
|
||||||
|
* Signature: (Lorg/sqlite/jni/Fts5Context;)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_org_sqlite_jni_Fts5ExtensionApi_xColumnCount
|
||||||
|
(JNIEnv *, jobject, jobject);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_sqlite_jni_Fts5ExtensionApi
|
||||||
|
* Method: xRowCount
|
||||||
|
* Signature: (Lorg/sqlite/jni/Fts5Context;Lorg/sqlite/jni/OutputPointer/Int64;)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_org_sqlite_jni_Fts5ExtensionApi_xRowCount
|
||||||
|
(JNIEnv *, jobject, jobject, jobject);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_sqlite_jni_Fts5ExtensionApi
|
||||||
|
* Method: xColumnTotalSize
|
||||||
|
* Signature: (Lorg/sqlite/jni/Fts5Context;ILorg/sqlite/jni/OutputPointer/Int64;)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_org_sqlite_jni_Fts5ExtensionApi_xColumnTotalSize
|
||||||
|
(JNIEnv *, jobject, jobject, jint, jobject);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_sqlite_jni_Fts5ExtensionApi
|
||||||
|
* Method: xPhraseCount
|
||||||
|
* Signature: (Lorg/sqlite/jni/Fts5Context;)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_org_sqlite_jni_Fts5ExtensionApi_xPhraseCount
|
||||||
|
(JNIEnv *, jobject, jobject);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_sqlite_jni_Fts5ExtensionApi
|
||||||
|
* Method: xPhraseSize
|
||||||
|
* Signature: (Lorg/sqlite/jni/Fts5Context;I)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_org_sqlite_jni_Fts5ExtensionApi_xPhraseSize
|
||||||
|
(JNIEnv *, jobject, jobject, jint);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
23
ext/jni/src/org/sqlite/jni/Fts5Context.java
Normal file
23
ext/jni/src/org/sqlite/jni/Fts5Context.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
** 2023-08-04
|
||||||
|
**
|
||||||
|
** The author disclaims copyright to this source code. In place of
|
||||||
|
** a legal notice, here is a blessing:
|
||||||
|
**
|
||||||
|
** May you do good and not evil.
|
||||||
|
** May you find forgiveness for yourself and forgive others.
|
||||||
|
** May you share freely, never taking more than you give.
|
||||||
|
**
|
||||||
|
*************************************************************************
|
||||||
|
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||||
|
*/
|
||||||
|
package org.sqlite.jni;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A wrapper for communicating C-level (Fts5Context*) instances with
|
||||||
|
Java. These wrappers do not own their associated pointer, they
|
||||||
|
simply provide a type-safe way to communicate it between Java and C
|
||||||
|
via JNI.
|
||||||
|
*/
|
||||||
|
public final class Fts5Context extends NativePointerHolder<Fts5Context> {
|
||||||
|
}
|
65
ext/jni/src/org/sqlite/jni/Fts5ExtensionApi.java
Normal file
65
ext/jni/src/org/sqlite/jni/Fts5ExtensionApi.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
** 2023-08-04
|
||||||
|
**
|
||||||
|
** The author disclaims copyright to this source code. In place of
|
||||||
|
** a legal notice, here is a blessing:
|
||||||
|
**
|
||||||
|
** May you do good and not evil.
|
||||||
|
** May you find forgiveness for yourself and forgive others.
|
||||||
|
** May you share freely, never taking more than you give.
|
||||||
|
**
|
||||||
|
*************************************************************************
|
||||||
|
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||||
|
*/
|
||||||
|
package org.sqlite.jni;
|
||||||
|
|
||||||
|
/**
|
||||||
|
FAR FROM COMPLETE and the feasibility of binding this to Java
|
||||||
|
is still undetermined. This might be removed.
|
||||||
|
|
||||||
|
Reminder to self: the native Fts5ExtensionApi is a singleton.
|
||||||
|
*/
|
||||||
|
public final class Fts5ExtensionApi extends NativePointerHolder<Fts5ExtensionApi> {
|
||||||
|
//! Only called from JNI
|
||||||
|
private Fts5ExtensionApi(){}
|
||||||
|
private int iVersion;
|
||||||
|
|
||||||
|
public static native Fts5ExtensionApi getInstance();
|
||||||
|
|
||||||
|
public native int xColumnCount(Fts5Context fcx);
|
||||||
|
public native int xRowCount(Fts5Context fcx, OutputPointer.Int64 nRow);
|
||||||
|
public native int xColumnTotalSize(Fts5Context fcx, int iCol, OutputPointer.Int64 pnToken);
|
||||||
|
public native int xPhraseCount(Fts5Context fcx);
|
||||||
|
public native int xPhraseSize(Fts5Context fcx, int iPhrase);
|
||||||
|
/**************************************************************
|
||||||
|
void *(*xUserData)(Fts5Context*);
|
||||||
|
|
||||||
|
int (*xTokenize)(Fts5Context*,
|
||||||
|
const char *pText, int nText,
|
||||||
|
void *pCtx,
|
||||||
|
int (*xToken)(void*, int, const char*, int, int, int)
|
||||||
|
);
|
||||||
|
|
||||||
|
int (*xPhraseCount)(Fts5Context*);
|
||||||
|
int (*xPhraseSize)(Fts5Context*, int iPhrase);
|
||||||
|
|
||||||
|
int (*xInstCount)(Fts5Context*, int *pnInst);
|
||||||
|
int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);
|
||||||
|
|
||||||
|
sqlite3_int64 (*xRowid)(Fts5Context*);
|
||||||
|
int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);
|
||||||
|
int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);
|
||||||
|
|
||||||
|
int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,
|
||||||
|
int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)
|
||||||
|
);
|
||||||
|
int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));
|
||||||
|
void *(*xGetAuxdata)(Fts5Context*, int bClear);
|
||||||
|
|
||||||
|
int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);
|
||||||
|
void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);
|
||||||
|
|
||||||
|
int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
|
||||||
|
void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);
|
||||||
|
**************************************************************/
|
||||||
|
}
|
27
ext/jni/src/org/sqlite/jni/Fts5Function.java
Normal file
27
ext/jni/src/org/sqlite/jni/Fts5Function.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
** 2023-08-04
|
||||||
|
**
|
||||||
|
** The author disclaims copyright to this source code. In place of
|
||||||
|
** a legal notice, here is a blessing:
|
||||||
|
**
|
||||||
|
** May you do good and not evil.
|
||||||
|
** May you find forgiveness for yourself and forgive others.
|
||||||
|
** May you share freely, never taking more than you give.
|
||||||
|
**
|
||||||
|
*************************************************************************
|
||||||
|
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||||
|
*/
|
||||||
|
package org.sqlite.jni;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fts5Function is used in conjunction with the
|
||||||
|
sqlite3_create_fts_function() JNI-bound API to give that native code
|
||||||
|
access to the callback functions needed in order to implement
|
||||||
|
FTS5 auxiliary functions in Java.
|
||||||
|
*/
|
||||||
|
public abstract class Fts5Function {
|
||||||
|
|
||||||
|
public abstract void xFunction(Fts5ExtensionApi pApi, Fts5Context pFts,
|
||||||
|
sqlite3_context pCtx, sqlite3_value argv[]);
|
||||||
|
public void xDestroy() {}
|
||||||
|
}
|
@ -776,14 +776,6 @@ public final class SQLite3Jni {
|
|||||||
|
|
||||||
public static native byte[] sqlite3_value_text16be(@NotNull sqlite3_value v);
|
public static native byte[] sqlite3_value_text16be(@NotNull sqlite3_value v);
|
||||||
|
|
||||||
//TODO: to_java() should return a closest-match type for the given
|
|
||||||
//value. The quirk is that it would need to return object-type values,
|
|
||||||
//e.g. Integer instead of int, and creating those is a bit of a nuisance
|
|
||||||
//from JNI.
|
|
||||||
//public static native Object sqlite3_value_to_java(@NotNull sqlite3_value v);
|
|
||||||
// Or we can just implement it in Java:
|
|
||||||
//public static Object sqlite3_value_to_java(@NotNull sqlite3_value v){...}
|
|
||||||
|
|
||||||
public static native int sqlite3_value_type(@NotNull sqlite3_value v);
|
public static native int sqlite3_value_type(@NotNull sqlite3_value v);
|
||||||
|
|
||||||
public static native int sqlite3_value_numeric_type(@NotNull sqlite3_value v);
|
public static native int sqlite3_value_numeric_type(@NotNull sqlite3_value v);
|
||||||
|
@ -877,7 +877,6 @@ public class Tester1 {
|
|||||||
sqlite3_close_v2(db);
|
sqlite3_close_v2(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void testRollbackHook(){
|
private static void testRollbackHook(){
|
||||||
final sqlite3 db = createNewDb();
|
final sqlite3 db = createNewDb();
|
||||||
final ValueHolder<Integer> counter = new ValueHolder<>(0);
|
final ValueHolder<Integer> counter = new ValueHolder<>(0);
|
||||||
@ -910,6 +909,12 @@ public class Tester1 {
|
|||||||
sqlite3_close_v2(db);
|
sqlite3_close_v2(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void testFts1(){
|
||||||
|
Fts5ExtensionApi fea = Fts5ExtensionApi.getInstance();
|
||||||
|
affirm( null != fea );
|
||||||
|
affirm( fea.getNativePointer() != 0 );
|
||||||
|
}
|
||||||
|
|
||||||
private static void testSleep(){
|
private static void testSleep(){
|
||||||
out("Sleeping briefly... ");
|
out("Sleeping briefly... ");
|
||||||
sqlite3_sleep(600);
|
sqlite3_sleep(600);
|
||||||
|
23
ext/jni/src/org/sqlite/jni/fts5_api.java
Normal file
23
ext/jni/src/org/sqlite/jni/fts5_api.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
** 2023-08-04
|
||||||
|
**
|
||||||
|
** The author disclaims copyright to this source code. In place of
|
||||||
|
** a legal notice, here is a blessing:
|
||||||
|
**
|
||||||
|
** May you do good and not evil.
|
||||||
|
** May you find forgiveness for yourself and forgive others.
|
||||||
|
** May you share freely, never taking more than you give.
|
||||||
|
**
|
||||||
|
*************************************************************************
|
||||||
|
** This file is part of the JNI bindings for the sqlite3 C API.
|
||||||
|
*/
|
||||||
|
package org.sqlite.jni;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A wrapper for communicating C-level (fts5_api*) instances with
|
||||||
|
Java. These wrappers do not own their associated pointer, they
|
||||||
|
simply provide a type-safe way to communicate it between Java and C
|
||||||
|
via JNI.
|
||||||
|
*/
|
||||||
|
public final class fts5_api extends NativePointerHolder<fts5_api> {
|
||||||
|
}
|
24
manifest
24
manifest
@ -1,5 +1,5 @@
|
|||||||
C Start\sincluding\sfts5\scustomization\sbits\sinto\sJNI,\sbut\sit's\sfar\sfrom\sfunctional.
|
C More\swork\stowards\sbinding\sFTS5\scustomization\sto\sJNI.\sAdd\sFts*.java\sfiles\smissing\sfrom\sprevious\scheckin.
|
||||||
D 2023-08-04T11:08:25.675
|
D 2023-08-04T12:44:06.920
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@ -230,24 +230,28 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c
|
|||||||
F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9
|
F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9
|
||||||
F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282
|
F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282
|
||||||
F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8
|
F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8
|
||||||
F ext/jni/GNUmakefile 4497a2f82b5d95cb409d9207f7d82c54f100eeb0cc2b05aa05e806566b6a38a1
|
F ext/jni/GNUmakefile ff5c539c686b79598c9703822343a3b3117b2153ccebde0935f805f760de0847
|
||||||
F ext/jni/README.md 6ff7e1f4100dee980434a6ee37a199b653bceec62e233a6e2ccde6e7ae0c58bf
|
F ext/jni/README.md 6ff7e1f4100dee980434a6ee37a199b653bceec62e233a6e2ccde6e7ae0c58bf
|
||||||
F ext/jni/src/c/sqlite3-jni.c 904404bc810a809c2ec7de9fc178d559ceb8c4310fec82629ac25107de3f0e28
|
F ext/jni/src/c/sqlite3-jni.c 8ec2c1cc63af05bc84965c73e0dacb39474f5efd9fa712c780a24a44237c5e4b
|
||||||
F ext/jni/src/c/sqlite3-jni.h 74aaf87e77f99857aa3afc013517c934cbc2c16618c83d8f5d6294351bc8e7b1
|
F ext/jni/src/c/sqlite3-jni.h ed03612024e9fe06a9e0655ccfe9f9f7bd899c7e68badad636c7d9833682655b
|
||||||
F ext/jni/src/org/sqlite/jni/BusyHandler.java 1b1d3e5c86cd796a0580c81b6af6550ad943baa25e47ada0dcca3aff3ebe978c
|
F ext/jni/src/org/sqlite/jni/BusyHandler.java 1b1d3e5c86cd796a0580c81b6af6550ad943baa25e47ada0dcca3aff3ebe978c
|
||||||
F ext/jni/src/org/sqlite/jni/Collation.java 8dffbb00938007ad0967b2ab424d3c908413af1bbd3d212b9c9899910f1218d1
|
F ext/jni/src/org/sqlite/jni/Collation.java 8dffbb00938007ad0967b2ab424d3c908413af1bbd3d212b9c9899910f1218d1
|
||||||
F ext/jni/src/org/sqlite/jni/CollationNeeded.java ebc7cd96d46a70daa76016a308e80f70a3f21d3282787c8d139aa840fdcb1bd7
|
F ext/jni/src/org/sqlite/jni/CollationNeeded.java ebc7cd96d46a70daa76016a308e80f70a3f21d3282787c8d139aa840fdcb1bd7
|
||||||
F ext/jni/src/org/sqlite/jni/CommitHook.java 87c6a8e5138c61a8eeff018fe16d23f29219150239746032687f245938baca1a
|
F ext/jni/src/org/sqlite/jni/CommitHook.java 87c6a8e5138c61a8eeff018fe16d23f29219150239746032687f245938baca1a
|
||||||
|
F ext/jni/src/org/sqlite/jni/Fts5Context.java 0a5a02047a6a1dd3e4a38b0e542a8dd2de365033ba30e6ae019a676305959890
|
||||||
|
F ext/jni/src/org/sqlite/jni/Fts5ExtensionApi.java a1352e38eda4f0a78c51d4e1d71bacc7aa9bd9a47f4724626399079992ffdb1f
|
||||||
|
F ext/jni/src/org/sqlite/jni/Fts5Function.java 65cde7151e441fee012250a5e03277de7babcd11a0c308a832b7940574259bcc
|
||||||
F ext/jni/src/org/sqlite/jni/NativePointerHolder.java 9c5d901cce4f7e57c3d623f4e2476f9f79a8eed6e51b2a603f37866018e040ee
|
F ext/jni/src/org/sqlite/jni/NativePointerHolder.java 9c5d901cce4f7e57c3d623f4e2476f9f79a8eed6e51b2a603f37866018e040ee
|
||||||
F ext/jni/src/org/sqlite/jni/OutputPointer.java c7868f1f4ad63435ee44d409377df7dd7e02592a3734df8887a22a9f74b12751
|
F ext/jni/src/org/sqlite/jni/OutputPointer.java c7868f1f4ad63435ee44d409377df7dd7e02592a3734df8887a22a9f74b12751
|
||||||
F ext/jni/src/org/sqlite/jni/ProgressHandler.java 5979450e996416d28543f1d42634d308439565a99332a8bd84e424af667116cc
|
F ext/jni/src/org/sqlite/jni/ProgressHandler.java 5979450e996416d28543f1d42634d308439565a99332a8bd84e424af667116cc
|
||||||
F ext/jni/src/org/sqlite/jni/RollbackHook.java b04c8abcc6ade44a8a57129e33765793f69df0ba909e49ba18d73f4268d92564
|
F ext/jni/src/org/sqlite/jni/RollbackHook.java b04c8abcc6ade44a8a57129e33765793f69df0ba909e49ba18d73f4268d92564
|
||||||
F ext/jni/src/org/sqlite/jni/SQLFunction.java 09ce81c1c637e31c3a830d4c859cce95d65f5e02ff45f8bd1985b3479381bc46
|
F ext/jni/src/org/sqlite/jni/SQLFunction.java 09ce81c1c637e31c3a830d4c859cce95d65f5e02ff45f8bd1985b3479381bc46
|
||||||
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 78c079efc177d2975932fca9cfd34dd4d2c2062feae3f6f2016d0964e5a7120c
|
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 78496a02c7cc65a2238f54e935af070acf4e2dbef95d7cc1ff46938c440848a4
|
||||||
F ext/jni/src/org/sqlite/jni/Tester1.java 9443cdbd2b10f6a8e1f3abd1694983a16b17960f8ed2f7e06bcc7e535fb5abcf
|
F ext/jni/src/org/sqlite/jni/Tester1.java fed44197213929cb16edbb59d68f057d0b851cb35c4b52366b021e158ded304b
|
||||||
F ext/jni/src/org/sqlite/jni/Tracer.java a5cece9f947b0af27669b8baec300b6dd7ff859c3e6a6e4a1bd8b50f9714775d
|
F ext/jni/src/org/sqlite/jni/Tracer.java a5cece9f947b0af27669b8baec300b6dd7ff859c3e6a6e4a1bd8b50f9714775d
|
||||||
F ext/jni/src/org/sqlite/jni/UpdateHook.java e58645a1727f8a9bbe72dc072ec5b40d9f9362cb0aa24acfe93f49ff56a9016d
|
F ext/jni/src/org/sqlite/jni/UpdateHook.java e58645a1727f8a9bbe72dc072ec5b40d9f9362cb0aa24acfe93f49ff56a9016d
|
||||||
F ext/jni/src/org/sqlite/jni/ValueHolder.java f022873abaabf64f3dd71ab0d6037c6e71cece3b8819fa10bf26a5461dc973ee
|
F ext/jni/src/org/sqlite/jni/ValueHolder.java f022873abaabf64f3dd71ab0d6037c6e71cece3b8819fa10bf26a5461dc973ee
|
||||||
|
F ext/jni/src/org/sqlite/jni/fts5_api.java 916fc40f96f1a9cb288d2d9656d88db69a684ae922c38fdf3dd947b1878bb357
|
||||||
F ext/jni/src/org/sqlite/jni/sqlite3.java 600c3ddc1ac28ee8f58669fb435fd0d21f2972c652039361fde907d4fe44eb58
|
F ext/jni/src/org/sqlite/jni/sqlite3.java 600c3ddc1ac28ee8f58669fb435fd0d21f2972c652039361fde907d4fe44eb58
|
||||||
F ext/jni/src/org/sqlite/jni/sqlite3_context.java d26573fc7b309228cb49786e9078597d96232257defa955a3425d10897bca810
|
F ext/jni/src/org/sqlite/jni/sqlite3_context.java d26573fc7b309228cb49786e9078597d96232257defa955a3425d10897bca810
|
||||||
F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 72a0698aeb50a183ad146cd29ee04952abb8c36021f6122656aa5ec20469f6f7
|
F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 72a0698aeb50a183ad146cd29ee04952abb8c36021f6122656aa5ec20469f6f7
|
||||||
@ -2071,8 +2075,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 2c88390faa108a60c8fb1eb7aad05d90f3daf4cfef14ca73987597aaf7be83c9
|
P abaf5edd0430e3301a11bd0acb9ce4b81b310237e1799701411db56ef7605e01
|
||||||
R 8bcf0b9bad61c244dfd6aa8e17b480b1
|
R 0ce682e16f3279fc573892c09d1e8907
|
||||||
U stephan
|
U stephan
|
||||||
Z a12eb6e80e9b1d3771520cdb25f8972d
|
Z cb3ae8248e37b24a50f177e201f5ab44
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
abaf5edd0430e3301a11bd0acb9ce4b81b310237e1799701411db56ef7605e01
|
91263178f463ca4623dd0203696eff6bcfd68abde5d2471be3f5a3edd791c52a
|
Reference in New Issue
Block a user