C# Class GSF.IO.FileStructure.Media.BufferedFile

A buffered file stream utilizes the MemoryPool to intellectually cache the contents of files.
This class is a special purpose class that can only be used for the TransactionalFileStructure and can not buffer general purpose file. The cache algorithm is a least recently used algorithm. This is accomplised by incrementing a counter every time a page is accessed and dividing by 2 every time a collection occurs from the MemoryPool.
Inheritance: IDiskMediumCoreFunctions
显示文件 Open project: GridProtectionAlliance/openHistorian Class Usage Examples

Public Methods

Method Description
BufferedFile ( CustomFileStream stream, MemoryPool pool, FileHeaderBlock header, bool isNewFile ) : System

Creates a file backed memory stream.

ChangeExtension ( string extension, bool isReadOnly, bool isSharingEnabled ) : void

Changes the extension of the current file.

ChangeShareMode ( bool isReadOnly, bool isSharingEnabled ) : void

Reopens the file with different permissions.

CommitChanges ( FileHeaderBlock header ) : void

Executes a commit of data. This will flush the data to the disk use the provided header data to properly execute this function.

CreateIoSession ( ) : BinaryStreamIoSessionBase

Creates a BinaryStreamIoSessionBase that can be used to read from this disk medium.

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

RollbackChanges ( ) : void

Rolls back all edits to the DiskMedium

Private Methods

Method Description
GetBlock ( PageReplacementAlgorithm pageLock, BlockArguments args ) : void

Populates the pointer data inside args for the desired block as specified in args. This function will block if needing to retrieve data from the disk.

GetBlockFromCommittedSpace ( PageReplacementAlgorithm pageLock, long position, IntPtr &pointer ) : void

Processes the GetBlock from the committed area.

The valid length is at least the size of the buffer pools page size.

ReleaseWriteBufferSpace ( ) : void

Releases the buffered data contained in the buffer pool. This is acomplished by disposing of the writer and recreating it.

m_pool_RequestCollection ( object sender, CollectionEventArgs e ) : void

Handles the MemoryPool.RequestCollection event.

Method Details

BufferedFile() public method

Creates a file backed memory stream.
public BufferedFile ( CustomFileStream stream, MemoryPool pool, FileHeaderBlock header, bool isNewFile ) : System
stream CustomFileStream The to buffer
pool GSF.IO.Unmanaged.MemoryPool The to allocate memory from
header FileHeaderBlock The to be managed when modifications occur
isNewFile bool Tells if this is a newly created file. This will make sure that the /// first 10 pages have the header data copied to it.
return System

ChangeExtension() public method

Changes the extension of the current file.
public ChangeExtension ( string extension, bool isReadOnly, bool isSharingEnabled ) : void
extension string the new extension
isReadOnly bool If the file should be reopened as readonly
isSharingEnabled bool If the file should share read privileges.
return void

ChangeShareMode() public method

Reopens the file with different permissions.
public ChangeShareMode ( bool isReadOnly, bool isSharingEnabled ) : void
isReadOnly bool If the file should be reopened as readonly
isSharingEnabled bool If the file should share read privileges.
return void

CommitChanges() public method

Executes a commit of data. This will flush the data to the disk use the provided header data to properly execute this function.
public CommitChanges ( FileHeaderBlock header ) : void
header FileHeaderBlock
return void

CreateIoSession() public method

Creates a BinaryStreamIoSessionBase that can be used to read from this disk medium.
public CreateIoSession ( ) : BinaryStreamIoSessionBase
return GSF.IO.Unmanaged.BinaryStreamIoSessionBase

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

RollbackChanges() public method

Rolls back all edits to the DiskMedium
public RollbackChanges ( ) : void
return void