# tff.program.FederatedDataSourceIterator

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

An abstract interface for representing federated data source iterators.

This interface abstracts away the specifics of iterating over data in a data
source.

Things one can do with a data source iterator:

- Determine the type of the data supplied by this iterator by inspecting
  the `federated_type` property. The type returned must match that of the data
  source that returned this iterator.

- Return a new selection of federated data from the iterator by invoking
  `select`.

Please see [`tff.program.FederatedDataSource`](https://www.tensorflow.org/federated/api_docs/python/tff/program/FederatedDataSource) for additional context and the
high-level description of how to use data sources.

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `federated_type` | The type of the data returned by calling `select`. |

<br />

## Methods

### `from_bytes`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @classmethod
    @abc.abstractmethod
    from_bytes(
        buffer: bytes
    ) -> 'Serializable'

Deserializes the object from bytes.

### `select`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @abc.abstractmethod
    select(
        k: Optional[int] = None
    ) -> object

Returns a new selection of federated data from this iterator.

<br />

<br />

<br />

| Args ||
|---|---|
| `k` | An optional number of elements to select. Must be a positive integer, or `None` if unspecified. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An object of type `federated_type` representing the selected data, and that can be supplied as an argument to a [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation). See [`tff.program.FederatedContext`](https://www.tensorflow.org/federated/api_docs/python/tff/program/FederatedContext) for more information about these types. ||

<br />

### `to_bytes`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @abc.abstractmethod
    to_bytes() -> bytes

Serializes the object to bytes.