Record Class IndexedRelation
java.lang.Object
java.lang.Record
com.darkcollective.relix.processor.exec.IndexedRelation
- Record Components:
schema- the schema shared by all rows in every group; never nullgroups- a map from group-key (list of values, one per grouping attribute) to the rows that belong to that group; stored as an unmodifiable view; never null
- All Implemented Interfaces:
MaterializedRelation
public record IndexedRelation(Schema schema, SequencedMap<List<Value>,List<Row>> groups)
extends Record
implements MaterializedRelation
A materialised relation whose rows are partitioned into groups by a
composite key — the
Relation type in the IBM flat-collection
taxonomy (Key, Element Equality, Unordered, Multiple).
Groups are stored in insertion order (LinkedHashMap) so that
output row ordering is stable and deterministic across executions.
This is the primary build structure for:
- Aggregation (
γ) — rows are grouped by the grouping attributes; each group is then reduced to a single aggregate output row. - Hash joins (future tasks) — the smaller input is indexed on the
join key; the probe side performs key lookups via
group(List).
-
Constructor Summary
ConstructorsConstructorDescriptionIndexedRelation(Schema schema, SequencedMap<List<Value>, List<Row>> groups) Creates an instance of aIndexedRelationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic IndexedRelationBuilds anIndexedRelationby partitioningrowson the given key extractor.final booleanIndicates whether some other object is "equal to" this one.Returns the rows belonging to the given group key, or an empty list if no such group exists.intReturns the number of distinct groups.SequencedMap<List<Value>, List<Row>> groups()Returns the value of thegroupsrecord component.final inthashCode()Returns a hash code value for this object.schema()Returns the value of theschemarecord component.stream()Returns a lazy stream over all rows in this relation.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
build
public static IndexedRelation build(Schema schema, Stream<Row> rows, Function<Row, List<Value>> keyExtractor) Builds anIndexedRelationby partitioningrowson the given key extractor. Insertion order of the first-seen key is preserved.- Parameters:
schema- the row schemarows- the rows to index; consumed oncekeyExtractor- a function from row to composite key
-
group
Returns the rows belonging to the given group key, or an empty list if no such group exists. -
groupCount
public int groupCount()Returns the number of distinct groups. -
stream
Returns a lazy stream over all rows in this relation. The stream may be consumed exactly once.Iterates groups in insertion order, yielding all rows from each group before moving to the next.
- Specified by:
streamin interfaceMaterializedRelation
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
schema
Returns the value of theschemarecord component.- Specified by:
schemain interfaceMaterializedRelation- Returns:
- the value of the
schemarecord component
-
groups
Returns the value of thegroupsrecord component.- Returns:
- the value of the
groupsrecord component
-