Class JoinAPI.On

java.lang.Object
io.avery.vinyl.JoinAPI.On
Enclosing class:
JoinAPI

public class JoinAPI.On extends Object
A sub-configurator used to define the join condition of a relational join operation. The join condition is encoded as a JoinPred predicate. The strategy for evaluating the join condition is determined by how the join condition is defined, enabling optimizations. In general, the following rules apply:
  1. If a predicate does not depend on left or right-side records, it may be evaluated as a pre-join check
  2. If a predicate depends on only left or only right-side records, it may be evaluated as a pre-join filter on the corresponding side
  3. If a predicate compares left-side records to right-side records via a supported comparison operator, it may be evaluated by creating an index over the right-side, and searching the index with each left-side record
  4. If a predicate is composed of multiple sub-predicates (via any / all), a more complex evaluation strategy may be used, eg combinations of right-side indexes and filters
  5. If no other optimization applies, a predicate may be evaluated by looping over right-side records for each left-side record
  • Method Details

    • left

      public <T> JoinExpr<T> left(Field<T> field)
      Creates a JoinExpr that evaluates to the value associated with the given field in each left-side record.
      Type Parameters:
      T - the value type of the field
      Parameters:
      field - the field whose associated value is to be returned from each right-side record
      Returns:
      a JoinExpr that evaluates to the value associated with the given field in each left-side record
      Throws:
      NoSuchElementException - if the left-side stream header does not contain the field
    • right

      public <T> JoinExpr<T> right(Field<T> field)
      Creates a JoinExpr that evaluates to the value associated with the given field in each right-side record.
      Type Parameters:
      T - the value type of the field
      Parameters:
      field - the field whose associated value is to be returned from each right-side record
      Returns:
      a JoinExpr that evaluates to the value associated with the given field in each right-side record
      Throws:
      NoSuchElementException - if the right-side stream header does not contain the field
    • left

      public <T> JoinExpr<T> left(Function<? super Record,T> mapper)
      Creates a JoinExpr that evaluates to the result of applying the given function to each left-side record.
      Type Parameters:
      T - the result type of the function
      Parameters:
      mapper - the function to apply to each left-side record
      Returns:
      a JoinExpr that evaluates to the result of applying the given function to each left-side record
    • right

      public <T> JoinExpr<T> right(Function<? super Record,T> mapper)
      Creates a JoinExpr that evaluates to the result of applying the given function to each right-side record.
      Type Parameters:
      T - the result type of the function
      Parameters:
      mapper - the function to apply to each right-side record
      Returns:
      a JoinExpr that evaluates to the result of applying the given function to each right-side record
    • eval

      public <T> JoinExpr<T> eval(Supplier<T> supplier)
      Creates a JoinExpr that evaluates to the result of calling the given supplier. The supplier will be called at most once during the join operation.
      Type Parameters:
      T - the result type of the function
      Parameters:
      supplier - the value-supplying function
      Returns:
      a JoinExpr that evaluates to the result of calling the given supplier
    • val

      public <T> JoinExpr<T> val(T val)
      Creates a JoinExpr that evaluates to the given value.
      Type Parameters:
      T - the value type
      Parameters:
      val - the value
      Returns:
      a JoinExpr that evaluates to the given value
    • eq

      public JoinPred eq(JoinExpr<?> left, JoinExpr<?> right)
      Creates a JoinPred that passes if the value of the left expression is equal to the value of the right expression, based on Objects.equals(Object, Object).
      Parameters:
      left - the left expression
      right - the right expression
      Returns:
      a JoinPred that passes if the value of the left expression is not equal to the value of the right expression
    • neq

      public JoinPred neq(JoinExpr<?> left, JoinExpr<?> right)
      Creates a JoinPred that passes if the value of the left expression is not equal to the value of the right expression, based on Objects.equals(Object, Object).
      Parameters:
      left - the left expression
      right - the right expression
      Returns:
      a JoinPred that passes if the value of the left expression is not equal to the value of the right expression
    • ceq

      public <T extends Comparable<? super T>> JoinPred ceq(JoinExpr<T> left, JoinExpr<T> right)
      Creates a JoinPred that passes if the value of the left expression compares equal to the value of the right expression, based on the natural ordering of the values (nulls first/lowest).
      Type Parameters:
      T - the type of the evaluated expressions
      Parameters:
      left - the left expression
      right - the right expression
      Returns:
      a JoinPred that passes if the value of the left expression compares equal to the value of the right expression
    • cneq

      public <T extends Comparable<? super T>> JoinPred cneq(JoinExpr<T> left, JoinExpr<T> right)
      Creates a JoinPred that passes if the value of the left expression compares not equal to the value of the right expression, based on the natural ordering of the values (nulls first/lowest).
      Type Parameters:
      T - the type of the evaluated expressions
      Parameters:
      left - the left expression
      right - the right expression
      Returns:
      a JoinPred that passes if the value of the left expression compares not equal to the value of the right expression
    • gt

      public <T extends Comparable<? super T>> JoinPred gt(JoinExpr<T> left, JoinExpr<T> right)
      Creates a JoinPred that passes if the value of the left expression compares greater than the value of the right expression, based on the natural ordering of the values (nulls first/lowest).
      Type Parameters:
      T - the type of the evaluated expressions
      Parameters:
      left - the left expression
      right - the right expression
      Returns:
      a JoinPred that passes if the value of the left expression compares greater than the value of the right expression
    • gte

      public <T extends Comparable<? super T>> JoinPred gte(JoinExpr<T> left, JoinExpr<T> right)
      Creates a JoinPred that passes if the value of the left expression compares greater than or equal to the value of the right expression, based on the natural ordering of the values (nulls first/lowest).
      Type Parameters:
      T - the type of the evaluated expressions
      Parameters:
      left - the left expression
      right - the right expression
      Returns:
      a JoinPred that passes if the value of the left expression compares greater than or equal to the value of the right expression
    • lt

      public <T extends Comparable<? super T>> JoinPred lt(JoinExpr<T> left, JoinExpr<T> right)
      Creates a JoinPred that passes if the value of the left expression compares less than the value of the right expression, based on the natural ordering of the values (nulls first/lowest).
      Type Parameters:
      T - the type of the evaluated expressions
      Parameters:
      left - the left expression
      right - the right expression
      Returns:
      a JoinPred that passes if the value of the left expression compares less than the value of the right expression
    • lte

      public <T extends Comparable<? super T>> JoinPred lte(JoinExpr<T> left, JoinExpr<T> right)
      Creates a JoinPred that passes if the value of the left expression compares less than or equal to the value of the right expression, based on the natural ordering of the values (nulls first/lowest).
      Type Parameters:
      T - the type of the evaluated expressions
      Parameters:
      left - the left expression
      right - the right expression
      Returns:
      a JoinPred that passes if the value of the left expression compares less than or equal to the value of the right expression
    • between

      public <T extends Comparable<? super T>> JoinPred between(JoinExpr<T> test, JoinExpr<T> begin, JoinExpr<T> end)
      Creates a JoinPred that passes if the value of the test expression lies between the values of the begin and end expressions. More formally, the predicate passes if the value of the test expression compares greater than or equal to the value of the begin expression and less than or equal to the value of the end expression, based on the natural ordering of the values (nulls first/lowest).

      This method is equivalent to:

      
       all(gte(test, begin), lte(test, end))
       
      Type Parameters:
      T - the type of the evaluated expressions
      Parameters:
      test - the test expression
      begin - the begin expression
      end - the end expression
      Returns:
      a JoinPred that passes if the value of the test expression lies between the values of the begin and end expressions
    • not

      public JoinPred not(JoinPred predicate)
      Creates a JoinPred that passes if the given predicate does not pass.
      Parameters:
      predicate - the given predicate
      Returns:
      a JoinPred that passes if the given predicate does not pass
    • any

      public JoinPred any(JoinPred... predicates)
      Creates a JoinPred that passes if any of the given predicates pass. If no predicates are given, the resultant predicate always fails.
      Parameters:
      predicates - the given predicates
      Returns:
      a JoinPred that passes if any of the given predicates pass
    • all

      public JoinPred all(JoinPred... predicates)
      Creates a JoinPred that passes if all of the given predicates pass. If no predicates are given, the resultant predicate always passes.
      Parameters:
      predicates - the given predicates
      Returns:
      a JoinPred that passes if all of the given predicates pass
    • leftMatch

      public JoinPred leftMatch(Predicate<? super Record> predicate)
      Creates a JoinPred that passes if the given plain predicate over left-side records passes. The resultant predicate inherently depends on left-side records.
      Parameters:
      predicate - the given plain predicate
      Returns:
      a JoinPred that passes if the given plain predicate over left-side records passes.
    • rightMatch

      public JoinPred rightMatch(Predicate<? super Record> predicate)
      Creates a JoinPred that passes if the given plain predicate over right-side records passes. The resultant predicate inherently depends on right-side records.
      Parameters:
      predicate - the given plain predicate
      Returns:
      a JoinPred that passes if the given plain predicate over right-side records passes.
    • match

      public JoinPred match(BiPredicate<? super Record,? super Record> predicate)
      Creates a JoinPred that passes if the given plain predicate over left and right-side records passes. The resultant predicate inherently depends on both left and right-side records.
      Parameters:
      predicate - the given plain predicate
      Returns:
      a JoinPred that passes if the given plain predicate over left and right-side records passes.