Table of Contents

Class ObjectDatabase

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

Gives access to the object database.

public class ObjectDatabase : IDisposable
Inheritance
ObjectDatabase
Implements
Extension Methods

Constructors

ObjectDatabase(string, string, string, bool)

Initializes a new instance of the ObjectDatabase class.

public ObjectDatabase(string vfsMainUrl, string indexName, string vfsAdditionalUrl = null, bool loadDefaultBundle = true)

Parameters

vfsMainUrl string

The VFS main URL.

indexName string

Name of the index file.

vfsAdditionalUrl string

The VFS additional URL. It will be used only if vfsMainUrl is read-only.

loadDefaultBundle bool

Properties

BundleBackend

public BundleOdbBackend BundleBackend { get; }

Property Value

BundleOdbBackend

ContentIndexMap

public ObjectDatabaseContentIndexMap ContentIndexMap { get; }

Property Value

ObjectDatabaseContentIndexMap

Methods

CreateBlob(IntPtr, int)

Creates a in-memory binary blob as a Blob that will also be stored using the active IOdbBackend. Even if Blob is new (not in the ODB), memory will be copied.

public Blob CreateBlob(IntPtr data, int size)

Parameters

data IntPtr

The data.

size int

The size.

Returns

Blob

The Blob containing given data, with its reference count incremented.

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

public string CreateBundle(ObjectId[] objectIds, string bundleName, BundleOdbBackend bundleBackend, ISet<ObjectId> disableCompressionIds, Dictionary<string, ObjectId> indexMap, IList<string> dependencies, bool useIncrementalBundle)

Parameters

objectIds ObjectId[]
bundleName string
bundleBackend BundleOdbBackend
disableCompressionIds ISet<ObjectId>
indexMap Dictionary<string, ObjectId>
dependencies IList<string>
useIncrementalBundle bool

Returns

string

CreateDefaultDatabase()

Creates a new instance of the ObjectDatabase class using default database path, index name, and local database path, and loading default bundle.

public static ObjectDatabase CreateDefaultDatabase()

Returns

ObjectDatabase

A new instance of the ObjectDatabase class.

CreateStream()

Creates a stream that can then be saved directly in the database using SaveStream.

public OdbStreamWriter CreateStream()

Returns

OdbStreamWriter

a stream writer that should be passed to SaveStream in order to be stored in the database

Delete(ObjectId)

public void Delete(ObjectId objectId)

Parameters

objectId ObjectId

Dispose()

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

public void Dispose()

EnumerateLooseObjects()

public IEnumerable<ObjectId> EnumerateLooseObjects()

Returns

IEnumerable<ObjectId>

EnumerateObjects()

public IEnumerable<ObjectId> EnumerateObjects()

Returns

IEnumerable<ObjectId>

Exists(ObjectId)

public bool Exists(ObjectId objectId)

Parameters

objectId ObjectId

Returns

bool

GetFilePath(ObjectId)

public string GetFilePath(ObjectId objectId)

Parameters

objectId ObjectId

Returns

string

GetSize(ObjectId)

public int GetSize(ObjectId objectId)

Parameters

objectId ObjectId

Returns

int

LoadBundle(string)

Loads the specified bundle.

public Task LoadBundle(string bundleName)

Parameters

bundleName string

Name of the bundle.

Returns

Task

Task that will complete when bundle is loaded.

Lookup(ObjectId)

Lookups the Blob with the specified ObjectId. Any object returned will have its reference count incremented.

public Blob Lookup(ObjectId objectId)

Parameters

objectId ObjectId

The object id.

Returns

Blob

The Blob matching this ObjectId with an incremented reference count if it exists; [null] otherwise.

OpenStream(ObjectId, VirtualFileMode, VirtualFileAccess, VirtualFileShare)

Opens a stream for the specified ObjectId.

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

Parameters

objectId ObjectId

The object identifier.

mode VirtualFileMode

The mode.

access VirtualFileAccess

The access.

share VirtualFileShare

The share.

Returns

Stream

A Stream.

Exceptions

InvalidOperationException

Read-only object database.

Read(ObjectId, bool)

Returns a data stream of the data specified ObjectId.

public Stream Read(ObjectId objectId, bool checkCache = false)

Parameters

objectId ObjectId

The ObjectId.

checkCache bool

if set to true [check cache for existing blobs].

Returns

Stream

A Stream of the requested data.

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)

Loads the specified bundle.

public void UnloadBundle(string bundleName)

Parameters

bundleName string

Name of the bundle.

Write(Stream)

Writes the specified data using the active IOdbBackend.

public ObjectId Write(Stream stream)

Parameters

stream Stream

The data stream.

Returns

ObjectId

The ObjectId of the given data.

Write(Stream, ObjectId, bool)

Writes the specified data using the active IOdbBackend and a precomputer ObjectId.

public ObjectId Write(Stream stream, ObjectId objectId, bool forceWrite = false)

Parameters

stream Stream

The data stream.

objectId ObjectId

The precomputed objectId.

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 ObjectId of the given data, which is the same that the passed one.

Write(IntPtr, int, bool)

Writes the specified data using the active IOdbBackend.

public ObjectId Write(IntPtr data, int size, bool forceWrite = false)

Parameters

data IntPtr

The data.

size int

The size.

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 ObjectId of the given data.