public long getColumnCardinality ( String schema , String table , Authorizations auths , String family , String qualifier , Collection < Range > colValues ) throws ExecutionException { LOG . debug ( "Getting cardinality for %s:%s" , family , qualifier ) ; // Collect all exact Accumulo Ranges, i.e. single value entries vs. a full scan Collection < CacheKey > exactRanges = colValues . stream ( ) . filter ( ColumnCardinalityCache :: isExact ) . map ( range -> new CacheKey ( schema , table , family , qualifier , range , auths ) ) . collect ( Collectors . toList ( ) ) ; LOG . debug ( "Column values contain %s exact ranges of %s" , exactRanges . size ( ) , colValues . size ( ) ) ; // Sum the cardinalities for the exact-value Ranges // This is where the reach-out to Accumulo occurs for all Ranges that have not // previously been fetched long sum = cache . getAll ( exactRanges ) . values ( ) . stream ( ) . mapToLong ( Long :: longValue ) . sum ( ) ; // If these collection sizes are not equal, // then there is at least one non-exact range if ( exactRanges . size ( ) != colValues . size ( ) ) { // for each range in the column value for ( Range range : colValues ) { // if this range is not exact if ( ! isExact ( range ) ) { // Then get the value for this range using the single-value cache lookup sum += cache . get ( new CacheKey ( schema , table , family , qualifier , range , auths ) ) ; } } } return sum ; }
Gets the column cardinality for all of the given range values . May reach out to the metrics table in Accumulo to retrieve new cache elements .