def reindex_halo_subsamples(halos, subsamp_start_key='subsamp_start', subsamp_len_key='subsamp_len'):
    """
    If we concatenate halos and particles into big files/arrays, the "subsample start" indices
    in the halos table no longer correspond to the concatenated particle array.  But we can
    easily reconstruct the correct indices.
    
    Parameters
    ----------
    halos: ndarray
        The FoF halo catalog from `read_halos_FoF`
        The halo catalog must be in its original order (i.e. the order
        on disk, because the subsamples on disk are in the same order)
        
    Returns
    -------
    njump: int
        The number of discontinuities that were fixed in the subsample indexing.
        Should be equal to the number of file splits.
    """
    
    # The number of "discontinuities" in particle indexing should equal the number of files
    # This helps us make sure the halos were not reordered
    njump = (halos[subsamp_start_key][:-1] + halos[subsamp_len_key][:-1] != halos[subsamp_start_key][1:]).sum()
    
    # Now reindex the halo records
    assert halos[subsamp_start_key][0] == 0
    halos[subsamp_start_key][1:] = halos[subsamp_len_key].cumsum()[:-1]
    
    return njump