Class BundleOdbBackend
Object Database Backend (ODB) implementation that bundles multiple chunks into a .bundle files, optionally compressed with LZ4.
[DataSerializerGlobal(null, typeof(List<string>), DataSerializerGenericMode.None, false, false)]
[DataSerializerGlobal(null, typeof(List<ObjectId>), DataSerializerGenericMode.None, false, false)]
[DataSerializerGlobal(null, typeof(List<KeyValuePair<ObjectId, BundleOdbBackend.ObjectInfo>>), DataSerializerGenericMode.None, false, false)]
[DataSerializerGlobal(null, typeof(List<KeyValuePair<string, ObjectId>>), DataSerializerGenericMode.None, false, false)]
public class BundleOdbBackend : IOdbBackend, IDisposable
- Inheritance
-
BundleOdbBackend
- Implements
- Extension Methods
Constructors
BundleOdbBackend(string)
public BundleOdbBackend(string vfsRootUrl)
Parameters
vfsRootUrl
string
Fields
BundleExtension
The bundle file extension.
public const string BundleExtension = ".bundle"
Field Value
Properties
BundleDirectory
public string BundleDirectory { get; }
Property Value
BundleResolve
Bundle resolve event asynchronous handler.
public BundleOdbBackend.BundleResolveDelegate BundleResolve { get; set; }
Property Value
ContentIndexMap
Gets the asset index map.
public IContentIndexMap ContentIndexMap { get; }
Property Value
- IContentIndexMap
The asset index map.
Methods
CreateBundle(string, IOdbBackend, ObjectId[], ISet<ObjectId>, Dictionary<string, ObjectId>, IList<string>, bool)
public static void CreateBundle(string bundleUrl, IOdbBackend backend, ObjectId[] objectIds, ISet<ObjectId> disableCompressionIds, Dictionary<string, ObjectId> indexMap, IList<string> dependencies, bool useIncrementalBundle)
Parameters
bundleUrl
stringbackend
IOdbBackendobjectIds
ObjectId[]disableCompressionIds
ISet<ObjectId>indexMap
Dictionary<string, ObjectId>dependencies
IList<string>useIncrementalBundle
bool
CreateStream()
Creates a stream that will be saved to database when closed and/or disposed.
public OdbStreamWriter CreateStream()
Returns
- OdbStreamWriter
a stream writer that should be passed to SaveStream in order to be stored in the database
Delete(ObjectId)
Deletes the specified ObjectId.
public void Delete(ObjectId objectId)
Parameters
objectId
ObjectIdThe object id.
DeleteBundles(Func<string, bool>)
public void DeleteBundles(Func<string, bool> bundleFileDeletePredicate)
Parameters
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
EnumerateObjects()
Enumerates the object stored in this backend.
public IEnumerable<ObjectId> EnumerateObjects()
Returns
Exists(ObjectId)
Determines weither the object with the specified ObjectId exists.
public bool Exists(ObjectId objectId)
Parameters
Returns
GetFilePath(ObjectId)
Returns the file path corresponding to the given id (in the VFS domain), if appliable.
public string GetFilePath(ObjectId objectId)
Parameters
Returns
- string
The file path.
GetObjectInfos()
public Dictionary<ObjectId, BundleOdbBackend.ObjectInfo> GetObjectInfos()
Returns
GetSize(ObjectId)
Requests that this backend read an object's length (but not its contents).
public int GetSize(ObjectId objectId)
Parameters
Returns
- int
The object size.
LoadBundle(string, ObjectDatabaseContentIndexMap)
Loads the specified bundle.
public Task LoadBundle(string bundleName, ObjectDatabaseContentIndexMap objectDatabaseContentIndexMap)
Parameters
bundleName
stringName of the bundle.
objectDatabaseContentIndexMap
ObjectDatabaseContentIndexMapThe object database asset index map, where newly loaded assets will be merged (ignored if null).
Returns
- Task
Task that will complete when bundle is loaded.
LoadBundleFromUrl(string, ObjectDatabaseContentIndexMap, string, bool)
public Task LoadBundleFromUrl(string bundleName, ObjectDatabaseContentIndexMap objectDatabaseContentIndexMap, string bundleUrl, bool ignoreDependencies = false)
Parameters
bundleName
stringobjectDatabaseContentIndexMap
ObjectDatabaseContentIndexMapbundleUrl
stringignoreDependencies
bool
Returns
OpenStream(ObjectId, VirtualFileMode, VirtualFileAccess, VirtualFileShare)
public Stream OpenStream(ObjectId objectId, VirtualFileMode mode = VirtualFileMode.Open, VirtualFileAccess access = VirtualFileAccess.Read, VirtualFileShare share = VirtualFileShare.Read)
Parameters
objectId
ObjectIdThe ObjectId.
mode
VirtualFileModeThe mode.
access
VirtualFileAccessThe access.
share
VirtualFileShareThe process share mode.
Returns
ReadBundleDescription(Stream)
Reads the bundle description.
public static BundleDescription ReadBundleDescription(Stream stream)
Parameters
stream
StreamThe stream.
Returns
- BundleDescription
The bundle description.
Exceptions
- InvalidOperationException
Invalid bundle header or Bundle has not been properly written
ReadBundleHeader(string, out List<string>)
public static BundleDescription ReadBundleHeader(string bundleUrl, out List<string> bundleUrls)
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, ObjectDatabaseContentIndexMap)
Unload the specified bundle.
public void UnloadBundle(string bundleName, ObjectDatabaseContentIndexMap objectDatabaseContentIndexMap)
Parameters
bundleName
stringName of the bundle.
objectDatabaseContentIndexMap
ObjectDatabaseContentIndexMapThe object database asset index map, where newly loaded assets will be merged (ignored if null).
Write(ObjectId, Stream, int, bool)
Writes an object to the backing store. The backend may need to compute the object ID and return it to the caller.
public ObjectId Write(ObjectId objectId, Stream dataStream, int length, bool forceWrite)
Parameters
objectId
ObjectIdThe ObjectId if already computed, or Empty if not determined yet.
dataStream
StreamThe data stream.
length
intThe data length.
forceWrite
boolSet to true to force writing the datastream even if a content is already stored with the same id. Default is false.