java.lang.Object
com.darkcollective.relix.processor.internal.ArrayRow
All Implemented Interfaces:
Row

public final class ArrayRow extends Object implements Row
A positional Row implementation backed by a fixed-size array of Values.

Column-name lookup scans the schema's column list; for the small schemas typical in relix queries this linear scan is negligible. Values are stored in declaration order matching Schema.columns().

Instances are immutable — the value array is defensive-copied on construction.

Example:


 Schema schema = new Schema(List.of(
     new ColumnDefinition("id",   ScalarType.NUMBER),
     new ColumnDefinition("name", ScalarType.STRING)
 ));
 Row row = ArrayRow.of(schema, NumberValue.of("1"), new StringValue("Alice"));
 row.get("id");   // NumberValue(1)
 row.get("NAME"); // StringValue("Alice")
 row.get(0);      // NumberValue(1)
 
  • Method Details

    • of

      public static ArrayRow of(Schema schema, List<Value> values)
      Creates a row from a list of values in schema-column order.
      Parameters:
      schema - the row's schema; must not be null
      values - values in declaration order; must not be null, must match schema width
      Returns:
      a new ArrayRow
      Throws:
      IllegalArgumentException - if the number of values does not match the schema width
    • of

      public static ArrayRow of(Schema schema, Value... values)
      Creates a row from varargs values in schema-column order.
      Parameters:
      schema - the row's schema; must not be null
      values - values in declaration order; must not be null, must match schema width
      Returns:
      a new ArrayRow
      Throws:
      IllegalArgumentException - if the number of values does not match the schema width
    • withSchema

      public ArrayRow withSchema(Schema newSchema)
      Returns a row with the same values as this one but a different schema of the same width. This is a metadata-only operation (e.g. a relation/column rename): the underlying value array is shared, not copied, which is safe because rows are immutable.
      Parameters:
      newSchema - the replacement schema; must have the same width as this row
      Returns:
      a row exposing this row's values under newSchema
      Throws:
      IllegalArgumentException - if newSchema has a different width
    • schema

      public Schema schema()
      Description copied from interface: Row
      Returns the schema that describes this row's columns.
      Specified by:
      schema in interface Row
      Returns:
      the row's schema; never null
    • get

      public Value get(String columnName)
      Description copied from interface: Row
      Returns the value in the named column (case-insensitive).
      Specified by:
      get in interface Row
      Parameters:
      columnName - the column name to look up
      Returns:
      the value; never null (absent values use NullValue.INSTANCE)
    • get

      public Value get(int index)
      Description copied from interface: Row
      Returns the value at the given zero-based column index.
      Specified by:
      get in interface Row
      Parameters:
      index - zero-based column index
      Returns:
      the value; never null
    • width

      public int width()
      Description copied from interface: Row
      Returns the number of columns in this row.
      Specified by:
      width in interface Row
      Returns:
      column count; always ≥ 1
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object