Class ObjectDatabase
Gives access to the object database.
public class ObjectDatabase : IDisposable- Inheritance
- 
      objectObjectDatabase
- 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
- vfsMainUrlstring
- The VFS main URL. 
- indexNamestring
- Name of the index file. 
- vfsAdditionalUrlstring
- The VFS additional URL. It will be used only if vfsMainUrl is read-only. 
- loadDefaultBundlebool
Properties
BundleBackend
public BundleOdbBackend BundleBackend { get; }Property Value
ContentIndexMap
public ObjectDatabaseContentIndexMap ContentIndexMap { get; }Property Value
Methods
CreateBlob(nint, 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(nint data, int size)Parameters
Returns
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
- objectIdsObjectId[]
- bundleNamestring
- bundleBackendBundleOdbBackend
- disableCompressionIdsISet<ObjectId>
- indexMapDictionary<string, ObjectId>
- dependenciesIList<string>
- useIncrementalBundlebool
Returns
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 Write(nint, int, bool).
public OdbStreamWriter CreateStream()Returns
- OdbStreamWriter
- a stream writer that should be passed to Write(nint, int, bool) in order to be stored in the database 
Delete(ObjectId)
public void Delete(ObjectId objectId)Parameters
- objectIdObjectId
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()EnumerateLooseObjects()
public IEnumerable<ObjectId> EnumerateLooseObjects()Returns
EnumerateObjects()
public IEnumerable<ObjectId> EnumerateObjects()Returns
Exists(ObjectId)
public bool Exists(ObjectId objectId)Parameters
- objectIdObjectId
Returns
GetFilePath(ObjectId)
public string GetFilePath(ObjectId objectId)Parameters
- objectIdObjectId
Returns
GetSize(ObjectId)
public int GetSize(ObjectId objectId)Parameters
- objectIdObjectId
Returns
LoadBundle(string)
Loads the specified bundle.
public Task LoadBundle(string bundleName)Parameters
- bundleNamestring
- 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
- objectIdObjectId
- 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
- objectIdObjectId
- The object identifier. 
- modeVirtualFileMode
- The mode. 
- accessVirtualFileAccess
- The access. 
- shareVirtualFileShare
- 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
Returns
TryGetObjectLocation(ObjectId, out string?, out long, out long)
public bool TryGetObjectLocation(ObjectId objectId, out string? filePath, out long start, out long end)Parameters
Returns
UnloadBundle(string)
Unloads the specified bundle.
public void UnloadBundle(string bundleName)Parameters
- bundleNamestring
- Name of the bundle. 
Write(Stream)
Writes the specified data using the active IOdbBackend.
public ObjectId Write(Stream stream)Parameters
- streamStream
- The data stream. 
Returns
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
- streamStream
- The data stream. 
- objectIdObjectId
- The precomputed objectId. 
- forceWritebool
- Set to true to force writing the datastream even if a content is already stored with the same id. Default is false. 
Returns
Write(nint, int, bool)
Writes the specified data using the active IOdbBackend.
public ObjectId Write(nint data, int size, bool forceWrite = false)Parameters
- datanint
- The data. 
- sizeint
- The size. 
- forceWritebool
- Set to true to force writing the datastream even if a content is already stored with the same id. Default is false.