Class ListKeyExpression

  • All Implemented Interfaces:
    KeyExpression, KeyExpressionWithChildren, PlanHashable, QueryHashable

    @API(MAINTAINED)
    public class ListKeyExpression
    extends BaseKeyExpression
    implements KeyExpressionWithChildren
    Combine keys from zero or more child keys.

    Form a cross-product similar to ThenKeyExpression, but producing lists containing each child's evaluation result rather than concatenating. When converted to a Tuple, the nth child corresponds to tuple.getNestedTuple(n), which is less compact on disk but easier to find the child boundaries in.

    Consider the expressions concat(field("child_1").nest(field("field_1")), field("child_2").nest(concat(field("field_1"), field("field_2"))) and concat(field("child_1").nest(concat(field("field_1"), field("field_2"))), field("child_2").nest(field("field_1"))). These might produce values like [[1.1, 2.1, 2.2]] and [[1.1, 1.2, 2.1]], respectively. Recovering the first child's contribution means remembering it or at least its KeyExpression.getColumnSize(), to know where the boundary is.

    Contrast list(field("child_1").nest(field("field_1")), field("child_2").nest(concat(field("field_1"), field("field_2"))) and list(field("child_1").nest(concat(field("field_1"), field("field_2"))), field("child_2").nest(field("field_1"))). These would produce [[[1.1], [2.1, 2.2]]] and [[[1.1, 1.2], [2.1]]], respectively.