Interface FunctionContext


public interface FunctionContext
The ambient state a function implementation may read while it runs.

Everything a function needs beyond its arguments arrives here, so that reading ambient state is an explicit dependency rather than a static call into the platform. The clock is the first member: NOW() reads it instead of Instant.now(), which is what makes a whole run reproducible when the engine pins one.

This is an interface rather than a record because it grows. A time zone, a random source or a locale can be added as a default member without breaking an implementation compiled against an earlier version.

  • Method Summary

    Modifier and Type
    Method
    Description
    The clock the current-time functions read.
    of(Clock clock)
    A context reading the given clock and nothing else.
    of(Clock clock, Comparator<Value> valueOrder)
    A context reading the given clock and ranking values with the given order.
    A context reading the system UTC clock — the default when nothing has pinned one, and the right choice in a test that does not observe time.
    default Comparator<Value>
    The engine's total order over values — what smaller means to a reduction that has to pick one.
  • Method Details

    • clock

      Clock clock()
      The clock the current-time functions read.
      Returns:
      the clock for this evaluation; never null
    • valueOrder

      default Comparator<Value> valueOrder()
      The engine's total order over values — what smaller means to a reduction that has to pick one.

      An aggregate that ranks its input cannot invent an ordering: two libraries that each defined their own would disagree with the engine's sort and with each other, and the disagreement would show up as a MIN that does not match the first row of a τ. The engine supplies one, and every implementation reads it from here.

      The default orders NULL last and compares like with like, which is what an implementation gets when nothing supplies a richer one. The engine's own order additionally reads an ISO-8601 string as the temporal value it spells, so a value that arrived as text from a schema-less source compares against a typed one.

      Returns:
      the comparator to rank values with; never null
    • of

      static FunctionContext of(Clock clock)
      A context reading the given clock and nothing else.
      Parameters:
      clock - the clock current-time functions read
      Returns:
      a context over clock
    • of

      static FunctionContext of(Clock clock, Comparator<Value> valueOrder)
      A context reading the given clock and ranking values with the given order.
      Parameters:
      clock - the clock current-time functions read
      valueOrder - the total order over values
      Returns:
      a context over clock and valueOrder
    • systemDefault

      static FunctionContext systemDefault()
      A context reading the system UTC clock — the default when nothing has pinned one, and the right choice in a test that does not observe time.
      Returns:
      a context over Clock.systemUTC()