public RecordList getUniqueRecordsBy ( String fieldName ) { Set < String > uniqueKeys = new HashSet < String > ( ) ; final RecordListBuilder uniqueRecordListBuilder = new RecordListBuilder ( schema ) ; for ( int rowIndex = 0 ; rowIndex < this . size ( ) ; rowIndex ++ ) { final Record currentRecord = this . records . get ( rowIndex ) ; String uniqueKeyField = currentRecord . getValueByFieldName ( fieldName ) ; if ( ! uniqueKeys . contains ( uniqueKeyField ) ) { uniqueRecordListBuilder . add ( currentRecord ) ; } uniqueKeys . add ( uniqueKeyField ) ; } return uniqueRecordListBuilder . createRecordList ( dataSourceHash ) ; }
Picks the first available record by given fieldName