Class ObjectDatabase
Gives access to the object database.
public class ObjectDatabase : IDisposable
- Inheritance
-
objectObjectDatabase
- Implements
- Extension Methods
Constructors
ObjectDatabase(string, string, string?, bool, string)
Initializes a new instance of the ObjectDatabase class.
public ObjectDatabase(string vfsMainUrl, string indexName, string? vfsAdditionalUrl = null, bool loadDefaultBundle = true, string defaultBundleName = "default")
Parameters
vfsMainUrlstringThe VFS main URL.
indexNamestringName of the index file.
vfsAdditionalUrlstringThe VFS additional URL. It will be used only if vfsMainUrl is read-only.
loadDefaultBundlebooldefaultBundleNamestringBundle name to load when
loadDefaultBundleis true.
Properties
BundleBackend
public BundleOdbBackend BundleBackend { get; }
Property Value
ContentAliases
Bare-to-rooted URL aliases (using semantics for namespaced packages); empty when none shipped. One "bare|rooted" entry per line ('|' cannot appear in URLs).
public IReadOnlyDictionary<string, string> ContentAliases { 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[]bundleNamestringbundleBackendBundleOdbBackenddisableCompressionIdsISet<ObjectId>indexMapDictionary<string, ObjectId>dependenciesIList<string>useIncrementalBundlebool
Returns
CreateDefaultDatabase(string)
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(string defaultBundleName = "default")
Parameters
defaultBundleNamestringName of the bundle to load (defaults to
"default").
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
bundleNamestringName 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
objectIdObjectIdThe 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
objectIdObjectIdThe object identifier.
modeVirtualFileModeThe mode.
accessVirtualFileAccessThe access.
shareVirtualFileShareThe 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
RetouchWorkingSet()
Re-touches every object hit this session so the working set doesn't age out of the mtime-LRU cache while the editor sits idle (no rebuilds to touch it on-hit). Throttled per file.
public void RetouchWorkingSet()
Touch(ObjectId)
Refreshes an object's last-use time for mtime-LRU GC and records it in the session working set (see RetouchWorkingSet()). Best-effort and throttled; only the writable loose-file store supports it (bundles/read-only backends are skipped).
public void Touch(ObjectId objectId)
Parameters
objectIdObjectId
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
bundleNamestringName of the bundle.
Write(Stream)
Writes the specified data using the active IOdbBackend.
public ObjectId Write(Stream stream)
Parameters
streamStreamThe 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
streamStreamThe data stream.
objectIdObjectIdThe precomputed objectId.
forceWriteboolSet 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
datanintThe data.
sizeintThe size.
forceWriteboolSet to true to force writing the datastream even if a content is already stored with the same id. Default is false.