@@ -18,7 +18,6 @@ namespace Microsoft.Data.Analysis
18
18
/// </summary>
19
19
public partial class VBufferDataFrameColumn < T > : DataFrameColumn , IEnumerable < VBuffer < T > >
20
20
{
21
-
22
21
public static int MaxCapacity = ArrayUtility . ArrayMaxSize / Unsafe . SizeOf < VBuffer < T > > ( ) ;
23
22
24
23
private readonly List < List < VBuffer < T > > > _vBuffers = new List < List < VBuffer < T > > > ( ) ; // To store more than intMax number of vbuffers
@@ -56,9 +55,7 @@ public VBufferDataFrameColumn(string name, IEnumerable<VBuffer<T>> values) : bas
56
55
}
57
56
}
58
57
59
- private long _nullCount ;
60
-
61
- public override long NullCount => _nullCount ;
58
+ public override long NullCount => 0 ;
62
59
63
60
protected internal override void Resize ( long length )
64
61
{
@@ -94,6 +91,11 @@ private int GetBufferIndexContainingRowIndex(long rowIndex)
94
91
}
95
92
96
93
protected override object GetValue ( long rowIndex )
94
+ {
95
+ return GetTypedValue ( rowIndex ) ;
96
+ }
97
+
98
+ protected VBuffer < T > GetTypedValue ( long rowIndex )
97
99
{
98
100
int bufferIndex = GetBufferIndexContainingRowIndex ( rowIndex ) ;
99
101
return _vBuffers [ bufferIndex ] [ ( int ) ( rowIndex % MaxCapacity ) ] ;
@@ -118,30 +120,30 @@ protected override IReadOnlyList<object> GetValues(long startIndex, int length)
118
120
119
121
protected override void SetValue ( long rowIndex , object value )
120
122
{
121
- if ( value == null || value is VBuffer < T > )
123
+ if ( value == null )
122
124
{
123
- int bufferIndex = GetBufferIndexContainingRowIndex ( rowIndex ) ;
124
- int bufferOffset = ( int ) ( rowIndex % MaxCapacity ) ;
125
- var oldValue = _vBuffers [ bufferIndex ] [ bufferOffset ] ;
126
- _vBuffers [ bufferIndex ] [ bufferOffset ] = ( VBuffer < T > ) value ;
127
- if ( ! oldValue . Equals ( ( VBuffer < T > ) value ) )
128
- {
129
- if ( value == null )
130
- _nullCount ++ ;
131
- if ( oldValue . Length == 0 && _nullCount > 0 )
132
- _nullCount -- ;
133
- }
125
+ throw new NotSupportedException ( "Null values are not supported by VBufferDataFrameColumn" ) ;
126
+ }
127
+ else if ( value is VBuffer < T > vbuffer )
128
+ {
129
+ SetTypedValue ( rowIndex , vbuffer ) ;
134
130
}
135
131
else
136
132
{
137
133
throw new ArgumentException ( string . Format ( Strings . MismatchedValueType , typeof ( VBuffer < T > ) ) , nameof ( value ) ) ;
138
134
}
139
135
}
140
136
137
+ protected void SetTypedValue ( long rowIndex , VBuffer < T > value )
138
+ {
139
+ int bufferIndex = GetBufferIndexContainingRowIndex ( rowIndex ) ;
140
+ _vBuffers [ bufferIndex ] [ ( int ) ( rowIndex % MaxCapacity ) ] = value ;
141
+ }
142
+
141
143
public new VBuffer < T > this [ long rowIndex ]
142
144
{
143
- get => ( VBuffer < T > ) GetValue ( rowIndex ) ;
144
- set => SetValue ( rowIndex , value ) ;
145
+ get => GetTypedValue ( rowIndex ) ;
146
+ set => SetTypedValue ( rowIndex , value ) ;
145
147
}
146
148
147
149
/// <summary>
0 commit comments