From 3cad50cd70630b0b29f7f87541a29d8cdf6f80bf Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Tue, 9 Aug 2022 16:49:14 -0500 Subject: [PATCH 1/9] add DateTime type --- .../DateTimeDataFrameColumn.cs | 23 ++++++++ .../IDataView.Extension.cs | 4 ++ ...imitiveDataFrameColumn.BinaryOperations.cs | 10 ++++ .../PrimitiveDataFrameColumn.cs | 15 +++-- .../ArrowIntegrationTests.cs | 23 ++++++++ .../DataFrameColumn.BinaryOperationTests.cs | 1 + .../DataFrameIDataViewTests.cs | 59 +++++++++++-------- .../DataFrameTests.cs | 34 +++++++---- 8 files changed, 128 insertions(+), 41 deletions(-) create mode 100644 src/Microsoft.Data.Analysis/DateTimeDataFrameColumn.cs diff --git a/src/Microsoft.Data.Analysis/DateTimeDataFrameColumn.cs b/src/Microsoft.Data.Analysis/DateTimeDataFrameColumn.cs new file mode 100644 index 0000000000..2bb875f66c --- /dev/null +++ b/src/Microsoft.Data.Analysis/DateTimeDataFrameColumn.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Data.Analysis +{ + public partial class DateTimeDataFrameColumn : PrimitiveDataFrameColumn + { + public DateTimeDataFrameColumn(string name, IEnumerable values) : base(name, values) { } + + public DateTimeDataFrameColumn(string name, IEnumerable values) : base(name, values) { } + + public DateTimeDataFrameColumn(string name, long length = 0) : base(name, length) { } + + public DateTimeDataFrameColumn(string name, ReadOnlyMemory buffer, ReadOnlyMemory nullBitMap, int length = 0, int nullCount = 0) : base(name, buffer, nullBitMap, length, nullCount) { } + + internal DateTimeDataFrameColumn(string name, PrimitiveColumnContainer values) : base(name, values) { } + } +} diff --git a/src/Microsoft.Data.Analysis/IDataView.Extension.cs b/src/Microsoft.Data.Analysis/IDataView.Extension.cs index 32b97d365a..aae5c38e63 100644 --- a/src/Microsoft.Data.Analysis/IDataView.Extension.cs +++ b/src/Microsoft.Data.Analysis/IDataView.Extension.cs @@ -68,6 +68,10 @@ public static DataFrame ToDataFrame(this IDataView dataView, long maxRows, param { dataFrameColumns.Add(new BooleanDataFrameColumn(dataViewColumn.Name)); } + else if (type == DateTimeDataViewType.Instance) + { + dataFrameColumns.Add(new DateTimeDataFrameColumn(dataViewColumn.Name)); + } else if (type == NumberDataViewType.Byte) { dataFrameColumns.Add(new ByteDataFrameColumn(dataViewColumn.Name)); diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.cs index 6a77e49ad4..f7235bf7f8 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.cs @@ -380,6 +380,8 @@ public override PrimitiveDataFrameColumn ElementwiseEquals(DataFrameColumn return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn charColumn: return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); + case PrimitiveDataFrameColumn dateTimeColumn: + return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn decimalColumn: return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn doubleColumn: @@ -1743,6 +1745,14 @@ internal PrimitiveDataFrameColumn ElementwiseEqualsImplementation(Primi PrimitiveDataFrameColumn retColumn = CloneAsBooleanColumn(); (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(column._columnContainer, retColumn._columnContainer); return retColumn; + case Type dateTimeType when dateTimeType == typeof(DateTime): + if (typeof(U) != typeof(DateTime)) + { + throw new NotSupportedException(); + } + PrimitiveDataFrameColumn newcolumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(column._columnContainer, newcolumn._columnContainer); + return newcolumn; case Type decimalType when decimalType == typeof(decimal): if (typeof(U) == typeof(bool)) { diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs index 730b8ddfd6..921a79027a 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs @@ -282,7 +282,7 @@ public override long NullCount public override bool IsNumericColumn() { bool ret = true; - if (typeof(T) == typeof(char) || typeof(T) == typeof(bool)) + if (typeof(T) == typeof(char) || typeof(T) == typeof(bool) || typeof(T) == typeof(DateTime)) ret = false; return ret; } @@ -325,7 +325,10 @@ public override DataFrame ValueCounts() } /// - public override bool HasDescription() => IsNumericColumn(); + public override bool HasDescription() + { + return this.IsNumericColumn() || typeof(T) == typeof(DateTime); + } /// /// Returns a preview of the column contents as a formatted string. @@ -687,7 +690,7 @@ protected internal override void AddDataViewColumn(DataViewSchema.Builder builde builder.AddColumn(Name, GetDataViewType()); } - private static DataViewType GetDataViewType() + public static DataViewType GetDataViewType() { if (typeof(T) == typeof(bool)) { @@ -701,6 +704,10 @@ private static DataViewType GetDataViewType() { return NumberDataViewType.Double; } + else if (typeof(T) == typeof(DateTime)) + { + return DateTimeDataViewType.Instance; + } else if (typeof(T) == typeof(float)) { return NumberDataViewType.Single; @@ -744,7 +751,7 @@ private static DataViewType GetDataViewType() return NumberDataViewType.Double; } - throw new NotSupportedException(); + throw new NotSupportedException("Type is " + typeof(T).Name); } protected internal override Delegate GetDataViewGetter(DataViewRowCursor cursor) diff --git a/test/Microsoft.Data.Analysis.Tests/ArrowIntegrationTests.cs b/test/Microsoft.Data.Analysis.Tests/ArrowIntegrationTests.cs index dacf43a8db..4e8e05131f 100644 --- a/test/Microsoft.Data.Analysis.Tests/ArrowIntegrationTests.cs +++ b/test/Microsoft.Data.Analysis.Tests/ArrowIntegrationTests.cs @@ -155,6 +155,29 @@ public void TestEmptyDataFrameRecordBatch() Assert.True(foundARecordBatch); } + [Fact] + public void TestDateTimeType() + { + var dataFrame = new DataFrame( + new List(){ + new SingleDataFrameColumn("Temp", new List(){.22F}), + new DateTimeDataFrameColumn("Dteday", new List() {new DateTime(2022, 6, 2)}), + } +); + + var col1 = new DateTimeDataFrameColumn("Dteday", new List() { new DateTime(2022, 6, 2) }); + var col2 = new DateTimeDataFrameColumn("Dteday2", new List() { new DateTime(2022, 6, 2) }); + + // var res21 = col1.Add(col2); + + var stringCol = new StringDataFrameColumn("test1", new List() { "Hello" }); + var stringCol2 = new StringDataFrameColumn("test2", new List() { "Hello" }); + + var res2 = stringCol.Add(stringCol2); + + var res = DateTimeDataFrameColumn.GetDataViewType(); + } + [Fact] public void TestMutationOnArrowColumn() { diff --git a/test/Microsoft.Data.Analysis.Tests/DataFrameColumn.BinaryOperationTests.cs b/test/Microsoft.Data.Analysis.Tests/DataFrameColumn.BinaryOperationTests.cs index 03854c7c5e..dff229d559 100644 --- a/test/Microsoft.Data.Analysis.Tests/DataFrameColumn.BinaryOperationTests.cs +++ b/test/Microsoft.Data.Analysis.Tests/DataFrameColumn.BinaryOperationTests.cs @@ -170,6 +170,7 @@ public void AddByteToByteDataFrameColumn() Assert.Equal(columnResult.Length, verify.Count()); Assert.True(columnResult.ElementwiseEquals(verifyColumn).All()); } + [Fact] public void AddDecimalToByteDataFrameColumn() { diff --git a/test/Microsoft.Data.Analysis.Tests/DataFrameIDataViewTests.cs b/test/Microsoft.Data.Analysis.Tests/DataFrameIDataViewTests.cs index 3264815293..a7dceb8774 100644 --- a/test/Microsoft.Data.Analysis.Tests/DataFrameIDataViewTests.cs +++ b/test/Microsoft.Data.Analysis.Tests/DataFrameIDataViewTests.cs @@ -19,7 +19,7 @@ public void TestIDataView() DataDebuggerPreview preview = dataView.Preview(); Assert.Equal(10, preview.RowView.Length); - Assert.Equal(15, preview.ColumnView.Length); + Assert.Equal(16, preview.ColumnView.Length); Assert.Equal("Byte", preview.ColumnView[0].Column.Name); Assert.Equal((byte)0, preview.ColumnView[0].Values[0]); @@ -73,13 +73,17 @@ public void TestIDataView() Assert.Equal((ushort)65, preview.ColumnView[12].Values[0]); Assert.Equal((ushort)66, preview.ColumnView[12].Values[1]); - Assert.Equal("Bool", preview.ColumnView[13].Column.Name); - Assert.Equal(true, preview.ColumnView[13].Values[0]); - Assert.Equal(false, preview.ColumnView[13].Values[1]); + Assert.Equal("DateTime", preview.ColumnView[13].Column.Name); + Assert.Equal(new DateTime(2021, 06, 04), preview.ColumnView[13].Values[0]); + Assert.Equal(new DateTime(2021, 06, 05), preview.ColumnView[13].Values[1]); - Assert.Equal("ArrowString", preview.ColumnView[14].Column.Name); - Assert.Equal("foo".ToString(), preview.ColumnView[14].Values[0].ToString()); - Assert.Equal("foo".ToString(), preview.ColumnView[14].Values[1].ToString()); + Assert.Equal("Bool", preview.ColumnView[14].Column.Name); + Assert.Equal(true, preview.ColumnView[14].Values[0]); + Assert.Equal(false, preview.ColumnView[14].Values[1]); + + Assert.Equal("ArrowString", preview.ColumnView[15].Column.Name); + Assert.Equal("foo".ToString(), preview.ColumnView[15].Values[0].ToString()); + Assert.Equal("foo".ToString(), preview.ColumnView[15].Values[1].ToString()); } [Fact] @@ -90,16 +94,16 @@ public void TestIDataViewSchemaInvalidate() IDataView dataView = df; DataViewSchema schema = dataView.Schema; - Assert.Equal(14, schema.Count); + Assert.Equal(15, schema.Count); df.Columns.Remove("Bool"); schema = dataView.Schema; - Assert.Equal(13, schema.Count); + Assert.Equal(14, schema.Count); DataFrameColumn boolColumn = new PrimitiveDataFrameColumn("Bool", Enumerable.Range(0, (int)df.Rows.Count).Select(x => x % 2 == 1)); df.Columns.Insert(0, boolColumn); schema = dataView.Schema; - Assert.Equal(14, schema.Count); + Assert.Equal(15, schema.Count); Assert.Equal("Bool", schema[0].Name); DataFrameColumn boolClone = boolColumn.Clone(); @@ -117,7 +121,7 @@ public void TestIDataViewWithNulls() DataDebuggerPreview preview = dataView.Preview(); Assert.Equal(length, preview.RowView.Length); - Assert.Equal(15, preview.ColumnView.Length); + Assert.Equal(16, preview.ColumnView.Length); Assert.Equal("Byte", preview.ColumnView[0].Column.Name); Assert.Equal((byte)0, preview.ColumnView[0].Values[0]); @@ -210,19 +214,26 @@ public void TestIDataViewWithNulls() Assert.Equal((ushort)0, preview.ColumnView[12].Values[5]); // null row Assert.Equal((ushort)71, preview.ColumnView[12].Values[6]); - Assert.Equal("Bool", preview.ColumnView[13].Column.Name); - Assert.Equal(true, preview.ColumnView[13].Values[0]); - Assert.Equal(false, preview.ColumnView[13].Values[1]); - Assert.Equal(true, preview.ColumnView[13].Values[4]); - Assert.Equal(false, preview.ColumnView[13].Values[5]); // null row - Assert.Equal(true, preview.ColumnView[13].Values[6]); - - Assert.Equal("ArrowString", preview.ColumnView[14].Column.Name); - Assert.Equal("foo", preview.ColumnView[14].Values[0].ToString()); - Assert.Equal("foo", preview.ColumnView[14].Values[1].ToString()); - Assert.Equal("foo", preview.ColumnView[14].Values[4].ToString()); - Assert.Equal("", preview.ColumnView[14].Values[5].ToString()); // null row - Assert.Equal("foo", preview.ColumnView[14].Values[6].ToString()); + Assert.Equal("DateTime", preview.ColumnView[13].Column.Name); + Assert.Equal(new DateTime(2021, 06, 04), preview.ColumnView[13].Values[0]); + Assert.Equal(new DateTime(2021, 06, 05), preview.ColumnView[13].Values[1]); + Assert.Equal(new DateTime(2021, 06, 08), preview.ColumnView[13].Values[4]); + Assert.Equal(new DateTime(), preview.ColumnView[13].Values[5]); // null row + Assert.Equal(new DateTime(2021, 06, 10), preview.ColumnView[13].Values[6]); + + Assert.Equal("Bool", preview.ColumnView[14].Column.Name); + Assert.Equal(true, preview.ColumnView[14].Values[0]); + Assert.Equal(false, preview.ColumnView[14].Values[1]); + Assert.Equal(true, preview.ColumnView[14].Values[4]); + Assert.Equal(false, preview.ColumnView[14].Values[5]); // null row + Assert.Equal(true, preview.ColumnView[14].Values[6]); + + Assert.Equal("ArrowString", preview.ColumnView[15].Column.Name); + Assert.Equal("foo", preview.ColumnView[15].Values[0].ToString()); + Assert.Equal("foo", preview.ColumnView[15].Values[1].ToString()); + Assert.Equal("foo", preview.ColumnView[15].Values[4].ToString()); + Assert.Equal("", preview.ColumnView[15].Values[5].ToString()); // null row + Assert.Equal("foo", preview.ColumnView[15].Values[6].ToString()); } [Fact] diff --git a/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs b/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs index 8f0e7bb00b..a10004293c 100644 --- a/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs +++ b/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs @@ -84,7 +84,7 @@ public static DataFrame MakeDataFrameWithAllColumnTypes(int length, bool withNul public static DataFrame MakeDataFrameWithAllMutableColumnTypes(int length, bool withNulls = true) { - DataFrame df = MakeDataFrameWithNumericAndStringColumns(length, withNulls); + DataFrame df = MakeDataFrameWithNumericStringAndDateTimeColumns(length, withNulls); DataFrameColumn boolColumn = new BooleanDataFrameColumn("Bool", Enumerable.Range(0, length).Select(x => x % 2 == 0)); df.Columns.Insert(df.Columns.Count, boolColumn); if (withNulls) @@ -130,7 +130,7 @@ public static DataFrame MakeDataFrameWithNumericStringAndDateTimeColumns(int len { DataFrame df = MakeDataFrameWithNumericAndStringColumns(length, withNulls); - DataFrameColumn dateTimeColumn = new PrimitiveDataFrameColumn("DateTime", Enumerable.Range(0, length).Select(x => SampleDateTime.AddDays(x))); + DataFrameColumn dateTimeColumn = new DateTimeDataFrameColumn("DateTime", Enumerable.Range(0, length).Select(x => SampleDateTime.AddDays(x))); df.Columns.Insert(df.Columns.Count, dateTimeColumn); if (withNulls) { @@ -701,6 +701,8 @@ public void TestComputations() Assert.Throws(() => df.Columns["Byte"].Any()); Assert.Throws(() => df.Columns["Char"].All()); Assert.Throws(() => df.Columns["Char"].Any()); + Assert.Throws(() => df.Columns["DateTime"].All()); + Assert.Throws(() => df.Columns["DateTime"].Any()); Assert.Throws(() => df.Columns["Decimal"].All()); Assert.Throws(() => df.Columns["Decimal"].Any()); Assert.Throws(() => df.Columns["Double"].All()); @@ -819,6 +821,20 @@ public void TestComputations() Assert.Throws(() => column.Sum()); continue; } + else if (column.DataType == typeof(DateTime)) + { + column.CumulativeMax(); + column.CumulativeMin(); + column.Max(); + column.Min(); + + Assert.Throws(() => column.CumulativeProduct()); + Assert.Throws(() => column.CumulativeSum()); + Assert.Throws(() => column.Product()); + Assert.Throws(() => column.Sum()); + continue; + } + column.CumulativeMax(); column.CumulativeMin(); column.CumulativeProduct(); @@ -1791,7 +1807,7 @@ public void TestDataFrameFilter() for (int i = 0; i < boolColumnFiltered.Columns.Count; i++) { DataFrameColumn column = boolColumnFiltered.Columns[i]; - if (column.Name == "Char" || column.Name == "Bool" || column.Name == "String") + if (column.Name == "Char" || column.Name == "Bool" || column.Name == "String" || column.Name == "DateTime") continue; for (int j = 0; j < column.Length; j++) { @@ -2587,14 +2603,6 @@ public void TestDescription() { DataFrame df = MakeDataFrameWithAllMutableColumnTypes(10); - // Add a column manually here until we fix https://github.com/dotnet/corefxlab/issues/2784 - PrimitiveDataFrameColumn dateTimes = new PrimitiveDataFrameColumn("DateTimes"); - for (int i = 0; i < 10; i++) - { - dateTimes.Append(DateTime.Parse("2019/01/01")); - } - df.Columns.Add(dateTimes); - DataFrame description = df.Description(); DataFrameColumn descriptionColumn = description.Columns[0]; Assert.Equal("Description", descriptionColumn.Name); @@ -2615,9 +2623,9 @@ public void TestDescription() // Explicitly check the dateTimes column DataFrameColumn dateTimeColumn = description.Columns[description.Columns.Count - 1]; - Assert.Equal(dateTimeColumn.Name, dateTimes.Name); + Assert.Equal("DateTime", dateTimeColumn.Name); Assert.Equal(4, dateTimeColumn.Length); - Assert.Equal((float)10, dateTimeColumn[0]); + Assert.Equal((float)9, dateTimeColumn[0]); Assert.Null(dateTimeColumn[1]); Assert.Null(dateTimeColumn[2]); Assert.Null(dateTimeColumn[3]); From 75e28fb1c4a9a64f09718ec691dca6829cec9c76 Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Wed, 17 Aug 2022 16:09:19 -0500 Subject: [PATCH 2/9] datetime computation changes --- .../DateTimeComputation.cs | 291 +++++++++ .../PrimitiveDataFrameColumnArithmetic.cs | 600 +++++++++--------- .../PrimitiveDataFrameColumnArithmetic.tt | 12 +- 3 files changed, 601 insertions(+), 302 deletions(-) diff --git a/src/Microsoft.Data.Analysis/DateTimeComputation.cs b/src/Microsoft.Data.Analysis/DateTimeComputation.cs index 5335d30f87..ecd6e4367c 100644 --- a/src/Microsoft.Data.Analysis/DateTimeComputation.cs +++ b/src/Microsoft.Data.Analysis/DateTimeComputation.cs @@ -311,4 +311,295 @@ public void Round(PrimitiveColumnContainer column) } } + + internal class DateTimeArithmetic : IPrimitiveDataFrameColumnArithmetic + { + public void Add(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Add(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + + public void Add(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Subtract(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Subtract(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + + public void Subtract(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Multiply(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Multiply(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + + public void Multiply(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Divide(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Divide(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + + public void Divide(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Modulo(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Modulo(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + + public void Modulo(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void And(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void And(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + + public void And(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Or(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + + public void Or(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Xor(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + + public void Xor(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + + public void LeftShift(PrimitiveColumnContainer column, int value) + { + throw new NotSupportedException(); + } + public void RightShift(PrimitiveColumnContainer column, int value) + { + throw new NotSupportedException(); + } + public void ElementwiseEquals(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + for (int b = 0; b < left.Buffers.Count; b++) + { + var buffer = left.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + left.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + var otherSpan = right.Buffers[b].ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] == otherSpan[i]); + } + } + } + public void ElementwiseEquals(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + for (int b = 0; b < column.Buffers.Count; b++) + { + var buffer = column.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + column.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] == scalar); + } + } + } + public void ElementwiseNotEquals(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + for (int b = 0; b < left.Buffers.Count; b++) + { + var buffer = left.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + left.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + var otherSpan = right.Buffers[b].ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] != otherSpan[i]); + } + } + } + public void ElementwiseNotEquals(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + for (int b = 0; b < column.Buffers.Count; b++) + { + var buffer = column.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + column.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] != scalar); + } + } + } + public void ElementwiseGreaterThanOrEqual(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + for (int b = 0; b < left.Buffers.Count; b++) + { + var buffer = left.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + left.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + var otherSpan = right.Buffers[b].ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] >= otherSpan[i]); + } + } + } + public void ElementwiseGreaterThanOrEqual(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + for (int b = 0; b < column.Buffers.Count; b++) + { + var buffer = column.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + column.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] >= scalar); + } + } + } + public void ElementwiseLessThanOrEqual(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + for (int b = 0; b < left.Buffers.Count; b++) + { + var buffer = left.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + left.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + var otherSpan = right.Buffers[b].ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] <= otherSpan[i]); + } + } + } + public void ElementwiseLessThanOrEqual(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + for (int b = 0; b < column.Buffers.Count; b++) + { + var buffer = column.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + column.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] <= scalar); + } + } + } + public void ElementwiseGreaterThan(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + for (int b = 0; b < left.Buffers.Count; b++) + { + var buffer = left.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + left.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + var otherSpan = right.Buffers[b].ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] > otherSpan[i]); + } + } + } + public void ElementwiseGreaterThan(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + for (int b = 0; b < column.Buffers.Count; b++) + { + var buffer = column.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + column.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] > scalar); + } + } + } + public void ElementwiseLessThan(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + for (int b = 0; b < left.Buffers.Count; b++) + { + var buffer = left.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + left.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + var otherSpan = right.Buffers[b].ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] < otherSpan[i]); + } + } + } + public void ElementwiseLessThan(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + for (int b = 0; b < column.Buffers.Count; b++) + { + var buffer = column.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + column.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] < scalar); + } + } + } + } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs index 84dd3bdec4..3dcdb3661f 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs @@ -116,6 +116,10 @@ public static IPrimitiveDataFrameColumnArithmetic GetArithmetic() { return (IPrimitiveDataFrameColumnArithmetic)new UShortArithmetic(); } + else if (typeof(T) == typeof(DateTime)) + { + return (IPrimitiveDataFrameColumnArithmetic)new DateTimeArithmetic(); + } throw new NotSupportedException(); } } @@ -130,10 +134,10 @@ public void Add(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - + public void Add(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Subtract(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -143,10 +147,10 @@ public void Subtract(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - + public void Subtract(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Multiply(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -156,10 +160,10 @@ public void Multiply(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - + public void Multiply(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Divide(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -169,10 +173,10 @@ public void Divide(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - + public void Divide(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Modulo(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -182,10 +186,10 @@ public void Modulo(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - + public void Modulo(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void And(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -216,16 +220,16 @@ public void And(PrimitiveColumnContainer column, bool scalar) } } } - + public void And(bool scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (bool)(scalar & span[i]); } @@ -260,16 +264,16 @@ public void Or(PrimitiveColumnContainer column, bool scalar) } } } - + public void Or(bool scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (bool)(scalar | span[i]); } @@ -304,16 +308,16 @@ public void Xor(PrimitiveColumnContainer column, bool scalar) } } } - + public void Xor(bool scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (bool)(scalar ^ span[i]); } @@ -449,16 +453,16 @@ public void Add(PrimitiveColumnContainer column, byte scalar) } } } - + public void Add(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar + span[i]); } @@ -493,16 +497,16 @@ public void Subtract(PrimitiveColumnContainer column, byte scalar) } } } - + public void Subtract(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar - span[i]); } @@ -537,16 +541,16 @@ public void Multiply(PrimitiveColumnContainer column, byte scalar) } } } - + public void Multiply(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar * span[i]); } @@ -581,16 +585,16 @@ public void Divide(PrimitiveColumnContainer column, byte scalar) } } } - + public void Divide(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar / span[i]); } @@ -625,16 +629,16 @@ public void Modulo(PrimitiveColumnContainer column, byte scalar) } } } - + public void Modulo(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar % span[i]); } @@ -669,16 +673,16 @@ public void And(PrimitiveColumnContainer column, byte scalar) } } } - + public void And(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar & span[i]); } @@ -713,16 +717,16 @@ public void Or(PrimitiveColumnContainer column, byte scalar) } } } - + public void Or(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar | span[i]); } @@ -757,16 +761,16 @@ public void Xor(PrimitiveColumnContainer column, byte scalar) } } } - + public void Xor(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar ^ span[i]); } @@ -1006,16 +1010,16 @@ public void Add(PrimitiveColumnContainer column, char scalar) } } } - + public void Add(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar + span[i]); } @@ -1050,16 +1054,16 @@ public void Subtract(PrimitiveColumnContainer column, char scalar) } } } - + public void Subtract(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar - span[i]); } @@ -1094,16 +1098,16 @@ public void Multiply(PrimitiveColumnContainer column, char scalar) } } } - + public void Multiply(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar * span[i]); } @@ -1138,16 +1142,16 @@ public void Divide(PrimitiveColumnContainer column, char scalar) } } } - + public void Divide(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar / span[i]); } @@ -1182,16 +1186,16 @@ public void Modulo(PrimitiveColumnContainer column, char scalar) } } } - + public void Modulo(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar % span[i]); } @@ -1226,16 +1230,16 @@ public void And(PrimitiveColumnContainer column, char scalar) } } } - + public void And(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar & span[i]); } @@ -1270,16 +1274,16 @@ public void Or(PrimitiveColumnContainer column, char scalar) } } } - + public void Or(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar | span[i]); } @@ -1314,16 +1318,16 @@ public void Xor(PrimitiveColumnContainer column, char scalar) } } } - + public void Xor(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar ^ span[i]); } @@ -1563,16 +1567,16 @@ public void Add(PrimitiveColumnContainer column, decimal scalar) } } } - + public void Add(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar + span[i]); } @@ -1607,16 +1611,16 @@ public void Subtract(PrimitiveColumnContainer column, decimal scalar) } } } - + public void Subtract(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar - span[i]); } @@ -1651,16 +1655,16 @@ public void Multiply(PrimitiveColumnContainer column, decimal scalar) } } } - + public void Multiply(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar * span[i]); } @@ -1695,16 +1699,16 @@ public void Divide(PrimitiveColumnContainer column, decimal scalar) } } } - + public void Divide(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar / span[i]); } @@ -1739,16 +1743,16 @@ public void Modulo(PrimitiveColumnContainer column, decimal scalar) } } } - + public void Modulo(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar % span[i]); } @@ -1762,10 +1766,10 @@ public void And(PrimitiveColumnContainer column, decimal scalar) { throw new NotSupportedException(); } - + public void And(decimal scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -1775,10 +1779,10 @@ public void Or(PrimitiveColumnContainer column, decimal scalar) { throw new NotSupportedException(); } - + public void Or(decimal scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -1788,10 +1792,10 @@ public void Xor(PrimitiveColumnContainer column, decimal scalar) { throw new NotSupportedException(); } - + public void Xor(decimal scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void LeftShift(PrimitiveColumnContainer column, int value) { @@ -2007,16 +2011,16 @@ public void Add(PrimitiveColumnContainer column, double scalar) } } } - + public void Add(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar + span[i]); } @@ -2051,16 +2055,16 @@ public void Subtract(PrimitiveColumnContainer column, double scalar) } } } - + public void Subtract(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar - span[i]); } @@ -2095,16 +2099,16 @@ public void Multiply(PrimitiveColumnContainer column, double scalar) } } } - + public void Multiply(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar * span[i]); } @@ -2139,16 +2143,16 @@ public void Divide(PrimitiveColumnContainer column, double scalar) } } } - + public void Divide(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar / span[i]); } @@ -2183,16 +2187,16 @@ public void Modulo(PrimitiveColumnContainer column, double scalar) } } } - + public void Modulo(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar % span[i]); } @@ -2206,10 +2210,10 @@ public void And(PrimitiveColumnContainer column, double scalar) { throw new NotSupportedException(); } - + public void And(double scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -2219,10 +2223,10 @@ public void Or(PrimitiveColumnContainer column, double scalar) { throw new NotSupportedException(); } - + public void Or(double scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -2232,10 +2236,10 @@ public void Xor(PrimitiveColumnContainer column, double scalar) { throw new NotSupportedException(); } - + public void Xor(double scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void LeftShift(PrimitiveColumnContainer column, int value) { @@ -2451,16 +2455,16 @@ public void Add(PrimitiveColumnContainer column, float scalar) } } } - + public void Add(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar + span[i]); } @@ -2495,16 +2499,16 @@ public void Subtract(PrimitiveColumnContainer column, float scalar) } } } - + public void Subtract(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar - span[i]); } @@ -2539,16 +2543,16 @@ public void Multiply(PrimitiveColumnContainer column, float scalar) } } } - + public void Multiply(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar * span[i]); } @@ -2583,16 +2587,16 @@ public void Divide(PrimitiveColumnContainer column, float scalar) } } } - + public void Divide(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar / span[i]); } @@ -2627,16 +2631,16 @@ public void Modulo(PrimitiveColumnContainer column, float scalar) } } } - + public void Modulo(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar % span[i]); } @@ -2650,10 +2654,10 @@ public void And(PrimitiveColumnContainer column, float scalar) { throw new NotSupportedException(); } - + public void And(float scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -2663,10 +2667,10 @@ public void Or(PrimitiveColumnContainer column, float scalar) { throw new NotSupportedException(); } - + public void Or(float scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -2676,10 +2680,10 @@ public void Xor(PrimitiveColumnContainer column, float scalar) { throw new NotSupportedException(); } - + public void Xor(float scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void LeftShift(PrimitiveColumnContainer column, int value) { @@ -2895,16 +2899,16 @@ public void Add(PrimitiveColumnContainer column, int scalar) } } } - + public void Add(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar + span[i]); } @@ -2939,16 +2943,16 @@ public void Subtract(PrimitiveColumnContainer column, int scalar) } } } - + public void Subtract(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar - span[i]); } @@ -2983,16 +2987,16 @@ public void Multiply(PrimitiveColumnContainer column, int scalar) } } } - + public void Multiply(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar * span[i]); } @@ -3027,16 +3031,16 @@ public void Divide(PrimitiveColumnContainer column, int scalar) } } } - + public void Divide(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar / span[i]); } @@ -3071,16 +3075,16 @@ public void Modulo(PrimitiveColumnContainer column, int scalar) } } } - + public void Modulo(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar % span[i]); } @@ -3115,16 +3119,16 @@ public void And(PrimitiveColumnContainer column, int scalar) } } } - + public void And(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar & span[i]); } @@ -3159,16 +3163,16 @@ public void Or(PrimitiveColumnContainer column, int scalar) } } } - + public void Or(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar | span[i]); } @@ -3203,16 +3207,16 @@ public void Xor(PrimitiveColumnContainer column, int scalar) } } } - + public void Xor(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar ^ span[i]); } @@ -3452,16 +3456,16 @@ public void Add(PrimitiveColumnContainer column, long scalar) } } } - + public void Add(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar + span[i]); } @@ -3496,16 +3500,16 @@ public void Subtract(PrimitiveColumnContainer column, long scalar) } } } - + public void Subtract(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar - span[i]); } @@ -3540,16 +3544,16 @@ public void Multiply(PrimitiveColumnContainer column, long scalar) } } } - + public void Multiply(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar * span[i]); } @@ -3584,16 +3588,16 @@ public void Divide(PrimitiveColumnContainer column, long scalar) } } } - + public void Divide(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar / span[i]); } @@ -3628,16 +3632,16 @@ public void Modulo(PrimitiveColumnContainer column, long scalar) } } } - + public void Modulo(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar % span[i]); } @@ -3672,16 +3676,16 @@ public void And(PrimitiveColumnContainer column, long scalar) } } } - + public void And(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar & span[i]); } @@ -3716,16 +3720,16 @@ public void Or(PrimitiveColumnContainer column, long scalar) } } } - + public void Or(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar | span[i]); } @@ -3760,16 +3764,16 @@ public void Xor(PrimitiveColumnContainer column, long scalar) } } } - + public void Xor(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar ^ span[i]); } @@ -4009,16 +4013,16 @@ public void Add(PrimitiveColumnContainer column, sbyte scalar) } } } - + public void Add(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar + span[i]); } @@ -4053,16 +4057,16 @@ public void Subtract(PrimitiveColumnContainer column, sbyte scalar) } } } - + public void Subtract(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar - span[i]); } @@ -4097,16 +4101,16 @@ public void Multiply(PrimitiveColumnContainer column, sbyte scalar) } } } - + public void Multiply(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar * span[i]); } @@ -4141,16 +4145,16 @@ public void Divide(PrimitiveColumnContainer column, sbyte scalar) } } } - + public void Divide(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar / span[i]); } @@ -4185,16 +4189,16 @@ public void Modulo(PrimitiveColumnContainer column, sbyte scalar) } } } - + public void Modulo(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar % span[i]); } @@ -4229,16 +4233,16 @@ public void And(PrimitiveColumnContainer column, sbyte scalar) } } } - + public void And(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar & span[i]); } @@ -4273,16 +4277,16 @@ public void Or(PrimitiveColumnContainer column, sbyte scalar) } } } - + public void Or(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar | span[i]); } @@ -4317,16 +4321,16 @@ public void Xor(PrimitiveColumnContainer column, sbyte scalar) } } } - + public void Xor(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar ^ span[i]); } @@ -4566,16 +4570,16 @@ public void Add(PrimitiveColumnContainer column, short scalar) } } } - + public void Add(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar + span[i]); } @@ -4610,16 +4614,16 @@ public void Subtract(PrimitiveColumnContainer column, short scalar) } } } - + public void Subtract(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar - span[i]); } @@ -4654,16 +4658,16 @@ public void Multiply(PrimitiveColumnContainer column, short scalar) } } } - + public void Multiply(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar * span[i]); } @@ -4698,16 +4702,16 @@ public void Divide(PrimitiveColumnContainer column, short scalar) } } } - + public void Divide(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar / span[i]); } @@ -4742,16 +4746,16 @@ public void Modulo(PrimitiveColumnContainer column, short scalar) } } } - + public void Modulo(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar % span[i]); } @@ -4786,16 +4790,16 @@ public void And(PrimitiveColumnContainer column, short scalar) } } } - + public void And(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar & span[i]); } @@ -4830,16 +4834,16 @@ public void Or(PrimitiveColumnContainer column, short scalar) } } } - + public void Or(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar | span[i]); } @@ -4874,16 +4878,16 @@ public void Xor(PrimitiveColumnContainer column, short scalar) } } } - + public void Xor(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar ^ span[i]); } @@ -5123,16 +5127,16 @@ public void Add(PrimitiveColumnContainer column, uint scalar) } } } - + public void Add(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar + span[i]); } @@ -5167,16 +5171,16 @@ public void Subtract(PrimitiveColumnContainer column, uint scalar) } } } - + public void Subtract(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar - span[i]); } @@ -5211,16 +5215,16 @@ public void Multiply(PrimitiveColumnContainer column, uint scalar) } } } - + public void Multiply(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar * span[i]); } @@ -5255,16 +5259,16 @@ public void Divide(PrimitiveColumnContainer column, uint scalar) } } } - + public void Divide(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar / span[i]); } @@ -5299,16 +5303,16 @@ public void Modulo(PrimitiveColumnContainer column, uint scalar) } } } - + public void Modulo(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar % span[i]); } @@ -5343,16 +5347,16 @@ public void And(PrimitiveColumnContainer column, uint scalar) } } } - + public void And(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar & span[i]); } @@ -5387,16 +5391,16 @@ public void Or(PrimitiveColumnContainer column, uint scalar) } } } - + public void Or(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar | span[i]); } @@ -5431,16 +5435,16 @@ public void Xor(PrimitiveColumnContainer column, uint scalar) } } } - + public void Xor(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar ^ span[i]); } @@ -5680,16 +5684,16 @@ public void Add(PrimitiveColumnContainer column, ulong scalar) } } } - + public void Add(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar + span[i]); } @@ -5724,16 +5728,16 @@ public void Subtract(PrimitiveColumnContainer column, ulong scalar) } } } - + public void Subtract(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar - span[i]); } @@ -5768,16 +5772,16 @@ public void Multiply(PrimitiveColumnContainer column, ulong scalar) } } } - + public void Multiply(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar * span[i]); } @@ -5812,16 +5816,16 @@ public void Divide(PrimitiveColumnContainer column, ulong scalar) } } } - + public void Divide(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar / span[i]); } @@ -5856,16 +5860,16 @@ public void Modulo(PrimitiveColumnContainer column, ulong scalar) } } } - + public void Modulo(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar % span[i]); } @@ -5900,16 +5904,16 @@ public void And(PrimitiveColumnContainer column, ulong scalar) } } } - + public void And(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar & span[i]); } @@ -5944,16 +5948,16 @@ public void Or(PrimitiveColumnContainer column, ulong scalar) } } } - + public void Or(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar | span[i]); } @@ -5988,16 +5992,16 @@ public void Xor(PrimitiveColumnContainer column, ulong scalar) } } } - + public void Xor(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar ^ span[i]); } @@ -6237,16 +6241,16 @@ public void Add(PrimitiveColumnContainer column, ushort scalar) } } } - + public void Add(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar + span[i]); } @@ -6281,16 +6285,16 @@ public void Subtract(PrimitiveColumnContainer column, ushort scalar) } } } - + public void Subtract(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar - span[i]); } @@ -6325,16 +6329,16 @@ public void Multiply(PrimitiveColumnContainer column, ushort scalar) } } } - + public void Multiply(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar * span[i]); } @@ -6369,16 +6373,16 @@ public void Divide(PrimitiveColumnContainer column, ushort scalar) } } } - + public void Divide(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar / span[i]); } @@ -6413,16 +6417,16 @@ public void Modulo(PrimitiveColumnContainer column, ushort scalar) } } } - + public void Modulo(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar % span[i]); } @@ -6457,16 +6461,16 @@ public void And(PrimitiveColumnContainer column, ushort scalar) } } } - + public void And(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar & span[i]); } @@ -6501,16 +6505,16 @@ public void Or(PrimitiveColumnContainer column, ushort scalar) } } } - + public void Or(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar | span[i]); } @@ -6545,16 +6549,16 @@ public void Xor(PrimitiveColumnContainer column, ushort scalar) } } } - + public void Xor(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar ^ span[i]); } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt index 7af9f7b040..6b8a436a14 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt @@ -21,9 +21,9 @@ namespace Microsoft.Data.Analysis where T : struct { <# foreach (MethodConfiguration method in methodConfiguration) { #> - <#= method.GetMethodSignature("PrimitiveColumnContainer", "T")#>; + <#= method.GetMethodSignature("PrimitiveColumnContainer", "T")#>; <# if (method.MethodType == MethodType.BinaryScalar) { #> - <#= method.GetInvertedMethodSignatureForBinaryScalarsOps("PrimitiveColumnContainer", "T")#>; + <#= method.GetInvertedMethodSignatureForBinaryScalarsOps("PrimitiveColumnContainer", "T")#>; <# } #> <# } #> } @@ -45,6 +45,10 @@ namespace Microsoft.Data.Analysis return (IPrimitiveDataFrameColumnArithmetic)new <#=type.ClassPrefix#>Arithmetic(); } <# } #> + else if (typeof(T) == typeof(DateTime)) + { + return (IPrimitiveDataFrameColumnArithmetic)new DateTimeArithmetic(); + } throw new NotSupportedException(); } } @@ -58,7 +62,7 @@ namespace Microsoft.Data.Analysis <# if ((method.IsNumeric && !type.SupportsNumeric) || (method.IsBitwise && !type.SupportsBitwise) || (type.UnsupportedMethods.Contains(method.MethodName))) { #> throw new NotSupportedException(); <# } else if (method.Operator != null) { #> - for (int b = 0 ; b < <#= method.Op1Name #>.Buffers.Count; b++) + for (int b = 0; b < <#= method.Op1Name #>.Buffers.Count; b++) { var buffer = <#= method.Op1Name #>.Buffers[b]; var mutableBuffer = DataFrameBuffer<<#=type.TypeName#>>.GetMutableBuffer(buffer); @@ -90,7 +94,7 @@ namespace Microsoft.Data.Analysis <# if ((method.IsNumeric && !type.SupportsNumeric) || (method.IsBitwise && !type.SupportsBitwise) || (type.UnsupportedMethods.Contains(method.MethodName))) { #> throw new NotSupportedException(); <# } else if (method.Operator != null) { #> - for (int b = 0 ; b < <#= method.Op1Name #>.Buffers.Count; b++) + for (int b = 0; b < <#= method.Op1Name #>.Buffers.Count; b++) { var buffer = <#= method.Op1Name #>.Buffers[b]; var mutableBuffer = DataFrameBuffer<<#=type.TypeName#>>.GetMutableBuffer(buffer); From c45d398ea7e8eb6062096538269e3d3666f6cb75 Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Thu, 18 Aug 2022 13:19:57 -0500 Subject: [PATCH 3/9] update primitivedataframe.tt --- .../PrimitiveDataFrameColumnArithmetic.cs | 496 +++++++----------- .../PrimitiveDataFrameColumnArithmetic.tt | 12 +- 2 files changed, 198 insertions(+), 310 deletions(-) diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs index 3dcdb3661f..10351efead 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs @@ -134,10 +134,9 @@ public void Add(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - public void Add(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Subtract(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -147,10 +146,9 @@ public void Subtract(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - public void Subtract(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Multiply(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -160,10 +158,9 @@ public void Multiply(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - public void Multiply(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Divide(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -173,10 +170,9 @@ public void Divide(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - public void Divide(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Modulo(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -186,10 +182,9 @@ public void Modulo(PrimitiveColumnContainer column, bool scalar) { throw new NotSupportedException(); } - public void Modulo(bool scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void And(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -220,16 +215,15 @@ public void And(PrimitiveColumnContainer column, bool scalar) } } } - public void And(bool scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (bool)(scalar & span[i]); } @@ -264,16 +258,15 @@ public void Or(PrimitiveColumnContainer column, bool scalar) } } } - public void Or(bool scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (bool)(scalar | span[i]); } @@ -308,16 +301,15 @@ public void Xor(PrimitiveColumnContainer column, bool scalar) } } } - public void Xor(bool scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (bool)(scalar ^ span[i]); } @@ -453,16 +445,15 @@ public void Add(PrimitiveColumnContainer column, byte scalar) } } } - public void Add(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar + span[i]); } @@ -497,16 +488,15 @@ public void Subtract(PrimitiveColumnContainer column, byte scalar) } } } - public void Subtract(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar - span[i]); } @@ -541,16 +531,15 @@ public void Multiply(PrimitiveColumnContainer column, byte scalar) } } } - public void Multiply(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar * span[i]); } @@ -585,16 +574,15 @@ public void Divide(PrimitiveColumnContainer column, byte scalar) } } } - public void Divide(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar / span[i]); } @@ -629,16 +617,15 @@ public void Modulo(PrimitiveColumnContainer column, byte scalar) } } } - public void Modulo(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar % span[i]); } @@ -673,16 +660,15 @@ public void And(PrimitiveColumnContainer column, byte scalar) } } } - public void And(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar & span[i]); } @@ -717,16 +703,15 @@ public void Or(PrimitiveColumnContainer column, byte scalar) } } } - public void Or(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar | span[i]); } @@ -761,16 +746,15 @@ public void Xor(PrimitiveColumnContainer column, byte scalar) } } } - public void Xor(byte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (byte)(scalar ^ span[i]); } @@ -1010,16 +994,15 @@ public void Add(PrimitiveColumnContainer column, char scalar) } } } - public void Add(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar + span[i]); } @@ -1054,16 +1037,15 @@ public void Subtract(PrimitiveColumnContainer column, char scalar) } } } - public void Subtract(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar - span[i]); } @@ -1098,16 +1080,15 @@ public void Multiply(PrimitiveColumnContainer column, char scalar) } } } - public void Multiply(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar * span[i]); } @@ -1142,16 +1123,15 @@ public void Divide(PrimitiveColumnContainer column, char scalar) } } } - public void Divide(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar / span[i]); } @@ -1186,16 +1166,15 @@ public void Modulo(PrimitiveColumnContainer column, char scalar) } } } - public void Modulo(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar % span[i]); } @@ -1230,16 +1209,15 @@ public void And(PrimitiveColumnContainer column, char scalar) } } } - public void And(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar & span[i]); } @@ -1274,16 +1252,15 @@ public void Or(PrimitiveColumnContainer column, char scalar) } } } - public void Or(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar | span[i]); } @@ -1318,16 +1295,15 @@ public void Xor(PrimitiveColumnContainer column, char scalar) } } } - public void Xor(char scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (char)(scalar ^ span[i]); } @@ -1567,16 +1543,15 @@ public void Add(PrimitiveColumnContainer column, decimal scalar) } } } - public void Add(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar + span[i]); } @@ -1611,16 +1586,15 @@ public void Subtract(PrimitiveColumnContainer column, decimal scalar) } } } - public void Subtract(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar - span[i]); } @@ -1655,16 +1629,15 @@ public void Multiply(PrimitiveColumnContainer column, decimal scalar) } } } - public void Multiply(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar * span[i]); } @@ -1699,16 +1672,15 @@ public void Divide(PrimitiveColumnContainer column, decimal scalar) } } } - public void Divide(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar / span[i]); } @@ -1743,16 +1715,15 @@ public void Modulo(PrimitiveColumnContainer column, decimal scalar) } } } - public void Modulo(decimal scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (decimal)(scalar % span[i]); } @@ -1766,10 +1737,9 @@ public void And(PrimitiveColumnContainer column, decimal scalar) { throw new NotSupportedException(); } - public void And(decimal scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -1779,10 +1749,9 @@ public void Or(PrimitiveColumnContainer column, decimal scalar) { throw new NotSupportedException(); } - public void Or(decimal scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -1792,10 +1761,9 @@ public void Xor(PrimitiveColumnContainer column, decimal scalar) { throw new NotSupportedException(); } - public void Xor(decimal scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void LeftShift(PrimitiveColumnContainer column, int value) { @@ -2011,16 +1979,15 @@ public void Add(PrimitiveColumnContainer column, double scalar) } } } - public void Add(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar + span[i]); } @@ -2055,16 +2022,15 @@ public void Subtract(PrimitiveColumnContainer column, double scalar) } } } - public void Subtract(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar - span[i]); } @@ -2099,16 +2065,15 @@ public void Multiply(PrimitiveColumnContainer column, double scalar) } } } - public void Multiply(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar * span[i]); } @@ -2143,16 +2108,15 @@ public void Divide(PrimitiveColumnContainer column, double scalar) } } } - public void Divide(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar / span[i]); } @@ -2187,16 +2151,15 @@ public void Modulo(PrimitiveColumnContainer column, double scalar) } } } - public void Modulo(double scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (double)(scalar % span[i]); } @@ -2210,10 +2173,9 @@ public void And(PrimitiveColumnContainer column, double scalar) { throw new NotSupportedException(); } - public void And(double scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -2223,10 +2185,9 @@ public void Or(PrimitiveColumnContainer column, double scalar) { throw new NotSupportedException(); } - public void Or(double scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -2236,10 +2197,9 @@ public void Xor(PrimitiveColumnContainer column, double scalar) { throw new NotSupportedException(); } - public void Xor(double scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void LeftShift(PrimitiveColumnContainer column, int value) { @@ -2455,16 +2415,15 @@ public void Add(PrimitiveColumnContainer column, float scalar) } } } - public void Add(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar + span[i]); } @@ -2499,16 +2458,15 @@ public void Subtract(PrimitiveColumnContainer column, float scalar) } } } - public void Subtract(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar - span[i]); } @@ -2543,16 +2501,15 @@ public void Multiply(PrimitiveColumnContainer column, float scalar) } } } - public void Multiply(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar * span[i]); } @@ -2587,16 +2544,15 @@ public void Divide(PrimitiveColumnContainer column, float scalar) } } } - public void Divide(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar / span[i]); } @@ -2631,16 +2587,15 @@ public void Modulo(PrimitiveColumnContainer column, float scalar) } } } - public void Modulo(float scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (float)(scalar % span[i]); } @@ -2654,10 +2609,9 @@ public void And(PrimitiveColumnContainer column, float scalar) { throw new NotSupportedException(); } - public void And(float scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -2667,10 +2621,9 @@ public void Or(PrimitiveColumnContainer column, float scalar) { throw new NotSupportedException(); } - public void Or(float scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) { @@ -2680,10 +2633,9 @@ public void Xor(PrimitiveColumnContainer column, float scalar) { throw new NotSupportedException(); } - public void Xor(float scalar, PrimitiveColumnContainer column) { - throw new NotSupportedException(); + throw new NotSupportedException(); } public void LeftShift(PrimitiveColumnContainer column, int value) { @@ -2899,16 +2851,15 @@ public void Add(PrimitiveColumnContainer column, int scalar) } } } - public void Add(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar + span[i]); } @@ -2943,16 +2894,15 @@ public void Subtract(PrimitiveColumnContainer column, int scalar) } } } - public void Subtract(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar - span[i]); } @@ -2987,16 +2937,15 @@ public void Multiply(PrimitiveColumnContainer column, int scalar) } } } - public void Multiply(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar * span[i]); } @@ -3031,16 +2980,15 @@ public void Divide(PrimitiveColumnContainer column, int scalar) } } } - public void Divide(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar / span[i]); } @@ -3075,16 +3023,15 @@ public void Modulo(PrimitiveColumnContainer column, int scalar) } } } - public void Modulo(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar % span[i]); } @@ -3119,16 +3066,15 @@ public void And(PrimitiveColumnContainer column, int scalar) } } } - public void And(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar & span[i]); } @@ -3163,16 +3109,15 @@ public void Or(PrimitiveColumnContainer column, int scalar) } } } - public void Or(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar | span[i]); } @@ -3207,16 +3152,15 @@ public void Xor(PrimitiveColumnContainer column, int scalar) } } } - public void Xor(int scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (int)(scalar ^ span[i]); } @@ -3456,16 +3400,15 @@ public void Add(PrimitiveColumnContainer column, long scalar) } } } - public void Add(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar + span[i]); } @@ -3500,16 +3443,15 @@ public void Subtract(PrimitiveColumnContainer column, long scalar) } } } - public void Subtract(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar - span[i]); } @@ -3544,16 +3486,15 @@ public void Multiply(PrimitiveColumnContainer column, long scalar) } } } - public void Multiply(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar * span[i]); } @@ -3588,16 +3529,15 @@ public void Divide(PrimitiveColumnContainer column, long scalar) } } } - public void Divide(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar / span[i]); } @@ -3632,16 +3572,15 @@ public void Modulo(PrimitiveColumnContainer column, long scalar) } } } - public void Modulo(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar % span[i]); } @@ -3676,16 +3615,15 @@ public void And(PrimitiveColumnContainer column, long scalar) } } } - public void And(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar & span[i]); } @@ -3720,16 +3658,15 @@ public void Or(PrimitiveColumnContainer column, long scalar) } } } - public void Or(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar | span[i]); } @@ -3764,16 +3701,15 @@ public void Xor(PrimitiveColumnContainer column, long scalar) } } } - public void Xor(long scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (long)(scalar ^ span[i]); } @@ -4013,16 +3949,15 @@ public void Add(PrimitiveColumnContainer column, sbyte scalar) } } } - public void Add(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar + span[i]); } @@ -4057,16 +3992,15 @@ public void Subtract(PrimitiveColumnContainer column, sbyte scalar) } } } - public void Subtract(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar - span[i]); } @@ -4101,16 +4035,15 @@ public void Multiply(PrimitiveColumnContainer column, sbyte scalar) } } } - public void Multiply(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar * span[i]); } @@ -4145,16 +4078,15 @@ public void Divide(PrimitiveColumnContainer column, sbyte scalar) } } } - public void Divide(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar / span[i]); } @@ -4189,16 +4121,15 @@ public void Modulo(PrimitiveColumnContainer column, sbyte scalar) } } } - public void Modulo(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar % span[i]); } @@ -4233,16 +4164,15 @@ public void And(PrimitiveColumnContainer column, sbyte scalar) } } } - public void And(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar & span[i]); } @@ -4277,16 +4207,15 @@ public void Or(PrimitiveColumnContainer column, sbyte scalar) } } } - public void Or(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar | span[i]); } @@ -4321,16 +4250,15 @@ public void Xor(PrimitiveColumnContainer column, sbyte scalar) } } } - public void Xor(sbyte scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (sbyte)(scalar ^ span[i]); } @@ -4570,16 +4498,15 @@ public void Add(PrimitiveColumnContainer column, short scalar) } } } - public void Add(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar + span[i]); } @@ -4614,16 +4541,15 @@ public void Subtract(PrimitiveColumnContainer column, short scalar) } } } - public void Subtract(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar - span[i]); } @@ -4658,16 +4584,15 @@ public void Multiply(PrimitiveColumnContainer column, short scalar) } } } - public void Multiply(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar * span[i]); } @@ -4702,16 +4627,15 @@ public void Divide(PrimitiveColumnContainer column, short scalar) } } } - public void Divide(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar / span[i]); } @@ -4746,16 +4670,15 @@ public void Modulo(PrimitiveColumnContainer column, short scalar) } } } - public void Modulo(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar % span[i]); } @@ -4790,16 +4713,15 @@ public void And(PrimitiveColumnContainer column, short scalar) } } } - public void And(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar & span[i]); } @@ -4834,16 +4756,15 @@ public void Or(PrimitiveColumnContainer column, short scalar) } } } - public void Or(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar | span[i]); } @@ -4878,16 +4799,15 @@ public void Xor(PrimitiveColumnContainer column, short scalar) } } } - public void Xor(short scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (short)(scalar ^ span[i]); } @@ -5127,16 +5047,15 @@ public void Add(PrimitiveColumnContainer column, uint scalar) } } } - public void Add(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar + span[i]); } @@ -5171,16 +5090,15 @@ public void Subtract(PrimitiveColumnContainer column, uint scalar) } } } - public void Subtract(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar - span[i]); } @@ -5215,16 +5133,15 @@ public void Multiply(PrimitiveColumnContainer column, uint scalar) } } } - public void Multiply(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar * span[i]); } @@ -5259,16 +5176,15 @@ public void Divide(PrimitiveColumnContainer column, uint scalar) } } } - public void Divide(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar / span[i]); } @@ -5303,16 +5219,15 @@ public void Modulo(PrimitiveColumnContainer column, uint scalar) } } } - public void Modulo(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar % span[i]); } @@ -5347,16 +5262,15 @@ public void And(PrimitiveColumnContainer column, uint scalar) } } } - public void And(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar & span[i]); } @@ -5391,16 +5305,15 @@ public void Or(PrimitiveColumnContainer column, uint scalar) } } } - public void Or(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar | span[i]); } @@ -5435,16 +5348,15 @@ public void Xor(PrimitiveColumnContainer column, uint scalar) } } } - public void Xor(uint scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (uint)(scalar ^ span[i]); } @@ -5684,16 +5596,15 @@ public void Add(PrimitiveColumnContainer column, ulong scalar) } } } - public void Add(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar + span[i]); } @@ -5728,16 +5639,15 @@ public void Subtract(PrimitiveColumnContainer column, ulong scalar) } } } - public void Subtract(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar - span[i]); } @@ -5772,16 +5682,15 @@ public void Multiply(PrimitiveColumnContainer column, ulong scalar) } } } - public void Multiply(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar * span[i]); } @@ -5816,16 +5725,15 @@ public void Divide(PrimitiveColumnContainer column, ulong scalar) } } } - public void Divide(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar / span[i]); } @@ -5860,16 +5768,15 @@ public void Modulo(PrimitiveColumnContainer column, ulong scalar) } } } - public void Modulo(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar % span[i]); } @@ -5904,16 +5811,15 @@ public void And(PrimitiveColumnContainer column, ulong scalar) } } } - public void And(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar & span[i]); } @@ -5948,16 +5854,15 @@ public void Or(PrimitiveColumnContainer column, ulong scalar) } } } - public void Or(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar | span[i]); } @@ -5992,16 +5897,15 @@ public void Xor(PrimitiveColumnContainer column, ulong scalar) } } } - public void Xor(ulong scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ulong)(scalar ^ span[i]); } @@ -6241,16 +6145,15 @@ public void Add(PrimitiveColumnContainer column, ushort scalar) } } } - public void Add(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar + span[i]); } @@ -6285,16 +6188,15 @@ public void Subtract(PrimitiveColumnContainer column, ushort scalar) } } } - public void Subtract(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar - span[i]); } @@ -6329,16 +6231,15 @@ public void Multiply(PrimitiveColumnContainer column, ushort scalar) } } } - public void Multiply(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar * span[i]); } @@ -6373,16 +6274,15 @@ public void Divide(PrimitiveColumnContainer column, ushort scalar) } } } - public void Divide(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar / span[i]); } @@ -6417,16 +6317,15 @@ public void Modulo(PrimitiveColumnContainer column, ushort scalar) } } } - public void Modulo(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar % span[i]); } @@ -6461,16 +6360,15 @@ public void And(PrimitiveColumnContainer column, ushort scalar) } } } - public void And(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar & span[i]); } @@ -6505,16 +6403,15 @@ public void Or(PrimitiveColumnContainer column, ushort scalar) } } } - public void Or(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar | span[i]); } @@ -6549,16 +6446,15 @@ public void Xor(PrimitiveColumnContainer column, ushort scalar) } } } - public void Xor(ushort scalar, PrimitiveColumnContainer column) { for (int b = 0; b < column.Buffers.Count; b++) { - var buffer = column.Buffers[b]; + var buffer = column.Buffers[b]; var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); column.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { span[i] = (ushort)(scalar ^ span[i]); } @@ -6767,8 +6663,4 @@ public void ElementwiseLessThan(PrimitiveColumnContainer column, ushort } } } - - - - } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt index 6b8a436a14..90b9009396 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt @@ -88,22 +88,22 @@ namespace Microsoft.Data.Analysis } <# } #> } -<# if (method.MethodType == MethodType.BinaryScalar) { #> +<# if (method.MethodType == MethodType.BinaryScalar) { #> public <#= method.GetInvertedMethodSignatureForBinaryScalarsOps("PrimitiveColumnContainer", type.TypeName) #> { <# if ((method.IsNumeric && !type.SupportsNumeric) || (method.IsBitwise && !type.SupportsBitwise) || (type.UnsupportedMethods.Contains(method.MethodName))) { #> - throw new NotSupportedException(); + throw new NotSupportedException(); <# } else if (method.Operator != null) { #> for (int b = 0; b < <#= method.Op1Name #>.Buffers.Count; b++) { - var buffer = <#= method.Op1Name #>.Buffers[b]; + var buffer = <#= method.Op1Name #>.Buffers[b]; var mutableBuffer = DataFrameBuffer<<#=type.TypeName#>>.GetMutableBuffer(buffer); <#= method.Op1Name #>.Buffers[b] = mutableBuffer; var span = mutableBuffer.Span; <# if (method.MethodType == MethodType.Binary || method.MethodType == MethodType.Comparison) { #> var otherSpan = <#=method.Op2Name#>.Buffers[b].ReadOnlySpan; <# } #> - for (int i = 0; i < span.Length; i++) + for (int i = 0; i < span.Length; i++) { <# if (method.MethodType == MethodType.BinaryScalar || method.MethodType == MethodType.BinaryInt) { #> span[i] = (<#=type.TypeName#>)(<#= method.Op2Name #> <#= method.Operator #> span[i]); @@ -116,8 +116,4 @@ namespace Microsoft.Data.Analysis <# } #> } <# } #> - - - - } From 4c6c201d41a9019b5854fb7f897240f05caad5b2 Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Wed, 24 Aug 2022 12:30:01 -0500 Subject: [PATCH 4/9] pr cleanup --- .../PrimitiveDataFrameColumn.cs | 2 +- .../ArrowIntegrationTests.cs | 23 ------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs index 921a79027a..3cd6799780 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs @@ -690,7 +690,7 @@ protected internal override void AddDataViewColumn(DataViewSchema.Builder builde builder.AddColumn(Name, GetDataViewType()); } - public static DataViewType GetDataViewType() + private static DataViewType GetDataViewType() { if (typeof(T) == typeof(bool)) { diff --git a/test/Microsoft.Data.Analysis.Tests/ArrowIntegrationTests.cs b/test/Microsoft.Data.Analysis.Tests/ArrowIntegrationTests.cs index 4e8e05131f..dacf43a8db 100644 --- a/test/Microsoft.Data.Analysis.Tests/ArrowIntegrationTests.cs +++ b/test/Microsoft.Data.Analysis.Tests/ArrowIntegrationTests.cs @@ -155,29 +155,6 @@ public void TestEmptyDataFrameRecordBatch() Assert.True(foundARecordBatch); } - [Fact] - public void TestDateTimeType() - { - var dataFrame = new DataFrame( - new List(){ - new SingleDataFrameColumn("Temp", new List(){.22F}), - new DateTimeDataFrameColumn("Dteday", new List() {new DateTime(2022, 6, 2)}), - } -); - - var col1 = new DateTimeDataFrameColumn("Dteday", new List() { new DateTime(2022, 6, 2) }); - var col2 = new DateTimeDataFrameColumn("Dteday2", new List() { new DateTime(2022, 6, 2) }); - - // var res21 = col1.Add(col2); - - var stringCol = new StringDataFrameColumn("test1", new List() { "Hello" }); - var stringCol2 = new StringDataFrameColumn("test2", new List() { "Hello" }); - - var res2 = stringCol.Add(stringCol2); - - var res = DateTimeDataFrameColumn.GetDataViewType(); - } - [Fact] public void TestMutationOnArrowColumn() { From e00dd2f1be3b493af9ba1333c4dd9d9d39bece4e Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Mon, 29 Aug 2022 16:52:06 -0500 Subject: [PATCH 5/9] update binaryoperations --- .../ColumnArithmeticTemplate.ttinclude | 3 +- .../DateTimeComputation.cs | 291 ------------------ ...imitiveDataFrameColumn.BinaryOperations.cs | 140 +++++++-- ...imitiveDataFrameColumn.BinaryOperations.tt | 24 +- .../PrimitiveDataFrameColumnArithmetic.cs | 201 ++++++++++++ .../DataFrameTests.cs | 24 ++ 6 files changed, 357 insertions(+), 326 deletions(-) diff --git a/src/Microsoft.Data.Analysis/ColumnArithmeticTemplate.ttinclude b/src/Microsoft.Data.Analysis/ColumnArithmeticTemplate.ttinclude index 4c3e9f332b..bb31da6a94 100644 --- a/src/Microsoft.Data.Analysis/ColumnArithmeticTemplate.ttinclude +++ b/src/Microsoft.Data.Analysis/ColumnArithmeticTemplate.ttinclude @@ -150,7 +150,8 @@ new TypeConfiguration("short", unsupportedMethods: new[] {"All", "Any"}), new TypeConfiguration("uint", classPrefix:"UInt", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}), new TypeConfiguration("ulong", classPrefix:"ULong", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}), - new TypeConfiguration("ushort", classPrefix:"UShort", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}) + new TypeConfiguration("ushort", classPrefix:"UShort", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"}), + new TypeConfiguration("DateTime", supportsBitwise: false, supportsNumeric: false, unsupportedMethods: new[] {"And", "Or", "Xor"}) }; public string GetBinaryShiftOperationReturnType(TypeConfiguration t1) diff --git a/src/Microsoft.Data.Analysis/DateTimeComputation.cs b/src/Microsoft.Data.Analysis/DateTimeComputation.cs index ecd6e4367c..5335d30f87 100644 --- a/src/Microsoft.Data.Analysis/DateTimeComputation.cs +++ b/src/Microsoft.Data.Analysis/DateTimeComputation.cs @@ -311,295 +311,4 @@ public void Round(PrimitiveColumnContainer column) } } - - internal class DateTimeArithmetic : IPrimitiveDataFrameColumnArithmetic - { - public void Add(PrimitiveColumnContainer left, PrimitiveColumnContainer right) - { - throw new NotSupportedException(); - } - public void Add(PrimitiveColumnContainer column, DateTime scalar) - { - throw new NotSupportedException(); - } - - public void Add(DateTime scalar, PrimitiveColumnContainer column) - { - throw new NotSupportedException(); - } - public void Subtract(PrimitiveColumnContainer left, PrimitiveColumnContainer right) - { - throw new NotSupportedException(); - } - public void Subtract(PrimitiveColumnContainer column, DateTime scalar) - { - throw new NotSupportedException(); - } - - public void Subtract(DateTime scalar, PrimitiveColumnContainer column) - { - throw new NotSupportedException(); - } - public void Multiply(PrimitiveColumnContainer left, PrimitiveColumnContainer right) - { - throw new NotSupportedException(); - } - public void Multiply(PrimitiveColumnContainer column, DateTime scalar) - { - throw new NotSupportedException(); - } - - public void Multiply(DateTime scalar, PrimitiveColumnContainer column) - { - throw new NotSupportedException(); - } - public void Divide(PrimitiveColumnContainer left, PrimitiveColumnContainer right) - { - throw new NotSupportedException(); - } - public void Divide(PrimitiveColumnContainer column, DateTime scalar) - { - throw new NotSupportedException(); - } - - public void Divide(DateTime scalar, PrimitiveColumnContainer column) - { - throw new NotSupportedException(); - } - public void Modulo(PrimitiveColumnContainer left, PrimitiveColumnContainer right) - { - throw new NotSupportedException(); - } - public void Modulo(PrimitiveColumnContainer column, DateTime scalar) - { - throw new NotSupportedException(); - } - - public void Modulo(DateTime scalar, PrimitiveColumnContainer column) - { - throw new NotSupportedException(); - } - public void And(PrimitiveColumnContainer left, PrimitiveColumnContainer right) - { - throw new NotSupportedException(); - } - public void And(PrimitiveColumnContainer column, DateTime scalar) - { - throw new NotSupportedException(); - } - - public void And(DateTime scalar, PrimitiveColumnContainer column) - { - throw new NotSupportedException(); - } - public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) - { - throw new NotSupportedException(); - } - public void Or(PrimitiveColumnContainer column, DateTime scalar) - { - throw new NotSupportedException(); - } - - public void Or(DateTime scalar, PrimitiveColumnContainer column) - { - throw new NotSupportedException(); - } - public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) - { - throw new NotSupportedException(); - } - public void Xor(PrimitiveColumnContainer column, DateTime scalar) - { - throw new NotSupportedException(); - } - - public void Xor(DateTime scalar, PrimitiveColumnContainer column) - { - throw new NotSupportedException(); - } - - public void LeftShift(PrimitiveColumnContainer column, int value) - { - throw new NotSupportedException(); - } - public void RightShift(PrimitiveColumnContainer column, int value) - { - throw new NotSupportedException(); - } - public void ElementwiseEquals(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) - { - for (int b = 0; b < left.Buffers.Count; b++) - { - var buffer = left.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - left.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - var otherSpan = right.Buffers[b].ReadOnlySpan; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] == otherSpan[i]); - } - } - } - public void ElementwiseEquals(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) - { - for (int b = 0; b < column.Buffers.Count; b++) - { - var buffer = column.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - column.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] == scalar); - } - } - } - public void ElementwiseNotEquals(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) - { - for (int b = 0; b < left.Buffers.Count; b++) - { - var buffer = left.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - left.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - var otherSpan = right.Buffers[b].ReadOnlySpan; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] != otherSpan[i]); - } - } - } - public void ElementwiseNotEquals(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) - { - for (int b = 0; b < column.Buffers.Count; b++) - { - var buffer = column.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - column.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] != scalar); - } - } - } - public void ElementwiseGreaterThanOrEqual(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) - { - for (int b = 0; b < left.Buffers.Count; b++) - { - var buffer = left.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - left.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - var otherSpan = right.Buffers[b].ReadOnlySpan; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] >= otherSpan[i]); - } - } - } - public void ElementwiseGreaterThanOrEqual(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) - { - for (int b = 0; b < column.Buffers.Count; b++) - { - var buffer = column.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - column.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] >= scalar); - } - } - } - public void ElementwiseLessThanOrEqual(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) - { - for (int b = 0; b < left.Buffers.Count; b++) - { - var buffer = left.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - left.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - var otherSpan = right.Buffers[b].ReadOnlySpan; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] <= otherSpan[i]); - } - } - } - public void ElementwiseLessThanOrEqual(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) - { - for (int b = 0; b < column.Buffers.Count; b++) - { - var buffer = column.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - column.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] <= scalar); - } - } - } - public void ElementwiseGreaterThan(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) - { - for (int b = 0; b < left.Buffers.Count; b++) - { - var buffer = left.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - left.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - var otherSpan = right.Buffers[b].ReadOnlySpan; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] > otherSpan[i]); - } - } - } - public void ElementwiseGreaterThan(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) - { - for (int b = 0; b < column.Buffers.Count; b++) - { - var buffer = column.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - column.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] > scalar); - } - } - } - public void ElementwiseLessThan(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) - { - for (int b = 0; b < left.Buffers.Count; b++) - { - var buffer = left.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - left.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - var otherSpan = right.Buffers[b].ReadOnlySpan; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] < otherSpan[i]); - } - } - } - public void ElementwiseLessThan(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) - { - for (int b = 0; b < column.Buffers.Count; b++) - { - var buffer = column.Buffers[b]; - var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); - column.Buffers[b] = mutableBuffer; - var span = mutableBuffer.Span; - for (int i = 0; i < span.Length; i++) - { - ret[i] = (span[i] < scalar); - } - } - } - } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.cs index f7235bf7f8..fc265060ae 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.cs @@ -45,6 +45,8 @@ public override DataFrameColumn Add(DataFrameColumn column, bool inPlace = false return AddImplementation(column as PrimitiveDataFrameColumn, inPlace); case PrimitiveDataFrameColumn ushortColumn: return AddImplementation(column as PrimitiveDataFrameColumn, inPlace); + case PrimitiveDataFrameColumn DateTimeColumn: + return AddImplementation(column as PrimitiveDataFrameColumn, inPlace); default: throw new NotSupportedException(); } @@ -90,6 +92,8 @@ public override DataFrameColumn Subtract(DataFrameColumn column, bool inPlace = return SubtractImplementation(column as PrimitiveDataFrameColumn, inPlace); case PrimitiveDataFrameColumn ushortColumn: return SubtractImplementation(column as PrimitiveDataFrameColumn, inPlace); + case PrimitiveDataFrameColumn DateTimeColumn: + return SubtractImplementation(column as PrimitiveDataFrameColumn, inPlace); default: throw new NotSupportedException(); } @@ -135,6 +139,8 @@ public override DataFrameColumn Multiply(DataFrameColumn column, bool inPlace = return MultiplyImplementation(column as PrimitiveDataFrameColumn, inPlace); case PrimitiveDataFrameColumn ushortColumn: return MultiplyImplementation(column as PrimitiveDataFrameColumn, inPlace); + case PrimitiveDataFrameColumn DateTimeColumn: + return MultiplyImplementation(column as PrimitiveDataFrameColumn, inPlace); default: throw new NotSupportedException(); } @@ -180,6 +186,8 @@ public override DataFrameColumn Divide(DataFrameColumn column, bool inPlace = fa return DivideImplementation(column as PrimitiveDataFrameColumn, inPlace); case PrimitiveDataFrameColumn ushortColumn: return DivideImplementation(column as PrimitiveDataFrameColumn, inPlace); + case PrimitiveDataFrameColumn DateTimeColumn: + return DivideImplementation(column as PrimitiveDataFrameColumn, inPlace); default: throw new NotSupportedException(); } @@ -225,6 +233,8 @@ public override DataFrameColumn Modulo(DataFrameColumn column, bool inPlace = fa return ModuloImplementation(column as PrimitiveDataFrameColumn, inPlace); case PrimitiveDataFrameColumn ushortColumn: return ModuloImplementation(column as PrimitiveDataFrameColumn, inPlace); + case PrimitiveDataFrameColumn DateTimeColumn: + return ModuloImplementation(column as PrimitiveDataFrameColumn, inPlace); default: throw new NotSupportedException(); } @@ -270,6 +280,8 @@ public override DataFrameColumn And(DataFrameColumn column, bool inPlace = false return AndImplementation(column as PrimitiveDataFrameColumn, inPlace); case PrimitiveDataFrameColumn ushortColumn: return AndImplementation(column as PrimitiveDataFrameColumn, inPlace); + case PrimitiveDataFrameColumn DateTimeColumn: + return AndImplementation(column as PrimitiveDataFrameColumn, inPlace); default: throw new NotSupportedException(); } @@ -310,6 +322,8 @@ public override DataFrameColumn Or(DataFrameColumn column, bool inPlace = false) return OrImplementation(column as PrimitiveDataFrameColumn, inPlace); case PrimitiveDataFrameColumn ushortColumn: return OrImplementation(column as PrimitiveDataFrameColumn, inPlace); + case PrimitiveDataFrameColumn DateTimeColumn: + return OrImplementation(column as PrimitiveDataFrameColumn, inPlace); default: throw new NotSupportedException(); } @@ -350,6 +364,8 @@ public override DataFrameColumn Xor(DataFrameColumn column, bool inPlace = false return XorImplementation(column as PrimitiveDataFrameColumn, inPlace); case PrimitiveDataFrameColumn ushortColumn: return XorImplementation(column as PrimitiveDataFrameColumn, inPlace); + case PrimitiveDataFrameColumn DateTimeColumn: + return XorImplementation(column as PrimitiveDataFrameColumn, inPlace); default: throw new NotSupportedException(); } @@ -380,8 +396,6 @@ public override PrimitiveDataFrameColumn ElementwiseEquals(DataFrameColumn return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn charColumn: return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); - case PrimitiveDataFrameColumn dateTimeColumn: - return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn decimalColumn: return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn doubleColumn: @@ -402,6 +416,8 @@ public override PrimitiveDataFrameColumn ElementwiseEquals(DataFrameColumn return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn ushortColumn: return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); + case PrimitiveDataFrameColumn DateTimeColumn: + return ElementwiseEqualsImplementation(column as PrimitiveDataFrameColumn); default: throw new NotSupportedException(); } @@ -447,6 +463,8 @@ public override PrimitiveDataFrameColumn ElementwiseNotEquals(DataFrameCol return ElementwiseNotEqualsImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn ushortColumn: return ElementwiseNotEqualsImplementation(column as PrimitiveDataFrameColumn); + case PrimitiveDataFrameColumn DateTimeColumn: + return ElementwiseNotEqualsImplementation(column as PrimitiveDataFrameColumn); default: throw new NotSupportedException(); } @@ -492,6 +510,8 @@ public override PrimitiveDataFrameColumn ElementwiseGreaterThanOrEqual(Dat return ElementwiseGreaterThanOrEqualImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn ushortColumn: return ElementwiseGreaterThanOrEqualImplementation(column as PrimitiveDataFrameColumn); + case PrimitiveDataFrameColumn DateTimeColumn: + return ElementwiseGreaterThanOrEqualImplementation(column as PrimitiveDataFrameColumn); default: throw new NotSupportedException(); } @@ -537,6 +557,8 @@ public override PrimitiveDataFrameColumn ElementwiseLessThanOrEqual(DataFr return ElementwiseLessThanOrEqualImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn ushortColumn: return ElementwiseLessThanOrEqualImplementation(column as PrimitiveDataFrameColumn); + case PrimitiveDataFrameColumn DateTimeColumn: + return ElementwiseLessThanOrEqualImplementation(column as PrimitiveDataFrameColumn); default: throw new NotSupportedException(); } @@ -582,6 +604,8 @@ public override PrimitiveDataFrameColumn ElementwiseGreaterThan(DataFrameC return ElementwiseGreaterThanImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn ushortColumn: return ElementwiseGreaterThanImplementation(column as PrimitiveDataFrameColumn); + case PrimitiveDataFrameColumn DateTimeColumn: + return ElementwiseGreaterThanImplementation(column as PrimitiveDataFrameColumn); default: throw new NotSupportedException(); } @@ -627,6 +651,8 @@ public override PrimitiveDataFrameColumn ElementwiseLessThan(DataFrameColu return ElementwiseLessThanImplementation(column as PrimitiveDataFrameColumn); case PrimitiveDataFrameColumn ushortColumn: return ElementwiseLessThanImplementation(column as PrimitiveDataFrameColumn); + case PrimitiveDataFrameColumn DateTimeColumn: + return ElementwiseLessThanImplementation(column as PrimitiveDataFrameColumn); default: throw new NotSupportedException(); } @@ -676,6 +702,8 @@ internal DataFrameColumn AddImplementation(PrimitiveDataFrameColumn column decimalColumn._columnContainer.Add(column.CloneAsDecimalColumn()._columnContainer); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -751,6 +779,8 @@ internal DataFrameColumn AddImplementation(U value, bool inPlace) decimalColumn._columnContainer.Add(DecimalConverter.Instance.GetDecimal(value)); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -831,6 +861,8 @@ internal DataFrameColumn SubtractImplementation(PrimitiveDataFrameColumn c decimalColumn._columnContainer.Subtract(column.CloneAsDecimalColumn()._columnContainer); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -906,6 +938,8 @@ internal DataFrameColumn SubtractImplementation(U value, bool inPlace) decimalColumn._columnContainer.Subtract(DecimalConverter.Instance.GetDecimal(value)); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -986,6 +1020,8 @@ internal DataFrameColumn MultiplyImplementation(PrimitiveDataFrameColumn c decimalColumn._columnContainer.Multiply(column.CloneAsDecimalColumn()._columnContainer); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1061,6 +1097,8 @@ internal DataFrameColumn MultiplyImplementation(U value, bool inPlace) decimalColumn._columnContainer.Multiply(DecimalConverter.Instance.GetDecimal(value)); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1141,6 +1179,8 @@ internal DataFrameColumn DivideImplementation(PrimitiveDataFrameColumn col decimalColumn._columnContainer.Divide(column.CloneAsDecimalColumn()._columnContainer); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1216,6 +1256,8 @@ internal DataFrameColumn DivideImplementation(U value, bool inPlace) decimalColumn._columnContainer.Divide(DecimalConverter.Instance.GetDecimal(value)); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1296,6 +1338,8 @@ internal DataFrameColumn ModuloImplementation(PrimitiveDataFrameColumn col decimalColumn._columnContainer.Modulo(column.CloneAsDecimalColumn()._columnContainer); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1371,6 +1415,8 @@ internal DataFrameColumn ModuloImplementation(U value, bool inPlace) decimalColumn._columnContainer.Modulo(DecimalConverter.Instance.GetDecimal(value)); return decimalColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1447,6 +1493,7 @@ internal DataFrameColumn AndImplementation(PrimitiveDataFrameColumn column case Type uintType when uintType == typeof(uint): case Type ulongType when ulongType == typeof(ulong): case Type ushortType when ushortType == typeof(ushort): + case Type DateTimeType when DateTimeType == typeof(DateTime): default: throw new NotSupportedException(); } @@ -1476,6 +1523,7 @@ internal PrimitiveDataFrameColumn AndImplementation(U value, bool inPla case Type uintType when uintType == typeof(uint): case Type ulongType when ulongType == typeof(ulong): case Type ushortType when ushortType == typeof(ushort): + case Type DateTimeType when DateTimeType == typeof(DateTime): default: throw new NotSupportedException(); } @@ -1510,6 +1558,7 @@ internal DataFrameColumn OrImplementation(PrimitiveDataFrameColumn column, case Type uintType when uintType == typeof(uint): case Type ulongType when ulongType == typeof(ulong): case Type ushortType when ushortType == typeof(ushort): + case Type DateTimeType when DateTimeType == typeof(DateTime): default: throw new NotSupportedException(); } @@ -1539,6 +1588,7 @@ internal PrimitiveDataFrameColumn OrImplementation(U value, bool inPlac case Type uintType when uintType == typeof(uint): case Type ulongType when ulongType == typeof(ulong): case Type ushortType when ushortType == typeof(ushort): + case Type DateTimeType when DateTimeType == typeof(DateTime): default: throw new NotSupportedException(); } @@ -1573,6 +1623,7 @@ internal DataFrameColumn XorImplementation(PrimitiveDataFrameColumn column case Type uintType when uintType == typeof(uint): case Type ulongType when ulongType == typeof(ulong): case Type ushortType when ushortType == typeof(ushort): + case Type DateTimeType when DateTimeType == typeof(DateTime): default: throw new NotSupportedException(); } @@ -1602,6 +1653,7 @@ internal PrimitiveDataFrameColumn XorImplementation(U value, bool inPla case Type uintType when uintType == typeof(uint): case Type ulongType when ulongType == typeof(ulong): case Type ushortType when ushortType == typeof(ushort): + case Type DateTimeType when DateTimeType == typeof(DateTime): default: throw new NotSupportedException(); } @@ -1663,6 +1715,8 @@ internal DataFrameColumn LeftShiftImplementation(int value, bool inPlace) PrimitiveDataFrameColumn newushortColumn = inPlace ? ushortColumn : ushortColumn.Clone(); newushortColumn._columnContainer.LeftShift(value); return newushortColumn; + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); default: throw new NotSupportedException(); } @@ -1724,6 +1778,8 @@ internal DataFrameColumn RightShiftImplementation(int value, bool inPlace) PrimitiveDataFrameColumn newushortColumn = inPlace ? ushortColumn : ushortColumn.Clone(); newushortColumn._columnContainer.RightShift(value); return newushortColumn; + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); default: throw new NotSupportedException(); } @@ -1742,17 +1798,9 @@ internal PrimitiveDataFrameColumn ElementwiseEqualsImplementation(Primi { throw new NotSupportedException(); } - PrimitiveDataFrameColumn retColumn = CloneAsBooleanColumn(); - (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(column._columnContainer, retColumn._columnContainer); - return retColumn; - case Type dateTimeType when dateTimeType == typeof(DateTime): - if (typeof(U) != typeof(DateTime)) - { - throw new NotSupportedException(); - } - PrimitiveDataFrameColumn newcolumn = CloneAsBooleanColumn(); - (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(column._columnContainer, newcolumn._columnContainer); - return newcolumn; + PrimitiveDataFrameColumn retboolColumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(column._columnContainer, retboolColumn._columnContainer); + return retboolColumn; case Type decimalType when decimalType == typeof(decimal): if (typeof(U) == typeof(bool)) { @@ -1773,6 +1821,14 @@ internal PrimitiveDataFrameColumn ElementwiseEqualsImplementation(Primi decimalColumn._columnContainer.ElementwiseEquals(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + if (typeof(U) != typeof(DateTime)) + { + throw new NotSupportedException(); + } + PrimitiveDataFrameColumn retDateTimeColumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(column._columnContainer, retDateTimeColumn._columnContainer); + return retDateTimeColumn; case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1826,9 +1882,9 @@ internal PrimitiveDataFrameColumn ElementwiseEqualsImplementation(U val { throw new NotSupportedException(); } - PrimitiveDataFrameColumn retColumn = CloneAsBooleanColumn(); - (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(Unsafe.As(ref value), retColumn._columnContainer); - return retColumn; + PrimitiveDataFrameColumn retboolColumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(Unsafe.As(ref value), retboolColumn._columnContainer); + return retboolColumn; case Type decimalType when decimalType == typeof(decimal): if (typeof(U) == typeof(bool)) { @@ -1849,6 +1905,14 @@ internal PrimitiveDataFrameColumn ElementwiseEqualsImplementation(U val decimalColumn._columnContainer.ElementwiseEquals(DecimalConverter.Instance.GetDecimal(value), newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + if (typeof(U) != typeof(DateTime)) + { + throw new NotSupportedException(); + } + PrimitiveDataFrameColumn retDateTimeColumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseEquals(Unsafe.As(ref value), retDateTimeColumn._columnContainer); + return retDateTimeColumn; case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1907,9 +1971,9 @@ internal PrimitiveDataFrameColumn ElementwiseNotEqualsImplementation(Pr { throw new NotSupportedException(); } - PrimitiveDataFrameColumn retColumn = CloneAsBooleanColumn(); - (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseNotEquals(column._columnContainer, retColumn._columnContainer); - return retColumn; + PrimitiveDataFrameColumn retboolColumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseNotEquals(column._columnContainer, retboolColumn._columnContainer); + return retboolColumn; case Type decimalType when decimalType == typeof(decimal): if (typeof(U) == typeof(bool)) { @@ -1930,6 +1994,14 @@ internal PrimitiveDataFrameColumn ElementwiseNotEqualsImplementation(Pr decimalColumn._columnContainer.ElementwiseNotEquals(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + if (typeof(U) != typeof(DateTime)) + { + throw new NotSupportedException(); + } + PrimitiveDataFrameColumn retDateTimeColumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseNotEquals(column._columnContainer, retDateTimeColumn._columnContainer); + return retDateTimeColumn; case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -1983,9 +2055,9 @@ internal PrimitiveDataFrameColumn ElementwiseNotEqualsImplementation(U { throw new NotSupportedException(); } - PrimitiveDataFrameColumn retColumn = CloneAsBooleanColumn(); - (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseNotEquals(Unsafe.As(ref value), retColumn._columnContainer); - return retColumn; + PrimitiveDataFrameColumn retboolColumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseNotEquals(Unsafe.As(ref value), retboolColumn._columnContainer); + return retboolColumn; case Type decimalType when decimalType == typeof(decimal): if (typeof(U) == typeof(bool)) { @@ -2006,6 +2078,14 @@ internal PrimitiveDataFrameColumn ElementwiseNotEqualsImplementation(U decimalColumn._columnContainer.ElementwiseNotEquals(DecimalConverter.Instance.GetDecimal(value), newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + if (typeof(U) != typeof(DateTime)) + { + throw new NotSupportedException(); + } + PrimitiveDataFrameColumn retDateTimeColumn = CloneAsBooleanColumn(); + (this as PrimitiveDataFrameColumn)._columnContainer.ElementwiseNotEquals(Unsafe.As(ref value), retDateTimeColumn._columnContainer); + return retDateTimeColumn; case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -2081,6 +2161,8 @@ internal PrimitiveDataFrameColumn ElementwiseGreaterThanOrEqualImplementat decimalColumn._columnContainer.ElementwiseGreaterThanOrEqual(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -2151,6 +2233,8 @@ internal PrimitiveDataFrameColumn ElementwiseGreaterThanOrEqualImplementat decimalColumn._columnContainer.ElementwiseGreaterThanOrEqual(DecimalConverter.Instance.GetDecimal(value), newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -2226,6 +2310,8 @@ internal PrimitiveDataFrameColumn ElementwiseLessThanOrEqualImplementation decimalColumn._columnContainer.ElementwiseLessThanOrEqual(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -2296,6 +2382,8 @@ internal PrimitiveDataFrameColumn ElementwiseLessThanOrEqualImplementation decimalColumn._columnContainer.ElementwiseLessThanOrEqual(DecimalConverter.Instance.GetDecimal(value), newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -2371,6 +2459,8 @@ internal PrimitiveDataFrameColumn ElementwiseGreaterThanImplementation( decimalColumn._columnContainer.ElementwiseGreaterThan(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -2441,6 +2531,8 @@ internal PrimitiveDataFrameColumn ElementwiseGreaterThanImplementation( decimalColumn._columnContainer.ElementwiseGreaterThan(DecimalConverter.Instance.GetDecimal(value), newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -2516,6 +2608,8 @@ internal PrimitiveDataFrameColumn ElementwiseLessThanImplementation(Pri decimalColumn._columnContainer.ElementwiseLessThan(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): @@ -2586,6 +2680,8 @@ internal PrimitiveDataFrameColumn ElementwiseLessThanImplementation(U v decimalColumn._columnContainer.ElementwiseLessThan(DecimalConverter.Instance.GetDecimal(value), newColumn._columnContainer); return newColumn; } + case Type DateTimeType when DateTimeType == typeof(DateTime): + throw new NotSupportedException(); case Type byteType when byteType == typeof(byte): case Type charType when charType == typeof(char): case Type doubleType when doubleType == typeof(double): diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.tt b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.tt index 6809de48d1..bbe3cdbb0f 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.tt +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.tt @@ -169,32 +169,32 @@ namespace Microsoft.Data.Analysis switch (typeof(T)) { <# foreach (TypeConfiguration type in typeConfiguration) { #> -<# if (type.TypeName == "bool") { #> +<# if (type.TypeName == "bool" || type.TypeName == "DateTime") { #> case Type <#=type.TypeName#>Type when <#=type.TypeName#>Type == typeof(<#=type.TypeName#>): <# if (method.IsNumeric == true) { #> throw new NotSupportedException(); <# } else { #> - if (typeof(U) != typeof(bool)) + if (typeof(U) != typeof(<#=type.TypeName#>)) { throw new NotSupportedException(); } <# if (method.MethodType == MethodType.ComparisonScalar || method.MethodType == MethodType.Comparison) { #> - PrimitiveDataFrameColumn retColumn = CloneAsBooleanColumn(); + PrimitiveDataFrameColumn ret<#=type.TypeName#>Column = CloneAsBooleanColumn(); <# if (method.MethodType == MethodType.ComparisonScalar) { #> - (this as PrimitiveDataFrameColumn)._columnContainer.<#=method.MethodName#>(Unsafe.As(ref value), retColumn._columnContainer); + (this as PrimitiveDataFrameColumn)._columnContainer.<#=method.MethodName#>(Unsafe.As(ref value), ret<#=type.TypeName#>Column._columnContainer); <# } else { #> - (this as PrimitiveDataFrameColumn)._columnContainer.<#=method.MethodName#>(column._columnContainer, retColumn._columnContainer); + (this as PrimitiveDataFrameColumn)._columnContainer.<#=method.MethodName#>(column._columnContainer, ret<#=type.TypeName#>Column._columnContainer); <# } #> <# } else if (method.MethodType == MethodType.BinaryScalar) {#> PrimitiveDataFrameColumn column = this as PrimitiveDataFrameColumn; - PrimitiveDataFrameColumn retColumn = <#=GenerateInPlaceStatement("column", "column.Clone()")#>; - retColumn._columnContainer.<#=method.MethodName#>(value); + PrimitiveDataFrameColumn ret<#=type.TypeName#>Column = <#=GenerateInPlaceStatement("column", "column.Clone()")#>; + ret<#=type.TypeName#>Column._columnContainer.<#=method.MethodName#>(value); <# } else { #> PrimitiveDataFrameColumn column = this as PrimitiveDataFrameColumn; - PrimitiveDataFrameColumn retColumn = <#=GenerateInPlaceStatement("column", "column.Clone()")#>; - retColumn._columnContainer.<#=method.MethodName#>(column._columnContainer); + PrimitiveDataFrameColumn ret<#=type.TypeName#>Column = <#=GenerateInPlaceStatement("column", "column.Clone()")#>; + ret<#=type.TypeName#>Column._columnContainer.<#=method.MethodName#>(column._columnContainer); <# } #> - return retColumn; + return ret<#=type.TypeName#>Column; <# } #> <# } else if (type.TypeName == "decimal") { #> case Type <#=type.TypeName#>Type when <#=type.TypeName#>Type == typeof(<#=type.TypeName#>): @@ -231,7 +231,7 @@ namespace Microsoft.Data.Analysis return newColumn; <# } #> } - else + else { <# if (method.MethodType == MethodType.BinaryScalar) { #> if (inPlace) @@ -314,7 +314,7 @@ namespace Microsoft.Data.Analysis return newColumn; <# } #> } - else + else { <# if (method.MethodType == MethodType.BinaryScalar) { #> if (inPlace) diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs index 10351efead..66d1d16999 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs @@ -120,6 +120,10 @@ public static IPrimitiveDataFrameColumnArithmetic GetArithmetic() { return (IPrimitiveDataFrameColumnArithmetic)new DateTimeArithmetic(); } + else if (typeof(T) == typeof(DateTime)) + { + return (IPrimitiveDataFrameColumnArithmetic)new DateTimeArithmetic(); + } throw new NotSupportedException(); } } @@ -6663,4 +6667,201 @@ public void ElementwiseLessThan(PrimitiveColumnContainer column, ushort } } } + internal class DateTimeArithmetic : IPrimitiveDataFrameColumnArithmetic + { + public void Add(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Add(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + public void Add(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Subtract(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Subtract(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + public void Subtract(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Multiply(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Multiply(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + public void Multiply(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Divide(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Divide(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + public void Divide(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Modulo(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Modulo(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + public void Modulo(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void And(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void And(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + public void And(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Or(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Or(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + public void Or(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void Xor(PrimitiveColumnContainer left, PrimitiveColumnContainer right) + { + throw new NotSupportedException(); + } + public void Xor(PrimitiveColumnContainer column, DateTime scalar) + { + throw new NotSupportedException(); + } + public void Xor(DateTime scalar, PrimitiveColumnContainer column) + { + throw new NotSupportedException(); + } + public void LeftShift(PrimitiveColumnContainer column, int value) + { + throw new NotSupportedException(); + } + public void RightShift(PrimitiveColumnContainer column, int value) + { + throw new NotSupportedException(); + } + public void ElementwiseEquals(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + for (int b = 0; b < left.Buffers.Count; b++) + { + var buffer = left.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + left.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + var otherSpan = right.Buffers[b].ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] == otherSpan[i]); + } + } + } + public void ElementwiseEquals(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + for (int b = 0; b < column.Buffers.Count; b++) + { + var buffer = column.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + column.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] == scalar); + } + } + } + public void ElementwiseNotEquals(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + for (int b = 0; b < left.Buffers.Count; b++) + { + var buffer = left.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + left.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + var otherSpan = right.Buffers[b].ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] != otherSpan[i]); + } + } + } + public void ElementwiseNotEquals(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + for (int b = 0; b < column.Buffers.Count; b++) + { + var buffer = column.Buffers[b]; + var mutableBuffer = DataFrameBuffer.GetMutableBuffer(buffer); + column.Buffers[b] = mutableBuffer; + var span = mutableBuffer.Span; + for (int i = 0; i < span.Length; i++) + { + ret[i] = (span[i] != scalar); + } + } + } + public void ElementwiseGreaterThanOrEqual(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + throw new NotSupportedException(); + } + public void ElementwiseGreaterThanOrEqual(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + throw new NotSupportedException(); + } + public void ElementwiseLessThanOrEqual(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + throw new NotSupportedException(); + } + public void ElementwiseLessThanOrEqual(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + throw new NotSupportedException(); + } + public void ElementwiseGreaterThan(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + throw new NotSupportedException(); + } + public void ElementwiseGreaterThan(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + throw new NotSupportedException(); + } + public void ElementwiseLessThan(PrimitiveColumnContainer left, PrimitiveColumnContainer right, PrimitiveColumnContainer ret) + { + throw new NotSupportedException(); + } + public void ElementwiseLessThan(PrimitiveColumnContainer column, DateTime scalar, PrimitiveColumnContainer ret) + { + throw new NotSupportedException(); + } + } } diff --git a/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs b/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs index a10004293c..3266dbb131 100644 --- a/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs +++ b/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs @@ -466,6 +466,30 @@ public void TestBinaryOperationsOnBoolColumn() Assert.Equal(true, newdf1[4, 1]); } + [Fact] + public void TestBinaryOperationsOnDateTimeColumn() + { + var df = new DataFrame(); + var dataFrameColumn1 = new DateTimeDataFrameColumn("DateTime1", Enumerable.Range(0, 10).Select(x => SampleDateTime.AddDays(x))); + var dataFrameColumn2 = new DateTimeDataFrameColumn("DateTime2", Enumerable.Range(0, 10).Select(x => SampleDateTime.AddDays(x))); + df.Columns.Insert(0, dataFrameColumn1); + df.Columns.Insert(1, dataFrameColumn2); + + // bool + int should throw + Assert.Throws(() => df.Add(5)); + // Left shift should throw + Assert.Throws(() => df.LeftShift(5)); + // Right shift should throw + Assert.Throws(() => df.RightShift(5)); + + // And should throw + Assert.Throws(() => df.And(true)); + // Or should throw + Assert.Throws(() => df.Or(true)); + // Xor should throw + Assert.Throws(() => df.Xor(true)); + } + [Fact] public void TestBinaryOperationsOnArrowStringColumn() { From 6536a7e92da1461ee72c26676efe8f8ee25724d0 Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Wed, 31 Aug 2022 18:27:59 -0500 Subject: [PATCH 6/9] re-generate all .tt files --- .../PrimitiveColumnContainer.cs | 20 ++++ ...umn.BinaryOperationAPIs.ExplodedColumns.cs | 54 +++++++++ ...BinaryOperationImplementations.Exploded.cs | 108 ++++++++++++++++++ ...ameColumn.BinaryOperations.Combinations.tt | 5 + ...mn.BinaryOperations.Combinations.ttinclude | 1 + ...ataFrameColumn.ReversedBinaryOperations.cs | 10 +- ...ataFrameColumn.ReversedBinaryOperations.tt | 3 - .../PrimitiveDataFrameColumn.cs | 6 + .../PrimitiveDataFrameColumnArithmetic.cs | 4 - .../PrimitiveDataFrameColumnArithmetic.tt | 4 - .../PrimitiveDataFrameColumnComputations.cs | 4 + .../PrimitiveDataFrameColumnComputations.tt | 2 + 12 files changed, 205 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs index 063a9b50af..677d0ee617 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs @@ -846,5 +846,25 @@ internal PrimitiveColumnContainer CloneAsFloatContainer() ret.NullCount = NullCount; return ret; } + + internal PrimitiveColumnContainer CloneAsDateTimeContainer() + { + var ret = new PrimitiveColumnContainer(); + foreach (ReadOnlyDataFrameBuffer buffer in Buffers) + { + ret.Length += buffer.Length; + DataFrameBuffer newBuffer = new DataFrameBuffer(); + ret.Buffers.Add(newBuffer); + newBuffer.EnsureCapacity(buffer.Length); + ReadOnlySpan span = buffer.ReadOnlySpan; + for (int i = 0; i < span.Length; i++) + { + newBuffer.Append((DateTime)(object)span[i]); + } + } + ret.NullBitMapBuffers = CloneNullBitMapBuffers(); + ret.NullCount = NullCount; + return ret; + } } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperationAPIs.ExplodedColumns.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperationAPIs.ExplodedColumns.cs index 51258d1d77..25f36cfdf9 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperationAPIs.ExplodedColumns.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperationAPIs.ExplodedColumns.cs @@ -12248,6 +12248,33 @@ public BooleanDataFrameColumn ElementwiseLessThan(UInt16DataFrameColumn column) return ElementwiseLessThanImplementation(column); } } + public partial class DateTimeDataFrameColumn + { + public BooleanDataFrameColumn ElementwiseEquals(DateTimeDataFrameColumn column) + { + return ElementwiseEqualsImplementation(column); + } + public BooleanDataFrameColumn ElementwiseNotEquals(DateTimeDataFrameColumn column) + { + return ElementwiseNotEqualsImplementation(column); + } + public BooleanDataFrameColumn ElementwiseGreaterThanOrEqual(DateTimeDataFrameColumn column) + { + return ElementwiseGreaterThanOrEqualImplementation(column); + } + public BooleanDataFrameColumn ElementwiseLessThanOrEqual(DateTimeDataFrameColumn column) + { + return ElementwiseLessThanOrEqualImplementation(column); + } + public BooleanDataFrameColumn ElementwiseGreaterThan(DateTimeDataFrameColumn column) + { + return ElementwiseGreaterThanImplementation(column); + } + public BooleanDataFrameColumn ElementwiseLessThan(DateTimeDataFrameColumn column) + { + return ElementwiseLessThanImplementation(column); + } + } public partial class BooleanDataFrameColumn { public BooleanDataFrameColumn ElementwiseEquals(bool value) @@ -15692,6 +15719,33 @@ public BooleanDataFrameColumn ElementwiseLessThan(ushort value) return ElementwiseLessThanImplementation(value); } } + public partial class DateTimeDataFrameColumn + { + public BooleanDataFrameColumn ElementwiseEquals(DateTime value) + { + return ElementwiseEqualsImplementation(value); + } + public BooleanDataFrameColumn ElementwiseNotEquals(DateTime value) + { + return ElementwiseNotEqualsImplementation(value); + } + public BooleanDataFrameColumn ElementwiseGreaterThanOrEqual(DateTime value) + { + return ElementwiseGreaterThanOrEqualImplementation(value); + } + public BooleanDataFrameColumn ElementwiseLessThanOrEqual(DateTime value) + { + return ElementwiseLessThanOrEqualImplementation(value); + } + public BooleanDataFrameColumn ElementwiseGreaterThan(DateTime value) + { + return ElementwiseGreaterThanImplementation(value); + } + public BooleanDataFrameColumn ElementwiseLessThan(DateTime value) + { + return ElementwiseLessThanImplementation(value); + } + } public partial class ByteDataFrameColumn { diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperationImplementations.Exploded.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperationImplementations.Exploded.cs index 9dd963a338..af3ac7e5ee 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperationImplementations.Exploded.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperationImplementations.Exploded.cs @@ -1204,6 +1204,15 @@ internal BooleanDataFrameColumn ElementwiseEqualsImplementation(UInt16DataFrameC return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseEqualsImplementation(DateTimeDataFrameColumn column) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseEquals(column.ColumnContainer, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseEqualsImplementation(bool value) @@ -1312,6 +1321,15 @@ internal BooleanDataFrameColumn ElementwiseEqualsImplementation(ushort value) return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseEqualsImplementation(DateTime value) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseEquals(value, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseNotEqualsImplementation(BooleanDataFrameColumn column) @@ -1420,6 +1438,15 @@ internal BooleanDataFrameColumn ElementwiseNotEqualsImplementation(UInt16DataFra return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseNotEqualsImplementation(DateTimeDataFrameColumn column) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseNotEquals(column.ColumnContainer, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseNotEqualsImplementation(bool value) @@ -1528,6 +1555,15 @@ internal BooleanDataFrameColumn ElementwiseNotEqualsImplementation(ushort value) return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseNotEqualsImplementation(DateTime value) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseNotEquals(value, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseGreaterThanOrEqualImplementation(BooleanDataFrameColumn column) @@ -1636,6 +1672,15 @@ internal BooleanDataFrameColumn ElementwiseGreaterThanOrEqualImplementation(UInt return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseGreaterThanOrEqualImplementation(DateTimeDataFrameColumn column) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseGreaterThanOrEqual(column.ColumnContainer, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseGreaterThanOrEqualImplementation(bool value) @@ -1744,6 +1789,15 @@ internal BooleanDataFrameColumn ElementwiseGreaterThanOrEqualImplementation(usho return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseGreaterThanOrEqualImplementation(DateTime value) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseGreaterThanOrEqual(value, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseLessThanOrEqualImplementation(BooleanDataFrameColumn column) @@ -1852,6 +1906,15 @@ internal BooleanDataFrameColumn ElementwiseLessThanOrEqualImplementation(UInt16D return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseLessThanOrEqualImplementation(DateTimeDataFrameColumn column) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseLessThanOrEqual(column.ColumnContainer, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseLessThanOrEqualImplementation(bool value) @@ -1960,6 +2023,15 @@ internal BooleanDataFrameColumn ElementwiseLessThanOrEqualImplementation(ushort return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseLessThanOrEqualImplementation(DateTime value) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseLessThanOrEqual(value, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseGreaterThanImplementation(BooleanDataFrameColumn column) @@ -2068,6 +2140,15 @@ internal BooleanDataFrameColumn ElementwiseGreaterThanImplementation(UInt16DataF return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseGreaterThanImplementation(DateTimeDataFrameColumn column) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseGreaterThan(column.ColumnContainer, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseGreaterThanImplementation(bool value) @@ -2176,6 +2257,15 @@ internal BooleanDataFrameColumn ElementwiseGreaterThanImplementation(ushort valu return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseGreaterThanImplementation(DateTime value) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseGreaterThan(value, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseLessThanImplementation(BooleanDataFrameColumn column) @@ -2284,6 +2374,15 @@ internal BooleanDataFrameColumn ElementwiseLessThanImplementation(UInt16DataFram return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseLessThanImplementation(DateTimeDataFrameColumn column) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseLessThan(column.ColumnContainer, newColumn.ColumnContainer); + return newColumn; + } + } public partial class BooleanDataFrameColumn { internal BooleanDataFrameColumn ElementwiseLessThanImplementation(bool value) @@ -2392,4 +2491,13 @@ internal BooleanDataFrameColumn ElementwiseLessThanImplementation(ushort value) return newColumn; } } + public partial class DateTimeDataFrameColumn + { + internal BooleanDataFrameColumn ElementwiseLessThanImplementation(DateTime value) + { + BooleanDataFrameColumn newColumn = CloneAsBooleanColumn(); + ColumnContainer.ElementwiseLessThan(value, newColumn.ColumnContainer); + return newColumn; + } + } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.Combinations.tt b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.Combinations.tt index 33f0a0ad72..b1ea4e40bb 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.Combinations.tt +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.Combinations.tt @@ -86,10 +86,15 @@ public static class ComparisonOperationCombinations { continue; } + // Bool should only compare with bool, DateTime only with DateTime if (type.TypeName == "bool" && innerType.TypeName != "bool") { continue; } + if (type.TypeName == "DateTime" && innerType.TypeName != "DateTime") + { + continue; + } if (type.SupportsNumeric != innerType.SupportsNumeric) { continue; diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.Combinations.ttinclude b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.Combinations.ttinclude index 23a88d1f12..946e0a7e12 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.Combinations.ttinclude +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.BinaryOperations.Combinations.ttinclude @@ -266,6 +266,7 @@ public static class ComparisonOperationCombinations new TypeCombination("ushort", "uint", "bool"), new TypeCombination("ushort", "ulong", "bool"), new TypeCombination("ushort", "ushort", "bool"), + new TypeCombination("DateTime", "DateTime", "bool"), }; } #> diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.ReversedBinaryOperations.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.ReversedBinaryOperations.cs index 80f003cd68..3cc07217e3 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.ReversedBinaryOperations.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.ReversedBinaryOperations.cs @@ -55,6 +55,7 @@ public override DataFrameColumn ReverseAdd(U value, bool inPlace = false) case PrimitiveDataFrameColumn uintColumn: case PrimitiveDataFrameColumn ulongColumn: case PrimitiveDataFrameColumn ushortColumn: + case PrimitiveDataFrameColumn DateTimeColumn: if (typeof(U) == typeof(bool)) { throw new NotSupportedException(); @@ -129,6 +130,7 @@ public override DataFrameColumn ReverseSubtract(U value, bool inPlace = false case PrimitiveDataFrameColumn uintColumn: case PrimitiveDataFrameColumn ulongColumn: case PrimitiveDataFrameColumn ushortColumn: + case PrimitiveDataFrameColumn DateTimeColumn: if (typeof(U) == typeof(bool)) { throw new NotSupportedException(); @@ -203,6 +205,7 @@ public override DataFrameColumn ReverseMultiply(U value, bool inPlace = false case PrimitiveDataFrameColumn uintColumn: case PrimitiveDataFrameColumn ulongColumn: case PrimitiveDataFrameColumn ushortColumn: + case PrimitiveDataFrameColumn DateTimeColumn: if (typeof(U) == typeof(bool)) { throw new NotSupportedException(); @@ -277,6 +280,7 @@ public override DataFrameColumn ReverseDivide(U value, bool inPlace = false) case PrimitiveDataFrameColumn uintColumn: case PrimitiveDataFrameColumn ulongColumn: case PrimitiveDataFrameColumn ushortColumn: + case PrimitiveDataFrameColumn DateTimeColumn: if (typeof(U) == typeof(bool)) { throw new NotSupportedException(); @@ -351,6 +355,7 @@ public override DataFrameColumn ReverseModulo(U value, bool inPlace = false) case PrimitiveDataFrameColumn uintColumn: case PrimitiveDataFrameColumn ulongColumn: case PrimitiveDataFrameColumn ushortColumn: + case PrimitiveDataFrameColumn DateTimeColumn: if (typeof(U) == typeof(bool)) { throw new NotSupportedException(); @@ -396,7 +401,6 @@ public override PrimitiveDataFrameColumn ReverseAnd(bool value, bool inPla return retColumn; default: throw new NotSupportedException(); - } } /// @@ -410,7 +414,6 @@ public override PrimitiveDataFrameColumn ReverseOr(bool value, bool inPlac return retColumn; default: throw new NotSupportedException(); - } } /// @@ -424,10 +427,7 @@ public override PrimitiveDataFrameColumn ReverseXor(bool value, bool inPla return retColumn; default: throw new NotSupportedException(); - } } - - } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.ReversedBinaryOperations.tt b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.ReversedBinaryOperations.tt index 68382f5b92..6bb592486e 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.ReversedBinaryOperations.tt +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.ReversedBinaryOperations.tt @@ -40,7 +40,6 @@ namespace Microsoft.Data.Analysis return retColumn; default: throw new NotSupportedException(); - } <# } else { #> switch (this) @@ -113,7 +112,5 @@ namespace Microsoft.Data.Analysis } <# } #> <# } #> - - } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs index 3cd6799780..c8ddf6487d 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs @@ -520,6 +520,12 @@ internal SingleDataFrameColumn CloneAsSingleColumn() return new SingleDataFrameColumn(Name, newColumnContainer); } + internal DateTimeDataFrameColumn CloneAsDateTimeColumn() + { + PrimitiveColumnContainer newColumnContainer = _columnContainer.CloneAsDateTimeContainer(); + return new DateTimeDataFrameColumn(Name, newColumnContainer); + } + /// public override GroupBy GroupBy(int columnIndex, DataFrame parent) { diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs index 66d1d16999..f432805185 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.cs @@ -120,10 +120,6 @@ public static IPrimitiveDataFrameColumnArithmetic GetArithmetic() { return (IPrimitiveDataFrameColumnArithmetic)new DateTimeArithmetic(); } - else if (typeof(T) == typeof(DateTime)) - { - return (IPrimitiveDataFrameColumnArithmetic)new DateTimeArithmetic(); - } throw new NotSupportedException(); } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt index 90b9009396..0c04fe549e 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnArithmetic.tt @@ -45,10 +45,6 @@ namespace Microsoft.Data.Analysis return (IPrimitiveDataFrameColumnArithmetic)new <#=type.ClassPrefix#>Arithmetic(); } <# } #> - else if (typeof(T) == typeof(DateTime)) - { - return (IPrimitiveDataFrameColumnArithmetic)new DateTimeArithmetic(); - } throw new NotSupportedException(); } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.cs index afca6d48e1..a4c5d73b0d 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.cs @@ -103,6 +103,10 @@ public static IPrimitiveColumnComputation GetComputation() { return (IPrimitiveColumnComputation)new DateTimeComputation(); } + else if (typeof(T) == typeof(DateTime)) + { + return (IPrimitiveColumnComputation)new DateTimeComputation(); + } throw new NotSupportedException(); } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.tt b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.tt index 3532b5f281..12523d2eb4 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.tt +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.tt @@ -65,6 +65,8 @@ namespace Microsoft.Data.Analysis } <# foreach (TypeConfiguration type in typeConfiguration) { #> +<# if (type.TypeName == "DateTime") {#> +<# continue; }#> internal class <#=type.ClassPrefix#>Computation : IPrimitiveColumnComputation<<#=type.TypeName#>> { <# foreach (MethodConfiguration method in computationMethodConfiguration) { #> From f30925e0d67585fd9a139c17d30d34b5ac45e7e0 Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Thu, 1 Sep 2022 11:25:49 -0500 Subject: [PATCH 7/9] add DateTime computation comment --- .../PrimitiveDataFrameColumnComputations.tt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.tt b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.tt index 12523d2eb4..e71fc10a90 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.tt +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumnComputations.tt @@ -66,6 +66,7 @@ namespace Microsoft.Data.Analysis <# foreach (TypeConfiguration type in typeConfiguration) { #> <# if (type.TypeName == "DateTime") {#> +<# // DateTime computation in DateTimeComputation.cs #> <# continue; }#> internal class <#=type.ClassPrefix#>Computation : IPrimitiveColumnComputation<<#=type.TypeName#>> { From 998397ae39e4f29bcfbfbf4f99626cef3270eb92 Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Wed, 7 Sep 2022 17:13:52 -0500 Subject: [PATCH 8/9] remove the unecessary CloneAsDateTime --- .../PrimitiveColumnContainer.cs | 20 ------------------- .../PrimitiveDataFrameColumn.cs | 6 ------ 2 files changed, 26 deletions(-) diff --git a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs index 677d0ee617..063a9b50af 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs @@ -846,25 +846,5 @@ internal PrimitiveColumnContainer CloneAsFloatContainer() ret.NullCount = NullCount; return ret; } - - internal PrimitiveColumnContainer CloneAsDateTimeContainer() - { - var ret = new PrimitiveColumnContainer(); - foreach (ReadOnlyDataFrameBuffer buffer in Buffers) - { - ret.Length += buffer.Length; - DataFrameBuffer newBuffer = new DataFrameBuffer(); - ret.Buffers.Add(newBuffer); - newBuffer.EnsureCapacity(buffer.Length); - ReadOnlySpan span = buffer.ReadOnlySpan; - for (int i = 0; i < span.Length; i++) - { - newBuffer.Append((DateTime)(object)span[i]); - } - } - ret.NullBitMapBuffers = CloneNullBitMapBuffers(); - ret.NullCount = NullCount; - return ret; - } } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs index c8ddf6487d..3cd6799780 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs @@ -520,12 +520,6 @@ internal SingleDataFrameColumn CloneAsSingleColumn() return new SingleDataFrameColumn(Name, newColumnContainer); } - internal DateTimeDataFrameColumn CloneAsDateTimeColumn() - { - PrimitiveColumnContainer newColumnContainer = _columnContainer.CloneAsDateTimeContainer(); - return new DateTimeDataFrameColumn(Name, newColumnContainer); - } - /// public override GroupBy GroupBy(int columnIndex, DataFrame parent) { From 03b7b8adad379895df57053100dc2674bfed0624 Mon Sep 17 00:00:00 2001 From: Becca McHenry Date: Wed, 7 Sep 2022 18:34:05 -0500 Subject: [PATCH 9/9] add more equality test support --- .../DataFrameTests.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs b/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs index 3266dbb131..31263b4eff 100644 --- a/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs +++ b/test/Microsoft.Data.Analysis.Tests/DataFrameTests.cs @@ -470,12 +470,14 @@ public void TestBinaryOperationsOnBoolColumn() public void TestBinaryOperationsOnDateTimeColumn() { var df = new DataFrame(); - var dataFrameColumn1 = new DateTimeDataFrameColumn("DateTime1", Enumerable.Range(0, 10).Select(x => SampleDateTime.AddDays(x))); - var dataFrameColumn2 = new DateTimeDataFrameColumn("DateTime2", Enumerable.Range(0, 10).Select(x => SampleDateTime.AddDays(x))); + var dataFrameColumn1 = new DateTimeDataFrameColumn("DateTime1", Enumerable.Range(0, 5).Select(x => SampleDateTime.AddDays(x))); + // Make the second data frame column have one value that is different + var dataFrameColumn2 = new DateTimeDataFrameColumn("DateTime2", Enumerable.Range(0, 4).Select(x => SampleDateTime.AddDays(x))); + dataFrameColumn2.Append(SampleDateTime.AddDays(6)); df.Columns.Insert(0, dataFrameColumn1); df.Columns.Insert(1, dataFrameColumn2); - // bool + int should throw + // DateTime + int should throw Assert.Throws(() => df.Add(5)); // Left shift should throw Assert.Throws(() => df.LeftShift(5)); @@ -488,6 +490,14 @@ public void TestBinaryOperationsOnDateTimeColumn() Assert.Throws(() => df.Or(true)); // Xor should throw Assert.Throws(() => df.Xor(true)); + + var equalsResult = dataFrameColumn1.ElementwiseEquals(dataFrameColumn2); + Assert.True(equalsResult[0]); + Assert.False(equalsResult[4]); + + var notEqualsResult = dataFrameColumn1.ElementwiseNotEquals(dataFrameColumn2); + Assert.False(notEqualsResult[0]); + Assert.True(notEqualsResult[4]); } [Fact]