private ValueFrequency getDistinctValueCount ( final ValueCountingAnalyzerResult res ) { int distinctValueCounter = 0 ; ValueFrequency valueCount = null ; if ( res . getNullCount ( ) > 0 ) { distinctValueCounter ++ ; valueCount = new SingleValueFrequency ( LabelUtils . NULL_LABEL , res . getNullCount ( ) ) ; } final int uniqueCount = res . getUniqueCount ( ) ; if ( uniqueCount > 0 ) { if ( uniqueCount > 1 ) { // more than one distinct value return null ; } distinctValueCounter ++ ; final Collection < String > uniqueValues = res . getUniqueValues ( ) ; String label = LabelUtils . UNIQUE_LABEL ; if ( ! uniqueValues . isEmpty ( ) ) { label = uniqueValues . iterator ( ) . next ( ) ; } valueCount = new CompositeValueFrequency ( label , 1 ) ; } if ( distinctValueCounter > 1 ) { // more than one distinct value return null ; } final Collection < ValueFrequency > valueCounts = res . getValueCounts ( ) ; if ( valueCounts . size ( ) > 0 ) { distinctValueCounter += valueCounts . size ( ) ; valueCount = valueCounts . iterator ( ) . next ( ) ; } if ( distinctValueCounter > 1 ) { // more than one distinct value return null ; } return valueCount ; }
Determines if a group result has just a single distinct value count . If so this value count is returned or else null is returned .