code: private void accum_all(Chunk chks[], Chunk wrks, int nnids[]) {
        final DHistogram hcs[][] = _hcs;
        // Sort the rows by NID, so we visit all the same NIDs in a row
        // Find the count of unique NIDs in this chunk
        int nh[] = new int[hcs.length+1];
        for( int i : nnids ) if( i >= 0 ) nh[i+1]++;
        // Rollup the histogram of rows-per-NID in this chunk
        for( int i=0; i<hcs.length; i++ ) nh[i+1] += nh[i];
        // Splat the rows into NID-groups
        int rows[] = new int[nnids.length];
        for( int row=0; row<nnids.length; row++ )
          if( nnids[row] >= 0 )
            rows[nh[nnids[row]]++] = row;
        // rows[] has Chunk-local ROW-numbers now, in-order, grouped by NID.
        // nh[] lists the start of each new NID, and is indexed by NID+1.
        accum_all2(chks,wrks,nh,rows);
      }
docs: histograms once-per-NID, but requires pre-sorting the rows by NID.