优化
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.sw.inbound.objbox
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
||||
import android.util.Log
|
||||
@@ -51,6 +52,7 @@ import kotlin.jvm.javaClass
|
||||
* Singleton to keep BoxStore reference and provide current list of Notes Objects.
|
||||
* Inserts demo data if no Objects are stored.
|
||||
*/
|
||||
@SuppressLint("LogNotTimber")
|
||||
object ObjectBox {
|
||||
|
||||
// 确保所有设备/版本使用相同的objectbox-models/default.json
|
||||
@@ -76,8 +78,8 @@ object ObjectBox {
|
||||
boxStore = try {
|
||||
MyObjectBox.builder()
|
||||
.androidContext(context.applicationContext)
|
||||
.disableMultiProcess() // 开启多进程支持(按需关闭,单进程可删)
|
||||
.disableFileCompression() // 禁用文件压缩,避免存储异常
|
||||
//.disableMultiProcess() // 开启多进程支持(按需关闭,单进程可删)
|
||||
//.disableFileCompression() // 禁用文件压缩,避免存储异常
|
||||
.build()
|
||||
} catch (e: DbException) {
|
||||
if (e.javaClass == DbException::class.java || e is FileCorruptException) {
|
||||
@@ -149,7 +151,7 @@ object ObjectBox {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun query(floatArray: FloatArray?, queryCount: Int) = safeDbOp {
|
||||
suspend fun query(floatArray: FloatArray, queryCount: Int) = safeDbOp {
|
||||
val query: Query<Food>? = getBox<Food>()?.query(
|
||||
Food_.foodVector
|
||||
.nearestNeighbors(floatArray, queryCount)
|
||||
|
||||
Reference in New Issue
Block a user