我想继续使用 Room,但我看不到如何创建使用 rtree 的实体。有 @FTS3 和 @FTS4 注释,但我没有看到 RTree 的注释。是否可以使用 R-Tree 创建实体?
我尝试使用此代码进行迁移,但我仍然没有 Room 的实体...
val TABLE_CREATE = "CREATE VIRTUAL TABLE if not exists my_table_name USING rtree(" +
"row_id," + // Primary key
"minX, maxX," + // Minimum and maximum X coordinate
"minY, maxY" + // Minimum and maximum Y coordinate
");"
db.execSQL(TABLE_CREATE)
最佳答案
我认为目前不可能在 Room 中使用 RTree。
要使用 RTree,您需要使用选项 -DSQLITE_ENABLE_RTREE=1 编译的 SQLite 发行版。
Room 是 SQLite 上的一个抽象层,随 Android 设备一起分发,我相信它没有启用 RTree(如果是的话,我猜@RTree 注释将可用)。
例如在 API 31 上,如果您尝试使用您会得到:-
E/SQLiteLog: (1) statement aborts at 28: [CREATE VIRTUAL TABLE rtree1 USING rtree(id,minX,maxX,minY,maxY);] no such module: rtree
即rtree 未启用。
关于android - 是否可以使用 Android Room 数据库创建 R*Tree 表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69593568/