C API reference · Kjarni 0.2.8

indexer

kjarni_index_info_free

void kjarni_index_info_free(struct KjarniIndexInfo info);

Free memory allocated for index info strings

Safety

  • info must be a value returned by kjarni_index_info, passed here exactly once. Its buffers are invalid to read afterwards.

kjarni_indexer_config_default

struct KjarniIndexerConfig kjarni_indexer_config_default(void);

Get default indexer configuration

kjarni_indexer_new

enum KjarniErrorCode kjarni_indexer_new(const struct KjarniIndexerConfig *config, struct KjarniIndexer **out);

Create a new Indexer

Safety

  • out must be null, or a live handle returned by kjarni_indexer_new that has not been freed.

kjarni_indexer_free

void kjarni_indexer_free(struct KjarniIndexer *indexer);

Free an Indexer handle

Safety

  • indexer must be null, or a handle returned by kjarni_indexer_new that has not already been passed to this function. It is invalid to use afterwards.

kjarni_indexer_create

enum KjarniErrorCode kjarni_indexer_create(struct KjarniIndexer *indexer, const char *index_path, const char *const *inputs, uintptr_t num_inputs, int32_t force, struct KjarniIndexStats *out);

Create a new index from files/directories

Safety

  • indexer must be null, or a live handle returned by kjarni_indexer_new that has not been freed.
  • index_path must be null, or a valid pointer to a nul-terminated C string.
  • inputs must point to the accompanying count readable pointers, each null or a valid nul-terminated C string that stays valid for the call.
  • out must be a valid, writable pointer to a KjarniIndexStats. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.

kjarni_indexer_create_with_callback

enum KjarniErrorCode kjarni_indexer_create_with_callback(struct KjarniIndexer *indexer, const char *index_path, const char *const *inputs, uintptr_t num_inputs, int32_t force, KjarniProgressCallbackFn progress_callback, void *user_data, const struct KjarniCancelToken *cancel_token, struct KjarniIndexStats *out);

Create a new index with progress callback and cancellation support.

Safety

  • indexer must be null, or a live handle returned by kjarni_indexer_new that has not been freed.
  • index_path must be null, or a valid pointer to a nul-terminated C string.
  • inputs must point to the accompanying count readable pointers, each null or a valid nul-terminated C string that stays valid for the call.
  • user_data must be a valid, writable pointer to a c_void. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.
  • cancel_token must be null, or a live handle returned by kjarni_cancel_token_new that has not been freed.
  • out must be a valid, writable pointer to a KjarniIndexStats. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.

kjarni_indexer_add

enum KjarniErrorCode kjarni_indexer_add(struct KjarniIndexer *indexer, const char *index_path, const char *const *inputs, uintptr_t num_inputs, uintptr_t *documents_added);

Add documents to an existing index

Safety

  • indexer must be null, or a live handle returned by kjarni_indexer_new that has not been freed.
  • index_path must be null, or a valid pointer to a nul-terminated C string.
  • inputs must point to the accompanying count readable pointers, each null or a valid nul-terminated C string that stays valid for the call.
  • documents_added must be a valid, writable pointer to a usize. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.

kjarni_indexer_add_with_callback

enum KjarniErrorCode kjarni_indexer_add_with_callback(struct KjarniIndexer *indexer, const char *index_path, const char *const *inputs, uintptr_t num_inputs, KjarniProgressCallbackFn progress_callback, void *user_data, const struct KjarniCancelToken *cancel_token, uintptr_t *documents_added);

Add documents to an existing index with progress callback and cancellation support.

Safety

  • indexer must be null, or a live handle returned by kjarni_indexer_new that has not been freed.
  • index_path must be null, or a valid pointer to a nul-terminated C string.
  • inputs must point to the accompanying count readable pointers, each null or a valid nul-terminated C string that stays valid for the call.
  • user_data must be a valid, writable pointer to a c_void. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.
  • cancel_token must be null, or a live handle returned by kjarni_cancel_token_new that has not been freed.
  • documents_added must be a valid, writable pointer to a usize. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.

kjarni_index_info

enum KjarniErrorCode kjarni_index_info(const char *index_path, struct KjarniIndexInfo *out);

Get information about an existing index

Safety

  • index_path must be null, or a valid pointer to a nul-terminated C string.
  • out must be a valid, writable pointer to a KjarniIndexInfo. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.

kjarni_index_delete

enum KjarniErrorCode kjarni_index_delete(const char *index_path);

Delete an index.

Safety

  • index_path must be null, or a valid pointer to a nul-terminated C string.

kjarni_indexer_model_name

uintptr_t kjarni_indexer_model_name(const struct KjarniIndexer *indexer, char *buf, uintptr_t buf_len);

Get the embedding model name used by the indexer.

Safety

  • indexer must be null, or a live handle returned by kjarni_indexer_new that has not been freed.
  • buf must be null, or point to at least buf_len writable bytes. When it is null the required size is returned and nothing is written.

kjarni_indexer_dimension

uintptr_t kjarni_indexer_dimension(const struct KjarniIndexer *indexer);

Get the embedding dimension used by the indexer.

Safety

  • indexer must be null, or a live handle returned by kjarni_indexer_new that has not been freed.

kjarni_indexer_chunk_size

uintptr_t kjarni_indexer_chunk_size(const struct KjarniIndexer *indexer);

Get the chunk size configured for the indexer.

Safety

  • indexer must be null, or a live handle returned by kjarni_indexer_new that has not been freed.

Kjarni runs the same engine on every platform: