MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SequentialRecordReader

Class SequentialRecordReader

tensorflow/core/lib/io/record_reader.h:120–153  ·  view source on GitHub ↗

High-level interface to read TFRecord files. Note: this class is not thread safe; external synchronization required.

Source from the content-addressed store, hash-verified

118//
119// Note: this class is not thread safe; external synchronization required.
120class SequentialRecordReader {
121 public:
122 // Create a reader that will return log records from "*file".
123 // "*file" must remain live while this Reader is in use.
124 explicit SequentialRecordReader(
125 RandomAccessFile* file,
126 const RecordReaderOptions& options = RecordReaderOptions());
127
128 virtual ~SequentialRecordReader() = default;
129
130 // Reads the next record in the file into *record. Returns OK on success,
131 // OUT_OF_RANGE for end of file, or something else for an error.
132 Status ReadRecord(string* record) {
133 return underlying_.ReadRecord(&offset_, record);
134 }
135
136 // Returns the current offset in the file.
137 uint64 TellOffset() { return offset_; }
138
139 // Seek to this offset within the file and set this offset as the current
140 // offset. Trying to seek backward will throw error.
141 Status SeekOffset(uint64 offset) {
142 if (offset < offset_)
143 return errors::InvalidArgument(
144 "Trying to seek offset: ", offset,
145 " which is less than the current offset: ", offset_);
146 offset_ = offset;
147 return Status::OK();
148 }
149
150 private:
151 RecordReader underlying_;
152 uint64 offset_ = 0;
153};
154
155} // namespace io
156} // namespace tensorflow

Callers

nothing calls this directly

Calls 1

RecordReaderOptionsClass · 0.85

Tested by

no test coverage detected