> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/api/client-libraries/redivis-js/reference/readstream.md).

# ReadStream

## *class* <mark style="color:purple;">ReadStream</mark>

A ReadStream is one part of a parallelized read of a table, query, or upload. Each stream contains a subset of the rows, and can be read independently of the others, with the same `to*` methods as its parent.

## Constructors

| Method                                                                                                                                                | Description                                                                                                                                                                                                                          |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [**`Table.toReadStreams`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table/table.toreadstreams.md)(\[targetCount, options]) | Split a table into ReadStreams. Also callable on [Queries](https://docs.redivis.com/api/client-libraries/redivis-js/reference/query.md) and [Uploads](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload.md). |

## Examples

```javascript
const table = redivis.table('demo.us_forest_service_fires:5k9t:v1_1.us_fire_perimeters:9r58');

// The server may return fewer streams than requested, depending on the size of the table
const streams = await table.toReadStreams(4, { variables: ['FIRENAME', 'FIREYEAR'] });

// Read the streams concurrently
const results = await Promise.all(streams.map((stream) => stream.toRowsArray()));
const rows = results.flat();
```

## Attributes

| Name             | Description                                                                                                                                                                                                                                                                                                 |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`id`**         | The stream's id.                                                                                                                                                                                                                                                                                            |
| **`parent`**     | The [Table](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md), [Query](https://docs.redivis.com/api/client-libraries/redivis-js/reference/query.md), or [Upload](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload.md) that the stream was created from. |
| **`properties`** | An object containing the stream's metadata, including `estimatedRows`.                                                                                                                                                                                                                                      |

## Methods

| Method                                                                                                                                         | Description                                                                                                                                                                                                      |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**`ReadStream.to*`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/readstream/readstream.to.md)(\[maxResults, options]) | Various methods to read the stream's data. Mirrors the corresponding [`Table.to*`](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md#methods) methods (e.g., `stream.toArrowTable()`). |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.redivis.com/api/client-libraries/redivis-js/reference/readstream.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
