Merge "Quit creating empty dictionary file in ExpandableBinaryDictionary."
This commit is contained in:
commit
98e276a0ec
2 changed files with 9 additions and 10 deletions
|
@ -27,7 +27,6 @@ import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
|
||||||
import com.android.inputmethod.latin.makedict.WordProperty;
|
import com.android.inputmethod.latin.makedict.WordProperty;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.utils.AsyncResultHolder;
|
import com.android.inputmethod.latin.utils.AsyncResultHolder;
|
||||||
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.CombinedFormatUtils;
|
import com.android.inputmethod.latin.utils.CombinedFormatUtils;
|
||||||
import com.android.inputmethod.latin.utils.ExecutorUtils;
|
import com.android.inputmethod.latin.utils.ExecutorUtils;
|
||||||
|
@ -233,24 +232,24 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
||||||
mBinaryDictionary = null;
|
mBinaryDictionary = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createBinaryDictionaryLocked() {
|
|
||||||
BinaryDictionaryUtils.createEmptyDictFile(mDictFile.getAbsolutePath(),
|
|
||||||
DICTIONARY_FORMAT_VERSION, mLocale, getHeaderAttributeMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openBinaryDictionaryLocked() {
|
private void openBinaryDictionaryLocked() {
|
||||||
mBinaryDictionary = new BinaryDictionary(
|
mBinaryDictionary = new BinaryDictionary(
|
||||||
mDictFile.getAbsolutePath(), 0 /* offset */, mDictFile.length(),
|
mDictFile.getAbsolutePath(), 0 /* offset */, mDictFile.length(),
|
||||||
true /* useFullEditDistance */, mLocale, mDictType, true /* isUpdatable */);
|
true /* useFullEditDistance */, mLocale, mDictType, true /* isUpdatable */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createOnMemoryBinaryDictionaryLocked() {
|
||||||
|
mBinaryDictionary = new BinaryDictionary(
|
||||||
|
mDictFile.getAbsolutePath(), true /* useFullEditDistance */, mLocale, mDictType,
|
||||||
|
DICTIONARY_FORMAT_VERSION, getHeaderAttributeMap());
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
ExecutorUtils.getExecutor(mDictName).execute(new Runnable() {
|
ExecutorUtils.getExecutor(mDictName).execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
removeBinaryDictionaryLocked();
|
removeBinaryDictionaryLocked();
|
||||||
createBinaryDictionaryLocked();
|
createOnMemoryBinaryDictionaryLocked();
|
||||||
openBinaryDictionaryLocked();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -512,8 +511,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
||||||
+ mDictNameDictionaryUpdateController.mLastUpdateTime);
|
+ mDictNameDictionaryUpdateController.mLastUpdateTime);
|
||||||
}
|
}
|
||||||
removeBinaryDictionaryLocked();
|
removeBinaryDictionaryLocked();
|
||||||
createBinaryDictionaryLocked();
|
createOnMemoryBinaryDictionaryLocked();
|
||||||
openBinaryDictionaryLocked();
|
|
||||||
loadInitialContentsLocked();
|
loadInitialContentsLocked();
|
||||||
// Run GC and flush to file when initial contents have been loaded.
|
// Run GC and flush to file when initial contents have been loaded.
|
||||||
mBinaryDictionary.flushWithGCIfHasUpdated();
|
mBinaryDictionary.flushWithGCIfHasUpdated();
|
||||||
|
|
|
@ -91,6 +91,7 @@ public final class BinaryDictionaryUtils {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UsedForTesting
|
||||||
public static boolean createEmptyDictFile(final String filePath, final long dictVersion,
|
public static boolean createEmptyDictFile(final String filePath, final long dictVersion,
|
||||||
final Locale locale, final Map<String, String> attributeMap) {
|
final Locale locale, final Map<String, String> attributeMap) {
|
||||||
final String[] keyArray = new String[attributeMap.size()];
|
final String[] keyArray = new String[attributeMap.size()];
|
||||||
|
|
Loading…
Reference in a new issue