diff --git a/src/microsoft-update-partition/Metadata/UpdateBase.cs b/src/microsoft-update-partition/Metadata/UpdateBase.cs index 23af3ae6..5fad9b32 100644 --- a/src/microsoft-update-partition/Metadata/UpdateBase.cs +++ b/src/microsoft-update-partition/Metadata/UpdateBase.cs @@ -164,18 +164,29 @@ public string Description { get { - if (_MetadataLoaded) + if (_DescriptionLoaded) { return _Description; } - else - { - LoadNonIndexedMetadataBase(); - return _Description; - } - } + else if (_FastLookupSource != null) + { + _FastLookupSource.TrySimpleKeyLookup(_Id, Storage.Index.AvailableIndexes.DescriptionsIndexName, out string description); + return description; + } + else if (_MetadataSource != null) + { + LoadNonIndexedMetadataBase(); + _DescriptionLoaded = true; + return _Description; + } + else + { + return null; + } + } } - private string _Description = null; + private bool _DescriptionLoaded; + private string _Description = null; /// /// Gets the list of files (content) for update @@ -464,6 +475,7 @@ internal MicrosoftUpdatePackage(MicrosoftUpdatePackageIdentity id, XPathNavigato _TitleLoaded = true; _Description = UpdateParser.GetDescription(metadataNavigator, namespaceManager); + _DescriptionLoaded = true; _MetadataLoaded = true; _Prerequisites = PrerequisiteParser.FromXml(metadataNavigator, namespaceManager); diff --git a/src/microsoft-update-partition/PackageGraph/Partitions/PartitionRegistration.cs b/src/microsoft-update-partition/PackageGraph/Partitions/PartitionRegistration.cs index 0c4834f8..114fd51f 100644 --- a/src/microsoft-update-partition/PackageGraph/Partitions/PartitionRegistration.cs +++ b/src/microsoft-update-partition/PackageGraph/Partitions/PartitionRegistration.cs @@ -20,7 +20,7 @@ class PartitionRegistration { Factory = null, HasExternalContentFileMetadata = false, - Indexes = new List() { TitlesIndex.TitlesIndexDefinition }, + Indexes = new List() { TitlesIndex.TitlesIndexDefinition, DescriptionsIndex.DescriptionsIndexDefinition }, HandlesIdentities = false, } }, diff --git a/src/microsoft-update-partition/PackageGraph/Storage/Index/DescriptionsIndex.cs b/src/microsoft-update-partition/PackageGraph/Storage/Index/DescriptionsIndex.cs new file mode 100644 index 00000000..d1bd5e15 --- /dev/null +++ b/src/microsoft-update-partition/PackageGraph/Storage/Index/DescriptionsIndex.cs @@ -0,0 +1,33 @@ +using Microsoft.PackageGraph.ObjectModel; + +namespace Microsoft.PackageGraph.Storage.Index +{ + class DescriptionsIndex : SimpleIndex, ISimpleMetadataIndex + { + internal static readonly IndexDefinition DescriptionsIndexDefinition = + new() + { + Name = AvailableIndexes.DescriptionsIndexName, + PartitionName = null, + Version = DescriptionsIndex.CurrentVersion, + Factory = new InternalIndexFactory(), + Tag = "stream" + }; + + public override IndexDefinition Definition => DescriptionsIndexDefinition; + + public DescriptionsIndex(IIndexContainer container) : base(container, AvailableIndexes.TitlesIndexName) + { + } + + public override void IndexPackage(IPackage package, int packageIndex) + { + Add(packageIndex, package.Description); + } + + public new bool TryGet(int packageIndex, out string description) + { + return base.TryGet(packageIndex, out description); + } + } +} diff --git a/src/microsoft-update-partition/PackageGraph/Storage/Index/IndexTypes.cs b/src/microsoft-update-partition/PackageGraph/Storage/Index/IndexTypes.cs index e63ca78e..96fcbf45 100644 --- a/src/microsoft-update-partition/PackageGraph/Storage/Index/IndexTypes.cs +++ b/src/microsoft-update-partition/PackageGraph/Storage/Index/IndexTypes.cs @@ -8,6 +8,7 @@ namespace Microsoft.PackageGraph.Storage.Index abstract class AvailableIndexes { public const string TitlesIndexName = "titles"; + public const string DescriptionsIndexName = "descriptions"; } class InternalIndexFactory : IIndexFactory @@ -17,6 +18,7 @@ public IIndex CreateIndex(IndexDefinition definition, IIndexContainer container) return definition.Name switch { AvailableIndexes.TitlesIndexName => new TitlesIndex(container), + AvailableIndexes.DescriptionsIndexName => new DescriptionsIndex(container), _ => throw new NotImplementedException(), }; }