Vixen
02b45cc4
csharp
public sealed class ObjectDatabase

Content-addressed storage: values in, ObjectIds out.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

An id is the hash of the content, which gives three things for the price of one. Deduplication: two materials with identical parameters are one chunk, without anybody comparing them. Integrity: a chunk that does not hash to its own name is corrupt, and Verify says so. Delta detection: an update knows what changed by comparing names, so a patch ships the chunks whose content differs and nothing else.

Backends are searched in order, and only the first accepts writes. That is the shape the editor wants: loose files first, then the bundles the last content build produced, so an artefact that has been rebuilt shadows the packed one without either of them knowing.

Fields and properties (2)

  • public CompressionMethod DefaultCompression

    How chunks are compressed when the caller does not say.

  • public IReadOnlyList<IOdbBackend> Backends

    The backends, most specific first.

Methods (13)

  • public ObjectDatabase(params IOdbBackend[] backends)

    Creates a database over any number of backends.

  • public bool Mount(IOdbBackend backend)

    Adds a backend that was not known when the database was created.

  • public ObjectId Write<T>(in T value, ReadOnlySpan<ObjectId> references = default(ReadOnlySpan<ObjectId>), CompressionMethod? compression = null)

    Serialises a value and stores it.

  • public ObjectId WriteRaw(ulong typeId, ReadOnlySpan<ObjectId> references, ReadOnlySpan<byte> payload, CompressionMethod? compression = null)

    Stores an already-serialised payload.

  • public T Read<T>(ObjectId id)

    Reads a value back.

  • public object ReadObject(ObjectId id)

    Reads a value back without knowing its type.

  • public bool TryReadObject(ObjectId id, out object? value)

    Reads a value back without knowing its type, if anything here can.

  • public byte[] ReadRaw(ObjectId id, out ulong typeId)

    Reads a chunk's payload without deserialising it.

  • public bool TryDescribe(ObjectId id, out ChunkInfo info)

    Reads a chunk's header without deserialising it.

  • public bool Exists(ObjectId id)

    Whether a chunk is in any backend.

  • public bool Verify(ObjectId id)

    Re-hashes a chunk and checks that it still answers to its own name.

  • public IEnumerable<ObjectId> Enumerate()

    Every chunk in every backend, without duplicates.

  • public ImmutableArray<ObjectId> Closure(params ReadOnlySpan<ObjectId> roots)

    Collects a chunk and everything it transitively references.

Used by (26)

  • ContentAddressablesRemote
  • AssetManagerVixen.Assets
  • AssetMaterialSourceTestsVixen.Engine.Renderer.Tests
  • AssetTextureSourceTestsVixen.Engine.Renderer.Tests
  • CompositorContentTestsVixen.Assets.Tests
  • ContentMountVixen.App.Hosting
  • ContentReferenceTestsVixen.Assets.Tests
  • LooseContentSourceVixen.Assets
  • ObjectDatabaseTestsVixen.Core.Serialization.Tests
  • ReferenceWorldVixen.Assets.Tests
  • RemoteWorldVixen.Assets.Tests
  • StreamedContentTestsVixen.Assets.Tests
  • WorldVixen.Assets.Tests
  • WorldRendererTestsVixen.Engine.Renderer.Tests
  • ChunksVixen.Editor.Assets.Tests
  • ContentMountTestsVixen.App.Tests
  • ImportPipelineVixen.Editor.Assets
  • ImportPipelineTestsVixen.Editor.Assets.Tests
  • LooseContentTestsVixen.Editor.Assets.Tests
  • PlannedProjectVixen.Editor.Assets.Tests
  • ProjectVixen.Cli
  • ProjectMeshSourceVixen.Editor.Assets
  • ProjectSurfaceSourceVixen.Editor.Assets
  • ProjectWorkspaceVixen.Editor.Assets
  • RemoteContentMountTestsVixen.App.Tests
  • StartupSceneTestsVixen.App.Tests