Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote 16.1.0-beta3 to stable release #477

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 13 additions & 61 deletions csharp/DateTimeNanos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,14 @@ namespace ParquetSharp
[StructLayout(LayoutKind.Sequential)]
public readonly struct DateTimeNanos : IEquatable<DateTimeNanos>, IComparable, IComparable<DateTimeNanos>
{
/// <summary>
/// Minimum DateTime representable: 1677-09-21 00:12:43.
/// </summary>
public static readonly DateTime MinDateTimeValue = new DateTimeNanos(long.MinValue).DateTime;

/// <summary>
/// Maximum DateTime representable: 2262-04-11 23:47:16.
/// </summary>
public static readonly DateTime MaxDateTimeValue = new DateTimeNanos(long.MaxValue).DateTime;

public DateTimeNanos(long ticks)
{
Ticks = ticks;
}

public DateTimeNanos(DateTime dateTime)
{
Ticks = DotnetTicksToNanosSinceEpoch(dateTime.Ticks);
}

/// <summary>
/// Make a new <see cref="DateTimeNanos"/> object from a specified dotnet ticks value
/// </summary>
public static DateTimeNanos FromDotnetTicks(long dotnetTicks)
{
return new DateTimeNanos(DotnetTicksToNanosSinceEpoch(dotnetTicks));
Ticks = (dateTime.Ticks - DateTimeOffset) * (1_000_000L / TimeSpan.TicksPerMillisecond);
}

/// <summary>
Expand All @@ -46,7 +28,7 @@ public static DateTimeNanos FromDotnetTicks(long dotnetTicks)
/// <summary>
/// Convert to System.DateTime with reduced precision.
/// </summary>
public DateTime DateTime => new(NanosSinceEpochToDotnetTicks(Ticks));
public DateTime DateTime => new DateTime(DateTimeOffset + Ticks / (1_000_000L / TimeSpan.TicksPerMillisecond));

public bool Equals(DateTimeNanos other)
{
Expand Down Expand Up @@ -78,36 +60,6 @@ public int CompareTo(DateTimeNanos other)
return Ticks.CompareTo(other.Ticks);
}

public static bool operator ==(DateTimeNanos left, DateTimeNanos right)
{
return left.Ticks == right.Ticks;
}

public static bool operator !=(DateTimeNanos left, DateTimeNanos right)
{
return left.Ticks != right.Ticks;
}

public static bool operator <(DateTimeNanos left, DateTimeNanos right)
{
return left.Ticks < right.Ticks;
}

public static bool operator <=(DateTimeNanos left, DateTimeNanos right)
{
return left.Ticks <= right.Ticks;
}

public static bool operator >=(DateTimeNanos left, DateTimeNanos right)
{
return left.Ticks >= right.Ticks;
}

public static bool operator >(DateTimeNanos left, DateTimeNanos right)
{
return left.Ticks > right.Ticks;
}

/// <summary>
/// Converts this DateTimeNanos object to a string using a default formatting string with nanosecond precision
/// and the current culture's formatting conventions.
Expand Down Expand Up @@ -137,18 +89,18 @@ public string ToString(string? format, IFormatProvider? formatProvider = null)
return DateTime.ToString(adjustedFormat, formatProvider);
}

private const long DateTimeOffsetTicks = 621355968000000000; // new DateTime(1970, 01, 01).Ticks
private const string DefaultFormat = "yyyy-MM-dd HH:mm:ss.fffffffff";
private const long NanosPerTick = 1_000_000L / TimeSpan.TicksPerMillisecond;
/// <summary>
/// Minimum DateTime representable: 1677-09-21 00:12:43.
/// </summary>
public static readonly DateTime MinDateTimeValue = new DateTimeNanos(long.MinValue).DateTime;

private static long DotnetTicksToNanosSinceEpoch(long dotnetTicks)
{
return (dotnetTicks - DateTimeOffsetTicks) * NanosPerTick;
}
/// <summary>
/// Maximum DateTime representable: 2262-04-11 23:47:16.
/// </summary>
public static readonly DateTime MaxDateTimeValue = new DateTimeNanos(long.MaxValue).DateTime;

private static long NanosSinceEpochToDotnetTicks(long nanosSinceEpoch)
{
return DateTimeOffsetTicks + nanosSinceEpoch / NanosPerTick;
}
private const long DateTimeOffset = 621355968000000000; // new DateTime(1970, 01, 01).Ticks

private const string DefaultFormat = "yyyy-MM-dd HH:mm:ss.fffffffff";
}
}
2 changes: 1 addition & 1 deletion csharp/ParquetSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>1591;</NoWarn>
<VersionPrefix>16.1.0-beta3</VersionPrefix>
<VersionPrefix>16.1.0</VersionPrefix>
<Company>G-Research</Company>
<Authors>G-Research</Authors>
<Product>ParquetSharp</Product>
Expand Down
7 changes: 0 additions & 7 deletions csharp/PublicAPI/net471/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,6 @@ static ParquetSharp.Arrow.ArrowReaderProperties.GetDefault() -> ParquetSharp.Arr
static ParquetSharp.Arrow.ArrowWriterProperties.GetDefault() -> ParquetSharp.Arrow.ArrowWriterProperties!
static ParquetSharp.Column.CreateSchemaNode(ParquetSharp.Column![]! columns, ParquetSharp.LogicalTypeFactory! logicalTypeFactory, string! nodeName = "schema") -> ParquetSharp.Schema.GroupNode!
static ParquetSharp.Column.CreateSchemaNode(ParquetSharp.Column![]! columns, string! nodeName = "schema") -> ParquetSharp.Schema.GroupNode!
static ParquetSharp.DateTimeNanos.FromDotnetTicks(long dotnetTicks) -> ParquetSharp.DateTimeNanos
static ParquetSharp.DateTimeNanos.operator !=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator <(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator <=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator ==(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator >(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator >=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DefaultWriterProperties.Compression.get -> ParquetSharp.Compression?
static ParquetSharp.DefaultWriterProperties.Compression.set -> void
static ParquetSharp.DefaultWriterProperties.CompressionLevel.get -> int?
Expand Down
7 changes: 0 additions & 7 deletions csharp/PublicAPI/net6/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -835,13 +835,6 @@ static ParquetSharp.Arrow.ArrowReaderProperties.GetDefault() -> ParquetSharp.Arr
static ParquetSharp.Arrow.ArrowWriterProperties.GetDefault() -> ParquetSharp.Arrow.ArrowWriterProperties!
static ParquetSharp.Column.CreateSchemaNode(ParquetSharp.Column![]! columns, ParquetSharp.LogicalTypeFactory! logicalTypeFactory, string! nodeName = "schema") -> ParquetSharp.Schema.GroupNode!
static ParquetSharp.Column.CreateSchemaNode(ParquetSharp.Column![]! columns, string! nodeName = "schema") -> ParquetSharp.Schema.GroupNode!
static ParquetSharp.DateTimeNanos.FromDotnetTicks(long dotnetTicks) -> ParquetSharp.DateTimeNanos
static ParquetSharp.DateTimeNanos.operator !=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator <(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator <=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator ==(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator >(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator >=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DefaultWriterProperties.Compression.get -> ParquetSharp.Compression?
static ParquetSharp.DefaultWriterProperties.Compression.set -> void
static ParquetSharp.DefaultWriterProperties.CompressionLevel.get -> int?
Expand Down
7 changes: 0 additions & 7 deletions csharp/PublicAPI/netstandard2.1/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,6 @@ static ParquetSharp.Arrow.ArrowReaderProperties.GetDefault() -> ParquetSharp.Arr
static ParquetSharp.Arrow.ArrowWriterProperties.GetDefault() -> ParquetSharp.Arrow.ArrowWriterProperties!
static ParquetSharp.Column.CreateSchemaNode(ParquetSharp.Column![]! columns, ParquetSharp.LogicalTypeFactory! logicalTypeFactory, string! nodeName = "schema") -> ParquetSharp.Schema.GroupNode!
static ParquetSharp.Column.CreateSchemaNode(ParquetSharp.Column![]! columns, string! nodeName = "schema") -> ParquetSharp.Schema.GroupNode!
static ParquetSharp.DateTimeNanos.FromDotnetTicks(long dotnetTicks) -> ParquetSharp.DateTimeNanos
static ParquetSharp.DateTimeNanos.operator !=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator <(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator <=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator ==(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator >(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DateTimeNanos.operator >=(ParquetSharp.DateTimeNanos left, ParquetSharp.DateTimeNanos right) -> bool
static ParquetSharp.DefaultWriterProperties.Compression.get -> ParquetSharp.Compression?
static ParquetSharp.DefaultWriterProperties.Compression.set -> void
static ParquetSharp.DefaultWriterProperties.CompressionLevel.get -> int?
Expand Down
Loading