static byte [ ] flattenTags ( final boolean use_query_tags , final boolean include_agg_tags , final ByteMap < byte [ ] > tags , final ByteSet agg_tags , final ITimeSyncedIterator sub ) { if ( tags . isEmpty ( ) ) { return HBaseClient . EMPTY_ARRAY ; } 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 : tags . entrySet ( ) ) { if ( query_tagks . contains ( pair . getKey ( ) ) ) { i ++ ; } } } else { query_tagks = new ByteSet ( ) ; } tag_size = i ; } else { query_tagks = new ByteSet ( ) ; tag_size = tags . size ( ) ; } int len = ( tag_size * ( TSDB . tagk_width ( ) + TSDB . tagv_width ( ) ) ) + ( include_agg_tags ? ( agg_tags . size ( ) * TSDB . tagk_width ( ) ) : 0 ) ; final byte [ ] tagks = new byte [ len ] ; int i = 0 ; for ( final Map . Entry < byte [ ] , byte [ ] > pair : tags . entrySet ( ) ) { if ( use_query_tags && ! query_tagks . contains ( pair . getKey ( ) ) ) { continue ; } System . arraycopy ( pair . getKey ( ) , 0 , tagks , i , TSDB . tagk_width ( ) ) ; i += TSDB . tagk_width ( ) ; System . arraycopy ( pair . getValue ( ) , 0 , tagks , i , TSDB . tagv_width ( ) ) ; i += TSDB . tagv_width ( ) ; } if ( include_agg_tags ) { for ( final byte [ ] tagk : agg_tags ) { System . arraycopy ( tagk , 0 , tagks , i , TSDB . tagk_width ( ) ) ; i += TSDB . tagk_width ( ) ; } } return tagks ; }
Flattens the appropriate tags into a single byte array