QcRegionFile Namespace
One region file of a world (decision E-373). More...
| Header: | #include <server/storage/QcRegionFile.h> |
Classes
Types
Variables
| const int | chunksPerRegion |
| const quint32 | maxBlobBytes |
| const int | regionSize |
Functions
| QString | path(const QString &folder, QcChunkPos region, const QString &extension) |
| QcResult<QcRegionFile::AllBlobs> | readAll(const QString &path, const QcRegionFile::Index &index) |
| QcResult<QByteArray> | readBlob(const QString &path, QcRegionFile::Entry entry) |
| QcResult<QcRegionFile::Index> | readIndex(const QString &path, QcChunkPos region, QByteArrayView magic, quint16 version) |
| QcChunkPos | regionOf(QcChunkPos chunk) |
| std::optional<QcChunkPos> | regionOfFile(const QString &fileName, const QString &extension) |
| QcResult<QcRegionFile::Index> | write(const QString &path, QByteArrayView magic, quint16 version, const QList<QcRegionFile::Blob> &blobs) |
Detailed Description
It holds the data of up to regionSize x regionSize chunks of one kind (blocks, block entities or entities), each chunk a separate blob found through an index at the start, so one chunk is read without reading or decoding the others:
[magic 4][quint16 version][quint32 entry count][quint32 crc of the entries] entries: [quint16 slot (x + regionSize * z within the region)][quint16 marks] [quint32 offset][quint32 size][quint32 crc of the blob] blobs marks is a small value its owner keeps beside a chunk without reading the blob (the circuit marks of QcChunkLinks). A damaged index makes the file unreadable; a damaged blob only its chunk.
Classes
class AllBlobs
Every blob of a file, and the chunks whose bytes do not match their checksum. More...
class Blob
The blob of a chunk to write or as read. More...
class Entry
The index entry of a chunk: its marks, and offset, size and checksum of its blob. More...
Type Documentation
[alias] QcRegionFile::Index
The index of a file by chunk.
Variable Documentation
const int QcRegionFile::chunksPerRegion
The chunks of a region.
const quint32 QcRegionFile::maxBlobBytes
Bigger blobs are damaged data (a chunk of blocks is far smaller).
const int QcRegionFile::regionSize
The side of a region in chunks.
Function Documentation
QString QcRegionFile::path(const QString &folder, QcChunkPos region, const QString &extension)
Returns the file of region in folder with extension: <folder>/r.<x>.<z>.<extension>.
QcResult<QcRegionFile::AllBlobs> QcRegionFile::readAll(const QString &path, const QcRegionFile::Index &index)
Returns every blob of the file path (as index lists them) in one read with the marks and checksum of its entry (rewriting a region keeps the blobs that did not change, damaged ones included).
QcResult<QByteArray> QcRegionFile::readBlob(const QString &path, QcRegionFile::Entry entry)
Returns the blob of entry read from the file path, checked against its crc.
QcResult<QcRegionFile::Index> QcRegionFile::readIndex(const QString &path, QcChunkPos region, QByteArrayView magic, quint16 version)
Returns the index read from the file path of region, which starts with magic; a chunk of another region, a slot twice or an entry beyond the end of the file is damage. version must match: older development versions are refused (decision E-356).
QcChunkPos QcRegionFile::regionOf(QcChunkPos chunk)
Returns the region that holds chunk.
std::optional<QcChunkPos> QcRegionFile::regionOfFile(const QString &fileName, const QString &extension)
Returns the region fileName names, if it is one (r.<x>.<z>.<extension> with extension).
QcResult<QcRegionFile::Index> QcRegionFile::write(const QString &path, QByteArrayView magic, quint16 version, const QList<QcRegionFile::Blob> &blobs)
Writes blobs as a whole file at path with magic and version (no staging; QcChunkStore stages and renames). Returns the index of what was written.