public static void setDataTableScanFilter ( final Scanner scanner , final List < byte [ ] > group_bys , final ByteMap < byte [ ] [ ] > row_key_literals , final boolean explicit_tags , final boolean enable_fuzzy_filter , final int end_time ) { // no-op if ( ( group_bys == null || group_bys . isEmpty ( ) ) && ( row_key_literals == null || row_key_literals . isEmpty ( ) ) ) { return ; } final int prefix_width = Const . SALT_WIDTH ( ) + TSDB . metrics_width ( ) + Const . TIMESTAMP_BYTES ; final short name_width = TSDB . tagk_width ( ) ; final short value_width = TSDB . tagv_width ( ) ; final byte [ ] fuzzy_key ; final byte [ ] fuzzy_mask ; if ( explicit_tags && enable_fuzzy_filter ) { fuzzy_key = new byte [ prefix_width + ( row_key_literals . size ( ) * ( name_width + value_width ) ) ] ; fuzzy_mask = new byte [ prefix_width + ( row_key_literals . size ( ) * ( name_width + value_width ) ) ] ; System . arraycopy ( scanner . getCurrentKey ( ) , 0 , fuzzy_key , 0 , scanner . getCurrentKey ( ) . length ) ; } else { fuzzy_key = fuzzy_mask = null ; } final String regex = getRowKeyUIDRegex ( group_bys , row_key_literals , explicit_tags , fuzzy_key , fuzzy_mask ) ; final KeyRegexpFilter regex_filter = new KeyRegexpFilter ( regex . toString ( ) , Const . ASCII_CHARSET ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Regex for scanner: " + scanner + ": " + byteRegexToString ( regex ) ) ; } if ( ! ( explicit_tags && enable_fuzzy_filter ) ) { scanner . setFilter ( regex_filter ) ; return ; } scanner . setStartKey ( fuzzy_key ) ; final byte [ ] stop_key = Arrays . copyOf ( fuzzy_key , fuzzy_key . length ) ; Internal . setBaseTime ( stop_key , end_time ) ; int idx = Const . SALT_WIDTH ( ) + TSDB . metrics_width ( ) + Const . TIMESTAMP_BYTES + TSDB . tagk_width ( ) ; // max out the tag values while ( idx < stop_key . length ) { for ( int i = 0 ; i < TSDB . tagv_width ( ) ; i ++ ) { stop_key [ idx ++ ] = ( byte ) 0xFF ; } idx += TSDB . tagk_width ( ) ; } scanner . setStopKey ( stop_key ) ; final List < ScanFilter > filters = new ArrayList < ScanFilter > ( 2 ) ; filters . add ( new FuzzyRowFilter ( new FuzzyRowFilter . FuzzyFilterPair ( fuzzy_key , fuzzy_mask ) ) ) ; filters . add ( regex_filter ) ; scanner . setFilter ( new FilterList ( filters ) ) ; }
Sets a filter or filter list on the scanner based on whether or not the query had tags it needed to match .