fetch method

List<ZvecSearchHit> fetch(
  1. List<String> ids
)

Implementation

List<ZvecSearchHit> fetch(List<String> ids) {
  _ensureOpen();
  if (ids.isEmpty) {
    return const <ZvecSearchHit>[];
  }

  final idPointers = calloc<Pointer<Utf8>>(ids.length);
  final results = calloc<Pointer<_NativeSearchResult>>();
  final outCount = calloc<Uint32>();

  try {
    for (var index = 0; index < ids.length; index++) {
      idPointers[index] = ids[index].toNativeUtf8();
    }

    final status = _bindings.zvecFetch(
      _handle,
      idPointers,
      ids.length,
      results,
      outCount,
    );
    _throwIfFailed(status);
    return _readSearchResults(results.value, outCount.value);
  } finally {
    for (var index = 0; index < ids.length; index++) {
      calloc.free(idPointers[index]);
    }
    calloc.free(idPointers);
    calloc.free(results);
    calloc.free(outCount);
  }
}