Table of Contents

Class BundleOdbBackend

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

Object Database Backend (ODB) implementation that bundles multiple chunks into a .bundle files, optionally compressed with LZ4.

[DataSerializerGlobal(null, typeof(List<string>), DataSerializerGenericMode.None, false, false)]
[DataSerializerGlobal(null, typeof(List<ObjectId>), DataSerializerGenericMode.None, false, false)]
[DataSerializerGlobal(null, typeof(List<KeyValuePair<ObjectId, BundleOdbBackend.ObjectInfo>>), DataSerializerGenericMode.None, false, false)]
[DataSerializerGlobal(null, typeof(List<KeyValuePair<string, ObjectId>>), DataSerializerGenericMode.None, false, false)]
public class BundleOdbBackend : IOdbBackend, IDisposable
Inheritance
BundleOdbBackend
Implements
Extension Methods

Constructors

BundleOdbBackend(string)

public BundleOdbBackend(string vfsRootUrl)

Parameters

vfsRootUrl string

Fields

BundleExtension

The bundle file extension.

public const string BundleExtension = ".bundle"

Field Value

string

Properties

BundleDirectory

public string BundleDirectory { get; }

Property Value

string

BundleResolve

Bundle resolve event asynchronous handler.

public BundleOdbBackend.BundleResolveDelegate BundleResolve { get; set; }

Property Value

BundleOdbBackend.BundleResolveDelegate

ContentIndexMap

Gets the asset index map.

public IContentIndexMap ContentIndexMap { get; }

Property Value

IContentIndexMap

The asset index map.

Methods

CreateBundle(string, IOdbBackend, ObjectId[], ISet<ObjectId>, Dictionary<string, ObjectId>, IList<string>, bool)

public static void CreateBundle(string bundleUrl, IOdbBackend backend, ObjectId[] objectIds, ISet<ObjectId> disableCompressionIds, Dictionary<string, ObjectId> indexMap, IList<string> dependencies, bool useIncrementalBundle)

Parameters

bundleUrl string
backend IOdbBackend
objectIds ObjectId[]
disableCompressionIds ISet<ObjectId>
indexMap Dictionary<string, ObjectId>
dependencies IList<string>
useIncrementalBundle bool

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 SaveStream 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.

DeleteBundles(Func<string, bool>)

public void DeleteBundles(Func<string, bool> bundleFileDeletePredicate)

Parameters

bundleFileDeletePredicate Func<string, bool>

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 weither the object with the specified ObjectId exists.

public 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.

GetObjectInfos()

public Dictionary<ObjectId, BundleOdbBackend.ObjectInfo> GetObjectInfos()

Returns

Dictionary<ObjectId, BundleOdbBackend.ObjectInfo>

GetSize(ObjectId)

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

public int GetSize(ObjectId objectId)

Parameters

objectId ObjectId

The ObjectId.

Returns

int

The object size.

LoadBundle(string, ObjectDatabaseContentIndexMap)

Loads the specified bundle.

public Task LoadBundle(string bundleName, ObjectDatabaseContentIndexMap objectDatabaseContentIndexMap)

Parameters

bundleName string

Name of the bundle.

objectDatabaseContentIndexMap ObjectDatabaseContentIndexMap

The object database asset index map, where newly loaded assets will be merged (ignored if null).

Returns

Task

Task that will complete when bundle is loaded.

LoadBundleFromUrl(string, ObjectDatabaseContentIndexMap, string, bool)

public Task LoadBundleFromUrl(string bundleName, ObjectDatabaseContentIndexMap objectDatabaseContentIndexMap, string bundleUrl, bool ignoreDependencies = false)

Parameters

bundleName string
objectDatabaseContentIndexMap ObjectDatabaseContentIndexMap
bundleUrl string
ignoreDependencies bool

Returns

Task

OpenStream(ObjectId, VirtualFileMode, VirtualFileAccess, VirtualFileShare)

Opens a Stream of the object with the specified ObjectId.

public 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.

ReadBundleDescription(Stream)

Reads the bundle description.

public static BundleDescription ReadBundleDescription(Stream stream)

Parameters

stream Stream

The stream.

Returns

BundleDescription

The bundle description.

Exceptions

InvalidOperationException

Invalid bundle header or Bundle has not been properly written

ReadBundleHeader(string, out List<string>)

public static BundleDescription ReadBundleHeader(string bundleUrl, out List<string> bundleUrls)

Parameters

bundleUrl string
bundleUrls List<string>

Returns

BundleDescription

TryGetObjectLocation(ObjectId, out string, out long, out long)

public bool TryGetObjectLocation(ObjectId objectId, out string filePath, out long start, out long end)

Parameters

objectId ObjectId
filePath string
start long
end long

Returns

bool

UnloadBundle(string, ObjectDatabaseContentIndexMap)

Unload the specified bundle.

public void UnloadBundle(string bundleName, ObjectDatabaseContentIndexMap objectDatabaseContentIndexMap)

Parameters

bundleName string

Name of the bundle.

objectDatabaseContentIndexMap ObjectDatabaseContentIndexMap

The object database asset index map, where newly loaded assets will be merged (ignored if null).

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 ObjectId Write(ObjectId objectId, Stream dataStream, int length, bool forceWrite)

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.