From ce5fd94b9714f0b8bf3c28eef7176a30b9334bcb Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Wed, 1 Oct 2014 17:40:20 +0900 Subject: [PATCH] Add jni method to update entries for a word efficiently. Bug: 14425059 Change-Id: Ic628939ea68cdee17573409883a8403c73b78905 --- .../inputmethod/latin/BinaryDictionary.java | 3 +++ ...roid_inputmethod_latin_BinaryDictionary.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 1da33ed3f..6f3c48c47 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -199,6 +199,9 @@ public final class BinaryDictionary extends Dictionary { int[] word, int probability, int timestamp); private static native boolean removeNgramEntryNative(long dict, int[][] prevWordCodePointArrays, boolean[] isBeginningOfSentenceArray, int[] word); + private static native boolean updateCounterNative(long dict, + int[][] prevWordCodePointArrays, boolean[] isBeginningOfSentenceArray, + int[] word, boolean isValidWord, int count, int timestamp); private static native int addMultipleDictionaryEntriesNative(long dict, LanguageModelParam[] languageModelParams, int startIndex); private static native String getPropertyNative(long dict, String query); diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp index da8c2ac03..1e6baa5ec 100644 --- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp @@ -427,6 +427,19 @@ static bool latinime_BinaryDictionary_removeNgramEntry(JNIEnv *env, jclass clazz CodePointArrayView(wordCodePoints, codePointCount)); } +static bool latinime_BinaryDictionary_updateCounter(JNIEnv *env, jclass clazz, jlong dict, + jobjectArray prevWordCodePointArrays, jbooleanArray isBeginningOfSentenceArray, + jintArray word, jboolean isValidWord, jint count, jint timestamp) { + Dictionary *dictionary = reinterpret_cast(dict); + if (!dictionary) { + return false; + } + jsize wordLength = env->GetArrayLength(word); + int wordCodePoints[wordLength]; + env->GetIntArrayRegion(word, 0, wordLength, wordCodePoints); + return false; +} + // Returns how many language model params are processed. static int latinime_BinaryDictionary_addMultipleDictionaryEntries(JNIEnv *env, jclass clazz, jlong dict, jobjectArray languageModelParams, jint startIndex) { @@ -724,6 +737,11 @@ static const JNINativeMethod sMethods[] = { const_cast("(J[[I[Z[I)Z"), reinterpret_cast(latinime_BinaryDictionary_removeNgramEntry) }, + { + const_cast("updateCounterNative"), + const_cast("(J[[I[Z[IZII)Z"), + reinterpret_cast(latinime_BinaryDictionary_updateCounter) + }, { const_cast("addMultipleDictionaryEntriesNative"), const_cast(