View Source Guesswork.Ast.Statement.Opts (Guesswork v0.8.0)

Defines the options used by the Guesswork.Ast.Statement protocol, as well as the current state of the query.

The following fields are available:

  • :knowledge_base (term/0) - The Guesswork.KnowledgeBase used to resolve queries. The default value is Guesswork.EmptyCollection.

  • :query_id (String.t/0) - The id used to report telemetry. Defaults to a new UUID (v4).

  • :precompute_count (integer/0) - The number of answer sets to compute when resolving a fact. This allows repeated facts (that would result in the same matches) to reuse computation. Note that, with recusive queries, this can lead to infinate searches. The default value is 0.

negated Vs. negate_constraints

Elixir.Guesswork.Ast.Statement.Opts tracks two different negated values: negated and negate_constraints. negated is used for resolving facts either to facts and falsehoods and is only changed when a Guesswork.Ast.Not is used. negate_constraints is used to figure out what the result of a constraint should be and is changed by Guesswork.Ast.Not and then reset when rules are resolved.

Summary

Types

opts_list()

@type opts_list() :: [
  knowledge_base: term(),
  query_id: binary(),
  precompute_count: integer()
]

t()

@type t() :: %Guesswork.Ast.Statement.Opts{
  call_depth: non_neg_integer(),
  knowledge_base: module(),
  negate_constraints: boolean(),
  negated: boolean(),
  precompute_cache: :ets.table(),
  precompute_count: non_neg_integer(),
  query_id: String.t()
}

Functions

inc_call_depth(opts)

@spec inc_call_depth(t()) :: t()

negate(opts)

@spec negate(t()) :: t()

new(opts \\ [])

@spec new(opts_list()) :: t()

reset_negate_constraints(opts)

@spec reset_negate_constraints(t()) :: t()

schema_list()