Skip to content

Commit 621902f

Browse files
author
Jack Dermody
committed
data store fixes
1 parent df5779b commit 621902f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

BrightData/Buffer/ByteDataProviders/ByteDataBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace BrightData.Buffer.ByteDataProviders;
99
/// <summary>
1010
/// A block of byte data
1111
/// </summary>
12-
public ref struct ByteDataBlock(ReadOnlySpan<byte> data, IDisposable? disposable) : IHaveByteData
12+
public ref struct ByteDataBlock(ReadOnlySpan<byte> data, IDisposable? disposable)
1313
{
1414
readonly ReadOnlySpan<byte> _data = data;
1515

BrightData/Helper/DataStore.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using BrightData.Buffer;
2+
using BrightData.Buffer.ByteDataProviders;
23
using BrightData.Types;
3-
using System;
44
using CommunityToolkit.HighPerformance;
5+
using System;
56

67
namespace BrightData.Helper
78
{
@@ -37,7 +38,8 @@ interface IResolveData<out T>
3738
public DataStore(OffsetAndSize dataTypes, IByteDataProvider dataProvider)
3839
{
3940
_dataProvider = dataProvider;
40-
_dataTypes = dataProvider.GetDataSpan(dataTypes).Cast<byte, DataType>().ToArray();
41+
using var dataTypesBlock = dataProvider.GetDataSpan(dataTypes);
42+
_dataTypes = dataTypesBlock.ByteData.Cast<byte, DataType>().ToArray();
4143

4244
// create the data types
4345
var index = 0;
@@ -54,9 +56,9 @@ public T Get<T>(uint index)
5456
return default;
5557
}
5658

57-
ReadOnlySpan<byte> GetData(uint index)
59+
ByteDataBlock GetData(uint index)
5860
{
59-
var (type, offset, size) = _dataTypes.Span[(int)index];
61+
var (_, offset, size) = _dataTypes.Span[(int)index];
6062
return _dataProvider.GetDataSpan(offset, size);
6163
}
6264
}

0 commit comments

Comments
 (0)