vector db more stats logging
This commit is contained in:
@@ -131,8 +131,10 @@ class ClipVectorDB {
|
||||
size: stats.$1.toInt(),
|
||||
capacity: stats.$2.toInt(),
|
||||
dimensions: stats.$3.toInt(),
|
||||
expansionAdd: stats.$4.toInt(),
|
||||
expansionSearch: stats.$5.toInt(),
|
||||
fileSize: stats.$4.toInt(),
|
||||
memoryUsage: stats.$5.toInt(),
|
||||
expansionAdd: stats.$6.toInt(),
|
||||
expansionSearch: stats.$7.toInt(),
|
||||
);
|
||||
} catch (e, s) {
|
||||
_logger.severe("Error getting index stats", e, s);
|
||||
@@ -210,6 +212,10 @@ class VectorDbStats {
|
||||
final int capacity;
|
||||
final int dimensions;
|
||||
|
||||
// in bytes
|
||||
final int fileSize;
|
||||
final int memoryUsage;
|
||||
|
||||
final int expansionAdd;
|
||||
final int expansionSearch;
|
||||
|
||||
@@ -217,12 +223,14 @@ class VectorDbStats {
|
||||
required this.size,
|
||||
required this.capacity,
|
||||
required this.dimensions,
|
||||
required this.fileSize,
|
||||
required this.memoryUsage,
|
||||
required this.expansionAdd,
|
||||
required this.expansionSearch,
|
||||
});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "VectorDbStats(size: $size, capacity: $capacity, dimensions: $dimensions, expansionAdd: $expansionAdd, expansionSearch: $expansionSearch)";
|
||||
return "VectorDbStats(size: $size, capacity: $capacity, dimensions: $dimensions, file size (bytes): $fileSize, memory usage (bytes): $memoryUsage, expansionAdd: $expansionAdd, expansionSearch: $expansionSearch)";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ abstract class VectorDb implements RustOpaqueInterface {
|
||||
|
||||
Future<void> deleteIndex();
|
||||
|
||||
Future<(BigInt, BigInt, BigInt, BigInt, BigInt)> getIndexStats();
|
||||
Future<(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)>
|
||||
getIndexStats();
|
||||
|
||||
Future<Float32List> getVector({required BigInt key});
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ abstract class RustLibApi extends BaseApi {
|
||||
|
||||
Future<void> crateApiUsearchApiVectorDbDeleteIndex({required VectorDb that});
|
||||
|
||||
Future<(BigInt, BigInt, BigInt, BigInt, BigInt)>
|
||||
Future<(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)>
|
||||
crateApiUsearchApiVectorDbGetIndexStats({required VectorDb that});
|
||||
|
||||
Future<Float32List> crateApiUsearchApiVectorDbGetVector(
|
||||
@@ -356,7 +356,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
);
|
||||
|
||||
@override
|
||||
Future<(BigInt, BigInt, BigInt, BigInt, BigInt)>
|
||||
Future<(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)>
|
||||
crateApiUsearchApiVectorDbGetIndexStats({required VectorDb that}) {
|
||||
return handler.executeNormal(NormalTask(
|
||||
callFfi: (port_) {
|
||||
@@ -367,7 +367,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
funcId: 8, port: port_);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_record_usize_usize_usize_usize_usize,
|
||||
decodeSuccessData:
|
||||
sse_decode_record_usize_usize_usize_usize_usize_usize_usize,
|
||||
decodeErrorData: null,
|
||||
),
|
||||
constMeta: kCrateApiUsearchApiVectorDbGetIndexStatsConstMeta,
|
||||
@@ -691,12 +692,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
}
|
||||
|
||||
@protected
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt)
|
||||
dco_decode_record_usize_usize_usize_usize_usize(dynamic raw) {
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)
|
||||
dco_decode_record_usize_usize_usize_usize_usize_usize_usize(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 5) {
|
||||
throw Exception('Expected 5 elements, got ${arr.length}');
|
||||
if (arr.length != 7) {
|
||||
throw Exception('Expected 7 elements, got ${arr.length}');
|
||||
}
|
||||
return (
|
||||
dco_decode_usize(arr[0]),
|
||||
@@ -704,6 +705,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
dco_decode_usize(arr[2]),
|
||||
dco_decode_usize(arr[3]),
|
||||
dco_decode_usize(arr[4]),
|
||||
dco_decode_usize(arr[5]),
|
||||
dco_decode_usize(arr[6]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -852,8 +855,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
}
|
||||
|
||||
@protected
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt)
|
||||
sse_decode_record_usize_usize_usize_usize_usize(
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)
|
||||
sse_decode_record_usize_usize_usize_usize_usize_usize_usize(
|
||||
SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
final var_field0 = sse_decode_usize(deserializer);
|
||||
@@ -861,7 +864,17 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
final var_field2 = sse_decode_usize(deserializer);
|
||||
final var_field3 = sse_decode_usize(deserializer);
|
||||
final var_field4 = sse_decode_usize(deserializer);
|
||||
return (var_field0, var_field1, var_field2, var_field3, var_field4);
|
||||
final var_field5 = sse_decode_usize(deserializer);
|
||||
final var_field6 = sse_decode_usize(deserializer);
|
||||
return (
|
||||
var_field0,
|
||||
var_field1,
|
||||
var_field2,
|
||||
var_field3,
|
||||
var_field4,
|
||||
var_field5,
|
||||
var_field6
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -1008,14 +1021,17 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_record_usize_usize_usize_usize_usize(
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt) self, SseSerializer serializer) {
|
||||
void sse_encode_record_usize_usize_usize_usize_usize_usize_usize(
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt) self,
|
||||
SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
sse_encode_usize(self.$1, serializer);
|
||||
sse_encode_usize(self.$2, serializer);
|
||||
sse_encode_usize(self.$3, serializer);
|
||||
sse_encode_usize(self.$4, serializer);
|
||||
sse_encode_usize(self.$5, serializer);
|
||||
sse_encode_usize(self.$6, serializer);
|
||||
sse_encode_usize(self.$7, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -1099,10 +1115,11 @@ class VectorDbImpl extends RustOpaque implements VectorDb {
|
||||
that: this,
|
||||
);
|
||||
|
||||
Future<(BigInt, BigInt, BigInt, BigInt, BigInt)> getIndexStats() =>
|
||||
RustLib.instance.api.crateApiUsearchApiVectorDbGetIndexStats(
|
||||
that: this,
|
||||
);
|
||||
Future<(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)>
|
||||
getIndexStats() =>
|
||||
RustLib.instance.api.crateApiUsearchApiVectorDbGetIndexStats(
|
||||
that: this,
|
||||
);
|
||||
|
||||
Future<Float32List> getVector({required BigInt key}) => RustLib.instance.api
|
||||
.crateApiUsearchApiVectorDbGetVector(that: this, key: key);
|
||||
|
||||
@@ -79,8 +79,8 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
) dco_decode_record_list_prim_u_64_strict_list_prim_f_32_strict(dynamic raw);
|
||||
|
||||
@protected
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt)
|
||||
dco_decode_record_usize_usize_usize_usize_usize(dynamic raw);
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)
|
||||
dco_decode_record_usize_usize_usize_usize_usize_usize_usize(dynamic raw);
|
||||
|
||||
@protected
|
||||
BigInt dco_decode_u_64(dynamic raw);
|
||||
@@ -149,8 +149,8 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt)
|
||||
sse_decode_record_usize_usize_usize_usize_usize(
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)
|
||||
sse_decode_record_usize_usize_usize_usize_usize_usize_usize(
|
||||
SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
@@ -225,8 +225,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
(Uint64List, Float32List) self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_record_usize_usize_usize_usize_usize(
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt) self, SseSerializer serializer);
|
||||
void sse_encode_record_usize_usize_usize_usize_usize_usize_usize(
|
||||
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt) self,
|
||||
SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_u_64(BigInt self, SseSerializer serializer);
|
||||
|
||||
@@ -164,13 +164,25 @@ impl VectorDB {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_index_stats(&self) -> (usize, usize, usize, usize, usize) {
|
||||
pub fn get_index_stats(&self) -> (usize, usize, usize, usize, usize, usize, usize) {
|
||||
let size = self.index.size();
|
||||
let capacity = self.index.capacity();
|
||||
let dimensions = self.index.dimensions();
|
||||
|
||||
let file_size = self.index.serialized_length();
|
||||
let memory_usage = self.index.memory_usage();
|
||||
|
||||
let expansion_add = self.index.expansion_add();
|
||||
let expansion_search = self.index.expansion_search();
|
||||
|
||||
(size, capacity, dimensions, expansion_add, expansion_search)
|
||||
(
|
||||
size,
|
||||
capacity,
|
||||
dimensions,
|
||||
file_size,
|
||||
memory_usage,
|
||||
expansion_add,
|
||||
expansion_search,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -904,7 +904,7 @@ impl SseDecode for (Vec<u64>, Vec<f32>) {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for (usize, usize, usize, usize, usize) {
|
||||
impl SseDecode for (usize, usize, usize, usize, usize, usize, usize) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
let mut var_field0 = <usize>::sse_decode(deserializer);
|
||||
@@ -912,7 +912,11 @@ impl SseDecode for (usize, usize, usize, usize, usize) {
|
||||
let mut var_field2 = <usize>::sse_decode(deserializer);
|
||||
let mut var_field3 = <usize>::sse_decode(deserializer);
|
||||
let mut var_field4 = <usize>::sse_decode(deserializer);
|
||||
return (var_field0, var_field1, var_field2, var_field3, var_field4);
|
||||
let mut var_field5 = <usize>::sse_decode(deserializer);
|
||||
let mut var_field6 = <usize>::sse_decode(deserializer);
|
||||
return (
|
||||
var_field0, var_field1, var_field2, var_field3, var_field4, var_field5, var_field6,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1171,7 +1175,7 @@ impl SseEncode for (Vec<u64>, Vec<f32>) {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for (usize, usize, usize, usize, usize) {
|
||||
impl SseEncode for (usize, usize, usize, usize, usize, usize, usize) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
<usize>::sse_encode(self.0, serializer);
|
||||
@@ -1179,6 +1183,8 @@ impl SseEncode for (usize, usize, usize, usize, usize) {
|
||||
<usize>::sse_encode(self.2, serializer);
|
||||
<usize>::sse_encode(self.3, serializer);
|
||||
<usize>::sse_encode(self.4, serializer);
|
||||
<usize>::sse_encode(self.5, serializer);
|
||||
<usize>::sse_encode(self.6, serializer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user