LiteCore
Couchbase Lite cross-platform core implementation
Loading...
Searching...
No Matches
C4PredictiveModel Struct Reference

Configuration struct for registering a predictive model. More...

#include <c4PredictiveQuery.h>

Data Fields

void * context
 A pointer to any external data needed by the prediction callback, which will receive this as its first parameter.
 
C4SliceResult(* prediction )(void *context, FLDict input, C4Database *database, C4Error *error)
 Called from within a query (or document indexing) to run the prediction.
 
void(* unregistered )(void *context)
 Called if the model is unregistered, so it can release resources.
 

Detailed Description

Configuration struct for registering a predictive model.

Field Documentation

◆ context

void* C4PredictiveModel::context

A pointer to any external data needed by the prediction callback, which will receive this as its first parameter.

◆ prediction

C4SliceResult(* C4PredictiveModel::prediction) (void *context, FLDict input, C4Database *database, C4Error *error)

Called from within a query (or document indexing) to run the prediction.

Warning
This function must be "pure": given the same input parameters it must always produce the same output (otherwise indexes or queries may be messed up). It MUST NOT alter the database or any documents, nor run a query: either of those are very likely to cause a crash.
Parameters
contextThe value of the C4PredictiveModel's context field; typically a pointer to external data needed by the implementation.
inputThe input dictionary from the query.
databaseThe database being queried. DO NOT use this reference to write to documents or to run queries!
errorStore an error here on failure. It is NOT a failure for input parameters to be missing or the wrong type, since this can easily happen when the query reaches a document that doesn't contain input data, or if the document's schema is incorrect. This should not abort the entire query! Instead just return a null slice.
Returns
The output of the prediction function, encoded as a Fleece dictionary, or as {NULL, 0} if there is no output.

◆ unregistered

void(* C4PredictiveModel::unregistered) (void *context)

Called if the model is unregistered, so it can release resources.


The documentation for this struct was generated from the following file: