mxnet.recordio.MXIndexedRecordIO¶
-
class
mxnet.recordio.MXIndexedRecordIO(idx_path, uri, flag, key_type=<class 'int'>)[source]¶ Reads/writes RecordIO data format, supporting random access.
Examples
>>> for i in range(5): ... record.write_idx(i, 'record_%d'%i) >>> record.close() >>> record = mx.recordio.MXIndexedRecordIO('tmp.idx', 'tmp.rec', 'r') >>> record.read_idx(3) record_3
- Parameters
idx_path (str) – Path to the index file.
uri (str) – Path to the record file. Only supports seekable file types.
flag (str) – ‘w’ for write or ‘r’ for read.
key_type (type) – Data type for keys.
-
__init__(idx_path, uri, flag, key_type=<class 'int'>)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(idx_path, uri, flag[, key_type])Initialize self.
close()Closes the record file.
open()Opens the record file.
read()Returns record as a string.
read_idx(idx)Returns the record at given index.
reset()Resets the pointer to first item.
seek(idx)Sets the current read pointer position.
tell()Returns the current position of write head.
write(buf)Inserts a string buffer as a record.
write_idx(idx, buf)Inserts input record at given index.