|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.Diagnostics.DataContractReader.Data;
[CdacType(nameof(DataType.Bucket))]
internal sealed partial class Bucket : IData<Bucket>
{
public TargetPointer[] Keys { get; private set; }
public TargetPointer[] Values { get; private set; }
[MemberNotNull(nameof(Keys), nameof(Values))]
partial void OnInit(Target target, TargetPointer address)
{
Target.TypeInfo type = target.GetTypeInfo(DataType.Bucket);
ulong keysStart = address + (ulong)type.Fields[nameof(Keys)].Offset;
ulong valuesStart = address + (ulong)type.Fields[nameof(Values)].Offset;
uint numSlots = target.ReadGlobal<uint>(Constants.Globals.HashMapSlotsPerBucket);
Keys = new TargetPointer[numSlots];
Values = new TargetPointer[numSlots];
for (int i = 0; i < numSlots; i++)
{
Keys[i] = target.ReadPointer(keysStart + (ulong)(i * target.PointerSize));
Values[i] = target.ReadPointer(valuesStart + (ulong)(i * target.PointerSize));
}
}
}
|