From d09040ff96ac1870e001f7c4c9cc9213ad3243ae Mon Sep 17 00:00:00 2001 From: Florian Spiess Date: Tue, 26 Oct 2021 11:55:53 +0200 Subject: [PATCH 1/3] Split MetadataStore into abstract MetadataStore and specific ObjectMetadataStore. --- .../CineastApi/Model/Data/MetadataStore.cs | 195 +++++++----------- .../Model/Data/MetadataStore.cs.meta | 2 +- .../CineastApi/Model/Data/ObjectData.cs | 14 +- .../Model/Data/ObjectMetadataStore.cs | 61 ++++++ .../Model/Data/ObjectMetadataStore.cs.meta | 11 + .../Model/Registries/ObjectRegistry.cs | 4 +- .../CineastApi/Utils/MetadataUtils.cs | 16 +- 7 files changed, 166 insertions(+), 137 deletions(-) create mode 100644 Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs create mode 100644 Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs.meta diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs index 53dca6f..100e814 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs @@ -1,116 +1,81 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Org.Vitrivr.CineastApi.Model; -using UnityEngine; - -namespace Vitrivr.UnityInterface.CineastApi.Model.Data -{ - /// - /// Access and local representation of metadata - /// - [Serializable] - public class MetadataStore - { - public MetadataStore(string id) - { - ObjectId = id; - Initialized = false; - } - - /// - /// Actual internal storage of metadata - /// - private Dictionary> _storage = - new Dictionary>(); - - public string ObjectId { get; private set; } - - public bool Initialized { get; private set; } - - public void Initialize(MediaObjectMetadataQueryResult data) - { - if (Initialized) - { - Debug.LogWarning("Attempt to init already init'ed metadata container using cache data"); - return; - } - - foreach (var meta in data.Content.Where(meta => meta.ObjectId == ObjectId)) - { - if (!DomainExists(meta.Domain)) - { - _storage.Add(meta.Domain, new Dictionary()); - } - - var domain = _storage[meta.Domain]; - domain.Add(meta.Key, meta.Value); - } - - Initialized = true; - } - - public async Task InitializeAsync() - { - if (Initialized) - { - Debug.LogWarning($"Attempted to initialize already initialized metadata for media object {ObjectId}!"); - return; - } - - var metadataResult = await CineastWrapper.MetadataApi.FindMetaByIdAsync(ObjectId); - if (!Initialized) - { - Initialize(metadataResult); - } - } - - public async Task>> GetAll() - { - if (!Initialized) - { - await InitializeAsync(); - } - - return _storage; - } - - public bool DomainExists(string domain) - { - return _storage.ContainsKey(domain); - } - - public string Get(string domain, string key) - { - return _storage[domain][key]; - } - - /// - /// Retrieves a metadata value using the DOMAIN.KEY notation - /// - /// - /// - public string Get(string str) - { - var domainAndKey = str.Split('.'); - if (domainAndKey.Length >= 1) - { - return _storage[domainAndKey[0]][domainAndKey[1]]; - } - - throw new ArgumentException("Cannot retrieve without domain"); - } - - public List<(string Key, string Value)> GetDomain(string domain) - { - var items = _storage[domain]; - return items.Keys.Select(key => (key, items[key])).ToList(); - } - - public bool Exists(string domain, string key) - { - return DomainExists(domain) && _storage[domain].ContainsKey(key); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using UnityEngine.Assertions; + +namespace Vitrivr.UnityInterface.CineastApi.Model.Data +{ + [Serializable] + public abstract class MetadataStore + { + /// + /// Actual internal storage of metadata + /// + protected Dictionary> _storage = + new Dictionary>(); + + public bool Initialized { get; protected set; } + + public abstract Task InitializeAsync(); + + public async Task>> GetAll() + { + if (!Initialized) + { + await InitializeAsync(); + } + + return _storage; + } + + public bool DomainExists(string domain) + { + Assert.IsTrue(Initialized); + return _storage.ContainsKey(domain); + } + + public string Get(string domain, string key) + { + Assert.IsTrue(Initialized); + return _storage[domain][key]; + } + + /// + /// Retrieves a metadata value using the DOMAIN.KEY notation. + /// Requires metadata to be initialized. + /// + public string Get(string str) + { + Assert.IsTrue(Initialized); + var domainAndKey = str.Split('.'); + if (domainAndKey.Length >= 1) + { + return _storage[domainAndKey[0]][domainAndKey[1]]; + } + + throw new ArgumentException("Cannot retrieve without domain"); + } + + /// + /// Retrieves all metadata of a specific domain. + /// Requires metadata to be initialized. + /// + public List<(string Key, string Value)> GetDomain(string domain) + { + Assert.IsTrue(Initialized); + var items = _storage[domain]; + return items.Keys.Select(key => (key, items[key])).ToList(); + } + + /// + /// Checks if a domain key pair exists in the metadata. + /// Requires metadata to be initialized. + /// + public bool Exists(string domain, string key) + { + Assert.IsTrue(Initialized); + return DomainExists(domain) && _storage[domain].ContainsKey(key); + } + } } \ No newline at end of file diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs.meta b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs.meta index fac1e23..5b48a7f 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs.meta +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 51316df1894e44fa94b77c857f7cd774 +guid: 9da4c87b513484d09bb3713fd9083842 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs index 0ce3c0b..f76f271 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs @@ -38,9 +38,11 @@ public class ObjectData public ObjectData(string id) { _id = id; - Metadata = new MetadataStore(_id); + ObjectMetadata = new ObjectMetadataStore(_id); } + public ObjectMetadataStore ObjectMetadata { get; private set; } + /// /// Constructs a new instance with the given wrapper content. /// @@ -48,7 +50,7 @@ public ObjectData(string id) public ObjectData(MediaObjectDescriptor descriptor) { _id = descriptor.ObjectId; - Metadata = new MetadataStore(_id); + ObjectMetadata = new ObjectMetadataStore(_id); Initialize(descriptor); } @@ -57,8 +59,6 @@ public ObjectData(MediaObjectDescriptor descriptor) /// public bool Initialized { get; private set; } - public MetadataStore Metadata { get; private set; } - /// /// ID of this object's /// @@ -91,7 +91,7 @@ private async Task InitializeAsync(bool withMetadata = true) if (withMetadata) { - await Metadata.InitializeAsync(); + await ObjectMetadata.InitializeAsync(); } } finally @@ -124,14 +124,14 @@ public void Initialize(MediaObjectDescriptor descriptor) public void InitializeMeta(MediaObjectMetadataQueryResult meta) { - if (Metadata.Initialized) + if (ObjectMetadata.Initialized) { Debug.LogWarning("Attempt to initialize already initialized object metadata for media object with id " + $"\"{Id}\". Using cached data."); return; } - Metadata.Initialize(meta); + ObjectMetadata.Initialize(meta); } /// diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs new file mode 100644 index 0000000..b42475e --- /dev/null +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Org.Vitrivr.CineastApi.Model; +using UnityEngine; + +namespace Vitrivr.UnityInterface.CineastApi.Model.Data +{ + /// + /// Access and local representation of metadata + /// + [Serializable] + public class ObjectMetadataStore : MetadataStore + { + public ObjectMetadataStore(string id) + { + ObjectId = id; + Initialized = false; + } + + public string ObjectId { get; private set; } + + public void Initialize(MediaObjectMetadataQueryResult data) + { + if (Initialized) + { + Debug.LogWarning("Attempt to init already init'ed metadata container using cache data"); + return; + } + + foreach (var meta in data.Content.Where(meta => meta.ObjectId == ObjectId)) + { + if (!DomainExists(meta.Domain)) + { + _storage.Add(meta.Domain, new Dictionary()); + } + + var domain = _storage[meta.Domain]; + domain.Add(meta.Key, meta.Value); + } + + Initialized = true; + } + + public override async Task InitializeAsync() + { + if (Initialized) + { + Debug.LogWarning($"Attempted to initialize already initialized metadata for media object {ObjectId}!"); + return; + } + + var metadataResult = await CineastWrapper.MetadataApi.FindMetaByIdAsync(ObjectId); + if (!Initialized) + { + Initialize(metadataResult); + } + } + } +} \ No newline at end of file diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs.meta b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs.meta new file mode 100644 index 0000000..fac1e23 --- /dev/null +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 51316df1894e44fa94b77c857f7cd774 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/ObjectRegistry.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/ObjectRegistry.cs index aab3bca..a9daaf9 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/ObjectRegistry.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/ObjectRegistry.cs @@ -93,14 +93,14 @@ public static async Task BatchFetchObjectDataWithMeta(List objects) public static async Task BatchFetchObjectMetadata(IEnumerable objects) { - var toInitObj = objects.Where(obj => !obj.Metadata.Initialized).ToList(); + var toInitObj = objects.Where(obj => !obj.ObjectMetadata.Initialized).ToList(); var toInit = toInitObj.Select(obj => obj.Id).ToList(); Debug.Log($"Having to initialise {toInit.Count} obj's metadata"); var result = await Task.Run(() => CineastWrapper.MetadataApi.FindMetadataForObjectIdBatchedAsync(new OptionallyFilteredIdList(ids: toInit))); foreach (var obj in toInitObj) { - obj.Metadata.Initialize(result); + obj.ObjectMetadata.Initialize(result); } Debug.Log("Finished fetching obj"); } diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Utils/MetadataUtils.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Utils/MetadataUtils.cs index 1da073d..21e77ab 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Utils/MetadataUtils.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Utils/MetadataUtils.cs @@ -39,10 +39,8 @@ public static class MetadataUtils public const string TEMPORAL_DATETIME = "datetime"; /// - /// Quick-access to latitude + /// Quick-access to latitude. /// - /// - /// /// If the store was not initialised previously public static double GetLatitude(MetadataStore store) { @@ -57,10 +55,8 @@ public static double GetLatitude(MetadataStore store) } /// - /// Quick-access to longitude + /// Quick-access to longitude. /// - /// - /// /// If the store was not initialised previously public static double GetLongitude(MetadataStore store) { @@ -75,10 +71,8 @@ public static double GetLongitude(MetadataStore store) } /// - /// Quick-access to bearing + /// Quick-access to bearing. /// - /// - /// /// If the store was not initialised previously public static double GetBearing(MetadataStore store) { @@ -91,10 +85,8 @@ public static double GetBearing(MetadataStore store) } /// - /// Quick-access to datetime + /// Quick-access to datetime. /// - /// - /// /// If the store was not initialised previously public static string GetDateTime(MetadataStore store) { From b78d67be22f6374274ce714b119a13f2822d8e9a Mon Sep 17 00:00:00 2001 From: Florian Spiess Date: Tue, 26 Oct 2021 12:31:10 +0200 Subject: [PATCH 2/3] Implemented SegmentMetadataStore and fixed bug where assertion would prevent initialization of metadata. --- .../CineastApi/Model/Data/MetadataStore.cs | 14 ++--- .../CineastApi/Model/Data/ObjectData.cs | 6 +- .../Model/Data/ObjectMetadataStore.cs | 6 +- .../CineastApi/Model/Data/SegmentData.cs | 23 ++++++- .../Model/Data/SegmentMetadataStore.cs | 61 +++++++++++++++++++ .../Model/Data/SegmentMetadataStore.cs.meta | 11 ++++ .../Model/Registries/SegmentRegistry.cs | 7 +-- 7 files changed, 108 insertions(+), 20 deletions(-) create mode 100644 Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs create mode 100644 Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs.meta diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs index 100e814..c0aa23a 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/MetadataStore.cs @@ -12,7 +12,7 @@ public abstract class MetadataStore /// /// Actual internal storage of metadata /// - protected Dictionary> _storage = + protected Dictionary> Storage = new Dictionary>(); public bool Initialized { get; protected set; } @@ -26,19 +26,19 @@ public async Task>> GetAll() await InitializeAsync(); } - return _storage; + return Storage; } public bool DomainExists(string domain) { Assert.IsTrue(Initialized); - return _storage.ContainsKey(domain); + return Storage.ContainsKey(domain); } public string Get(string domain, string key) { Assert.IsTrue(Initialized); - return _storage[domain][key]; + return Storage[domain][key]; } /// @@ -51,7 +51,7 @@ public string Get(string str) var domainAndKey = str.Split('.'); if (domainAndKey.Length >= 1) { - return _storage[domainAndKey[0]][domainAndKey[1]]; + return Storage[domainAndKey[0]][domainAndKey[1]]; } throw new ArgumentException("Cannot retrieve without domain"); @@ -64,7 +64,7 @@ public string Get(string str) public List<(string Key, string Value)> GetDomain(string domain) { Assert.IsTrue(Initialized); - var items = _storage[domain]; + var items = Storage[domain]; return items.Keys.Select(key => (key, items[key])).ToList(); } @@ -75,7 +75,7 @@ public string Get(string str) public bool Exists(string domain, string key) { Assert.IsTrue(Initialized); - return DomainExists(domain) && _storage[domain].ContainsKey(key); + return DomainExists(domain) && Storage[domain].ContainsKey(key); } } } \ No newline at end of file diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs index f76f271..e6f16a9 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs @@ -31,22 +31,20 @@ public class ObjectData /// private List _segments; + public ObjectMetadataStore ObjectMetadata { get; private set; } + /// /// Constructs a new instance with the given id, for lazy loading. /// - /// public ObjectData(string id) { _id = id; ObjectMetadata = new ObjectMetadataStore(_id); } - public ObjectMetadataStore ObjectMetadata { get; private set; } - /// /// Constructs a new instance with the given wrapper content. /// - /// public ObjectData(MediaObjectDescriptor descriptor) { _id = descriptor.ObjectId; diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs index b42475e..38721d5 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectMetadataStore.cs @@ -31,12 +31,12 @@ public void Initialize(MediaObjectMetadataQueryResult data) foreach (var meta in data.Content.Where(meta => meta.ObjectId == ObjectId)) { - if (!DomainExists(meta.Domain)) + if (!Storage.ContainsKey(meta.Domain)) { - _storage.Add(meta.Domain, new Dictionary()); + Storage.Add(meta.Domain, new Dictionary()); } - var domain = _storage[meta.Domain]; + var domain = Storage[meta.Domain]; domain.Add(meta.Key, meta.Value); } diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentData.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentData.cs index eaf0c25..65d7b57 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentData.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentData.cs @@ -27,23 +27,27 @@ public class SegmentData // TODO: Consider combining lazy loading requests into batch requests every x seconds to reduce request overhead private static readonly SemaphoreSlim InitLock = new SemaphoreSlim(1, 1); + public SegmentMetadataStore SegmentMetadata { get; private set; } + public SegmentData(string id) { _id = id; + SegmentMetadata = new SegmentMetadataStore(_id); } public SegmentData(MediaSegmentDescriptor descriptor) { _descriptor = descriptor; _id = descriptor.SegmentId; + SegmentMetadata = new SegmentMetadataStore(_id); Initialized = true; } /// /// Runs asynchronous segment ID query to initialize the data for this segment. /// - private async Task InitializeAsync() + private async Task InitializeAsync(bool withMetadata = true) { await InitLock.WaitAsync(); try @@ -63,6 +67,11 @@ private async Task InitializeAsync() var result = queryResult.Content[0]; Initialize(result); + + if (withMetadata) + { + await SegmentMetadata.InitializeAsync(); + } } finally { @@ -94,6 +103,18 @@ public void Initialize(MediaSegmentDescriptor data) Initialized = true; } + public void InitializeMeta(MediaSegmentMetadataQueryResult meta) + { + if (SegmentMetadata.Initialized) + { + Debug.LogWarning("Attempt to initialize already initialized segment metadata for media object with " + + $"id \"{Id}\". Using cached data."); + return; + } + + SegmentMetadata.Initialize(meta); + } + /// /// ID of the /// diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs new file mode 100644 index 0000000..e312222 --- /dev/null +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Org.Vitrivr.CineastApi.Model; +using UnityEngine; + +namespace Vitrivr.UnityInterface.CineastApi.Model.Data +{ + /// + /// Access and local representation of metadata for segments. + /// + [Serializable] + public class SegmentMetadataStore : MetadataStore + { + public SegmentMetadataStore(string id) + { + SegmentId = id; + Initialized = false; + } + + public string SegmentId { get; private set; } + + public void Initialize(MediaSegmentMetadataQueryResult data) + { + if (Initialized) + { + Debug.LogWarning($"Attempted to initialize already initialized metadata for media object {SegmentId}!"); + return; + } + + foreach (var meta in data.Content.Where(meta => meta.SegmentId == SegmentId)) + { + if (!Storage.ContainsKey(meta.Domain)) + { + Storage.Add(meta.Domain, new Dictionary()); + } + + var domain = Storage[meta.Domain]; + domain.Add(meta.Key, meta.Value); + } + + Initialized = true; + } + + public override async Task InitializeAsync() + { + if (Initialized) + { + Debug.LogWarning($"Attempted to initialize already initialized metadata for media object {SegmentId}!"); + return; + } + + var metadataResult = await CineastWrapper.MetadataApi.FindSegMetaByIdAsync(SegmentId); + if (!Initialized) + { + Initialize(metadataResult); + } + } + } +} \ No newline at end of file diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs.meta b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs.meta new file mode 100644 index 0000000..1add9b2 --- /dev/null +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9f4b1b2ed631f476bb6e7e9f4198037d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/SegmentRegistry.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/SegmentRegistry.cs index 87dbd4b..627e051 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/SegmentRegistry.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/SegmentRegistry.cs @@ -109,7 +109,7 @@ public static void Reset() } /// - /// Whether the given segmentId is known to this registry + /// Whether the given segmentId is known to this registry. /// /// /// @@ -119,14 +119,11 @@ public static bool Exists(string segmentId) } /// - /// Gets the corresponding object of the segment specified + /// Gets the corresponding object of the segment specified. /// - /// - /// /// public static async Task GetObjectOf(string segmentId) { - // TODO might require a dedicated cache if (!Exists(segmentId)) { throw new ArgumentException($"Cannot get object of unknown segment with id {segmentId}"); From fd3dec4deea8dcbcea814d939e1ed4f8b8d71ecd Mon Sep 17 00:00:00 2001 From: Florian Spiess Date: Tue, 26 Oct 2021 13:05:35 +0200 Subject: [PATCH 3/3] Renamed Metadata variables to be more backwards compatible. --- .../CineastApi/Model/Data/ObjectData.cs | 12 ++++++------ .../CineastApi/Model/Data/SegmentData.cs | 12 ++++++------ .../CineastApi/Model/Registries/ObjectRegistry.cs | 4 ++-- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs index e6f16a9..76b283e 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/ObjectData.cs @@ -31,7 +31,7 @@ public class ObjectData /// private List _segments; - public ObjectMetadataStore ObjectMetadata { get; private set; } + public ObjectMetadataStore Metadata { get; private set; } /// /// Constructs a new instance with the given id, for lazy loading. @@ -39,7 +39,7 @@ public class ObjectData public ObjectData(string id) { _id = id; - ObjectMetadata = new ObjectMetadataStore(_id); + Metadata = new ObjectMetadataStore(_id); } /// @@ -48,7 +48,7 @@ public ObjectData(string id) public ObjectData(MediaObjectDescriptor descriptor) { _id = descriptor.ObjectId; - ObjectMetadata = new ObjectMetadataStore(_id); + Metadata = new ObjectMetadataStore(_id); Initialize(descriptor); } @@ -89,7 +89,7 @@ private async Task InitializeAsync(bool withMetadata = true) if (withMetadata) { - await ObjectMetadata.InitializeAsync(); + await Metadata.InitializeAsync(); } } finally @@ -122,14 +122,14 @@ public void Initialize(MediaObjectDescriptor descriptor) public void InitializeMeta(MediaObjectMetadataQueryResult meta) { - if (ObjectMetadata.Initialized) + if (Metadata.Initialized) { Debug.LogWarning("Attempt to initialize already initialized object metadata for media object with id " + $"\"{Id}\". Using cached data."); return; } - ObjectMetadata.Initialize(meta); + Metadata.Initialize(meta); } /// diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentData.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentData.cs index 65d7b57..deb4f3e 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentData.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentData.cs @@ -27,20 +27,20 @@ public class SegmentData // TODO: Consider combining lazy loading requests into batch requests every x seconds to reduce request overhead private static readonly SemaphoreSlim InitLock = new SemaphoreSlim(1, 1); - public SegmentMetadataStore SegmentMetadata { get; private set; } + public SegmentMetadataStore Metadata { get; private set; } public SegmentData(string id) { _id = id; - SegmentMetadata = new SegmentMetadataStore(_id); + Metadata = new SegmentMetadataStore(_id); } public SegmentData(MediaSegmentDescriptor descriptor) { _descriptor = descriptor; _id = descriptor.SegmentId; - SegmentMetadata = new SegmentMetadataStore(_id); + Metadata = new SegmentMetadataStore(_id); Initialized = true; } @@ -70,7 +70,7 @@ private async Task InitializeAsync(bool withMetadata = true) if (withMetadata) { - await SegmentMetadata.InitializeAsync(); + await Metadata.InitializeAsync(); } } finally @@ -105,14 +105,14 @@ public void Initialize(MediaSegmentDescriptor data) public void InitializeMeta(MediaSegmentMetadataQueryResult meta) { - if (SegmentMetadata.Initialized) + if (Metadata.Initialized) { Debug.LogWarning("Attempt to initialize already initialized segment metadata for media object with " + $"id \"{Id}\". Using cached data."); return; } - SegmentMetadata.Initialize(meta); + Metadata.Initialize(meta); } /// diff --git a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/ObjectRegistry.cs b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/ObjectRegistry.cs index a9daaf9..aab3bca 100644 --- a/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/ObjectRegistry.cs +++ b/Runtime/Vitrivr/UnityInterface/CineastApi/Model/Registries/ObjectRegistry.cs @@ -93,14 +93,14 @@ public static async Task BatchFetchObjectDataWithMeta(List objects) public static async Task BatchFetchObjectMetadata(IEnumerable objects) { - var toInitObj = objects.Where(obj => !obj.ObjectMetadata.Initialized).ToList(); + var toInitObj = objects.Where(obj => !obj.Metadata.Initialized).ToList(); var toInit = toInitObj.Select(obj => obj.Id).ToList(); Debug.Log($"Having to initialise {toInit.Count} obj's metadata"); var result = await Task.Run(() => CineastWrapper.MetadataApi.FindMetadataForObjectIdBatchedAsync(new OptionallyFilteredIdList(ids: toInit))); foreach (var obj in toInitObj) { - obj.ObjectMetadata.Initialize(result); + obj.Metadata.Initialize(result); } Debug.Log("Finished fetching obj"); } diff --git a/package.json b/package.json index 15f407f..ba1ffbf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "org.vitrivr.unityinterface.cineastapi", - "version": "1.0.0-SNAPSHOT", + "version": "0.0.1", "displayName": "Cineast Unity Interface", "description": "An all-unity client for [Cineast](https://github.com/vitrivr/cineast/).", "unity": "2019.4",