public void add ( String metricIndex , long docCount ) { final String [ ] tokens = metricIndex . split ( METRIC_TOKEN_SEPARATOR_REGEX ) ; /** * * For the ES response shown in class description, for a baseLevel of 2, * the data is classified as follows * * metricNamesWithNextLevelSet -> {foo.bar.baz} (Metric Names which are at base + 1 level and also have a subsequent level.) * * For count map, data is in the form {metricIndex, (actualDocCount, childrenTotalDocCount)} * * metricNameBaseLevelMap -> {foo.bar.baz -> (2, 1)} (all indexes which are of same length as baseLevel) * */ switch ( tokens . length - baseLevel ) { case 1 : if ( baseLevel > 0 ) { metricNamesWithNextLevelSet . add ( metricIndex . substring ( 0 , metricIndex . lastIndexOf ( "." ) ) ) ; } else { metricNamesWithNextLevelSet . add ( metricIndex . substring ( 0 , metricIndex . indexOf ( "." ) ) ) ; } //For foo.bar.baz, baseLevel=3 we update children doc count of foo.bar.baz addChildrenDocCount ( metricNameBaseLevelMap , metricIndex . substring ( 0 , metricIndex . lastIndexOf ( "." ) ) , docCount ) ; break ; case 0 : setActualDocCount ( metricNameBaseLevelMap , metricIndex , docCount ) ; break ; default : break ; } }
For a given metricIndex and docCount classifies the data with respect to baseLevel and stores it accordingly .