Class ObjectDatabase
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
stringThe VFS main URL.
indexName
stringName of the index file.
vfsAdditionalUrl
stringThe VFS additional URL. It will be used only if vfsMainUrl is read-only.
loadDefaultBundle
bool
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
objectIds
ObjectId[]bundleName
stringbundleBackend
BundleOdbBackenddisableCompressionIds
ISet<ObjectId>indexMap
Dictionary<string, ObjectId>dependencies
IList<string>useIncrementalBundle
bool
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
objectId
ObjectId
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
objectId
ObjectId
Returns
GetFilePath(ObjectId)
public string GetFilePath(ObjectId objectId)
Parameters
objectId
ObjectId
Returns
GetSize(ObjectId)
public int GetSize(ObjectId objectId)
Parameters
objectId
ObjectId
Returns
LoadBundle(string)
Loads the specified bundle.
public Task LoadBundle(string bundleName)
Parameters
bundleName
stringName 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
ObjectIdThe 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
ObjectIdThe object identifier.
mode
VirtualFileModeThe mode.
access
VirtualFileAccessThe access.
share
VirtualFileShareThe 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
bundleName
stringName of the bundle.
Write(Stream)
Writes the specified data using the active IOdbBackend.
public ObjectId Write(Stream stream)
Parameters
stream
StreamThe 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
stream
StreamThe data stream.
objectId
ObjectIdThe precomputed objectId.
forceWrite
boolSet 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
data
nintThe data.
size
intThe size.
forceWrite
boolSet to true to force writing the datastream even if a content is already stored with the same id. Default is false.