Table of Contents

Class FileOdbBackend

Namespace
Stride.Core.Storage
Assembly
Stride.Core.Serialization.dll

Object Database Backend (ODB) implementation using VirtualFileSystem

public class FileOdbBackend : IOdbBackend, IDisposable
Inheritance
object
FileOdbBackend
Implements
Extension Methods

Constructors

FileOdbBackend(string, string, bool)

public FileOdbBackend(string vfsRootUrl, string indexName, bool isReadOnly)

Parameters

vfsRootUrl string
indexName string
isReadOnly bool

Properties

ContentIndexMap

Gets the asset index map.

public IContentIndexMap ContentIndexMap { get; }

Property Value

IContentIndexMap

The asset index map.

IsReadOnly

public bool IsReadOnly { get; }

Property Value

bool

TouchThrottle

Touch throttle (X): a stored object's mtime is only refreshed by Touch(ObjectId) if it is already older than this, bounding write amplification. GC eviction age must stay above it.

public static TimeSpan TouchThrottle { get; set; }

Property Value

TimeSpan

Methods

BuildUrl(string, ObjectId)

public static string BuildUrl(string vfsRootUrl, ObjectId objectId)

Parameters

vfsRootUrl string
objectId ObjectId

Returns

string

CreateStream()

Creates a stream that will be saved to database when closed and/or disposed.

public OdbStreamWriter CreateStream()

Returns

OdbStreamWriter

a stream writer that should be passed to Write(ObjectId, Stream, int, bool) in order to be stored in the database

Delete(ObjectId)

Deletes the specified ObjectId.

public void Delete(ObjectId objectId)

Parameters

objectId ObjectId

The object id.

Dispose()

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

public void Dispose()

EnumerateObjects()

Enumerates the object stored in this backend.

public IEnumerable<ObjectId> EnumerateObjects()

Returns

IEnumerable<ObjectId>

Exists(ObjectId)

Determines if the object with the specified ObjectId exists.

public virtual bool Exists(ObjectId objectId)

Parameters

objectId ObjectId

The ObjectId to check existence for.

Returns

bool

true if an object with the specified ObjectId exists; otherwise, false.

GetFilePath(ObjectId)

Returns the file path corresponding to the given id (in the VFS domain), if appliable.

public string GetFilePath(ObjectId objectId)

Parameters

objectId ObjectId

The ObjectId.

Returns

string

The file path.

GetSize(ObjectId)

Requests that this backend read an object's length (but not its contents).

public virtual int GetSize(ObjectId objectId)

Parameters

objectId ObjectId

The ObjectId.

Returns

int

The object size.

OpenStream(ObjectId, VirtualFileMode, VirtualFileAccess, VirtualFileShare)

Opens a Stream of the object with the specified ObjectId.

public virtual Stream OpenStream(ObjectId objectId, VirtualFileMode mode = VirtualFileMode.Open, VirtualFileAccess access = VirtualFileAccess.Read, VirtualFileShare share = VirtualFileShare.Read)

Parameters

objectId ObjectId

The ObjectId.

mode VirtualFileMode

The mode.

access VirtualFileAccess

The access.

share VirtualFileShare

The process share mode.

Returns

Stream

A Stream opened from the specified ObjectId.

Touch(ObjectId)

Refreshes an object's last-write time so mtime-LRU GC treats it as recently used. Best-effort and throttled by TouchThrottle; no-op on read-only backends.

public void Touch(ObjectId objectId)

Parameters

objectId ObjectId

Write(ObjectId, Stream, int, bool)

Writes an object to the backing store. The backend may need to compute the object ID and return it to the caller.

public virtual ObjectId Write(ObjectId objectId, Stream dataStream, int length, bool forceWrite = false)

Parameters

objectId ObjectId

The ObjectId if already computed, or Empty if not determined yet.

dataStream Stream

The data stream.

length int

The data length.

forceWrite bool

Set to true to force writing the datastream even if a content is already stored with the same id. Default is false.

Returns

ObjectId

The generated ObjectId.