Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Class for vector db stats

laurenspriem63d90ea275f6
diff --git a/mobile/lib/db/ml/clip_vector_db.dart b/mobile/lib/db/ml/clip_vector_db.dart
index 84d3261460..9454a7a128 100644
--- a/mobile/lib/db/ml/clip_vector_db.dart
+++ b/mobile/lib/db/ml/clip_vector_db.dart
@@ -122,14 +122,16 @@ class ClipVectorDB {
}
}
- Future<(int, int, int)> getIndexStats() async {
+ Future<VectorDbStats> getIndexStats() async {
final db = await _vectorDB;
try {
final stats = await db.getIndexStats();
- return (
- stats.$1.toInt(),
- stats.$2.toInt(),
- stats.$3.toInt(),
+ return VectorDbStats(
+ size: stats.$1.toInt(),
+ capacity: stats.$2.toInt(),
+ dimensions: stats.$3.toInt(),
+ expansionAdd: stats.$4.toInt(),
+ expansionSearch: stats.$5.toInt(),
);
} catch (e, s) {
_logger.severe("Error getting index stats", e, s);
@@ -165,3 +167,25 @@ class ClipVectorDB {
}
}
}
+
+class VectorDbStats {
+ final int size;
+ final int capacity;
+ final int dimensions;
+
+ final int expansionAdd;
+ final int expansionSearch;
+
+ VectorDbStats({
+ required this.size,
+ required this.capacity,
+ required this.dimensions,
+ required this.expansionAdd,
+ required this.expansionSearch,
+ });
+
+ @override
+ String toString() {
+ return "VectorDbStats(size: $size, capacity: $capacity, dimensions: $dimensions, expansionAdd: $expansionAdd, expansionSearch: $expansionSearch)";
+ }
+}
diff --git a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
index 7ccdd26f56..7010860b97 100644
--- a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
+++ b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
@@ -155,12 +155,8 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
await clipVectorDB.deleteAllEmbeddings();
logger.info("Clean vector DB");
final stats = await clipVectorDB.getIndexStats();
- logger.info("ClipVectorDB stats: size: ${stats.$1}, "
- "capacity: ${stats.$2}, dimensions: ${stats.$3}");
- showShortToast(
- context,
- "ClipVectorDB stats: size: ${stats.$1}, "
- "capacity: ${stats.$2}, dimensions: ${stats.$3}");
+ logger.info(stats.toString());
+ showShortToast(context, stats.toString());
final fileIDs = allClipSmall.map((e) => e.fileID).toList();
final embeddings = allClipSmall
@@ -179,12 +175,8 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
"ClipVectorDB bulk insert took ${duration.inMilliseconds} ms for ${fileIDs.length} embeddings",
);
final statsAfter = await clipVectorDB.getIndexStats();
- logger.info("ClipVectorDB stats after: size: ${statsAfter.$1}, "
- "capacity: ${statsAfter.$2}, dimensions: ${statsAfter.$3}");
- showShortToast(
- context,
- "ClipVectorDB stats after: size: ${statsAfter.$1}, "
- "capacity: ${statsAfter.$2}, dimensions: ${statsAfter.$3}");
+ logger.info(statsAfter.toString());
+ showShortToast(context, statsAfter.toString());
} catch (e, s) {
logger.warning('ClipVectorDB migration failed ', e, s);
await showGenericErrorDialog(context: context, error: e);
@@ -201,7 +193,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
trailingIconIsMuted: true,
onTap: () async {
try {
- await MLDataDB.instance.migrateFillClipVectorDB();
+ await MLDataDB.instance.checkMigrateFillClipVectorDB();
showShortToast(context, "Migration done!");
} catch (e, s) {
logger.warning('ClipVectorDB migration failed ', e, s);
@@ -221,12 +213,8 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
try {
final clipVectorDB = ClipVectorDB.instance;
final stats = await clipVectorDB.getIndexStats();
- logger.info("ClipVectorDB stats: size: ${stats.$1}, "
- "capacity: ${stats.$2}, dimensions: ${stats.$3}");
- showShortToast(
- context,
- "ClipVectorDB stats: size: ${stats.$1}, "
- "capacity: ${stats.$2}, dimensions: ${stats.$3}");
+ logger.info(stats.toString());
+ showShortToast(context, stats.toString());
} catch (e, s) {
logger.warning('ClipVectorDB stats failed ', e, s);
await showGenericErrorDialog(context: context, error: e);