vectorIndexBuiltStateToJson function

Map<String, Object?>? vectorIndexBuiltStateToJson(
  1. Object idx, {
  2. int seed = 1234,
})

Dispatch on the runtime type of a built index and return its serialized state, or null when the type isn't recognised.

Implementation

Map<String, Object?>? vectorIndexBuiltStateToJson(
  Object idx, {
  int seed = 1234,
}) {
  if (idx is FlatIndex) return idx.toJson();
  if (idx is HnswIndex) return idx.toJson();
  if (idx is IvfFlatIndex) return idx.toJson();
  if (idx is LshIndex) return idx.toJson(seed);
  if (idx is PqIndex) return idx.toJson();
  if (idx is IvfPqIndex) return idx.toJson();
  return null;
}