return (jlong)sqlite3_column_int64(PtrGet_sqlite3_stmt(jpStmt), (int)ndx);
}
-JDECL(jbyteArray,1column_1text)(JENV_CSELF, jobject jpStmt,
+JDECL(jbyteArray,1column_1text_1utf8)(JENV_CSELF, jobject jpStmt,
jint ndx){
sqlite3_stmt * const stmt = PtrGet_sqlite3_stmt(jpStmt);
const int n = sqlite3_column_bytes(stmt, (int)ndx);
const unsigned char * const p = sqlite3_column_text(stmt, (int)ndx);
- return s3jni_new_jbyteArray(env, p, n);
+ return p ? s3jni_new_jbyteArray(env, p, n) : NULL;
}
JDECL(jstring,1column_1text16)(JENV_CSELF, jobject jpStmt,
return rv ? rv->jObj : NULL;
}
-JDECL(jstring,1value_1text)(JENV_CSELF, jobject jpSVal){
- sqlite3_value * const sv = PtrGet_sqlite3_value(jpSVal);
- int const n = sqlite3_value_bytes16(sv);
- const void * const p = sqlite3_value_text16(sv);
- return s3jni_text16_to_jstring(env, p, n);
-}
-
JDECL(jbyteArray,1value_1text_1utf8)(JENV_CSELF, jobject jpSVal){
sqlite3_value * const sv = PtrGet_sqlite3_value(jpSVal);
int const n = sqlite3_value_bytes(sv);
const unsigned char * const p = sqlite3_value_text(sv);
- return s3jni_new_jbyteArray(env, p, n);
+ return p ? s3jni_new_jbyteArray(env, p, n) : 0;
}
static jbyteArray value_text16(int mode, JNIEnv * const env, jobject jpSVal){
/*
* Class: org_sqlite_jni_SQLite3Jni
- * Method: sqlite3_column_text16
- * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)Ljava/lang/String;
+ * Method: sqlite3_column_text_utf8
+ * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)[B
*/
-JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1text16
+JNIEXPORT jbyteArray JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1text_1utf8
(JNIEnv *, jclass, jobject, jint);
/*
* Class: org_sqlite_jni_SQLite3Jni
- * Method: sqlite3_column_text
- * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)[B
+ * Method: sqlite3_column_text16
+ * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)Ljava/lang/String;
*/
-JNIEXPORT jbyteArray JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1text
+JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1text16
(JNIEnv *, jclass, jobject, jint);
/*
JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1java_1object
(JNIEnv *, jclass, jobject);
-/*
- * Class: org_sqlite_jni_SQLite3Jni
- * Method: sqlite3_value_text
- * Signature: (Lorg/sqlite/jni/sqlite3_value;)Ljava/lang/String;
- */
-JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1text
- (JNIEnv *, jclass, jobject);
-
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: sqlite3_value_text_utf8
public final class Fts5ExtensionApi extends NativePointerHolder<Fts5ExtensionApi> {
//! Only called from JNI
private Fts5ExtensionApi(){}
- private int iVersion = 2;
+ private final int iVersion = 2;
/* Callback type for used by xQueryPhrase(). */
public static interface xQueryPhraseCallback {
/**
Returns the singleton instance of this class.
*/
- public static synchronized native Fts5ExtensionApi getInstance();
+ public static native Fts5ExtensionApi getInstance();
- public synchronized native int xColumnCount(@NotNull Fts5Context fcx);
- public synchronized native int xColumnSize(@NotNull Fts5Context cx, int iCol,
+ public native int xColumnCount(@NotNull Fts5Context fcx);
+ public native int xColumnSize(@NotNull Fts5Context cx, int iCol,
@NotNull OutputPointer.Int32 pnToken);
- public synchronized native int xColumnText(@NotNull Fts5Context cx, int iCol,
+ public native int xColumnText(@NotNull Fts5Context cx, int iCol,
@NotNull OutputPointer.String txt);
- public synchronized native int xColumnTotalSize(@NotNull Fts5Context fcx, int iCol,
+ public native int xColumnTotalSize(@NotNull Fts5Context fcx, int iCol,
@NotNull OutputPointer.Int64 pnToken);
- public synchronized native Object xGetAuxdata(@NotNull Fts5Context cx, boolean clearIt);
- public synchronized native int xInst(@NotNull Fts5Context cx, int iIdx,
+ public native Object xGetAuxdata(@NotNull Fts5Context cx, boolean clearIt);
+ public native int xInst(@NotNull Fts5Context cx, int iIdx,
@NotNull OutputPointer.Int32 piPhrase,
@NotNull OutputPointer.Int32 piCol,
@NotNull OutputPointer.Int32 piOff);
- public synchronized native int xInstCount(@NotNull Fts5Context fcx,
+ public native int xInstCount(@NotNull Fts5Context fcx,
@NotNull OutputPointer.Int32 pnInst);
- public synchronized native int xPhraseCount(@NotNull Fts5Context fcx);
- public synchronized native int xPhraseFirst(@NotNull Fts5Context cx, int iPhrase,
+ public native int xPhraseCount(@NotNull Fts5Context fcx);
+ public native int xPhraseFirst(@NotNull Fts5Context cx, int iPhrase,
@NotNull Fts5PhraseIter iter,
@NotNull OutputPointer.Int32 iCol,
@NotNull OutputPointer.Int32 iOff);
- public synchronized native int xPhraseFirstColumn(@NotNull Fts5Context cx, int iPhrase,
+ public native int xPhraseFirstColumn(@NotNull Fts5Context cx, int iPhrase,
@NotNull Fts5PhraseIter iter,
@NotNull OutputPointer.Int32 iCol);
- public synchronized native void xPhraseNext(@NotNull Fts5Context cx,
+ public native void xPhraseNext(@NotNull Fts5Context cx,
@NotNull Fts5PhraseIter iter,
@NotNull OutputPointer.Int32 iCol,
@NotNull OutputPointer.Int32 iOff);
- public synchronized native void xPhraseNextColumn(@NotNull Fts5Context cx,
+ public native void xPhraseNextColumn(@NotNull Fts5Context cx,
@NotNull Fts5PhraseIter iter,
@NotNull OutputPointer.Int32 iCol);
- public synchronized native int xPhraseSize(@NotNull Fts5Context fcx, int iPhrase);
- public synchronized native int xQueryPhrase(@NotNull Fts5Context cx, int iPhrase,
+ public native int xPhraseSize(@NotNull Fts5Context fcx, int iPhrase);
+ public native int xQueryPhrase(@NotNull Fts5Context cx, int iPhrase,
@NotNull xQueryPhraseCallback callback);
- public synchronized native int xRowCount(@NotNull Fts5Context fcx,
+ public native int xRowCount(@NotNull Fts5Context fcx,
@NotNull OutputPointer.Int64 nRow);
- public synchronized native long xRowid(@NotNull Fts5Context cx);
+ public native long xRowid(@NotNull Fts5Context cx);
/* Note that the JNI binding lacks the C version's xDelete()
callback argument. Instead, if pAux has an xDestroy() method, it
is called if the FTS5 API finalizes the aux state (including if
allocation of storage for the auxdata fails). Any reference to
pAux held by the JNI layer will be relinquished regardless of
whether pAux has an xDestroy() method. */
- public synchronized native int xSetAuxdata(@NotNull Fts5Context cx, @Nullable Object pAux);
- public synchronized native int xTokenize(@NotNull Fts5Context cx, @NotNull byte[] pText,
+ public native int xSetAuxdata(@NotNull Fts5Context cx, @Nullable Object pAux);
+ public native int xTokenize(@NotNull Fts5Context cx, @NotNull byte[] pText,
@NotNull Fts5.xTokenizeCallback callback);
- public synchronized native Object xUserData(Fts5Context cx);
+ public native Object xUserData(Fts5Context cx);
//^^^ returns the pointer passed as the 3rd arg to the C-level
// fts5_api::xCreateFunction.
}
);
/**
- To extract _standard_ UTF-8, use sqlite3_column_text().
- This API includes no functions for working with Java's Modified
- UTF-8.
+ Returns the given column's contents as UTF-8-encoded (not MUTF-8)
+ text. Returns null if the C-level sqlite3_column_text() returns
+ NULL.
*/
- public static native String sqlite3_column_text16(
+ public static native byte[] sqlite3_column_text_utf8(
@NotNull sqlite3_stmt stmt, int ndx
);
- /**
- Returns the given column's contents as UTF-8-encoded (not MUTF-8) text.
- Use sqlite3_column_text16() to fetch the text
- */
- public static native byte[] sqlite3_column_text(
+ public static String sqlite3_column_text(
+ @NotNull sqlite3_stmt stmt, int ndx
+ ){
+ final byte[] ba = sqlite3_column_text_utf8(stmt, ndx);
+ return ba==null ? null : new String(ba, StandardCharsets.UTF_8);
+ }
+
+ public static native String sqlite3_column_text16(
@NotNull sqlite3_stmt stmt, int ndx
);
}
/**
- See sqlite3_column_text() for notes about encoding conversions.
- See sqlite3_value_text_utf8() for how to extract text in standard
- UTF-8.
- */
- public static native String sqlite3_value_text(@NotNull sqlite3_value v);
-
- /**
- The sqlite3_value counterpart of sqlite3_column_text_utf8().
+ Returns the given value as UTF-8-encoded bytes, or null if the
+ underlying C API returns null for sqlite3_value_text().
*/
public static native byte[] sqlite3_value_text_utf8(@NotNull sqlite3_value v);
+ public static String sqlite3_value_text(@NotNull sqlite3_value v){
+ final byte[] ba = sqlite3_value_text_utf8(v);
+ return null==ba ? null : new String(ba, StandardCharsets.UTF_8);
+ }
+
public static native byte[] sqlite3_value_text16(@NotNull sqlite3_value v);
public static native byte[] sqlite3_value_text16le(@NotNull sqlite3_value v);
import java.util.concurrent.Future;
public class Tester1 implements Runnable {
+ //! True when running in multi-threaded mode.
+ private static boolean mtMode = false;
+
private static final class Metrics {
int dbOpen;
}
testAuthorizer();
testAutoExtension();
if(!fromThread){
- // testFts5(); // skip for now: messes with affirm() counts.
testBusy();
+ if( !mtMode ){
+ testFts5();
+ }
}
}
if( nThread==null || nThread<=1 ){
new Tester1(0).runTests(false);
}else{
+ Tester1.mtMode = true;
final ExecutorService ex = Executors.newFixedThreadPool( nThread );
//final List<Future<?>> futures = new ArrayList<>();
++nLoop;
affirm( xDestroyCalled.value );
}
- public TesterFts5(boolean outputStats){
+ public TesterFts5(){
int oldAffirmCount = Tester1.affirmCount;
- Tester1.affirmCount = 0;
- final long timeStart = System.nanoTime();
+ final long timeStart = System.currentTimeMillis();
test1();
- final long timeEnd = System.nanoTime();
+ final long timeEnd = System.currentTimeMillis();
outln("FTS5 Tests done. Metrics:");
outln("\tAssertions checked: "+Tester1.affirmCount);
outln("\tTotal time = "
- +((timeEnd - timeStart)/1000000.0)+"ms");
- Tester1.affirmCount = oldAffirmCount;
+ +(timeEnd - timeStart)+"ms");
}
}
-C Merge\strunk\sinto\sjni-threading\sbranch.
-D 2023-08-19T12:34:23.970
+C JNI\scleanups.
+D 2023-08-19T14:49:08.030
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/jni/GNUmakefile 4849b0ac41c3a92777aebf0ec3d51c2be7c78d3ea9b91ece03ade6f9fa13d99a
F ext/jni/README.md 975b35173debbbf3a4ab7166e14d2ffa2bacff9b6850414f09cc919805e81ba4
F ext/jni/jar-dist.make 9a03d10dbb5a74c724bfec4b76fd9e4c9865cbbc858d731cb48f38ac897d73a3
-F ext/jni/src/c/sqlite3-jni.c 8608cb36223d6bc64e8ddd9296b6d63a4fc54efaf8dbc3ea7e5eca81f4801d42
-F ext/jni/src/c/sqlite3-jni.h f10d2f38720687c70ecdd5e44f6e8db98efee2caa05fc86b2d9e0c76e6cc0a18
+F ext/jni/src/c/sqlite3-jni.c fc9ab59b3d966219f20fdc93fae7bc5ce19900f7c979b84489be4384c8532120
+F ext/jni/src/c/sqlite3-jni.h 8b0ab1a3f0f92b75d4ff50db4a88b66a137cfb561268eb15bb3993ed174dbb74
F ext/jni/src/org/sqlite/jni/Authorizer.java 1308988f7f40579ea0e4deeaec3c6be971630566bd021c31367fe3f5140db892
F ext/jni/src/org/sqlite/jni/AutoExtension.java 18e83f6f463e306df60b2dceb65247d32af1f78af4bbbae9155411a8c6cdb093
F ext/jni/src/org/sqlite/jni/BusyHandler.java 1b1d3e5c86cd796a0580c81b6af6550ad943baa25e47ada0dcca3aff3ebe978c
F ext/jni/src/org/sqlite/jni/CommitHook.java 87c6a8e5138c61a8eeff018fe16d23f29219150239746032687f245938baca1a
F ext/jni/src/org/sqlite/jni/Fts5.java 13844685231e8b4840a706db3bed84d5dfcf15be0ae7e809eac40420dba24901
F ext/jni/src/org/sqlite/jni/Fts5Context.java 0a5a02047a6a1dd3e4a38b0e542a8dd2de365033ba30e6ae019a676305959890
-F ext/jni/src/org/sqlite/jni/Fts5ExtensionApi.java 93c0643e77a0226dad31610489490c6348ed9842c91e98f3ab0c440a173e75e7
+F ext/jni/src/org/sqlite/jni/Fts5ExtensionApi.java 7ecfce8075381999fcdfb94467535be9c63df0332e63bf57cbcb072036e1d113
F ext/jni/src/org/sqlite/jni/Fts5Function.java 65cde7151e441fee012250a5e03277de7babcd11a0c308a832b7940574259bcc
F ext/jni/src/org/sqlite/jni/Fts5PhraseIter.java 6642beda341c0b1b46af4e2d7f6f9ab03a7aede43277b2c92859176d6bce3be9
F ext/jni/src/org/sqlite/jni/Fts5Tokenizer.java 91489893596b6528c0df5cd7180bd5b55809c26e2b797fb321dfcdbc1298c060
F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86
F ext/jni/src/org/sqlite/jni/RollbackHook.java b04c8abcc6ade44a8a57129e33765793f69df0ba909e49ba18d73f4268d92564
F ext/jni/src/org/sqlite/jni/SQLFunction.java 8c1ad92c35bcc1b2f7256cf6e229b31340ed6d1a404d487f0a9adb28ba7fc332
-F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 26b3083501a9f42e9aa49b941f6b378213cf91ae1a8f705602773ed750043a3c
-F ext/jni/src/org/sqlite/jni/Tester1.java b0ad66a7e7b70dcff98557d3b092e1a2b195d1c7e91e02e51ea8597f842dc5a4
-F ext/jni/src/org/sqlite/jni/TesterFts5.java 3914b0a7ab0ff752c1082b1ae0c09b32827d81962fff62bcd0e13b9ec3a6f03f
+F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 5c469585946b63592cafe134b01af0b9144a12131f22ea352e12f4c3ec70efb2
+F ext/jni/src/org/sqlite/jni/Tester1.java d1e59c7601100e60f5467e52a04f032881344246436601912eafc5f61aeea134
+F ext/jni/src/org/sqlite/jni/TesterFts5.java bd4b6316ef83e2c85b5f1f9729383c736c1771652339d1135493b5217c9d1bb3
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/ValueHolder.java f022873abaabf64f3dd71ab0d6037c6e71cece3b8819fa10bf26a5461dc973ee
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 0c7ac34f30e1f7e35a2ac4e5e55e5f24857b24afa81a7abecba60f1c9c68b9ff c319033276c3565d0f1f2cae1c91791940d322fe79696bc26d74fddeb2664373
-R 35896553571ede397fc34e5af8e0e6bc
+P 8254479c6ff1ea3cc9e56de1698db8405c03da90b9bf4c401182e47e0842baf8
+R 846f6f71bef64f8d4f48e59243174d3b
U stephan
-Z 1f979ceda0d0b798d0ca7e29bc8a0301
+Z 63d30481f30daf5779abda92ef1829f2
# Remove this line to create a well-formed Fossil manifest.
-8254479c6ff1ea3cc9e56de1698db8405c03da90b9bf4c401182e47e0842baf8
\ No newline at end of file
+0a84131008a2e7886dac64a3545dea634811f6eac2b90885ec9c61ed1e6544c3
\ No newline at end of file