Documentation ¶
Index ¶
- Constants
- type ContentEntry
- type EdfFile
- func (e *EdfFile) AllocPages(pagesRequested uint32, thread uint32) (EdfRange, error)
- func (e *EdfFile) FindThread(targetName string) (uint32, error)
- func (e *EdfFile) FixedAlloc(bytesRequested uint32) (EdfRange, error)
- func (e *EdfFile) GetPageRange(pageStart uint64, pageEnd uint64) EdfRange
- func (e *EdfFile) GetPageSize() uint64
- func (e *EdfFile) GetSegmentSize() uint64
- func (e *EdfFile) GetThreadBlocks(thread uint32) ([]EdfRange, error)
- func (e *EdfFile) GetThreadCount() uint32
- func (e *EdfFile) GetThreads() (map[uint32]string, error)
- func (e *EdfFile) IResolveRange(r EdfRange, prev uint64) ([]byte, uint64)
- func (e *EdfFile) Range(byteStart uint64, byteEnd uint64) EdfRange
- func (e *EdfFile) ResolveRange(r EdfRange) [][]byte
- func (e *EdfFile) Sync() error
- func (e *EdfFile) Unmap(flags int) error
- func (e *EdfFile) VerifyHeader() error
- func (e *EdfFile) WriteThread(t *Thread) error
- type EdfPosition
- type EdfRange
- type Thread
Constants ¶
const ( // EDF_VERSION is the file format version EDF_VERSION = 1 // EDF_LENGTH is th number of OS pages in each slice EDF_LENGTH = 32 // EDF_SIZE sets the maximum size of the mapping, represented with // EDF_LENGTH segments // Currently set arbitrarily to 128 MiB EDF_SIZE = 128 * (1024 * 1024) )
const ( // EDF_READ_ONLY means the file will only be read, modifications fail EDF_READ_ONLY = iota // EDF_READ_WRITE specifies that the file will be read and written EDF_READ_WRITE // EDF_CREATE means the file will be created and opened with EDF_READ_WRITE EDF_CREATE )
const ( // EDF_UNMAP_NOSYNC means the file won't be // Sync'd to disk before unmapping EDF_UNMAP_NOSYNC = iota // EDF_UNMAP_SYNC synchronises the EDF file to disk // during unmapping EDF_UNMAP_SYNC )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentEntry ¶
type ContentEntry struct { // Which thread this entry is assigned to Thread uint32 // Which page this block starts at Start uint32 // The page up to and including which the block ends End uint32 }
ContentEntry structs are stored in ContentEntry blocks which always at block 2.
type EdfFile ¶
type EdfFile struct {
// contains filtered or unexported fields
}
EdfFile represents a mapped file on disk or and anonymous mapping for instance storage
func EdfAnonMap ¶
EdfAnonMap maps the EdfFile structure into RAM IMPORTANT: everything's lost if unmapped
func EdfMap ¶
EdfMap takes an os.File and returns an EdfMappedFile structure, which represents the mmap'd underlying file
The `mode` parameter takes the following values
EDF_CREATE: EdfMap will truncate the file to the right length and write the correct header information EDF_READ_WRITE: EdfMap will verify header information EDF_READ_ONLY: EdfMap will verify header information
IMPORTANT: EDF_LENGTH (edf.go) controls the size of the address space mapping. This means that the file can be truncated to the correct size without remapping. On 32-bit systems, this is set to 2GiB.
func (*EdfFile) AllocPages ¶
AllocPages allocates a |pagesRequested| chunk of pages on the Thread with the given identifier. Returns an EdfRange describing the result.
func (*EdfFile) FindThread ¶
FindThread obtains the index of a thread in the EdfFile.
func (*EdfFile) FixedAlloc ¶
FixedAlloc allocates a |bytesRequested| chunk of pages on the FIXED thread.
func (*EdfFile) GetPageRange ¶
GetPageRange returns the segment offset and range of two pages in the file.
func (*EdfFile) GetPageSize ¶
GetPageSize returns the pageSize of an EdfFile
func (*EdfFile) GetSegmentSize ¶
GetSegmentSize returns the segmentSize of an EdfFile
func (*EdfFile) GetThreadBlocks ¶
GetThreadBlocks returns EdfRanges containing blocks assigned to a given thread.
func (*EdfFile) GetThreadCount ¶
GetThreadCount returns the number of threads in this file.
func (*EdfFile) GetThreads ¶
GetThreads returns the thread identifier -> name map.
func (*EdfFile) IResolveRange ¶
IResolveRange returns a byte slice representing the current EdfRange and returns a value saying whether there's more. Subsequent calls to IncrementallyResolveRange should use the value returned by the previous one until no more ranges are available.
func (*EdfFile) ResolveRange ¶
ResolveRange returns a slice of byte slices representing the underlying memory referenced by EdfRange.
WARNING: slow.
func (*EdfFile) Unmap ¶
Unmap unlinks the EdfFile from the address space. EDF_UNMAP_NOSYNC skips calling Sync() on the underlying file before this happens. IMPORTANT: attempts to use this mapping after Unmap() is called will result in crashes.
func (*EdfFile) VerifyHeader ¶
VerifyHeader checks that this version of Golearn can read the file presented.
func (*EdfFile) WriteThread ¶
WriteThread inserts a new thread into the EdfFile.
type EdfPosition ¶
EdfPosition represents a start and finish point within the mapping
type EdfRange ¶
type EdfRange struct { Start EdfPosition End EdfPosition // contains filtered or unexported fields }
EdfRange represents a start and an end segment mapped in an EdfFile and also the byte offsets within that segment
type Thread ¶
type Thread struct {
// contains filtered or unexported fields
}
Threads are streams of data encapsulated within the file.
func (*Thread) Deserialize ¶
Deserialize copies the input byte slice into a thread.
func (*Thread) GetSpaceNeeded ¶
GetSpaceNeeded the number of bytes needed to serialize this Thread.