java.lang.Object
com.darkcollective.relix.processor.eval.EquationSolver

public final class EquationSolver extends Object
Fills the single unknown column of a row by inverting a goal-seek equation left = right (the engine side of the SOLVE operator).

For a given row, the participating columns are the distinct attribute references in left and right. When exactly one of them is NULL, it is the unknown u: because each column appears at most once across the equation (enforced by semantic validation), u lives in exactly one side and the other side is fully evaluable. The known side is evaluated to a target value, then the side containing u is walked top-down, applying the inverse of each arithmetic operation, until u itself is reached and assigned.

Rows without exactly one NULL participating column are returned unchanged: a fully-populated row is already complete, and a row with two or more blanks is underdetermined.

Division precision matches OperandEvaluator: ten fractional digits, RoundingMode.HALF_UP, trailing zeros stripped; division by zero throws an EvaluationException.

Instances are stateless apart from the immutable OperandEvaluator reference and are therefore thread-safe.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a solver that evaluates the known parts of an equation with the given operand evaluator.
  • Method Summary

    Modifier and Type
    Method
    Description
    solve(Operand left, Operand right, Row row)
    Returns row with its single NULL participating column filled by inverting left = right, or row unchanged when it does not have exactly one NULL participating column (or the column cannot be located in the row's schema).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EquationSolver

      public EquationSolver(OperandEvaluator evaluator)
      Constructs a solver that evaluates the known parts of an equation with the given operand evaluator.
      Parameters:
      evaluator - the evaluator for fully-known sub-expressions; must not be null
  • Method Details

    • solve

      public Row solve(Operand left, Operand right, Row row)
      Returns row with its single NULL participating column filled by inverting left = right, or row unchanged when it does not have exactly one NULL participating column (or the column cannot be located in the row's schema).
      Parameters:
      left - the left-hand side of the equation; must not be null
      right - the right-hand side of the equation; must not be null
      row - the row to complete; must not be null
      Returns:
      the completed row, or row unchanged
      Throws:
      EvaluationException - on division by zero or a non-numeric operand