Remove reset index
This commit is contained in:
@@ -31,8 +31,6 @@ abstract class VectorDb implements RustOpaqueInterface {
|
||||
|
||||
Future<BigInt> removeVector({required BigInt key});
|
||||
|
||||
Future<void> resetIndex();
|
||||
|
||||
Future<(Uint64List, Float32List)> searchVectors({
|
||||
required List<double> query,
|
||||
required BigInt count,
|
||||
|
||||
@@ -70,7 +70,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
|
||||
String get codegenVersion => '2.9.0';
|
||||
|
||||
@override
|
||||
int get rustContentHash => 862168794;
|
||||
int get rustContentHash => 846037902;
|
||||
|
||||
static const kDefaultExternalLibraryLoaderConfig =
|
||||
ExternalLibraryLoaderConfig(
|
||||
@@ -113,8 +113,6 @@ abstract class RustLibApi extends BaseApi {
|
||||
required BigInt key,
|
||||
});
|
||||
|
||||
Future<void> crateApiUsearchApiVectorDbResetIndex({required VectorDb that});
|
||||
|
||||
Future<(Uint64List, Float32List)> crateApiUsearchApiVectorDbSearchVectors({
|
||||
required VectorDb that,
|
||||
required List<double> query,
|
||||
@@ -398,40 +396,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
argNames: ["that", "key"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> crateApiUsearchApiVectorDbResetIndex({required VectorDb that}) {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
|
||||
that,
|
||||
serializer,
|
||||
);
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 8,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_unit,
|
||||
decodeErrorData: null,
|
||||
),
|
||||
constMeta: kCrateApiUsearchApiVectorDbResetIndexConstMeta,
|
||||
argValues: [that],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiUsearchApiVectorDbResetIndexConstMeta =>
|
||||
const TaskConstMeta(
|
||||
debugName: "VectorDb_reset_index",
|
||||
argNames: ["that"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<(Uint64List, Float32List)> crateApiUsearchApiVectorDbSearchVectors({
|
||||
required VectorDb that,
|
||||
@@ -451,7 +415,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 9,
|
||||
funcId: 8,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -480,7 +444,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
callFfi: () {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
sse_encode_String(name, serializer);
|
||||
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 10)!;
|
||||
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 9)!;
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_String,
|
||||
@@ -507,7 +471,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 11,
|
||||
funcId: 10,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1064,11 +1028,6 @@ class VectorDbImpl extends RustOpaque implements VectorDb {
|
||||
Future<BigInt> removeVector({required BigInt key}) => RustLib.instance.api
|
||||
.crateApiUsearchApiVectorDbRemoveVector(that: this, key: key);
|
||||
|
||||
Future<void> resetIndex() =>
|
||||
RustLib.instance.api.crateApiUsearchApiVectorDbResetIndex(
|
||||
that: this,
|
||||
);
|
||||
|
||||
Future<(Uint64List, Float32List)> searchVectors({
|
||||
required List<double> query,
|
||||
required BigInt count,
|
||||
|
||||
@@ -94,7 +94,6 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
|
||||
filePath: indexPath,
|
||||
dimensions: BigInt.from(tenEmbeddings.first.length),
|
||||
);
|
||||
await rustVectorDB.resetIndex();
|
||||
final stats = await rustVectorDB.getIndexStats();
|
||||
logger.info("vector_db stats: $stats");
|
||||
await rustVectorDB.bulkAddVectors(
|
||||
|
||||
@@ -98,11 +98,6 @@ impl VectorDB {
|
||||
removed_count
|
||||
}
|
||||
|
||||
pub fn reset_index(&mut self) {
|
||||
self.index.reset();
|
||||
self.save_index();
|
||||
}
|
||||
|
||||
pub fn delete_index(self) {
|
||||
if self.path.exists() {
|
||||
std::fs::remove_file(&self.path).expect("Failed to delete index file");
|
||||
|
||||
@@ -38,7 +38,7 @@ flutter_rust_bridge::frb_generated_boilerplate!(
|
||||
default_rust_auto_opaque = RustAutoOpaqueMoi,
|
||||
);
|
||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.9.0";
|
||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 862168794;
|
||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 846037902;
|
||||
|
||||
// Section: executor
|
||||
|
||||
@@ -370,57 +370,6 @@ fn wire__crate__api__usearch_api__VectorDb_remove_vector_impl(
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__usearch_api__VectorDb_reset_index_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
|
||||
rust_vec_len_: i32,
|
||||
data_len_: i32,
|
||||
) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
debug_name: "VectorDb_reset_index",
|
||||
port: Some(port_),
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||
},
|
||||
move || {
|
||||
let message = unsafe {
|
||||
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
|
||||
ptr_,
|
||||
rust_vec_len_,
|
||||
data_len_,
|
||||
)
|
||||
};
|
||||
let mut deserializer =
|
||||
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
|
||||
let api_that = <RustOpaqueMoi<
|
||||
flutter_rust_bridge::for_generated::RustAutoOpaqueInner<VectorDB>,
|
||||
>>::sse_decode(&mut deserializer);
|
||||
deserializer.end();
|
||||
move |context| {
|
||||
transform_result_sse::<_, ()>((move || {
|
||||
let mut api_that_guard = None;
|
||||
let decode_indices_ =
|
||||
flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![
|
||||
flutter_rust_bridge::for_generated::LockableOrderInfo::new(
|
||||
&api_that, 0, true,
|
||||
),
|
||||
]);
|
||||
for i in decode_indices_ {
|
||||
match i {
|
||||
0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
let mut api_that_guard = api_that_guard.unwrap();
|
||||
let output_ok = Result::<_, ()>::Ok({
|
||||
crate::api::usearch_api::VectorDB::reset_index(&mut *api_that_guard);
|
||||
})?;
|
||||
Ok(output_ok)
|
||||
})())
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__usearch_api__VectorDb_search_vectors_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
|
||||
@@ -739,19 +688,13 @@ fn pde_ffi_dispatcher_primary_impl(
|
||||
rust_vec_len,
|
||||
data_len,
|
||||
),
|
||||
8 => wire__crate__api__usearch_api__VectorDb_reset_index_impl(
|
||||
8 => wire__crate__api__usearch_api__VectorDb_search_vectors_impl(
|
||||
port,
|
||||
ptr,
|
||||
rust_vec_len,
|
||||
data_len,
|
||||
),
|
||||
9 => wire__crate__api__usearch_api__VectorDb_search_vectors_impl(
|
||||
port,
|
||||
ptr,
|
||||
rust_vec_len,
|
||||
data_len,
|
||||
),
|
||||
11 => wire__crate__api__simple__init_app_impl(port, ptr, rust_vec_len, data_len),
|
||||
10 => wire__crate__api__simple__init_app_impl(port, ptr, rust_vec_len, data_len),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -765,7 +708,7 @@ fn pde_ffi_dispatcher_sync_impl(
|
||||
// Codec=Pde (Serialization + dispatch), see doc to use other codecs
|
||||
match func_id {
|
||||
6 => wire__crate__api__usearch_api__VectorDb_new_impl(ptr, rust_vec_len, data_len),
|
||||
10 => wire__crate__api__simple__greet_impl(ptr, rust_vec_len, data_len),
|
||||
9 => wire__crate__api__simple__greet_impl(ptr, rust_vec_len, data_len),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user