Class RandomAccessStorage
Defined in File random-access-storage.h
Inheritance Relationships
Base Type
public gpa::serialization::Storage
(Class Storage)
Class Documentation
-
class RandomAccessStorage : public gpa::serialization::Storage
Public Functions
-
RandomAccessStorage(uint64_t id)
-
~RandomAccessStorage()
-
virtual bool IsRandomAccess() const final override
Identifies this stream as random-access or sequential.
- Returns
True if stream is random-access, false if sequential
-
virtual bool IsEmpty() const final override
Query whether the storage has any size (and therefore any data)
- Returns
True if stream has no data or is zero-sized, false otherwise
-
virtual View *Map(void *addrHint = nullptr, SizeType offset = 0, size_t windowSize = (size_t)-1) = 0
Map a view of the storage into the process virtual address space.
- Parameters
addrHint --
The preferred starting address for the mapping. The implementation is free to ignore this, or provide "best-
effort", but no guarantee is made that this address will be the same as the base address for the mapping. Passing nullptr for this argument indicates no caller preference for mapping address.
offset -- Number of bytes into the underlying Storage by which to offset the start of the mapping. Must be a multiple of the system page size. Default is 0 (no offset, start at beginning of storage).
windowSize -- Size of the mapped "window" in bytes. Must be a multiple of the system page size. The default of "-1" means that the implementation is free to choose a reasonable default for window size.
- Returns
A View* that represents the mapped window.
-
virtual void Unmap(View *view) = 0
Unmap a View previously mapped by Map. view is destroyed by this call, so the caller may consider this a "disposal" method as well.
- Parameters
view -- View to unmap.
-
virtual bool Resize(SizeType minSize) = 0
Resize the underlying storage to at least minSize bytes. if this method succeeds, the underlying storage will be guaranteed to be at least minSize bytes (but may be more, depending on the implementation).
Warning
If minSize would cause the underlying storage to shrink, data may be lost. It is up to the caller to ensure that no important data exists in the portion that would be lost.
- Parameters
minSize -- Minimum number of bytes to size the underlying storage. The size of the storage after a successful resize will be a multiple of the system page size, and at least minSize bytes.
- Returns
True if operation succeeds; false otherwise.
-
virtual bool Truncate(SizeType size) = 0
Truncate (trim) the underlying storage to exactly size bytes.
- Parameters
size -- Number of bytes the underlying storage will occupy following a successful operation. After a successful truncation, the underlying storage will be exactly size bytes, and not padded to a multiple of the system page size.
- Returns
True if the truncation succeeded, false otherwise.
-
RandomAccessStorage(uint64_t id)