Class ConstraintEvaluator

  • All Implemented Interfaces:
    AutoCloseable

    public class ConstraintEvaluator
    extends Object
    implements AutoCloseable
    Used to apply predicates to values inside your connector. Ideally you would also be able to push constraints into your source system (e.g. RDBMS via SQL). For each value you'd like to write for a given row, you call the 'apply' function on this class and if the values for all columns in the row return 'true' that indicates that the row passes the constraints.

    After being used, ConstraintEvaluator instance must be closed to ensure no Apache Arrow resources used by Markers that it creates as part of evaluation are leaked.

    See Also:
    for details on how Constraints are represented and individually applied.
    • Constructor Detail

      • ConstraintEvaluator

        public ConstraintEvaluator​(BlockAllocator allocator,
                                   org.apache.arrow.vector.types.pojo.Schema schema,
                                   Constraints constraints)
    • Method Detail

      • emptyEvaluator

        public static ConstraintEvaluator emptyEvaluator()
        This convenience method builds an empty Evaluator that can be useful when no constraints are present.
        Returns:
        An empty ConstraintEvaluator which always returns true when applied to a value for any field.
      • apply

        public boolean apply​(String fieldName,
                             Object value)
        Used check if the provided value passes all constraints on the given field.
        Parameters:
        fieldName - The name of the field whoe's constraints we'd like to apply to the value.
        value - The value to test.
        Returns:
        True if the value passed all constraints for the given field, False otherwise. This method also returns True if the field has no constraints, including if the field is unknown.
      • close

        public void close()
                   throws Exception
        Frees any Apache Arrow resources held by this Constraint Evaluator.
        Specified by:
        close in interface AutoCloseable
        Throws:
        Exception