Class ConstraintEvaluator
- java.lang.Object
-
- com.amazonaws.athena.connector.lambda.domain.predicate.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.
-
-
Constructor Summary
Constructors Constructor Description ConstraintEvaluator(BlockAllocator allocator, org.apache.arrow.vector.types.pojo.Schema schema, Constraints constraints)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
apply(String fieldName, Object value)
Used check if the provided value passes all constraints on the given field.void
close()
Frees any Apache Arrow resources held by this Constraint Evaluator.static ConstraintEvaluator
emptyEvaluator()
This convenience method builds an empty Evaluator that can be useful when no constraints are present.Optional<ConstraintProjector>
makeConstraintProjector(String fieldName)
-
-
-
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.
-
makeConstraintProjector
public Optional<ConstraintProjector> makeConstraintProjector(String fieldName)
-
close
public void close() throws Exception
Frees any Apache Arrow resources held by this Constraint Evaluator.- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-