java.lang.Object
java.lang.Record
com.darkcollective.relix.embed.Rows
Record Components:
schema - the heading of every row
rows - the rows, in the order the query produced them
events - the optimizer, planner and execution events of this run, in arrival order
All Implemented Interfaces:
Iterable<Tuple>

public record Rows(Schema schema, List<Tuple> rows, List<QueryEvent> events) extends Record implements Iterable<Tuple>
The result of one run — the rows, their heading, and what the engine did to produce them.

Relation.toList() answers the rows alone, which is what most callers want. This is Relation.run()'s answer, for a caller who also wants to know how: which rewrite rules fired, which join algorithm the planner chose, what was pushed into a database and what was evaluated in-engine.

The last event is always the run's own cardinality — an EXECUTE/ROWS event carrying EventMetrics.rows. It is stated as an event rather than as a field so that a consumer reads one feed rather than one feed and a side channel, and it is emitted by the terminal rather than by the executor because a row stream's length is not known until something drains it.

The events are this run's own. That is worth stating because the relix.events catalog relation cannot be: a statement's events postdate the analysis that would have to register them, so in a session there they describe the previous statement. An embedding has no such constraint — it runs the query and then hands the caller the result — so what arrives here is the feed for the rows beside it.

Since:
1.0
  • Constructor Details

    • Rows

      public Rows(Schema schema, List<Tuple> rows, List<QueryEvent> events)
      Canonical constructor; the lists are copied, so a result cannot change under its holder.
      Since:
      1.0
  • Method Details

    • size

      public int size()
      Returns how many rows the run produced.
      Returns:
      how many rows the run produced
      Since:
      1.0
    • isEmpty

      public boolean isEmpty()
      Returns whether the run produced no rows.
      Returns:
      whether the run produced no rows
      Since:
      1.0
    • truncated

      public boolean truncated()
      Returns whether the session's sandbox cut this result short.

      A closed Sandbox with an output limit returns at most that many rows. When a query had more, the rows here are the first ones and this is true; the events then include the EXECUTE/TRUNCATED event that reported it.

      Returns:
      whether the session's sandbox cut this result short
      Since:
      1.0
    • iterator

      public Iterator<Tuple> iterator()
      Specified by:
      iterator in interface Iterable<Tuple>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • schema

      public Schema schema()
      Returns the value of the schema record component.
      Returns:
      the value of the schema record component
    • rows

      public List<Tuple> rows()
      Returns the value of the rows record component.
      Returns:
      the value of the rows record component
    • events

      public List<QueryEvent> events()
      Returns the value of the events record component.
      Returns:
      the value of the events record component