From 80d2acc73bba95a9c41ef98f39cd6759ff42e565 Mon Sep 17 00:00:00 2001 From: Aleksei Smirnov Date: Thu, 19 Oct 2023 12:37:46 +0300 Subject: [PATCH 1/3] Increase performance of elementwise comparison operations --- .../ArrowStringDataFrameColumn.cs | 2 +- src/Microsoft.Data.Analysis/BitUtility.cs | 2 +- .../Computations/Arithmetic.cs | 52 +- .../Computations/Arithmetic.tt | 12 +- .../Computations/Arithmetics.cs | 608 +++++++++--------- .../Computations/Arithmetics.tt | 8 +- .../Computations/IArithmetic.cs | 4 +- .../DataFrameBuffer.cs | 4 +- ...imitiveColumnContainer.BinaryOperations.cs | 65 +- .../PrimitiveColumnContainer.cs | 28 +- .../PrimitiveDataFrameColumn.cs | 18 +- .../StringDataFrameColumn.cs | 2 +- .../Strings.Designer.cs | 18 +- src/Microsoft.Data.Analysis/Strings.resx | 6 +- .../VBufferDataFrameColumn.cs | 2 +- 15 files changed, 441 insertions(+), 390 deletions(-) diff --git a/src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs b/src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs index d0b9479e17..0d61a4aeaf 100644 --- a/src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs @@ -226,7 +226,7 @@ private int GetBufferIndexContainingRowIndex(long rowIndex, out int indexInBuffe { if (rowIndex >= Length) { - throw new ArgumentOutOfRangeException(Strings.ColumnIndexOutOfRange, nameof(rowIndex)); + throw new ArgumentOutOfRangeException(Strings.RowIndexOutOfRange, nameof(rowIndex)); } // Since the strings here could be of variable length, scan linearly diff --git a/src/Microsoft.Data.Analysis/BitUtility.cs b/src/Microsoft.Data.Analysis/BitUtility.cs index a95a22e49e..7377d744c3 100644 --- a/src/Microsoft.Data.Analysis/BitUtility.cs +++ b/src/Microsoft.Data.Analysis/BitUtility.cs @@ -148,7 +148,7 @@ public static long GetBitCount(ReadOnlySpan span, long length) { var endByteIndex = (int)(length / 8); - Debug.Assert(span.Length > endByteIndex); + Debug.Assert(span.Length >= endByteIndex); long count = 0; for (var i = 0; i < endByteIndex; i++) diff --git a/src/Microsoft.Data.Analysis/Computations/Arithmetic.cs b/src/Microsoft.Data.Analysis/Computations/Arithmetic.cs index e98acbdeee..41d267dd63 100644 --- a/src/Microsoft.Data.Analysis/Computations/Arithmetic.cs +++ b/src/Microsoft.Data.Analysis/Computations/Arithmetic.cs @@ -192,52 +192,52 @@ public void HandleOperation(BinaryIntOperation operation, ReadOnlySpan x, int //Comparison operations - public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, ReadOnlySpan y, Span destination) { switch (operation) { case ComparisonOperation.ElementwiseEquals: - ElementwiseEquals(x, y, result, offset); + ElementwiseEquals(x, y, destination); break; case ComparisonOperation.ElementwiseNotEquals: - ElementwiseNotEquals(x, y, result, offset); + ElementwiseNotEquals(x, y, destination); break; case ComparisonOperation.ElementwiseGreaterThanOrEqual: - ElementwiseGreaterThanOrEqual(x, y, result, offset); + ElementwiseGreaterThanOrEqual(x, y, destination); break; case ComparisonOperation.ElementwiseLessThanOrEqual: - ElementwiseLessThanOrEqual(x, y, result, offset); + ElementwiseLessThanOrEqual(x, y, destination); break; case ComparisonOperation.ElementwiseGreaterThan: - ElementwiseGreaterThan(x, y, result, offset); + ElementwiseGreaterThan(x, y, destination); break; case ComparisonOperation.ElementwiseLessThan: - ElementwiseLessThan(x, y, result, offset); + ElementwiseLessThan(x, y, destination); break; } } - public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) + public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, T y, Span destination) { switch (operation) { case ComparisonOperation.ElementwiseEquals: - ElementwiseEquals(x, y, result, offset); + ElementwiseEquals(x, y, destination); break; case ComparisonOperation.ElementwiseNotEquals: - ElementwiseNotEquals(x, y, result, offset); + ElementwiseNotEquals(x, y, destination); break; case ComparisonOperation.ElementwiseGreaterThanOrEqual: - ElementwiseGreaterThanOrEqual(x, y, result, offset); + ElementwiseGreaterThanOrEqual(x, y, destination); break; case ComparisonOperation.ElementwiseLessThanOrEqual: - ElementwiseLessThanOrEqual(x, y, result, offset); + ElementwiseLessThanOrEqual(x, y, destination); break; case ComparisonOperation.ElementwiseGreaterThan: - ElementwiseGreaterThan(x, y, result, offset); + ElementwiseGreaterThan(x, y, destination); break; case ComparisonOperation.ElementwiseLessThan: - ElementwiseLessThan(x, y, result, offset); + ElementwiseLessThan(x, y, destination); break; } } @@ -297,29 +297,29 @@ public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, T protected virtual void RightShift(ReadOnlySpan x, int y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseEquals(ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseEquals(ReadOnlySpan x, T y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseNotEquals(ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseNotEquals(ReadOnlySpan x, T y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, T y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseLessThanOrEqual(ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseLessThanOrEqual(ReadOnlySpan x, T y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseGreaterThan(ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseGreaterThan(ReadOnlySpan x, T y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) => throw new NotSupportedException(); - protected virtual void ElementwiseLessThan(ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void ElementwiseLessThan(ReadOnlySpan x, T y, Span destination) => throw new NotSupportedException(); protected virtual T Divide(T x, T y) => throw new NotSupportedException(); diff --git a/src/Microsoft.Data.Analysis/Computations/Arithmetic.tt b/src/Microsoft.Data.Analysis/Computations/Arithmetic.tt index 426bfeda37..f0e84c501f 100644 --- a/src/Microsoft.Data.Analysis/Computations/Arithmetic.tt +++ b/src/Microsoft.Data.Analysis/Computations/Arithmetic.tt @@ -125,28 +125,28 @@ namespace Microsoft.Data.Analysis //Comparison operations - public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, ReadOnlySpan y, Span destination) { switch (operation) { <# foreach (MethodConfiguration method in methodConfiguration) { #> <# if (method.MethodType == MethodType.Comparison) { #> case ComparisonOperation.<#=method.MethodName#>: - <#=method.MethodName#>(x, y, result, offset); + <#=method.MethodName#>(x, y, destination); break; <# } #> <# } #> } } - public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) + public void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, T y, Span destination) { switch (operation) { <# foreach (MethodConfiguration method in methodConfiguration) { #> <# if (method.MethodType == MethodType.ComparisonScalar) { #> case ComparisonOperation.<#=method.MethodName#>: - <#=method.MethodName#>(x, y, result, offset); + <#=method.MethodName#>(x, y, destination); break; <# } #> <# } #> @@ -158,11 +158,11 @@ namespace Microsoft.Data.Analysis <# foreach (MethodConfiguration method in methodConfiguration) { #> <# if (method.MethodType == MethodType.Comparison) { #> - protected virtual void <#=method.MethodName#>(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void <#=method.MethodName#>(ReadOnlySpan x, ReadOnlySpan y, Span destination) => throw new NotSupportedException(); <# } #> <# else if (method.MethodType == MethodType.ComparisonScalar) { #> - protected virtual void <#=method.MethodName#>(ReadOnlySpan x, T y, PrimitiveColumnContainer result, long offset) => throw new NotSupportedException(); + protected virtual void <#=method.MethodName#>(ReadOnlySpan x, T y, Span destination) => throw new NotSupportedException(); <# } #> <# else if (method.MethodType == MethodType.Binary) { #> diff --git a/src/Microsoft.Data.Analysis/Computations/Arithmetics.cs b/src/Microsoft.Data.Analysis/Computations/Arithmetics.cs index 4de6a52677..30bbefff36 100644 --- a/src/Microsoft.Data.Analysis/Computations/Arithmetics.cs +++ b/src/Microsoft.Data.Analysis/Computations/Arithmetics.cs @@ -113,35 +113,35 @@ protected override void Xor(bool x, ReadOnlySpan y, Span destination } } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, bool y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, bool y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, bool y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, bool y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } } @@ -518,99 +518,99 @@ protected override void RightShift(ReadOnlySpan x, int y, Span desti destination[i] = (byte)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, byte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, byte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, byte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, byte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, byte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, byte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, byte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, byte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, byte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, byte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, byte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, byte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -987,99 +987,99 @@ protected override void RightShift(ReadOnlySpan x, int y, Span desti destination[i] = (char)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, char y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, char y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, char y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, char y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, char y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, char y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, char y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, char y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, char y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, char y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, char y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, char y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -1261,99 +1261,99 @@ protected override void Modulo(decimal x, ReadOnlySpan y, Span } } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, decimal y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, decimal y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, decimal y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, decimal y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, decimal y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, decimal y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, decimal y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, decimal y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, decimal y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, decimal y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, decimal y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, decimal y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -1619,99 +1619,99 @@ protected override void Modulo(double x, ReadOnlySpan y, Span de } } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, double y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, double y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, double y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, double y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, double y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, double y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, double y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, double y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, double y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, double y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, double y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, double y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -1977,99 +1977,99 @@ protected override void Modulo(float x, ReadOnlySpan y, Span desti } } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, float y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, float y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, float y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, float y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, float y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, float y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, float y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, float y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, float y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, float y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, float y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, float y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -2446,99 +2446,99 @@ protected override void RightShift(ReadOnlySpan x, int y, Span destina destination[i] = (int)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, int y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, int y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, int y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, int y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, int y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, int y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, int y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, int y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, int y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, int y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, int y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, int y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -2915,99 +2915,99 @@ protected override void RightShift(ReadOnlySpan x, int y, Span desti destination[i] = (long)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, long y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, long y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, long y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, long y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, long y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, long y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, long y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, long y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, long y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, long y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, long y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, long y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -3384,99 +3384,99 @@ protected override void RightShift(ReadOnlySpan x, int y, Span des destination[i] = (sbyte)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, sbyte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, sbyte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, sbyte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, sbyte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, sbyte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, sbyte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, sbyte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, sbyte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, sbyte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, sbyte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, sbyte y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, sbyte y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -3853,99 +3853,99 @@ protected override void RightShift(ReadOnlySpan x, int y, Span des destination[i] = (short)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, short y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, short y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, short y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, short y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, short y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, short y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, short y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, short y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, short y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, short y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, short y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, short y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -4322,99 +4322,99 @@ protected override void RightShift(ReadOnlySpan x, int y, Span desti destination[i] = (uint)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, uint y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, uint y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, uint y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, uint y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, uint y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, uint y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, uint y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, uint y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, uint y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, uint y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, uint y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, uint y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -4791,99 +4791,99 @@ protected override void RightShift(ReadOnlySpan x, int y, Span des destination[i] = (ulong)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, ulong y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ulong y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ulong y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ulong y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ulong y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ulong y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ulong y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ulong y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ulong y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ulong y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ulong y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ulong y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } @@ -5260,134 +5260,134 @@ protected override void RightShift(ReadOnlySpan x, int y, Span d destination[i] = (ushort)(x[i] >> y); } - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, ushort y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ushort y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ushort y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ushort y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y[i]); + destination[i] = (x[i] >= y[i]); } } - protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ushort y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThanOrEqual(ReadOnlySpan x, ushort y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] >= y); + destination[i] = (x[i] >= y); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y[i]); + destination[i] = (x[i] <= y[i]); } } - protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ushort y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThanOrEqual(ReadOnlySpan x, ushort y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <= y); + destination[i] = (x[i] <= y); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y[i]); + destination[i] = (x[i] > y[i]); } } - protected override void ElementwiseGreaterThan(ReadOnlySpan x, ushort y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseGreaterThan(ReadOnlySpan x, ushort y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] > y); + destination[i] = (x[i] > y); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y[i]); + destination[i] = (x[i] < y[i]); } } - protected override void ElementwiseLessThan(ReadOnlySpan x, ushort y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseLessThan(ReadOnlySpan x, ushort y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] < y); + destination[i] = (x[i] < y); } } } internal class DateTimeArithmetic : Arithmetic { - protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y[i]); + destination[i] = (x[i] == y[i]); } } - protected override void ElementwiseEquals(ReadOnlySpan x, DateTime y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseEquals(ReadOnlySpan x, DateTime y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] == y); + destination[i] = (x[i] == y); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, ReadOnlySpan y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y[i]); + destination[i] = (x[i] != y[i]); } } - protected override void ElementwiseNotEquals(ReadOnlySpan x, DateTime y, PrimitiveColumnContainer result, long offset) + protected override void ElementwiseNotEquals(ReadOnlySpan x, DateTime y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] != y); + destination[i] = (x[i] != y); } } } diff --git a/src/Microsoft.Data.Analysis/Computations/Arithmetics.tt b/src/Microsoft.Data.Analysis/Computations/Arithmetics.tt index 200739953a..7971b09de4 100644 --- a/src/Microsoft.Data.Analysis/Computations/Arithmetics.tt +++ b/src/Microsoft.Data.Analysis/Computations/Arithmetics.tt @@ -25,20 +25,20 @@ namespace Microsoft.Data.Analysis <# if (!((method.IsNumeric && !type.SupportsNumeric) || (method.IsBitwise && !type.SupportsBitwise) || (type.UnsupportedMethods.Contains(method.MethodName))) && method.Operator != null) { #> <# if (method.MethodType == MethodType.Comparison) { #> - protected override void <#=method.MethodName#>(ReadOnlySpan<<#=type.TypeName#>> x, ReadOnlySpan<<#=type.TypeName#>> y, PrimitiveColumnContainer result, long offset) + protected override void <#=method.MethodName#>(ReadOnlySpan<<#=type.TypeName#>> x, ReadOnlySpan<<#=type.TypeName#>> y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <#= method.Operator #> y[i]); + destination[i] = (x[i] <#= method.Operator #> y[i]); } } <# } else if (method.MethodType == MethodType.ComparisonScalar) {#> - protected override void <#=method.MethodName#>(ReadOnlySpan<<#=type.TypeName#>> x, <#=type.TypeName#> y, PrimitiveColumnContainer result, long offset) + protected override void <#=method.MethodName#>(ReadOnlySpan<<#=type.TypeName#>> x, <#=type.TypeName#> y, Span destination) { for (var i = 0; i < x.Length; i++) { - result[i + offset] = (x[i] <#= method.Operator #> y); + destination[i] = (x[i] <#= method.Operator #> y); } } <# } else if (method.MethodType == MethodType.Binary) { #> diff --git a/src/Microsoft.Data.Analysis/Computations/IArithmetic.cs b/src/Microsoft.Data.Analysis/Computations/IArithmetic.cs index 8d3342462d..c35422275b 100644 --- a/src/Microsoft.Data.Analysis/Computations/IArithmetic.cs +++ b/src/Microsoft.Data.Analysis/Computations/IArithmetic.cs @@ -22,7 +22,7 @@ internal interface IArithmetic void HandleOperation(BinaryIntOperation operation, ReadOnlySpan x, int y, Span destination); //Comparison operations - void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, ReadOnlySpan y, PrimitiveColumnContainer destination, long offset); - void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, T y, PrimitiveColumnContainer destination, long offset); + void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, ReadOnlySpan y, Span destination); + void HandleOperation(ComparisonOperation operation, ReadOnlySpan x, T y, Span destination); } } diff --git a/src/Microsoft.Data.Analysis/DataFrameBuffer.cs b/src/Microsoft.Data.Analysis/DataFrameBuffer.cs index 23b16629d7..1a09ef3ce7 100644 --- a/src/Microsoft.Data.Analysis/DataFrameBuffer.cs +++ b/src/Microsoft.Data.Analysis/DataFrameBuffer.cs @@ -40,12 +40,12 @@ public Span RawSpan public DataFrameBuffer(int capacity = 0) { - if ((long)capacity * Size > MaxCapacity) + if ((long)capacity > MaxCapacity) { throw new ArgumentException($"{capacity} exceeds buffer capacity", nameof(capacity)); } - _memory = new byte[Math.Max(capacity, MinCapacity)]; + _memory = new byte[Math.Max(capacity, MinCapacity) * Size]; } internal DataFrameBuffer(ReadOnlyMemory buffer, int length) diff --git a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.BinaryOperations.cs b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.BinaryOperations.cs index 37589b9d3f..2388905c07 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.BinaryOperations.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.BinaryOperations.cs @@ -107,17 +107,41 @@ public PrimitiveColumnContainer HandleOperation(BinaryIntOperation operation, public PrimitiveColumnContainer HandleOperation(ComparisonOperation operation, PrimitiveColumnContainer right) { + var ret = new PrimitiveColumnContainer(Length, false); var arithmetic = Arithmetic.Instance; - var ret = new PrimitiveColumnContainer(Length); - long offset = 0; + //Size of any buffer in PrimitiveColumnContainer is larger (or equal) than size of the buffers for other types + long index = 0; for (int i = 0; i < this.Buffers.Count; i++) { var leftSpan = this.Buffers[i].ReadOnlySpan; var rightSpan = right.Buffers[i].ReadOnlySpan; - arithmetic.HandleOperation(operation, leftSpan, rightSpan, ret, offset); - offset += leftSpan.Length; + // Get correct ret Span for storing results + var retSpanIndex = ret.GetIndexOfBufferContainingRowIndex(index); + var retSpan = ret.Buffers.GetOrCreateMutable(retSpanIndex).Span; + + //Get offset in the buffer to store new data + var retOffset = (int)(index % DataFrameBuffer.MaxCapacity); + + //Check if there is enought space in the current ret buffer + var availableInRetSpan = DataFrameBuffer.MaxCapacity - retOffset; + if (availableInRetSpan < leftSpan.Length) + { + //We are not able to place all results into remaining space into our ret buffer, have to split the results + + //This will be simplified when the size of buffers of different types are done equal + //(not supported by classic .Net framework due to the 2 Gb limitation on array size) + + arithmetic.HandleOperation(operation, leftSpan.Slice(0, availableInRetSpan), rightSpan.Slice(0, availableInRetSpan), retSpan.Slice(retOffset)); + + var nextRetSpan = ret.Buffers.GetOrCreateMutable(retSpanIndex + 1).Span; + arithmetic.HandleOperation(operation, leftSpan.Slice(availableInRetSpan), rightSpan.Slice(availableInRetSpan), nextRetSpan); + } + else + arithmetic.HandleOperation(operation, leftSpan, rightSpan, retSpan.Slice(retOffset)); + + index += leftSpan.Length; } return ret; @@ -125,14 +149,41 @@ public PrimitiveColumnContainer HandleOperation(ComparisonOperation operat public PrimitiveColumnContainer HandleOperation(ComparisonOperation operation, T right) { - var ret = new PrimitiveColumnContainer(Length); - long offset = 0; + var ret = new PrimitiveColumnContainer(Length, false); var arithmetic = Arithmetic.Instance; + + //Size of any buffer in PrimitiveColumnContainer is larger (or equal) than size of the buffers for other types + long index = 0; for (int i = 0; i < this.Buffers.Count; i++) { var leftSpan = this.Buffers[i].ReadOnlySpan; - arithmetic.HandleOperation(operation, leftSpan, right, ret, offset); + //Get correct ret Span for storing results + var retSpanIndex = ret.GetIndexOfBufferContainingRowIndex(index); + var retSpan = ret.Buffers.GetOrCreateMutable(retSpanIndex).Span; + + //Get offset in the buffer to store new data + var retOffset = (int)(index % DataFrameBuffer.MaxCapacity); + + //Check if there is enought space in the current ret buffer + var availableInRetSpan = DataFrameBuffer.MaxCapacity - retOffset; + + if (availableInRetSpan < leftSpan.Length) + { + //We are not able to place all results into remaining space into our ret buffer, have to split the results + + //This will be simplified when the size of buffers of different types are done equal + //(not supported by classic .Net framework due to the 2 Gb limitation on array size) + + arithmetic.HandleOperation(operation, leftSpan.Slice(0, availableInRetSpan), right, retSpan.Slice(retOffset)); + + var nextRetSpan = ret.Buffers.GetOrCreateMutable(retSpanIndex + 1).Span; + arithmetic.HandleOperation(operation, leftSpan.Slice(availableInRetSpan), right, nextRetSpan); + } + else + arithmetic.HandleOperation(operation, leftSpan, right, retSpan.Slice(retOffset)); + + index += leftSpan.Length; } return ret; diff --git a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs index 876fbf9516..ed1596450e 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs @@ -98,9 +98,9 @@ public PrimitiveColumnContainer(ReadOnlyMemory buffer, ReadOnlyMemory= Length) { - throw new ArgumentOutOfRangeException(Strings.ColumnIndexOutOfRange, nameof(rowIndex)); + throw new ArgumentOutOfRangeException(Strings.RowIndexOutOfRange, nameof(rowIndex)); } return (int)(rowIndex / ReadOnlyDataFrameBuffer.MaxCapacity); } @@ -322,9 +322,9 @@ internal int MaxRecordBatchLength(long startIndex) { if (Length == 0) return 0; - int arrayIndex = GetArrayContainingRowIndex(startIndex); - startIndex = startIndex - arrayIndex * ReadOnlyDataFrameBuffer.MaxCapacity; - return Buffers[arrayIndex].Length - (int)startIndex; + int bufferIndex = GetIndexOfBufferContainingRowIndex(startIndex); + startIndex = startIndex - bufferIndex * ReadOnlyDataFrameBuffer.MaxCapacity; + return Buffers[bufferIndex].Length - (int)startIndex; } public IReadOnlyList this[long startIndex, int length] @@ -349,26 +349,26 @@ public T? this[long rowIndex] { return null; } - int arrayIndex = GetArrayContainingRowIndex(rowIndex); + int bufferIndex = GetIndexOfBufferContainingRowIndex(rowIndex); var bufferOffset = (int)(rowIndex % ReadOnlyDataFrameBuffer.MaxCapacity); - return Buffers[arrayIndex][bufferOffset]; + return Buffers[bufferIndex][bufferOffset]; } set { - int arrayIndex = GetArrayContainingRowIndex(rowIndex); + int bufferIndex = GetIndexOfBufferContainingRowIndex(rowIndex); var bufferOffset = (int)(rowIndex % ReadOnlyDataFrameBuffer.MaxCapacity); - Buffers.GetOrCreateMutable(arrayIndex); - NullBitMapBuffers.GetOrCreateMutable(arrayIndex); + Buffers.GetOrCreateMutable(bufferIndex); + NullBitMapBuffers.GetOrCreateMutable(bufferIndex); if (value.HasValue) { - Buffers[arrayIndex][bufferOffset] = value.Value; + Buffers[bufferIndex][bufferOffset] = value.Value; SetValidityBit(rowIndex, true); } else { - Buffers[arrayIndex][bufferOffset] = default; + Buffers[bufferIndex][bufferOffset] = default; SetValidityBit(rowIndex, false); } } diff --git a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs index 754e234b08..61299fecc6 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs @@ -27,9 +27,9 @@ public partial class PrimitiveDataFrameColumn : DataFrameColumn, IEnumerable< internal PrimitiveColumnContainer ColumnContainer => _columnContainer; - internal PrimitiveDataFrameColumn(string name, PrimitiveColumnContainer column) : base(name, column.Length, typeof(T)) + internal PrimitiveDataFrameColumn(string name, PrimitiveColumnContainer columnContainer) : base(name, columnContainer.Length, typeof(T)) { - _columnContainer = column; + _columnContainer = columnContainer; } public PrimitiveDataFrameColumn(string name, IEnumerable values) : base(name, 0, typeof(T)) @@ -129,10 +129,10 @@ private int GetNullCount(long startIndex, int numberOfRows) protected internal override Apache.Arrow.Array ToArrowArray(long startIndex, int numberOfRows) { - int arrayIndex = numberOfRows == 0 ? 0 : _columnContainer.GetArrayContainingRowIndex(startIndex); - int offset = (int)(startIndex - arrayIndex * ReadOnlyDataFrameBuffer.MaxCapacity); + int bufferIndex = numberOfRows == 0 ? 0 : _columnContainer.GetIndexOfBufferContainingRowIndex(startIndex); + int offset = (int)(startIndex - bufferIndex * ReadOnlyDataFrameBuffer.MaxCapacity); - if (numberOfRows != 0 && numberOfRows > _columnContainer.Buffers[arrayIndex].Length - offset) + if (numberOfRows != 0 && numberOfRows > _columnContainer.Buffers[bufferIndex].Length - offset) { throw new ArgumentException(Strings.SpansMultipleBuffers, nameof(numberOfRows)); } @@ -145,8 +145,8 @@ protected internal override Apache.Arrow.Array ToArrowArray(long startIndex, int if (numberOfRows == 0) return new Date64Array(ArrowBuffer.Empty, ArrowBuffer.Empty, numberOfRows, nullCount, offset); - ReadOnlyDataFrameBuffer valueBuffer = (numberOfRows == 0) ? null : _columnContainer.Buffers[arrayIndex]; - ReadOnlyDataFrameBuffer nullBuffer = (numberOfRows == 0) ? null : _columnContainer.NullBitMapBuffers[arrayIndex]; + ReadOnlyDataFrameBuffer valueBuffer = (numberOfRows == 0) ? null : _columnContainer.Buffers[bufferIndex]; + ReadOnlyDataFrameBuffer nullBuffer = (numberOfRows == 0) ? null : _columnContainer.NullBitMapBuffers[bufferIndex]; ReadOnlySpan valueSpan = MemoryMarshal.Cast(valueBuffer.ReadOnlySpan); Date64Array.Builder builder = new Date64Array.Builder().Reserve(valueBuffer.Length); @@ -163,8 +163,8 @@ protected internal override Apache.Arrow.Array ToArrowArray(long startIndex, int } //No convertion - ArrowBuffer arrowValueBuffer = numberOfRows == 0 ? ArrowBuffer.Empty : new ArrowBuffer(_columnContainer.Buffers[arrayIndex].ReadOnlyBuffer); - ArrowBuffer arrowNullBuffer = numberOfRows == 0 ? ArrowBuffer.Empty : new ArrowBuffer(_columnContainer.NullBitMapBuffers[arrayIndex].ReadOnlyBuffer); + ArrowBuffer arrowValueBuffer = numberOfRows == 0 ? ArrowBuffer.Empty : new ArrowBuffer(_columnContainer.Buffers[bufferIndex].ReadOnlyBuffer); + ArrowBuffer arrowNullBuffer = numberOfRows == 0 ? ArrowBuffer.Empty : new ArrowBuffer(_columnContainer.NullBitMapBuffers[bufferIndex].ReadOnlyBuffer); Type type = this.DataType; if (type == typeof(bool)) diff --git a/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs b/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs index 03d112d027..6827b731da 100644 --- a/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs @@ -82,7 +82,7 @@ private int GetBufferIndexContainingRowIndex(long rowIndex) { if (rowIndex >= Length) { - throw new ArgumentOutOfRangeException(Strings.ColumnIndexOutOfRange, nameof(rowIndex)); + throw new ArgumentOutOfRangeException(Strings.RowIndexOutOfRange, nameof(rowIndex)); } return (int)(rowIndex / MaxCapacity); } diff --git a/src/Microsoft.Data.Analysis/Strings.Designer.cs b/src/Microsoft.Data.Analysis/Strings.Designer.cs index 38cabf7ecb..3a3eb5cd48 100644 --- a/src/Microsoft.Data.Analysis/Strings.Designer.cs +++ b/src/Microsoft.Data.Analysis/Strings.Designer.cs @@ -105,15 +105,6 @@ internal static string CannotResizeDown { } } - /// - /// Looks up a localized string similar to Index cannot be greater than the Column's Length. - /// - internal static string ColumnIndexOutOfRange { - get { - return ResourceManager.GetString("ColumnIndexOutOfRange", resourceCulture); - } - } - /// /// Looks up a localized string similar to Comment token cannot contain whitespace. /// @@ -420,6 +411,15 @@ internal static string PositiveNumberOfCharacters { } } + /// + /// Looks up a localized string similar to Index cannot be greater than the Column's Length. + /// + internal static string RowIndexOutOfRange { + get { + return ResourceManager.GetString("RowIndexOutOfRange", resourceCulture); + } + } + /// /// Looks up a localized string similar to Cannot span multiple buffers. /// diff --git a/src/Microsoft.Data.Analysis/Strings.resx b/src/Microsoft.Data.Analysis/Strings.resx index 53120a4a73..55ac4aa547 100644 --- a/src/Microsoft.Data.Analysis/Strings.resx +++ b/src/Microsoft.Data.Analysis/Strings.resx @@ -132,9 +132,6 @@ Cannot resize down - - Index cannot be greater than the Column's Length - Comment token cannot contain whitespace @@ -237,6 +234,9 @@ {0} must be greater than 0 + + Index cannot be greater than the Column's Length + Cannot span multiple buffers diff --git a/src/Microsoft.Data.Analysis/VBufferDataFrameColumn.cs b/src/Microsoft.Data.Analysis/VBufferDataFrameColumn.cs index 064f9cf433..638fa6fb07 100644 --- a/src/Microsoft.Data.Analysis/VBufferDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/VBufferDataFrameColumn.cs @@ -84,7 +84,7 @@ private int GetBufferIndexContainingRowIndex(long rowIndex) { if (rowIndex >= Length) { - throw new ArgumentOutOfRangeException(Strings.ColumnIndexOutOfRange, nameof(rowIndex)); + throw new ArgumentOutOfRangeException(Strings.RowIndexOutOfRange, nameof(rowIndex)); } return (int)(rowIndex / MaxCapacity); From dea8cb830bc0b1c5bc0d03e955b366c7b4082fe8 Mon Sep 17 00:00:00 2001 From: Aleksei Smirnov Date: Thu, 19 Oct 2023 12:53:42 +0300 Subject: [PATCH 2/3] Fix Perf Test --- .../PerformanceTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.Data.Analysis.PerformanceTests/PerformanceTests.cs b/test/Microsoft.Data.Analysis.PerformanceTests/PerformanceTests.cs index a9247b0ed7..170b4d0150 100644 --- a/test/Microsoft.Data.Analysis.PerformanceTests/PerformanceTests.cs +++ b/test/Microsoft.Data.Analysis.PerformanceTests/PerformanceTests.cs @@ -209,9 +209,10 @@ public void ElementwiseEquals_Int32_Int32() [Benchmark] public void ElementwiseEquals_Int16_Int16() { - var column = _int32Column1.ElementwiseEquals(_int16Column2); + var column = _int16Column1.ElementwiseEquals(_int16Column2); } + [Benchmark] public void ElementwiseEquals_Double_Double() { From 12a296ae8070b40aa7a99e87a058c912a6b85b85 Mon Sep 17 00:00:00 2001 From: Aleksei Smirnov Date: Fri, 20 Oct 2023 12:13:33 +0300 Subject: [PATCH 3/3] Fix code review findings --- .../ArrowStringDataFrameColumn.cs | 2 +- .../PrimitiveColumnContainer.cs | 2 +- .../StringDataFrameColumn.cs | 2 +- .../Strings.Designer.cs | 18 +++++++++--------- src/Microsoft.Data.Analysis/Strings.resx | 6 +++--- .../VBufferDataFrameColumn.cs | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs b/src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs index 0d61a4aeaf..85b33b42e9 100644 --- a/src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs @@ -226,7 +226,7 @@ private int GetBufferIndexContainingRowIndex(long rowIndex, out int indexInBuffe { if (rowIndex >= Length) { - throw new ArgumentOutOfRangeException(Strings.RowIndexOutOfRange, nameof(rowIndex)); + throw new ArgumentOutOfRangeException(Strings.IndexIsGreaterThanColumnLength, nameof(rowIndex)); } // Since the strings here could be of variable length, scan linearly diff --git a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs index ed1596450e..74df1011f6 100644 --- a/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs +++ b/src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs @@ -313,7 +313,7 @@ public int GetIndexOfBufferContainingRowIndex(long rowIndex) { if (rowIndex >= Length) { - throw new ArgumentOutOfRangeException(Strings.RowIndexOutOfRange, nameof(rowIndex)); + throw new ArgumentOutOfRangeException(Strings.IndexIsGreaterThanColumnLength, nameof(rowIndex)); } return (int)(rowIndex / ReadOnlyDataFrameBuffer.MaxCapacity); } diff --git a/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs b/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs index 6827b731da..a496ee1c2f 100644 --- a/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs @@ -82,7 +82,7 @@ private int GetBufferIndexContainingRowIndex(long rowIndex) { if (rowIndex >= Length) { - throw new ArgumentOutOfRangeException(Strings.RowIndexOutOfRange, nameof(rowIndex)); + throw new ArgumentOutOfRangeException(Strings.IndexIsGreaterThanColumnLength, nameof(rowIndex)); } return (int)(rowIndex / MaxCapacity); } diff --git a/src/Microsoft.Data.Analysis/Strings.Designer.cs b/src/Microsoft.Data.Analysis/Strings.Designer.cs index 3a3eb5cd48..d3447362c1 100644 --- a/src/Microsoft.Data.Analysis/Strings.Designer.cs +++ b/src/Microsoft.Data.Analysis/Strings.Designer.cs @@ -258,6 +258,15 @@ internal static string InconsistentNullBitMapAndNullCount { } } + /// + /// Looks up a localized string similar to Index cannot be greater than the Column's Length. + /// + internal static string IndexIsGreaterThanColumnLength { + get { + return ResourceManager.GetString("IndexIsGreaterThanColumnLength", resourceCulture); + } + } + /// /// Looks up a localized string similar to Column '{0}' does not exist. /// @@ -411,15 +420,6 @@ internal static string PositiveNumberOfCharacters { } } - /// - /// Looks up a localized string similar to Index cannot be greater than the Column's Length. - /// - internal static string RowIndexOutOfRange { - get { - return ResourceManager.GetString("RowIndexOutOfRange", resourceCulture); - } - } - /// /// Looks up a localized string similar to Cannot span multiple buffers. /// diff --git a/src/Microsoft.Data.Analysis/Strings.resx b/src/Microsoft.Data.Analysis/Strings.resx index 55ac4aa547..27aafc9db2 100644 --- a/src/Microsoft.Data.Analysis/Strings.resx +++ b/src/Microsoft.Data.Analysis/Strings.resx @@ -183,6 +183,9 @@ Inconsistent null bitmaps and NullCounts + + Index cannot be greater than the Column's Length + Column '{0}' does not exist @@ -234,9 +237,6 @@ {0} must be greater than 0 - - Index cannot be greater than the Column's Length - Cannot span multiple buffers diff --git a/src/Microsoft.Data.Analysis/VBufferDataFrameColumn.cs b/src/Microsoft.Data.Analysis/VBufferDataFrameColumn.cs index 638fa6fb07..4cc9c3e110 100644 --- a/src/Microsoft.Data.Analysis/VBufferDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/VBufferDataFrameColumn.cs @@ -84,7 +84,7 @@ private int GetBufferIndexContainingRowIndex(long rowIndex) { if (rowIndex >= Length) { - throw new ArgumentOutOfRangeException(Strings.RowIndexOutOfRange, nameof(rowIndex)); + throw new ArgumentOutOfRangeException(Strings.IndexIsGreaterThanColumnLength, nameof(rowIndex)); } return (int)(rowIndex / MaxCapacity);