# 读取器

## 读取器

读取器从存储中的数据集迭代记录，并将数据加载到数据向量中。除了数据集中的单个条目之外，阅读器的用处包括：如果想要在语料库上训练文本生成器，或是以编程方式将两个条目组合在一起形成新的记录的时候该怎么办？读取器实现对于复杂的文件类型或分布式存储机制是有用的。

读取器返回记录记录中每一列的Writable类。这些类用于将每个记录转换为张量/NDArray 格式。

## 使用

每个读取器实现都扩展了BaseRecordReader并提供了一个简单的API用于选取数据集中的下一条记录，行为类似于迭代器。

包括以下有用的方法：

* `next`: 返回一个批量的 `Writable`。
* `nextRecord`: 返回单条记录，`RecordMetaData` 是可选的。
* `reset`: 重置基础迭代器。
* `hasNext`: 迭代器方法以确定是否有其他记录可用 。

## 监听器

你可以将自定义的RecordListener挂钩到记录读取器进行调试或可视化目的。在初始化类之后，立即将你的自定义侦听器传递给addListener基类方法。


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://deeplearning4j.konduit.ai/zhong-wen-v1.0.0/datavec/du-qu-qi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
