static byte [ ] flattenTags ( final boolean use_query_tags , final boolean include_agg_tags , final ExpressionDataPoint dp , final ITimeSyncedIterator sub ) { if ( dp . tags ( ) == null || dp . tags ( ) . isEmpty ( ) ) { return HBaseClient . EMPTY_ARRAY ; } final int tagk_width = TSDB . tagk_width ( ) ; final int tagv_width = TSDB . tagv_width ( ) ; final ByteSet query_tagks ; // NOTE: We MAY need the agg tags but I'm not sure yet final int tag_size ; if ( use_query_tags ) { int i = 0 ; if ( sub . getQueryTagKs ( ) != null && ! sub . getQueryTagKs ( ) . isEmpty ( ) ) { query_tagks = sub . getQueryTagKs ( ) ; for ( final Map . Entry < byte [ ] , byte [ ] > pair : dp . tags ( ) . entrySet ( ) ) { if ( query_tagks . contains ( pair . getKey ( ) ) ) { i ++ ; } } } else { query_tagks = new ByteSet ( ) ; } tag_size = i ; } else { query_tagks = new ByteSet ( ) ; tag_size = dp . tags ( ) . size ( ) ; } final int length = ( tag_size * ( tagk_width + tagv_width ) ) + ( include_agg_tags ? ( dp . aggregatedTags ( ) . size ( ) * tagk_width ) : 0 ) ; final byte [ ] key = new byte [ length ] ; int idx = 0 ; for ( final Entry < byte [ ] , byte [ ] > pair : dp . tags ( ) . entrySet ( ) ) { if ( use_query_tags && ! query_tagks . contains ( pair . getKey ( ) ) ) { continue ; } System . arraycopy ( pair . getKey ( ) , 0 , key , idx , tagk_width ) ; idx += tagk_width ; System . arraycopy ( pair . getValue ( ) , 0 , key , idx , tagv_width ) ; idx += tagv_width ; } if ( include_agg_tags ) { for ( final byte [ ] tagk : dp . aggregatedTags ( ) ) { System . arraycopy ( tagk , 0 , key , idx , tagk_width ) ; idx += tagk_width ; } } return key ; }
Creates a key based on the concatenation of the tag pairs then the agg tag keys .