[mob][photos] Moving more methods to sqlite async
This commit is contained in:
parent
3828fa328e
commit
b2a2078045
4 changed files with 21 additions and 21 deletions
|
@ -98,7 +98,7 @@ class FaceMLDataDB {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> updateClusterIdToFaceId(
|
||||
Future<void> updateFaceIdToClusterId(
|
||||
Map<String, int> faceIDToClusterID,
|
||||
) async {
|
||||
final db = await instance.database;
|
||||
|
@ -197,8 +197,8 @@ class FaceMLDataDB {
|
|||
int clusterID, {
|
||||
int? limit,
|
||||
}) async {
|
||||
final db = await instance.database;
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
final db = await instance.sqliteAsyncDB;
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
'SELECT $faceEmbeddingBlob FROM $facesTable WHERE $faceIDColumn in (SELECT $fcFaceId from $faceClustersTable where $fcClusterID = ?) ${limit != null ? 'LIMIT $limit' : ''}',
|
||||
[clusterID],
|
||||
);
|
||||
|
@ -209,7 +209,7 @@ class FaceMLDataDB {
|
|||
Iterable<int> clusterIDs, {
|
||||
int? limit,
|
||||
}) async {
|
||||
final db = await instance.database;
|
||||
final db = await instance.sqliteAsyncDB;
|
||||
final Map<int, List<Uint8List>> result = {};
|
||||
|
||||
final selectQuery = '''
|
||||
|
@ -220,7 +220,7 @@ class FaceMLDataDB {
|
|||
${limit != null ? 'LIMIT $limit' : ''}
|
||||
''';
|
||||
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(selectQuery);
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(selectQuery);
|
||||
|
||||
for (final map in maps) {
|
||||
final clusterID = map[fcClusterID] as int;
|
||||
|
@ -321,8 +321,8 @@ class FaceMLDataDB {
|
|||
}
|
||||
|
||||
Future<Face?> getFaceForFaceID(String faceID) async {
|
||||
final db = await instance.database;
|
||||
final result = await db.rawQuery(
|
||||
final db = await instance.sqliteAsyncDB;
|
||||
final result = await db.getAll(
|
||||
'SELECT * FROM $facesTable where $faceIDColumn = ?',
|
||||
[faceID],
|
||||
);
|
||||
|
@ -420,8 +420,8 @@ class FaceMLDataDB {
|
|||
Future<Map<String, int?>> getFaceIdsToClusterIds(
|
||||
Iterable<String> faceIds,
|
||||
) async {
|
||||
final db = await instance.database;
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
final db = await instance.sqliteAsyncDB;
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
'SELECT $fcFaceId, $fcClusterID FROM $faceClustersTable where $fcFaceId IN (${faceIds.map((id) => "'$id'").join(",")})',
|
||||
);
|
||||
final Map<String, int?> result = {};
|
||||
|
@ -433,8 +433,8 @@ class FaceMLDataDB {
|
|||
|
||||
Future<Map<int, Set<int>>> getFileIdToClusterIds() async {
|
||||
final Map<int, Set<int>> result = {};
|
||||
final db = await instance.database;
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
final db = await instance.sqliteAsyncDB;
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
'SELECT $fcClusterID, $fcFaceId FROM $faceClustersTable',
|
||||
);
|
||||
|
||||
|
@ -791,9 +791,9 @@ class FaceMLDataDB {
|
|||
|
||||
// for a given personID, return a map of clusterID to fileIDs using join query
|
||||
Future<Map<int, Set<int>>> getFileIdToClusterIDSet(String personID) {
|
||||
final db = instance.database;
|
||||
final db = instance.sqliteAsyncDB;
|
||||
return db.then((db) async {
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
'SELECT $faceClustersTable.$fcClusterID, $fcFaceId FROM $faceClustersTable '
|
||||
'INNER JOIN $clusterPersonTable '
|
||||
'ON $faceClustersTable.$fcClusterID = $clusterPersonTable.$clusterIDColumn '
|
||||
|
@ -814,9 +814,9 @@ class FaceMLDataDB {
|
|||
Future<Map<int, Set<int>>> getFileIdToClusterIDSetForCluster(
|
||||
Set<int> clusterIDs,
|
||||
) {
|
||||
final db = instance.database;
|
||||
final db = instance.sqliteAsyncDB;
|
||||
return db.then((db) async {
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
'SELECT $fcClusterID, $fcFaceId FROM $faceClustersTable '
|
||||
'WHERE $fcClusterID IN (${clusterIDs.join(",")})',
|
||||
);
|
||||
|
@ -894,8 +894,8 @@ class FaceMLDataDB {
|
|||
}
|
||||
|
||||
Future<Map<int, String>> getClusterIDToPersonID() async {
|
||||
final db = await instance.database;
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
final db = await instance.sqliteAsyncDB;
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
'SELECT $personIdColumn, $clusterIDColumn FROM $clusterPersonTable',
|
||||
);
|
||||
final Map<int, String> result = {};
|
||||
|
|
|
@ -350,7 +350,7 @@ class FaceMlService {
|
|||
}
|
||||
|
||||
await FaceMLDataDB.instance
|
||||
.updateClusterIdToFaceId(clusteringResult.newFaceIdToCluster);
|
||||
.updateFaceIdToClusterId(clusteringResult.newFaceIdToCluster);
|
||||
await FaceMLDataDB.instance
|
||||
.clusterSummaryUpdate(clusteringResult.newClusterSummaries!);
|
||||
_logger.info(
|
||||
|
@ -403,7 +403,7 @@ class FaceMlService {
|
|||
'Updating ${clusteringResult.newFaceIdToCluster.length} FaceIDs with clusterIDs in the DB',
|
||||
);
|
||||
await FaceMLDataDB.instance
|
||||
.updateClusterIdToFaceId(clusteringResult.newFaceIdToCluster);
|
||||
.updateFaceIdToClusterId(clusteringResult.newFaceIdToCluster);
|
||||
await FaceMLDataDB.instance
|
||||
.clusterSummaryUpdate(clusteringResult.newClusterSummaries!);
|
||||
_logger.info('Done updating FaceIDs with clusterIDs in the DB, in '
|
||||
|
|
|
@ -412,7 +412,7 @@ class ClusterFeedbackService {
|
|||
final newClusterID = startClusterID + blurValue ~/ 10;
|
||||
faceIdToCluster[faceID] = newClusterID;
|
||||
}
|
||||
await FaceMLDataDB.instance.updateClusterIdToFaceId(faceIdToCluster);
|
||||
await FaceMLDataDB.instance.updateFaceIdToClusterId(faceIdToCluster);
|
||||
|
||||
Bus.instance.fire(PeopleChangedEvent());
|
||||
} catch (e, s) {
|
||||
|
|
|
@ -193,7 +193,7 @@ class PersonService {
|
|||
}
|
||||
|
||||
logger.info("Storing feedback for ${faceIdToClusterID.length} faces");
|
||||
await faceMLDataDB.updateClusterIdToFaceId(faceIdToClusterID);
|
||||
await faceMLDataDB.updateFaceIdToClusterId(faceIdToClusterID);
|
||||
await faceMLDataDB.bulkAssignClusterToPersonID(clusterToPersonID);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue