Closed sunshine0576 closed 5 years ago
I wouldn't want to force caching for all query situations. Instead, I added the ability to iterate through the ids without creating the feature rows (for certain result types including RTree). Added some cache classes that you can use to maintain the rows within a single table and the rows for all tables in a single GeoPackage.
Example:
FeatureCacheTables featureCache = new FeatureCacheTables();
List<String> featureTables = geoPackage.getFeatureTables();
for (String featureTable : featureTables) {
FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
FeatureIndexManager featureIndexManager = new FeatureIndexManager(activity,
geoPackage, featureDao);
for(int i = 0; i < 2; i++) {
FeatureIndexResults featureIndexResults = featureIndexManager.query();
for (long featureRowId : featureIndexResults.ids()) {
FeatureRow featureRow = featureCache.get(featureTable, featureRowId);
if (featureRow == null) {
featureRow = featureDao.queryForIdRow(featureRowId);
featureCache.put(featureRow);
}
}
featureIndexResults.close();
}
featureIndexManager.close();
}
When large data is frequently queried, the speed of building data is too slow. For data over 1W, index queries take only a few milliseconds, and building FeatureRow takes more than 3-5 seconds. In most cases, only a small part of the data will be updated during map movement. Supporting caching when querying can greatly improve the speed of map loading.