我一直收到这个烦人的提示信息!
当数据插入本地数据库完成后,我看到了这条消息。
JNI critical lock held for 30.083ms on Thread[27,tid=23883,Runnable,Thread*=0xce150a00,peer=0x12cc0190,"Sqflite"]
如果我从表中选择数据,我会得到
W/CursorWindow(23809): Window is full: requested allocation 3095146 bytes, free space 2096696 bytes, window size 2097152 bytes
E/SQLiteQuery(23809): exception: Row too big to fit into CursorWindow requiredPos=0, totalRows=1; query: SELECT * FROM description_table;
I/flutter (23809): DatabaseException(Row too big to fit into CursorWindow requiredPos=0, totalRows=1) sql 'SELECT * FROM defect_description_table;' args []}
我没有任何二进制大对象数据,全部都是字符串。那么为什么会发生这种情况呢?
以下是 JSON 结构
[{ "id": 1, "name": "Descriptions","data": [{..},{...} ... ]},{....},{....}]
我认为问题出在数据列表上,因为它包含了很多数据(共10298个)?
这个问题应该怎么解决?
我的插入方法:
Future insertData(
BuildContext context, String urls, String accessToken) async {
CategoryTableData categoryData = CategoryTableData();
try {
var desc = List<Desc>();
var headers = {
'authorization': "Bearer" + " " + accessToken,
"Accept": "application/json"
};
var url = xxx;
var response = await http.get(url, headers: headers);
var res = json.decode(response.body);
for (var i in res) {
if (i['name'] == "Descriptions") {
desc.add(Desc(
id: i['id'], name: i['name'], data: i['data']));
}
}
await dao.batch((b) {
b.insertAll(_dao.descTable, desc);
});
categoryData = await _dao.selectAllCategories();
return categoryData;
} catch (e) {
print(e);
categoryData = await _dao.selectAllCategories();
return categoryData;
}
}
描述
class Desc extends Table {
IntColumn get id => integer().nullable()();
TextColumn get name => text().named("name").nullable()();
TextColumn get data => text().map(const ListConverter()).nullable()();
}