ObjectDatabase Class
Namespace: Stride.Core.StorageAssembly: Stride.Core.Serialization.dll
Gives access to the object database.
public class ObjectDatabase : IDisposable
Name | Description | |
---|---|---|
Constructors | ||
ObjectDatabase(String, String, String, Boolean) | Initializes a new instance of the ObjectDatabase class. |
|
Properties | ||
BundleBackend | ||
ContentIndexMap | ||
Methods | ||
CreateBlob(IntPtr, Int32) | 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. |
|
CreateBundle(ObjectId[], String, BundleOdbBackend, ISet<ObjectId>, Dictionary<String, ObjectId>, IList<String>, Boolean) | ||
CreateDefaultDatabase() | Creates a new instance of the ObjectDatabase class using default database path, index name, and local database path, and loading default bundle. |
|
CreateStream() | Creates a stream that can then be saved directly in the database using |
|
Delete(ObjectId) | ||
Dispose() | ||
EnumerateLooseObjects() | ||
EnumerateObjects() | ||
Exists(ObjectId) | ||
GetFilePath(ObjectId) | ||
GetSize(ObjectId) | ||
LoadBundle(String) | Loads the specified bundle. |
|
Lookup(ObjectId) | Lookups the Blob with the specified ObjectId. Any object returned will have its reference count incremented. |
|
OpenStream(ObjectId, VirtualFileMode, VirtualFileAccess, VirtualFileShare) | Opens a stream for the specified ObjectId. |
|
Read(ObjectId, Boolean) | Returns a data stream of the data specified ObjectId. |
|
TryGetObjectLocation(ObjectId, out String, out Int64, out Int64) | ||
UnloadBundle(String) | Loads the specified bundle. |
|
Write(IntPtr, Int32, Boolean) | Writes the specified data using the active IOdbBackend. |
|
Write(Stream) | Writes the specified data using the active IOdbBackend. |
|
Write(Stream, ObjectId, Boolean) | Writes the specified data using the active IOdbBackend and a precomputer ObjectId. |
Constructors
ObjectDatabase(String, String, String, Boolean)
Initializes a new instance of the ObjectDatabase class.
public ObjectDatabase(string vfsMainUrl, string indexName, string vfsAdditionalUrl = null, bool loadDefaultBundle = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | vfsMainUrl | The VFS main URL. |
System.String | indexName | Name of the index file. |
System.String | vfsAdditionalUrl | The VFS additional URL. It will be used only if vfsMainUrl is read-only. |
System.Boolean | loadDefaultBundle |
Properties
BundleBackend
public BundleOdbBackend BundleBackend { get; }
Property Value
Type | Description |
---|---|
BundleOdbBackend |
ContentIndexMap
public ObjectDatabaseContentIndexMap ContentIndexMap { get; }
Property Value
Type | Description |
---|---|
ObjectDatabaseContentIndexMap |
Methods
CreateBlob(IntPtr, Int32)
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
Type | Name | Description |
---|---|---|
System.IntPtr | data | The data. |
System.Int32 | size | The size. |
Returns
Type | Description |
---|---|
Blob | The Blob containing given data, with its reference count incremented. |
CreateBundle(ObjectId[], String, BundleOdbBackend, ISet<ObjectId>, Dictionary<String, ObjectId>, IList<String>, Boolean)
public string CreateBundle(ObjectId[] objectIds, string bundleName, BundleOdbBackend bundleBackend, ISet<ObjectId> disableCompressionIds, Dictionary<string, ObjectId> indexMap, IList<string> dependencies, bool useIncrementalBundle)
Parameters
Type | Name | Description |
---|---|---|
ObjectId[] | objectIds | |
System.String | bundleName | |
BundleOdbBackend | bundleBackend | |
System.Collections.Generic.ISet<ObjectId> | disableCompressionIds | |
System.Collections.Generic.Dictionary<System.String, ObjectId> | indexMap | |
System.Collections.Generic.IList<System.String> | dependencies | |
System.Boolean | useIncrementalBundle |
Returns
Type | Description |
---|---|
System.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
Type | Description |
---|---|
ObjectDatabase | A new instance of the ObjectDatabase class. |
CreateStream()
Creates a stream that can then be saved directly in the database using
public OdbStreamWriter CreateStream()
Returns
Type | Description |
---|---|
OdbStreamWriter | a stream writer that should be passed to |
Delete(ObjectId)
public void Delete(ObjectId objectId)
Parameters
Type | Name | Description |
---|---|---|
ObjectId | objectId |
Dispose()
public void Dispose()
EnumerateLooseObjects()
public IEnumerable<ObjectId> EnumerateLooseObjects()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ObjectId> |
EnumerateObjects()
public IEnumerable<ObjectId> EnumerateObjects()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ObjectId> |
Exists(ObjectId)
public bool Exists(ObjectId objectId)
Parameters
Type | Name | Description |
---|---|---|
ObjectId | objectId |
Returns
Type | Description |
---|---|
System.Boolean |
GetFilePath(ObjectId)
public string GetFilePath(ObjectId objectId)
Parameters
Type | Name | Description |
---|---|---|
ObjectId | objectId |
Returns
Type | Description |
---|---|
System.String |
GetSize(ObjectId)
public int GetSize(ObjectId objectId)
Parameters
Type | Name | Description |
---|---|---|
ObjectId | objectId |
Returns
Type | Description |
---|---|
System.Int32 |
LoadBundle(String)
Loads the specified bundle.
public Task LoadBundle(string bundleName)
Parameters
Type | Name | Description |
---|---|---|
System.String | bundleName | Name of the bundle. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.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
Type | Name | Description |
---|---|---|
ObjectId | objectId | The object id. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
ObjectId | objectId | The object identifier. |
VirtualFileMode | mode | The mode. |
VirtualFileAccess | access | The access. |
VirtualFileShare | share | The share. |
Returns
Type | Description |
---|---|
System.IO.Stream | A Stream. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Read-only object database. |
Read(ObjectId, Boolean)
Returns a data stream of the data specified ObjectId.
public Stream Read(ObjectId objectId, bool checkCache = false)
Parameters
Type | Name | Description |
---|---|---|
ObjectId | objectId | The ObjectId. |
System.Boolean | checkCache | if set to |
Returns
Type | Description |
---|---|
System.IO.Stream | A NativeStream of the requested data. |
TryGetObjectLocation(ObjectId, out String, out Int64, out Int64)
public bool TryGetObjectLocation(ObjectId objectId, out string filePath, out long start, out long end)
Parameters
Type | Name | Description |
---|---|---|
ObjectId | objectId | |
System.String | filePath | |
System.Int64 | start | |
System.Int64 | end |
Returns
Type | Description |
---|---|
System.Boolean |
UnloadBundle(String)
Loads the specified bundle.
public void UnloadBundle(string bundleName)
Parameters
Type | Name | Description |
---|---|---|
System.String | bundleName | Name of the bundle. |
Write(IntPtr, Int32, Boolean)
Writes the specified data using the active IOdbBackend.
public ObjectId Write(IntPtr data, int size, bool forceWrite = false)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | data | The data. |
System.Int32 | size | The size. |
System.Boolean | forceWrite | Set to true to force writing the datastream even if a content is already stored with the same id. Default is false. |
Returns
Type | Description |
---|---|
ObjectId | The ObjectId of the given data. |
Write(Stream)
Writes the specified data using the active IOdbBackend.
public ObjectId Write(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The data stream. |
Returns
Type | Description |
---|---|
ObjectId | The ObjectId of the given data. |
Write(Stream, ObjectId, Boolean)
Writes the specified data using the active IOdbBackend and a precomputer ObjectId.
public ObjectId Write(Stream stream, ObjectId objectId, bool forceWrite = false)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The data stream. |
ObjectId | objectId | The precomputed objectId. |
System.Boolean | forceWrite | Set to true to force writing the datastream even if a content is already stored with the same id. Default is false. |
Returns
Type | Description |
---|---|
ObjectId | The ObjectId of the given data, which is the same that the passed one. |