@transactional_session
def get_and_lock_file_replicas_for_dataset(scope, name, nowait=False, restrict_rses=None, total_threads=None, thread_id=None, session=None):
    '\n    Get file replicas for all files of a dataset.\n\n    :param scope:          The scope of the dataset.\n    :param name:           The name of the dataset.\n    :param nowait:         Nowait parameter for the FOR UPDATE statement\n    :param restrict_rses:  Possible RSE_ids to filter on.\n    :param total_threads:  Total threads\n    :param thread_id:      This thread\n    :param session:        The db session in use.\n    :returns:              (files in dataset, replicas in dataset)\n    '
    (files, replicas) = ({}, {})
    if (session.bind.dialect.name == 'postgresql'):
        content_query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
        if (total_threads and (total_threads > 1)):
            content_query = filter_thread_work(session=session, query=content_query, total_threads=total_threads, thread_id=thread_id, hash_variable='child_name')
        for (child_scope, child_name, bytes, md5, adler32) in content_query.yield_per(1000):
            files[(child_scope, child_name)] = {'scope': child_scope, 'name': child_name, 'bytes': bytes, 'md5': md5, 'adler32': adler32}
            replicas[(child_scope, child_name)] = []
        query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32, models.RSEFileAssociation).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').filter(and_((models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope), (models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name), (models.RSEFileAssociation.state != ReplicaState.BEING_DELETED))).filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
        if (restrict_rses is not None):
            if (len(restrict_rses) < 10):
                rse_clause = []
                for rse_id in restrict_rses:
                    rse_clause.append((models.RSEFileAssociation.rse_id == rse_id))
                if rse_clause:
                    query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32, models.RSEFileAssociation).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').filter(and_((models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope), (models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name), (models.RSEFileAssociation.state != ReplicaState.BEING_DELETED), or_(*rse_clause))).filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
    else:
        query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32, models.RSEFileAssociation).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').with_hint(models.RSEFileAssociation, 'INDEX(REPLICAS REPLICAS_PK)', 'oracle').outerjoin(models.RSEFileAssociation, and_((models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope), (models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name), (models.RSEFileAssociation.state != ReplicaState.BEING_DELETED))).filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
        if (restrict_rses is not None):
            if (len(restrict_rses) < 10):
                rse_clause = []
                for rse_id in restrict_rses:
                    rse_clause.append((models.RSEFileAssociation.rse_id == rse_id))
                if rse_clause:
                    query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32, models.RSEFileAssociation).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').outerjoin(models.RSEFileAssociation, and_((models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope), (models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name), (models.RSEFileAssociation.state != ReplicaState.BEING_DELETED), or_(*rse_clause))).filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
    if (total_threads and (total_threads > 1)):
        query = filter_thread_work(session=session, query=query, total_threads=total_threads, thread_id=thread_id, hash_variable='child_name')
    query = query.with_for_update(nowait=nowait, of=models.RSEFileAssociation.lock_cnt)
    for (child_scope, child_name, bytes, md5, adler32, replica) in query.yield_per(1000):
        if ((child_scope, child_name) not in files):
            files[(child_scope, child_name)] = {'scope': child_scope, 'name': child_name, 'bytes': bytes, 'md5': md5, 'adler32': adler32}
        if ((child_scope, child_name) in replicas):
            if (replica is not None):
                replicas[(child_scope, child_name)].append(replica)
        else:
            replicas[(child_scope, child_name)] = []
            if (replica is not None):
                replicas[(child_scope, child_name)].append(replica)
    return (list(files.values()), replicas)
Get file replicas for all files of a dataset.

:param scope:          The scope of the dataset.
:param name:           The name of the dataset.
:param nowait:         Nowait parameter for the FOR UPDATE statement
:param restrict_rses:  Possible RSE_ids to filter on.
:param total_threads:  Total threads
:param thread_id:      This thread
:param session:        The db session in use.
:returns:              (files in dataset, replicas in dataset)
@transactional_session
def get_and_lock_file_replicas_for_dataset(scope, name, nowait=False, restrict_rses=None, total_threads=None, thread_id=None, session=None):
    '\n    Get file replicas for all files of a dataset.\n\n    :param scope:          The scope of the dataset.\n    :param name:           The name of the dataset.\n    :param nowait:         Nowait parameter for the FOR UPDATE statement\n    :param restrict_rses:  Possible RSE_ids to filter on.\n    :param total_threads:  Total threads\n    :param thread_id:      This thread\n    :param session:        The db session in use.\n    :returns:              (files in dataset, replicas in dataset)\n    '
    (files, replicas) = ({}, {})
    if (session.bind.dialect.name == 'postgresql'):
        content_query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
        if (total_threads and (total_threads > 1)):
            content_query = filter_thread_work(session=session, query=content_query, total_threads=total_threads, thread_id=thread_id, hash_variable='child_name')
        for (child_scope, child_name, bytes, md5, adler32) in content_query.yield_per(1000):
            files[(child_scope, child_name)] = {'scope': child_scope, 'name': child_name, 'bytes': bytes, 'md5': md5, 'adler32': adler32}
            replicas[(child_scope, child_name)] = []
        query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32, models.RSEFileAssociation).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').filter(and_((models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope), (models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name), (models.RSEFileAssociation.state != ReplicaState.BEING_DELETED))).filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
        if (restrict_rses is not None):
            if (len(restrict_rses) < 10):
                rse_clause = []
                for rse_id in restrict_rses:
                    rse_clause.append((models.RSEFileAssociation.rse_id == rse_id))
                if rse_clause:
                    query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32, models.RSEFileAssociation).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').filter(and_((models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope), (models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name), (models.RSEFileAssociation.state != ReplicaState.BEING_DELETED), or_(*rse_clause))).filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
    else:
        query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32, models.RSEFileAssociation).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').with_hint(models.RSEFileAssociation, 'INDEX(REPLICAS REPLICAS_PK)', 'oracle').outerjoin(models.RSEFileAssociation, and_((models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope), (models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name), (models.RSEFileAssociation.state != ReplicaState.BEING_DELETED))).filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
        if (restrict_rses is not None):
            if (len(restrict_rses) < 10):
                rse_clause = []
                for rse_id in restrict_rses:
                    rse_clause.append((models.RSEFileAssociation.rse_id == rse_id))
                if rse_clause:
                    query = session.query(models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name, models.DataIdentifierAssociation.bytes, models.DataIdentifierAssociation.md5, models.DataIdentifierAssociation.adler32, models.RSEFileAssociation).with_hint(models.DataIdentifierAssociation, 'INDEX_RS_ASC(CONTENTS CONTENTS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)', 'oracle').outerjoin(models.RSEFileAssociation, and_((models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope), (models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name), (models.RSEFileAssociation.state != ReplicaState.BEING_DELETED), or_(*rse_clause))).filter((models.DataIdentifierAssociation.scope == scope), (models.DataIdentifierAssociation.name == name))
    if (total_threads and (total_threads > 1)):
        query = filter_thread_work(session=session, query=query, total_threads=total_threads, thread_id=thread_id, hash_variable='child_name')
    query = query.with_for_update(nowait=nowait, of=models.RSEFileAssociation.lock_cnt)
    for (child_scope, child_name, bytes, md5, adler32, replica) in query.yield_per(1000):
        if ((child_scope, child_name) not in files):
            files[(child_scope, child_name)] = {'scope': child_scope, 'name': child_name, 'bytes': bytes, 'md5': md5, 'adler32': adler32}
        if ((child_scope, child_name) in replicas):
            if (replica is not None):
                replicas[(child_scope, child_name)].append(replica)
        else:
            replicas[(child_scope, child_name)] = []
            if (replica is not None):
                replicas[(child_scope, child_name)].append(replica)
    return (list(files.values()), replicas)