Skip to content

Commit 323a40a

Browse files
committed
merge DvDateTime et. al.
1 parent 771f01d commit 323a40a

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/Microsoft.ML.Data/Data/Conversion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Microsoft.ML.Runtime.Data.Conversion
1616
{
17-
using BL = Boolean;;
17+
using BL = Boolean;
1818
using DT = DateTime;
1919
using DZ = DateTimeOffset;
2020
using R4 = Single;

src/Microsoft.ML.Data/DataLoadSave/Binary/CodecFactory.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,21 @@ public CodecFactory(IHostEnvironment env, MemoryStreamPool memPool = null)
5252
RegisterSimpleCodec(new UnsafeTypeCodec<uint>(this));
5353
RegisterSimpleCodec(new UnsafeTypeCodec<long>(this));
5454
RegisterSimpleCodec(new UnsafeTypeCodec<ulong>(this));
55-
RegisterSimpleCodec(new UnsafeTypeCodec<Single>(this));
56-
RegisterSimpleCodec(new UnsafeTypeCodec<Double>(this));
57-
RegisterSimpleCodec(new UnsafeTypeCodec<DvTimeSpan>(this));
58-
RegisterSimpleCodec(new DvTextCodec(this));
55+
RegisterSimpleCodec(new UnsafeTypeCodec<float>(this));
56+
RegisterSimpleCodec(new UnsafeTypeCodec<double>(this));
57+
RegisterSimpleCodec(new UnsafeTypeCodec<TimeSpan>(this));
58+
RegisterSimpleCodec(new TextCodec(this));
5959
RegisterSimpleCodec(new BoolCodec(this));
6060
RegisterSimpleCodec(new DateTimeCodec(this));
61-
RegisterSimpleCodec(new DateTimeZoneCodec(this));
61+
RegisterSimpleCodec(new DateTimeOffsetCodec(this));
6262
RegisterSimpleCodec(new UnsafeTypeCodec<UInt128>(this));
6363

64-
// Register the old boolean reading codec.
65-
var oldBool = new OldBoolCodec(this);
66-
RegisterOtherCodec("DvBool", oldBool.GetCodec);
64+
// Register the old type system reading codec.
65+
RegisterOtherCodec("DvBool", new OldBoolCodec(this).GetCodec);
66+
RegisterOtherCodec("DvDateTimeZone", new DateTimeOffsetCodec(this).GetCodec);
67+
RegisterOtherCodec("DvDateTime", new DateTimeCodec(this).GetCodec);
68+
RegisterOtherCodec("DvTimeSpan", new UnsafeTypeCodec<TimeSpan>(this).GetCodec);
69+
6770
RegisterOtherCodec("VBuffer", GetVBufferCodec);
6871
RegisterOtherCodec("Key", GetKeyCodec);
6972
}

src/Microsoft.ML.Data/DataLoadSave/Binary/Codecs.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public override void Read(T[] values, int index, int count)
305305
}
306306
}
307307

308-
private sealed class DvTextCodec : SimpleCodec<ReadOnlyMemory<char>>
308+
private sealed class TextCodec : SimpleCodec<ReadOnlyMemory<char>>
309309
{
310310
private const int LengthMask = unchecked((int)0x7FFFFFFF);
311311

@@ -319,7 +319,7 @@ public override string LoadName
319319
// int[entries]: The non-decreasing end-boundary character index array, with high bit set for "missing" values.
320320
// string: The UTF-8 encoded string, with the standard LEB128 byte-length preceeding it.
321321

322-
public DvTextCodec(CodecFactory factory)
322+
public TextCodec(CodecFactory factory)
323323
: base(factory, TextType.Instance)
324324
{
325325
}
@@ -339,7 +339,7 @@ private sealed class Writer : ValueWriterBase<ReadOnlyMemory<char>>
339339
private StringBuilder _builder;
340340
private List<int> _boundaries;
341341

342-
public Writer(DvTextCodec codec, Stream stream)
342+
public Writer(TextCodec codec, Stream stream)
343343
: base(codec.Factory, stream)
344344
{
345345
_builder = new StringBuilder();
@@ -379,7 +379,7 @@ private sealed class Reader : ValueReaderBase<ReadOnlyMemory<char>>
379379
private int _index;
380380
private string _text;
381381

382-
public Reader(DvTextCodec codec, Stream stream, int items)
382+
public Reader(TextCodec codec, Stream stream, int items)
383383
: base(codec.Factory, stream)
384384
{
385385
_entries = Reader.ReadInt32();
@@ -753,7 +753,6 @@ public Reader(DateTimeOffsetCodec codec, Stream stream, int items)
753753
Utils.EnsureSize(ref _ticks, _entries, false);
754754
for (int i = 0; i < _entries; i++)
755755
_ticks[i] = Reader.ReadInt64();
756-
757756
}
758757

759758
public override void MoveNext()

0 commit comments

Comments
 (0)