我一直在打这个烦人的消息!
当数据完成插入本地数据库时,我看到了这条消息
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 []}
我没有任何 blob 数据,都是字符串。那么为什么会发生这种情况呢?
这里是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()();
}