@@ -25,24 +25,6 @@ private protected ColumnType(Type rawType)
25
25
{
26
26
Contracts . CheckValue ( rawType , nameof ( rawType ) ) ;
27
27
RawType = rawType ;
28
- RawType . TryGetDataKind ( out var rawKind ) ;
29
- RawKind = rawKind ;
30
- }
31
-
32
- /// <summary>
33
- /// Internal sub types can pass both the <paramref name="rawType"/> and <paramref name="rawKind"/> values.
34
- /// This asserts that they are consistent.
35
- /// </summary>
36
- private protected ColumnType ( Type rawType , DataKind rawKind )
37
- {
38
- Contracts . AssertValue ( rawType ) ;
39
- #if DEBUG
40
- DataKind tmp ;
41
- rawType . TryGetDataKind ( out tmp ) ;
42
- Contracts . Assert ( tmp == rawKind ) ;
43
- #endif
44
- RawType = rawType ;
45
- RawKind = rawKind ;
46
28
}
47
29
48
30
/// <summary>
@@ -54,20 +36,11 @@ private protected ColumnType(Type rawType, DataKind rawKind)
54
36
/// </summary>
55
37
public Type RawType { get ; }
56
38
57
- /// <summary>
58
- /// The <see cref="DataKind"/> corresponding to <see cref="RawType"/>, if there is one (<c>default</c> otherwise).
59
- /// It is equivalent to the result produced by <see cref="DataKindExtensions.TryGetDataKind(Type, out DataKind)"/>.
60
- /// For external code it would be preferable to operate over <see cref="RawType"/>.
61
- /// </summary>
62
- [ BestFriend ]
63
- internal DataKind RawKind { get ; }
64
-
65
39
// IEquatable<T> interface recommends also to override base class implementations of
66
40
// Object.Equals(Object) and GetHashCode. In classes below where Equals(ColumnType other)
67
41
// is effectively a referencial comparison, there is no need to override base class implementations
68
42
// of Object.Equals(Object) (and GetHashCode) since its also a referencial comparison.
69
43
public abstract bool Equals ( ColumnType other ) ;
70
-
71
44
}
72
45
73
46
/// <summary>
@@ -79,11 +52,6 @@ protected StructuredType(Type rawType)
79
52
: base ( rawType )
80
53
{
81
54
}
82
-
83
- private protected StructuredType ( Type rawType , DataKind rawKind )
84
- : base ( rawType , rawKind )
85
- {
86
- }
87
55
}
88
56
89
57
/// <summary>
@@ -99,12 +67,6 @@ protected PrimitiveType(Type rawType)
99
67
"A " + nameof ( PrimitiveType ) + " cannot have a disposable " + nameof ( RawType ) ) ;
100
68
}
101
69
102
- private protected PrimitiveType ( Type rawType , DataKind rawKind )
103
- : base ( rawType , rawKind )
104
- {
105
- Contracts . Assert ( ! typeof ( IDisposable ) . IsAssignableFrom ( RawType ) ) ;
106
- }
107
-
108
70
[ BestFriend ]
109
71
internal static PrimitiveType FromKind ( DataKind kind )
110
72
{
@@ -155,7 +117,7 @@ public static TextType Instance
155
117
}
156
118
157
119
private TextType ( )
158
- : base ( typeof ( ReadOnlyMemory < char > ) , DataKind . TX )
120
+ : base ( typeof ( ReadOnlyMemory < char > ) )
159
121
{
160
122
}
161
123
@@ -177,8 +139,8 @@ public sealed class NumberType : PrimitiveType
177
139
{
178
140
private readonly string _name ;
179
141
180
- private NumberType ( DataKind kind , string name )
181
- : base ( kind . ToType ( ) , kind )
142
+ private NumberType ( Type rawType , string name )
143
+ : base ( rawType )
182
144
{
183
145
Contracts . AssertNonEmpty ( name ) ;
184
146
_name = name ;
@@ -190,7 +152,7 @@ public static NumberType I1
190
152
get
191
153
{
192
154
if ( _instI1 == null )
193
- Interlocked . CompareExchange ( ref _instI1 , new NumberType ( DataKind . I1 , "I1" ) , null ) ;
155
+ Interlocked . CompareExchange ( ref _instI1 , new NumberType ( typeof ( sbyte ) , "I1" ) , null ) ;
194
156
return _instI1 ;
195
157
}
196
158
}
@@ -201,7 +163,7 @@ public static NumberType U1
201
163
get
202
164
{
203
165
if ( _instU1 == null )
204
- Interlocked . CompareExchange ( ref _instU1 , new NumberType ( DataKind . U1 , "U1" ) , null ) ;
166
+ Interlocked . CompareExchange ( ref _instU1 , new NumberType ( typeof ( byte ) , "U1" ) , null ) ;
205
167
return _instU1 ;
206
168
}
207
169
}
@@ -212,7 +174,7 @@ public static NumberType I2
212
174
get
213
175
{
214
176
if ( _instI2 == null )
215
- Interlocked . CompareExchange ( ref _instI2 , new NumberType ( DataKind . I2 , "I2" ) , null ) ;
177
+ Interlocked . CompareExchange ( ref _instI2 , new NumberType ( typeof ( short ) , "I2" ) , null ) ;
216
178
return _instI2 ;
217
179
}
218
180
}
@@ -223,7 +185,7 @@ public static NumberType U2
223
185
get
224
186
{
225
187
if ( _instU2 == null )
226
- Interlocked . CompareExchange ( ref _instU2 , new NumberType ( DataKind . U2 , "U2" ) , null ) ;
188
+ Interlocked . CompareExchange ( ref _instU2 , new NumberType ( typeof ( ushort ) , "U2" ) , null ) ;
227
189
return _instU2 ;
228
190
}
229
191
}
@@ -234,7 +196,7 @@ public static NumberType I4
234
196
get
235
197
{
236
198
if ( _instI4 == null )
237
- Interlocked . CompareExchange ( ref _instI4 , new NumberType ( DataKind . I4 , "I4" ) , null ) ;
199
+ Interlocked . CompareExchange ( ref _instI4 , new NumberType ( typeof ( int ) , "I4" ) , null ) ;
238
200
return _instI4 ;
239
201
}
240
202
}
@@ -245,7 +207,7 @@ public static NumberType U4
245
207
get
246
208
{
247
209
if ( _instU4 == null )
248
- Interlocked . CompareExchange ( ref _instU4 , new NumberType ( DataKind . U4 , "U4" ) , null ) ;
210
+ Interlocked . CompareExchange ( ref _instU4 , new NumberType ( typeof ( uint ) , "U4" ) , null ) ;
249
211
return _instU4 ;
250
212
}
251
213
}
@@ -256,7 +218,7 @@ public static NumberType I8
256
218
get
257
219
{
258
220
if ( _instI8 == null )
259
- Interlocked . CompareExchange ( ref _instI8 , new NumberType ( DataKind . I8 , "I8" ) , null ) ;
221
+ Interlocked . CompareExchange ( ref _instI8 , new NumberType ( typeof ( long ) , "I8" ) , null ) ;
260
222
return _instI8 ;
261
223
}
262
224
}
@@ -267,7 +229,7 @@ public static NumberType U8
267
229
get
268
230
{
269
231
if ( _instU8 == null )
270
- Interlocked . CompareExchange ( ref _instU8 , new NumberType ( DataKind . U8 , "U8" ) , null ) ;
232
+ Interlocked . CompareExchange ( ref _instU8 , new NumberType ( typeof ( ulong ) , "U8" ) , null ) ;
271
233
return _instU8 ;
272
234
}
273
235
}
@@ -278,7 +240,7 @@ public static NumberType UG
278
240
get
279
241
{
280
242
if ( _instUG == null )
281
- Interlocked . CompareExchange ( ref _instUG , new NumberType ( DataKind . UG , "UG" ) , null ) ;
243
+ Interlocked . CompareExchange ( ref _instUG , new NumberType ( typeof ( RowId ) , "UG" ) , null ) ;
282
244
return _instUG ;
283
245
}
284
246
}
@@ -289,7 +251,7 @@ public static NumberType R4
289
251
get
290
252
{
291
253
if ( _instR4 == null )
292
- Interlocked . CompareExchange ( ref _instR4 , new NumberType ( DataKind . R4 , "R4" ) , null ) ;
254
+ Interlocked . CompareExchange ( ref _instR4 , new NumberType ( typeof ( float ) , "R4" ) , null ) ;
293
255
return _instR4 ;
294
256
}
295
257
}
@@ -300,7 +262,7 @@ public static NumberType R8
300
262
get
301
263
{
302
264
if ( _instR8 == null )
303
- Interlocked . CompareExchange ( ref _instR8 , new NumberType ( DataKind . R8 , "R8" ) , null ) ;
265
+ Interlocked . CompareExchange ( ref _instR8 , new NumberType ( typeof ( double ) , "R8" ) , null ) ;
304
266
return _instR8 ;
305
267
}
306
268
}
@@ -379,7 +341,7 @@ public static BoolType Instance
379
341
}
380
342
381
343
private BoolType ( )
382
- : base ( typeof ( bool ) , DataKind . BL )
344
+ : base ( typeof ( bool ) )
383
345
{
384
346
}
385
347
@@ -411,7 +373,7 @@ public static DateTimeType Instance
411
373
}
412
374
413
375
private DateTimeType ( )
414
- : base ( typeof ( DateTime ) , DataKind . DT )
376
+ : base ( typeof ( DateTime ) )
415
377
{
416
378
}
417
379
@@ -440,7 +402,7 @@ public static DateTimeOffsetType Instance
440
402
}
441
403
442
404
private DateTimeOffsetType ( )
443
- : base ( typeof ( DateTimeOffset ) , DataKind . DZ )
405
+ : base ( typeof ( DateTimeOffset ) )
444
406
{
445
407
}
446
408
@@ -472,7 +434,7 @@ public static TimeSpanType Instance
472
434
}
473
435
474
436
private TimeSpanType ( )
475
- : base ( typeof ( TimeSpan ) , DataKind . TS )
437
+ : base ( typeof ( TimeSpan ) )
476
438
{
477
439
}
478
440
@@ -506,7 +468,7 @@ public override bool Equals(ColumnType other)
506
468
public sealed class KeyType : PrimitiveType
507
469
{
508
470
private KeyType ( Type type , DataKind kind , ulong min , int count , bool contiguous )
509
- : base ( type , kind )
471
+ : base ( type )
510
472
{
511
473
Contracts . AssertValue ( type ) ;
512
474
Contracts . Assert ( kind . ToType ( ) == type ) ;
@@ -623,17 +585,18 @@ public override bool Equals(object other)
623
585
624
586
public override int GetHashCode ( )
625
587
{
626
- return Hashing . CombinedHash ( RawKind . GetHashCode ( ) , Contiguous , Min , Count ) ;
588
+ return Hashing . CombinedHash ( RawType . GetHashCode ( ) , Contiguous , Min , Count ) ;
627
589
}
628
590
629
591
public override string ToString ( )
630
592
{
593
+ DataKind rawKind = this . GetRawKind ( ) ;
631
594
if ( Count > 0 )
632
- return string . Format ( "Key<{0}, {1}-{2}>" , RawKind . GetString ( ) , Min , Min + ( ulong ) Count - 1 ) ;
595
+ return string . Format ( "Key<{0}, {1}-{2}>" , rawKind . GetString ( ) , Min , Min + ( ulong ) Count - 1 ) ;
633
596
if ( Contiguous )
634
- return string . Format ( "Key<{0}, {1}-*>" , RawKind . GetString ( ) , Min ) ;
597
+ return string . Format ( "Key<{0}, {1}-*>" , rawKind . GetString ( ) , Min ) ;
635
598
// This is the non-contiguous case - simply show the Min.
636
- return string . Format ( "Key<{0}, Min:{1}>" , RawKind . GetString ( ) , Min ) ;
599
+ return string . Format ( "Key<{0}, Min:{1}>" , rawKind . GetString ( ) , Min ) ;
637
600
}
638
601
}
639
602
@@ -642,7 +605,7 @@ public override string ToString()
642
605
/// </summary>
643
606
public sealed class VectorType : StructuredType
644
607
{
645
- /// <summary>b
608
+ /// <summary>
646
609
/// The dimensions. This will always have at least one item. All values will be non-negative.
647
610
/// As with <see cref="Size"/>, a zero value indicates that the vector type is considered to have
648
611
/// unknown length along that dimension.
@@ -655,7 +618,7 @@ public sealed class VectorType : StructuredType
655
618
/// <param name="itemType">The type of the items contained in the vector.</param>
656
619
/// <param name="size">The size of the single dimension.</param>
657
620
public VectorType ( PrimitiveType itemType , int size = 0 )
658
- : base ( GetRawType ( itemType ) , 0 )
621
+ : base ( GetRawType ( itemType ) )
659
622
{
660
623
Contracts . CheckParam ( size >= 0 , nameof ( size ) ) ;
661
624
@@ -672,7 +635,7 @@ public VectorType(PrimitiveType itemType, int size = 0)
672
635
/// non-negative values. Also, because <see cref="Size"/> is the product of <see cref="Dimensions"/>, the result of
673
636
/// multiplying all these values together must not overflow <see cref="int"/>.</param>
674
637
public VectorType ( PrimitiveType itemType , params int [ ] dimensions )
675
- : base ( GetRawType ( itemType ) , default )
638
+ : base ( GetRawType ( itemType ) )
676
639
{
677
640
Contracts . CheckParam ( Utils . Size ( dimensions ) > 0 , nameof ( dimensions ) ) ;
678
641
Contracts . CheckParam ( dimensions . All ( d => d >= 0 ) , nameof ( dimensions ) ) ;
@@ -687,7 +650,7 @@ public VectorType(PrimitiveType itemType, params int[] dimensions)
687
650
/// </summary>
688
651
[ BestFriend ]
689
652
internal VectorType ( PrimitiveType itemType , VectorType template )
690
- : base ( GetRawType ( itemType ) , default )
653
+ : base ( GetRawType ( itemType ) )
691
654
{
692
655
Contracts . CheckValue ( template , nameof ( template ) ) ;
693
656
@@ -702,7 +665,7 @@ internal VectorType(PrimitiveType itemType, VectorType template)
702
665
/// </summary>
703
666
[ BestFriend ]
704
667
internal VectorType ( PrimitiveType itemType , VectorType template , params int [ ] dims )
705
- : base ( GetRawType ( itemType ) , default )
668
+ : base ( GetRawType ( itemType ) )
706
669
{
707
670
Contracts . CheckValue ( template , nameof ( template ) ) ;
708
671
Contracts . CheckParam ( Utils . Size ( dims ) > 0 , nameof ( dims ) ) ;
0 commit comments