2424import network .aika .utils .ArrayUtils ;
2525
2626import java .util .*;
27- import java .util .stream .Collectors ;
2827import java .util .stream .Stream ;
2928
3029/**
@@ -43,18 +42,20 @@ public class FlattenedType<
4342
4443 private final short [] fields ;
4544 private final FieldDefinition <T , O >[][] fieldsReverse ;
45+ private final int numberOfFields ;
4646
4747 private FlattenedTypeRelation <T , O , RT , RO >[][] mapping ;
4848
4949 @ SuppressWarnings ("unchecked" )
50- private FlattenedType (Direction dir , T type , Map <FieldDefinition <T , O >, Short > fieldMappings ) {
50+ private FlattenedType (Direction dir , T type , Map <FieldDefinition <T , O >, Short > fieldMappings , int numberOfFields ) {
5151 this .direction = dir ;
5252 this .type = type ;
53+ this .numberOfFields = numberOfFields ;
5354
54- fields = new short [type .getTypeRegistry ().getNumberOfFields ()];
55+ fields = new short [type .getTypeRegistry ().getNumberOfFieldDefinitions ()];
5556 Arrays .fill (fields , (short ) -1 );
5657
57- fieldsReverse = new FieldDefinition [fieldMappings . size () ][];
58+ fieldsReverse = new FieldDefinition [numberOfFields ][];
5859 for (Map .Entry <FieldDefinition <T , O >, Short > e : fieldMappings .entrySet ()) {
5960 fields [e .getKey ().getFieldId ()] = e .getValue ();
6061 fieldsReverse [e .getValue ()] = new FieldDefinition [] {e .getKey ()};
@@ -80,7 +81,7 @@ FlattenedType<T, O, RT, RO> createInputFlattenedType(T type, Set<FieldDefinition
8081 fieldMappings .put (fd , i );
8182 }
8283
83- return new FlattenedType <>(Direction .INPUT , type , fieldMappings );
84+ return new FlattenedType <>(Direction .INPUT , type , fieldMappings , requiredFields . size () );
8485 }
8586
8687 public static <
@@ -98,7 +99,7 @@ FlattenedType<T, O, RT, RO> createOutputFlattenedType(T type, Set<FieldDefinitio
9899 fieldMappings .put (fd , fieldIndex );
99100 }
100101
101- return new FlattenedType <>(Direction .OUTPUT , type , fieldMappings );
102+ return new FlattenedType <>(Direction .OUTPUT , type , fieldMappings , inputSide . numberOfFields );
102103 }
103104
104105 @ SuppressWarnings ({"rawtypes" , "unchecked" })
0 commit comments