Class ArrayRow
java.lang.Object
com.darkcollective.relix.processor.internal.ArrayRow
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionbooleanget(int index) Returns the value at the given zero-based column index.Returns the value in the named column (case-insensitive).inthashCode()static ArrayRowCreates a row from varargs values in schema-column order.static ArrayRowCreates a row from a list of values in schema-column order.schema()Returns the schema that describes this row's columns.toString()intwidth()Returns the number of columns in this row.withSchema(Schema newSchema) Returns a row with the same values as this one but a different schema of the same width.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.darkcollective.relix.processor.Row
columnNames
-
Method Details
-
of
Creates a row from a list of values in schema-column order.- Parameters:
schema- the row's schema; must not benullvalues- values in declaration order; must not benull, must match schema width- Returns:
- a new
ArrayRow - Throws:
IllegalArgumentException- if the number of values does not match the schema width
-
of
Creates a row from varargs values in schema-column order.- Parameters:
schema- the row's schema; must not benullvalues- values in declaration order; must not benull, must match schema width- Returns:
- a new
ArrayRow - Throws:
IllegalArgumentException- if the number of values does not match the schema width
-
withSchema
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- ifnewSchemahas a different width
-
schema
Description copied from interface:RowReturns the schema that describes this row's columns. -
get
Description copied from interface:RowReturns the value in the named column (case-insensitive).- Specified by:
getin interfaceRow- Parameters:
columnName- the column name to look up- Returns:
- the value; never
null(absent values useNullValue.INSTANCE)
-
get
Description copied from interface:RowReturns the value at the given zero-based column index. -
width
public int width()Description copied from interface:RowReturns the number of columns in this row. -
equals
-
hashCode
public int hashCode() -
toString
-