Add binary operations and operators on the exploded columns (#2867)
* Generate combinations of binary operations and Add
* Numeric Converters and CloneAsNumericColumns
* Binary, Comparison and Shift operations
* Clean up and bug fix
* Fix the binary op apis to not be overridden
* Internal constructors for exploded types
* Proper return types for exploded types
* Update unit tests
* Update csproj
* Revert "Fix the binary op apis to not be overridden"
This reverts commit 1f723dd86b
.
* Bug fix and unit test
* Constructor that takes in a container
* Unit tests
* Call the implementation where possible
* Review sq
* sq
* Cherry pick for next commit
* sq
* Undo unnecessary change
* Rename to the system namespace column types
* Address comments
* Push to pull locally
* Mimic C#'s arithmetic grammar in DataFrame
* Address feedback
* Reduce the number of partial column definitions
* Address feedback
This commit is contained in:
Родитель
3f9ef6b7d7
Коммит
7f8ec72acd
|
@ -64,6 +64,38 @@
|
|||
{
|
||||
typeFirstCharUpper = type[0].ToString().ToUpper() + type.Substring(1);
|
||||
}
|
||||
if (typeFirstCharUpper == "Bool")
|
||||
{
|
||||
return "Boolean";
|
||||
}
|
||||
else if (typeFirstCharUpper == "Float")
|
||||
{
|
||||
return "Single";
|
||||
}
|
||||
else if (typeFirstCharUpper == "Int")
|
||||
{
|
||||
return "Int32";
|
||||
}
|
||||
else if (typeFirstCharUpper == "Short")
|
||||
{
|
||||
return "Int16";
|
||||
}
|
||||
else if (typeFirstCharUpper == "Long")
|
||||
{
|
||||
return "Int64";
|
||||
}
|
||||
else if (typeFirstCharUpper == "UInt")
|
||||
{
|
||||
return "UInt32";
|
||||
}
|
||||
else if (typeFirstCharUpper == "UShort")
|
||||
{
|
||||
return "UInt16";
|
||||
}
|
||||
else if (typeFirstCharUpper == "ULong")
|
||||
{
|
||||
return "UInt64";
|
||||
}
|
||||
return typeFirstCharUpper;
|
||||
}
|
||||
|
||||
|
@ -88,6 +120,22 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
// These are a subset of the implicit conversions allowed in C#. They are used to generate the return type for binary ops
|
||||
// https://github.com/dotnet/csharplang/blob/master/spec/conversions.md#implicit-numeric-conversions
|
||||
public Dictionary<string, IReadOnlyList<string>> primitiveTypeToImplicitConversions = new Dictionary<string, IReadOnlyList<string>> {
|
||||
{"sbyte", new List<string> {"int", "long", "float", "double", "decimal"}},
|
||||
{"byte", new List<string> {"int", "uint", "long", "ulong", "float", "double", "decimal"}},
|
||||
{"short", new List<string> {"int", "long", "float", "double", "decimal"}},
|
||||
{"ushort", new List<string> {"int", "uint", "long", "ulong", "float", "double", "decimal"}},
|
||||
{"int", new List<string> {"int", "long", "float", "double", "decimal"}},
|
||||
{"uint", new List<string> {"uint", "long", "ulong", "float", "double", "decimal"}},
|
||||
{"long", new List<string> {"long", "float", "double", "decimal"}},
|
||||
{"ulong", new List<string> {"ulong", "float", "double", "decimal"}},
|
||||
{"float", new List<string> {"float", "double"}},
|
||||
{"double", new List<string> {"double"}},
|
||||
{"decimal", new List<string> {"decimal"}},
|
||||
};
|
||||
|
||||
public TypeConfiguration[] typeConfiguration = new []
|
||||
{
|
||||
new TypeConfiguration("bool", oneLiteral:"true", zeroLiteral:"false", supportsNumeric: false, unsupportedMethods: new[] {"LeftShift", "RightShift"}),
|
||||
|
@ -105,28 +153,40 @@
|
|||
new TypeConfiguration("ushort", classPrefix:"UShort", unsupportedMethods: new[] {"UnaryMinus", "All", "Any"})
|
||||
};
|
||||
|
||||
public string GetBinaryShiftOperationReturnType(TypeConfiguration t1)
|
||||
{
|
||||
primitiveTypeToImplicitConversions.TryGetValue(t1.TypeName, out IReadOnlyList<string> t1ImplicitConversions);
|
||||
return t1ImplicitConversions.First() ?? string.Empty;
|
||||
}
|
||||
|
||||
public string GetBinaryOperationReturnType(string t1, string t2)
|
||||
{
|
||||
if (t1 == "long" && t2 == "ulong" || t1 == "ulong" && t2 == "long")
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
primitiveTypeToImplicitConversions.TryGetValue(t1, out IReadOnlyList<string> t1ImplicitConversions);
|
||||
primitiveTypeToImplicitConversions.TryGetValue(t2, out IReadOnlyList<string> t2ImplicitConversions);
|
||||
var intersection = t1ImplicitConversions.Intersect(t2ImplicitConversions);
|
||||
string ret;
|
||||
if (intersection.Count() == 0)
|
||||
{
|
||||
ret = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = intersection.First();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns an empty string for binary ops that are not valid: For ex: float + decimal is NOT allowed.
|
||||
// Special case: long + ulong is NOT allowed. The other mixed signed and unsigned are valid
|
||||
public string GetBinaryOperationReturnType(TypeConfiguration t1, TypeConfiguration t2)
|
||||
{
|
||||
int t1Level;
|
||||
if (!primitiveTypeToPrimitivityLevelMap.TryGetValue(t1.TypeName, out t1Level))
|
||||
{
|
||||
throw new Exception("Unknown type");
|
||||
}
|
||||
int t2Level;
|
||||
if (!primitiveTypeToPrimitivityLevelMap.TryGetValue(t2.TypeName, out t2Level))
|
||||
{
|
||||
throw new Exception("Unknown type");
|
||||
}
|
||||
if (t1Level + t2Level <= 2 * t1Level)
|
||||
{
|
||||
return t1.TypeName;
|
||||
}
|
||||
if (t1Level + t2Level <= 2 * t2Level)
|
||||
{
|
||||
return t2.TypeName;
|
||||
}
|
||||
throw new Exception("Bug in GetBinaryOperationReturnType");
|
||||
return "";
|
||||
string t1Type = t1.TypeName;
|
||||
string t2Type = t2.TypeName;
|
||||
return GetBinaryOperationReturnType(t1Type, t2Type);
|
||||
}
|
||||
|
||||
public enum MethodType
|
||||
|
|
|
@ -84,602 +84,602 @@ namespace Microsoft.Data.Analysis
|
|||
return (sbyte)value;
|
||||
}
|
||||
}
|
||||
internal interface IShortConverter<T>
|
||||
internal interface IInt16Converter<T>
|
||||
{
|
||||
short GetShort(T value);
|
||||
short GetInt16(T value);
|
||||
}
|
||||
internal static class ShortConverter<T>
|
||||
internal static class Int16Converter<T>
|
||||
{
|
||||
public static IShortConverter<T> Instance { get; } = ShortConverter.GetShortConverter<T>();
|
||||
public static IInt16Converter<T> Instance { get; } = Int16Converter.GetInt16Converter<T>();
|
||||
}
|
||||
internal static class ShortConverter
|
||||
internal static class Int16Converter
|
||||
{
|
||||
public static IShortConverter<T> GetShortConverter<T>()
|
||||
public static IInt16Converter<T> GetInt16Converter<T>()
|
||||
{
|
||||
if (typeof(T) == typeof(byte))
|
||||
{
|
||||
return (IShortConverter<T>)new ByteShortConverter();
|
||||
return (IInt16Converter<T>)new ByteInt16Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(sbyte))
|
||||
{
|
||||
return (IShortConverter<T>)new SByteShortConverter();
|
||||
return (IInt16Converter<T>)new SByteInt16Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (IShortConverter<T>)new ShortShortConverter();
|
||||
return (IInt16Converter<T>)new Int16Int16Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (IShortConverter<T>)new UShortShortConverter();
|
||||
return (IInt16Converter<T>)new UInt16Int16Converter();
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
internal class ByteShortConverter : IShortConverter<byte>
|
||||
internal class ByteInt16Converter : IInt16Converter<byte>
|
||||
{
|
||||
public short GetShort(byte value)
|
||||
public short GetInt16(byte value)
|
||||
{
|
||||
return (short)value;
|
||||
}
|
||||
}
|
||||
internal class SByteShortConverter : IShortConverter<sbyte>
|
||||
internal class SByteInt16Converter : IInt16Converter<sbyte>
|
||||
{
|
||||
public short GetShort(sbyte value)
|
||||
public short GetInt16(sbyte value)
|
||||
{
|
||||
return (short)value;
|
||||
}
|
||||
}
|
||||
internal class ShortShortConverter : IShortConverter<short>
|
||||
internal class Int16Int16Converter : IInt16Converter<short>
|
||||
{
|
||||
public short GetShort(short value)
|
||||
public short GetInt16(short value)
|
||||
{
|
||||
return (short)value;
|
||||
}
|
||||
}
|
||||
internal class UShortShortConverter : IShortConverter<ushort>
|
||||
internal class UInt16Int16Converter : IInt16Converter<ushort>
|
||||
{
|
||||
public short GetShort(ushort value)
|
||||
public short GetInt16(ushort value)
|
||||
{
|
||||
return (short)value;
|
||||
}
|
||||
}
|
||||
internal interface IUShortConverter<T>
|
||||
internal interface IUInt16Converter<T>
|
||||
{
|
||||
ushort GetUShort(T value);
|
||||
ushort GetUInt16(T value);
|
||||
}
|
||||
internal static class UShortConverter<T>
|
||||
internal static class UInt16Converter<T>
|
||||
{
|
||||
public static IUShortConverter<T> Instance { get; } = UShortConverter.GetUShortConverter<T>();
|
||||
public static IUInt16Converter<T> Instance { get; } = UInt16Converter.GetUInt16Converter<T>();
|
||||
}
|
||||
internal static class UShortConverter
|
||||
internal static class UInt16Converter
|
||||
{
|
||||
public static IUShortConverter<T> GetUShortConverter<T>()
|
||||
public static IUInt16Converter<T> GetUInt16Converter<T>()
|
||||
{
|
||||
if (typeof(T) == typeof(byte))
|
||||
{
|
||||
return (IUShortConverter<T>)new ByteUShortConverter();
|
||||
return (IUInt16Converter<T>)new ByteUInt16Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(sbyte))
|
||||
{
|
||||
return (IUShortConverter<T>)new SByteUShortConverter();
|
||||
return (IUInt16Converter<T>)new SByteUInt16Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (IUShortConverter<T>)new ShortUShortConverter();
|
||||
return (IUInt16Converter<T>)new Int16UInt16Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (IUShortConverter<T>)new UShortUShortConverter();
|
||||
return (IUInt16Converter<T>)new UInt16UInt16Converter();
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
internal class ByteUShortConverter : IUShortConverter<byte>
|
||||
internal class ByteUInt16Converter : IUInt16Converter<byte>
|
||||
{
|
||||
public ushort GetUShort(byte value)
|
||||
public ushort GetUInt16(byte value)
|
||||
{
|
||||
return (ushort)value;
|
||||
}
|
||||
}
|
||||
internal class SByteUShortConverter : IUShortConverter<sbyte>
|
||||
internal class SByteUInt16Converter : IUInt16Converter<sbyte>
|
||||
{
|
||||
public ushort GetUShort(sbyte value)
|
||||
public ushort GetUInt16(sbyte value)
|
||||
{
|
||||
return (ushort)value;
|
||||
}
|
||||
}
|
||||
internal class ShortUShortConverter : IUShortConverter<short>
|
||||
internal class Int16UInt16Converter : IUInt16Converter<short>
|
||||
{
|
||||
public ushort GetUShort(short value)
|
||||
public ushort GetUInt16(short value)
|
||||
{
|
||||
return (ushort)value;
|
||||
}
|
||||
}
|
||||
internal class UShortUShortConverter : IUShortConverter<ushort>
|
||||
internal class UInt16UInt16Converter : IUInt16Converter<ushort>
|
||||
{
|
||||
public ushort GetUShort(ushort value)
|
||||
public ushort GetUInt16(ushort value)
|
||||
{
|
||||
return (ushort)value;
|
||||
}
|
||||
}
|
||||
internal interface IIntConverter<T>
|
||||
internal interface IInt32Converter<T>
|
||||
{
|
||||
int GetInt(T value);
|
||||
int GetInt32(T value);
|
||||
}
|
||||
internal static class IntConverter<T>
|
||||
internal static class Int32Converter<T>
|
||||
{
|
||||
public static IIntConverter<T> Instance { get; } = IntConverter.GetIntConverter<T>();
|
||||
public static IInt32Converter<T> Instance { get; } = Int32Converter.GetInt32Converter<T>();
|
||||
}
|
||||
internal static class IntConverter
|
||||
internal static class Int32Converter
|
||||
{
|
||||
public static IIntConverter<T> GetIntConverter<T>()
|
||||
public static IInt32Converter<T> GetInt32Converter<T>()
|
||||
{
|
||||
if (typeof(T) == typeof(byte))
|
||||
{
|
||||
return (IIntConverter<T>)new ByteIntConverter();
|
||||
return (IInt32Converter<T>)new ByteInt32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(sbyte))
|
||||
{
|
||||
return (IIntConverter<T>)new SByteIntConverter();
|
||||
return (IInt32Converter<T>)new SByteInt32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (IIntConverter<T>)new ShortIntConverter();
|
||||
return (IInt32Converter<T>)new Int16Int32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (IIntConverter<T>)new UShortIntConverter();
|
||||
return (IInt32Converter<T>)new UInt16Int32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (IIntConverter<T>)new IntIntConverter();
|
||||
return (IInt32Converter<T>)new Int32Int32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(uint))
|
||||
{
|
||||
return (IIntConverter<T>)new UIntIntConverter();
|
||||
return (IInt32Converter<T>)new UInt32Int32Converter();
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
internal class ByteIntConverter : IIntConverter<byte>
|
||||
internal class ByteInt32Converter : IInt32Converter<byte>
|
||||
{
|
||||
public int GetInt(byte value)
|
||||
public int GetInt32(byte value)
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
}
|
||||
internal class SByteIntConverter : IIntConverter<sbyte>
|
||||
internal class SByteInt32Converter : IInt32Converter<sbyte>
|
||||
{
|
||||
public int GetInt(sbyte value)
|
||||
public int GetInt32(sbyte value)
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
}
|
||||
internal class ShortIntConverter : IIntConverter<short>
|
||||
internal class Int16Int32Converter : IInt32Converter<short>
|
||||
{
|
||||
public int GetInt(short value)
|
||||
public int GetInt32(short value)
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
}
|
||||
internal class UShortIntConverter : IIntConverter<ushort>
|
||||
internal class UInt16Int32Converter : IInt32Converter<ushort>
|
||||
{
|
||||
public int GetInt(ushort value)
|
||||
public int GetInt32(ushort value)
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
}
|
||||
internal class IntIntConverter : IIntConverter<int>
|
||||
internal class Int32Int32Converter : IInt32Converter<int>
|
||||
{
|
||||
public int GetInt(int value)
|
||||
public int GetInt32(int value)
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
}
|
||||
internal class UIntIntConverter : IIntConverter<uint>
|
||||
internal class UInt32Int32Converter : IInt32Converter<uint>
|
||||
{
|
||||
public int GetInt(uint value)
|
||||
public int GetInt32(uint value)
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
}
|
||||
internal interface IUIntConverter<T>
|
||||
internal interface IUInt32Converter<T>
|
||||
{
|
||||
uint GetUInt(T value);
|
||||
uint GetUInt32(T value);
|
||||
}
|
||||
internal static class UIntConverter<T>
|
||||
internal static class UInt32Converter<T>
|
||||
{
|
||||
public static IUIntConverter<T> Instance { get; } = UIntConverter.GetUIntConverter<T>();
|
||||
public static IUInt32Converter<T> Instance { get; } = UInt32Converter.GetUInt32Converter<T>();
|
||||
}
|
||||
internal static class UIntConverter
|
||||
internal static class UInt32Converter
|
||||
{
|
||||
public static IUIntConverter<T> GetUIntConverter<T>()
|
||||
public static IUInt32Converter<T> GetUInt32Converter<T>()
|
||||
{
|
||||
if (typeof(T) == typeof(byte))
|
||||
{
|
||||
return (IUIntConverter<T>)new ByteUIntConverter();
|
||||
return (IUInt32Converter<T>)new ByteUInt32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(sbyte))
|
||||
{
|
||||
return (IUIntConverter<T>)new SByteUIntConverter();
|
||||
return (IUInt32Converter<T>)new SByteUInt32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (IUIntConverter<T>)new ShortUIntConverter();
|
||||
return (IUInt32Converter<T>)new Int16UInt32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (IUIntConverter<T>)new UShortUIntConverter();
|
||||
return (IUInt32Converter<T>)new UInt16UInt32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (IUIntConverter<T>)new IntUIntConverter();
|
||||
return (IUInt32Converter<T>)new Int32UInt32Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(uint))
|
||||
{
|
||||
return (IUIntConverter<T>)new UIntUIntConverter();
|
||||
return (IUInt32Converter<T>)new UInt32UInt32Converter();
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
internal class ByteUIntConverter : IUIntConverter<byte>
|
||||
internal class ByteUInt32Converter : IUInt32Converter<byte>
|
||||
{
|
||||
public uint GetUInt(byte value)
|
||||
public uint GetUInt32(byte value)
|
||||
{
|
||||
return (uint)value;
|
||||
}
|
||||
}
|
||||
internal class SByteUIntConverter : IUIntConverter<sbyte>
|
||||
internal class SByteUInt32Converter : IUInt32Converter<sbyte>
|
||||
{
|
||||
public uint GetUInt(sbyte value)
|
||||
public uint GetUInt32(sbyte value)
|
||||
{
|
||||
return (uint)value;
|
||||
}
|
||||
}
|
||||
internal class ShortUIntConverter : IUIntConverter<short>
|
||||
internal class Int16UInt32Converter : IUInt32Converter<short>
|
||||
{
|
||||
public uint GetUInt(short value)
|
||||
public uint GetUInt32(short value)
|
||||
{
|
||||
return (uint)value;
|
||||
}
|
||||
}
|
||||
internal class UShortUIntConverter : IUIntConverter<ushort>
|
||||
internal class UInt16UInt32Converter : IUInt32Converter<ushort>
|
||||
{
|
||||
public uint GetUInt(ushort value)
|
||||
public uint GetUInt32(ushort value)
|
||||
{
|
||||
return (uint)value;
|
||||
}
|
||||
}
|
||||
internal class IntUIntConverter : IUIntConverter<int>
|
||||
internal class Int32UInt32Converter : IUInt32Converter<int>
|
||||
{
|
||||
public uint GetUInt(int value)
|
||||
public uint GetUInt32(int value)
|
||||
{
|
||||
return (uint)value;
|
||||
}
|
||||
}
|
||||
internal class UIntUIntConverter : IUIntConverter<uint>
|
||||
internal class UInt32UInt32Converter : IUInt32Converter<uint>
|
||||
{
|
||||
public uint GetUInt(uint value)
|
||||
public uint GetUInt32(uint value)
|
||||
{
|
||||
return (uint)value;
|
||||
}
|
||||
}
|
||||
internal interface ILongConverter<T>
|
||||
internal interface IInt64Converter<T>
|
||||
{
|
||||
long GetLong(T value);
|
||||
long GetInt64(T value);
|
||||
}
|
||||
internal static class LongConverter<T>
|
||||
internal static class Int64Converter<T>
|
||||
{
|
||||
public static ILongConverter<T> Instance { get; } = LongConverter.GetLongConverter<T>();
|
||||
public static IInt64Converter<T> Instance { get; } = Int64Converter.GetInt64Converter<T>();
|
||||
}
|
||||
internal static class LongConverter
|
||||
internal static class Int64Converter
|
||||
{
|
||||
public static ILongConverter<T> GetLongConverter<T>()
|
||||
public static IInt64Converter<T> GetInt64Converter<T>()
|
||||
{
|
||||
if (typeof(T) == typeof(byte))
|
||||
{
|
||||
return (ILongConverter<T>)new ByteLongConverter();
|
||||
return (IInt64Converter<T>)new ByteInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(sbyte))
|
||||
{
|
||||
return (ILongConverter<T>)new SByteLongConverter();
|
||||
return (IInt64Converter<T>)new SByteInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (ILongConverter<T>)new ShortLongConverter();
|
||||
return (IInt64Converter<T>)new Int16Int64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (ILongConverter<T>)new UShortLongConverter();
|
||||
return (IInt64Converter<T>)new UInt16Int64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (ILongConverter<T>)new IntLongConverter();
|
||||
return (IInt64Converter<T>)new Int32Int64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(uint))
|
||||
{
|
||||
return (ILongConverter<T>)new UIntLongConverter();
|
||||
return (IInt64Converter<T>)new UInt32Int64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(long))
|
||||
{
|
||||
return (ILongConverter<T>)new LongLongConverter();
|
||||
return (IInt64Converter<T>)new Int64Int64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(ulong))
|
||||
{
|
||||
return (ILongConverter<T>)new ULongLongConverter();
|
||||
return (IInt64Converter<T>)new UInt64Int64Converter();
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
internal class ByteLongConverter : ILongConverter<byte>
|
||||
internal class ByteInt64Converter : IInt64Converter<byte>
|
||||
{
|
||||
public long GetLong(byte value)
|
||||
public long GetInt64(byte value)
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
internal class SByteLongConverter : ILongConverter<sbyte>
|
||||
internal class SByteInt64Converter : IInt64Converter<sbyte>
|
||||
{
|
||||
public long GetLong(sbyte value)
|
||||
public long GetInt64(sbyte value)
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
internal class ShortLongConverter : ILongConverter<short>
|
||||
internal class Int16Int64Converter : IInt64Converter<short>
|
||||
{
|
||||
public long GetLong(short value)
|
||||
public long GetInt64(short value)
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
internal class UShortLongConverter : ILongConverter<ushort>
|
||||
internal class UInt16Int64Converter : IInt64Converter<ushort>
|
||||
{
|
||||
public long GetLong(ushort value)
|
||||
public long GetInt64(ushort value)
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
internal class IntLongConverter : ILongConverter<int>
|
||||
internal class Int32Int64Converter : IInt64Converter<int>
|
||||
{
|
||||
public long GetLong(int value)
|
||||
public long GetInt64(int value)
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
internal class UIntLongConverter : ILongConverter<uint>
|
||||
internal class UInt32Int64Converter : IInt64Converter<uint>
|
||||
{
|
||||
public long GetLong(uint value)
|
||||
public long GetInt64(uint value)
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
internal class LongLongConverter : ILongConverter<long>
|
||||
internal class Int64Int64Converter : IInt64Converter<long>
|
||||
{
|
||||
public long GetLong(long value)
|
||||
public long GetInt64(long value)
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
internal class ULongLongConverter : ILongConverter<ulong>
|
||||
internal class UInt64Int64Converter : IInt64Converter<ulong>
|
||||
{
|
||||
public long GetLong(ulong value)
|
||||
public long GetInt64(ulong value)
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
internal interface IULongConverter<T>
|
||||
internal interface IUInt64Converter<T>
|
||||
{
|
||||
ulong GetULong(T value);
|
||||
ulong GetUInt64(T value);
|
||||
}
|
||||
internal static class ULongConverter<T>
|
||||
internal static class UInt64Converter<T>
|
||||
{
|
||||
public static IULongConverter<T> Instance { get; } = ULongConverter.GetULongConverter<T>();
|
||||
public static IUInt64Converter<T> Instance { get; } = UInt64Converter.GetUInt64Converter<T>();
|
||||
}
|
||||
internal static class ULongConverter
|
||||
internal static class UInt64Converter
|
||||
{
|
||||
public static IULongConverter<T> GetULongConverter<T>()
|
||||
public static IUInt64Converter<T> GetUInt64Converter<T>()
|
||||
{
|
||||
if (typeof(T) == typeof(byte))
|
||||
{
|
||||
return (IULongConverter<T>)new ByteULongConverter();
|
||||
return (IUInt64Converter<T>)new ByteUInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(sbyte))
|
||||
{
|
||||
return (IULongConverter<T>)new SByteULongConverter();
|
||||
return (IUInt64Converter<T>)new SByteUInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (IULongConverter<T>)new ShortULongConverter();
|
||||
return (IUInt64Converter<T>)new Int16UInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (IULongConverter<T>)new UShortULongConverter();
|
||||
return (IUInt64Converter<T>)new UInt16UInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (IULongConverter<T>)new IntULongConverter();
|
||||
return (IUInt64Converter<T>)new Int32UInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(uint))
|
||||
{
|
||||
return (IULongConverter<T>)new UIntULongConverter();
|
||||
return (IUInt64Converter<T>)new UInt32UInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(long))
|
||||
{
|
||||
return (IULongConverter<T>)new LongULongConverter();
|
||||
return (IUInt64Converter<T>)new Int64UInt64Converter();
|
||||
}
|
||||
if (typeof(T) == typeof(ulong))
|
||||
{
|
||||
return (IULongConverter<T>)new ULongULongConverter();
|
||||
return (IUInt64Converter<T>)new UInt64UInt64Converter();
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
internal class ByteULongConverter : IULongConverter<byte>
|
||||
internal class ByteUInt64Converter : IUInt64Converter<byte>
|
||||
{
|
||||
public ulong GetULong(byte value)
|
||||
public ulong GetUInt64(byte value)
|
||||
{
|
||||
return (ulong)value;
|
||||
}
|
||||
}
|
||||
internal class SByteULongConverter : IULongConverter<sbyte>
|
||||
internal class SByteUInt64Converter : IUInt64Converter<sbyte>
|
||||
{
|
||||
public ulong GetULong(sbyte value)
|
||||
public ulong GetUInt64(sbyte value)
|
||||
{
|
||||
return (ulong)value;
|
||||
}
|
||||
}
|
||||
internal class ShortULongConverter : IULongConverter<short>
|
||||
internal class Int16UInt64Converter : IUInt64Converter<short>
|
||||
{
|
||||
public ulong GetULong(short value)
|
||||
public ulong GetUInt64(short value)
|
||||
{
|
||||
return (ulong)value;
|
||||
}
|
||||
}
|
||||
internal class UShortULongConverter : IULongConverter<ushort>
|
||||
internal class UInt16UInt64Converter : IUInt64Converter<ushort>
|
||||
{
|
||||
public ulong GetULong(ushort value)
|
||||
public ulong GetUInt64(ushort value)
|
||||
{
|
||||
return (ulong)value;
|
||||
}
|
||||
}
|
||||
internal class IntULongConverter : IULongConverter<int>
|
||||
internal class Int32UInt64Converter : IUInt64Converter<int>
|
||||
{
|
||||
public ulong GetULong(int value)
|
||||
public ulong GetUInt64(int value)
|
||||
{
|
||||
return (ulong)value;
|
||||
}
|
||||
}
|
||||
internal class UIntULongConverter : IULongConverter<uint>
|
||||
internal class UInt32UInt64Converter : IUInt64Converter<uint>
|
||||
{
|
||||
public ulong GetULong(uint value)
|
||||
public ulong GetUInt64(uint value)
|
||||
{
|
||||
return (ulong)value;
|
||||
}
|
||||
}
|
||||
internal class LongULongConverter : IULongConverter<long>
|
||||
internal class Int64UInt64Converter : IUInt64Converter<long>
|
||||
{
|
||||
public ulong GetULong(long value)
|
||||
public ulong GetUInt64(long value)
|
||||
{
|
||||
return (ulong)value;
|
||||
}
|
||||
}
|
||||
internal class ULongULongConverter : IULongConverter<ulong>
|
||||
internal class UInt64UInt64Converter : IUInt64Converter<ulong>
|
||||
{
|
||||
public ulong GetULong(ulong value)
|
||||
public ulong GetUInt64(ulong value)
|
||||
{
|
||||
return (ulong)value;
|
||||
}
|
||||
}
|
||||
internal interface IFloatConverter<T>
|
||||
internal interface ISingleConverter<T>
|
||||
{
|
||||
float GetFloat(T value);
|
||||
float GetSingle(T value);
|
||||
}
|
||||
internal static class FloatConverter<T>
|
||||
internal static class SingleConverter<T>
|
||||
{
|
||||
public static IFloatConverter<T> Instance { get; } = FloatConverter.GetFloatConverter<T>();
|
||||
public static ISingleConverter<T> Instance { get; } = SingleConverter.GetSingleConverter<T>();
|
||||
}
|
||||
internal static class FloatConverter
|
||||
internal static class SingleConverter
|
||||
{
|
||||
public static IFloatConverter<T> GetFloatConverter<T>()
|
||||
public static ISingleConverter<T> GetSingleConverter<T>()
|
||||
{
|
||||
if (typeof(T) == typeof(byte))
|
||||
{
|
||||
return (IFloatConverter<T>)new ByteFloatConverter();
|
||||
return (ISingleConverter<T>)new ByteSingleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(sbyte))
|
||||
{
|
||||
return (IFloatConverter<T>)new SByteFloatConverter();
|
||||
return (ISingleConverter<T>)new SByteSingleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (IFloatConverter<T>)new ShortFloatConverter();
|
||||
return (ISingleConverter<T>)new Int16SingleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (IFloatConverter<T>)new UShortFloatConverter();
|
||||
return (ISingleConverter<T>)new UInt16SingleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (IFloatConverter<T>)new IntFloatConverter();
|
||||
return (ISingleConverter<T>)new Int32SingleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(uint))
|
||||
{
|
||||
return (IFloatConverter<T>)new UIntFloatConverter();
|
||||
return (ISingleConverter<T>)new UInt32SingleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(long))
|
||||
{
|
||||
return (IFloatConverter<T>)new LongFloatConverter();
|
||||
return (ISingleConverter<T>)new Int64SingleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(ulong))
|
||||
{
|
||||
return (IFloatConverter<T>)new ULongFloatConverter();
|
||||
return (ISingleConverter<T>)new UInt64SingleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(float))
|
||||
{
|
||||
return (IFloatConverter<T>)new FloatFloatConverter();
|
||||
return (ISingleConverter<T>)new SingleSingleConverter();
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
internal class ByteFloatConverter : IFloatConverter<byte>
|
||||
internal class ByteSingleConverter : ISingleConverter<byte>
|
||||
{
|
||||
public float GetFloat(byte value)
|
||||
public float GetSingle(byte value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
internal class SByteFloatConverter : IFloatConverter<sbyte>
|
||||
internal class SByteSingleConverter : ISingleConverter<sbyte>
|
||||
{
|
||||
public float GetFloat(sbyte value)
|
||||
public float GetSingle(sbyte value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
internal class ShortFloatConverter : IFloatConverter<short>
|
||||
internal class Int16SingleConverter : ISingleConverter<short>
|
||||
{
|
||||
public float GetFloat(short value)
|
||||
public float GetSingle(short value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
internal class UShortFloatConverter : IFloatConverter<ushort>
|
||||
internal class UInt16SingleConverter : ISingleConverter<ushort>
|
||||
{
|
||||
public float GetFloat(ushort value)
|
||||
public float GetSingle(ushort value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
internal class IntFloatConverter : IFloatConverter<int>
|
||||
internal class Int32SingleConverter : ISingleConverter<int>
|
||||
{
|
||||
public float GetFloat(int value)
|
||||
public float GetSingle(int value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
internal class UIntFloatConverter : IFloatConverter<uint>
|
||||
internal class UInt32SingleConverter : ISingleConverter<uint>
|
||||
{
|
||||
public float GetFloat(uint value)
|
||||
public float GetSingle(uint value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
internal class LongFloatConverter : IFloatConverter<long>
|
||||
internal class Int64SingleConverter : ISingleConverter<long>
|
||||
{
|
||||
public float GetFloat(long value)
|
||||
public float GetSingle(long value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
internal class ULongFloatConverter : IFloatConverter<ulong>
|
||||
internal class UInt64SingleConverter : ISingleConverter<ulong>
|
||||
{
|
||||
public float GetFloat(ulong value)
|
||||
public float GetSingle(ulong value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
internal class FloatFloatConverter : IFloatConverter<float>
|
||||
internal class SingleSingleConverter : ISingleConverter<float>
|
||||
{
|
||||
public float GetFloat(float value)
|
||||
public float GetSingle(float value)
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
|
@ -706,31 +706,31 @@ namespace Microsoft.Data.Analysis
|
|||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (IDoubleConverter<T>)new ShortDoubleConverter();
|
||||
return (IDoubleConverter<T>)new Int16DoubleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (IDoubleConverter<T>)new UShortDoubleConverter();
|
||||
return (IDoubleConverter<T>)new UInt16DoubleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (IDoubleConverter<T>)new IntDoubleConverter();
|
||||
return (IDoubleConverter<T>)new Int32DoubleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(uint))
|
||||
{
|
||||
return (IDoubleConverter<T>)new UIntDoubleConverter();
|
||||
return (IDoubleConverter<T>)new UInt32DoubleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(long))
|
||||
{
|
||||
return (IDoubleConverter<T>)new LongDoubleConverter();
|
||||
return (IDoubleConverter<T>)new Int64DoubleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(ulong))
|
||||
{
|
||||
return (IDoubleConverter<T>)new ULongDoubleConverter();
|
||||
return (IDoubleConverter<T>)new UInt64DoubleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(float))
|
||||
{
|
||||
return (IDoubleConverter<T>)new FloatDoubleConverter();
|
||||
return (IDoubleConverter<T>)new SingleDoubleConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(double))
|
||||
{
|
||||
|
@ -753,49 +753,49 @@ namespace Microsoft.Data.Analysis
|
|||
return (double)value;
|
||||
}
|
||||
}
|
||||
internal class ShortDoubleConverter : IDoubleConverter<short>
|
||||
internal class Int16DoubleConverter : IDoubleConverter<short>
|
||||
{
|
||||
public double GetDouble(short value)
|
||||
{
|
||||
return (double)value;
|
||||
}
|
||||
}
|
||||
internal class UShortDoubleConverter : IDoubleConverter<ushort>
|
||||
internal class UInt16DoubleConverter : IDoubleConverter<ushort>
|
||||
{
|
||||
public double GetDouble(ushort value)
|
||||
{
|
||||
return (double)value;
|
||||
}
|
||||
}
|
||||
internal class IntDoubleConverter : IDoubleConverter<int>
|
||||
internal class Int32DoubleConverter : IDoubleConverter<int>
|
||||
{
|
||||
public double GetDouble(int value)
|
||||
{
|
||||
return (double)value;
|
||||
}
|
||||
}
|
||||
internal class UIntDoubleConverter : IDoubleConverter<uint>
|
||||
internal class UInt32DoubleConverter : IDoubleConverter<uint>
|
||||
{
|
||||
public double GetDouble(uint value)
|
||||
{
|
||||
return (double)value;
|
||||
}
|
||||
}
|
||||
internal class LongDoubleConverter : IDoubleConverter<long>
|
||||
internal class Int64DoubleConverter : IDoubleConverter<long>
|
||||
{
|
||||
public double GetDouble(long value)
|
||||
{
|
||||
return (double)value;
|
||||
}
|
||||
}
|
||||
internal class ULongDoubleConverter : IDoubleConverter<ulong>
|
||||
internal class UInt64DoubleConverter : IDoubleConverter<ulong>
|
||||
{
|
||||
public double GetDouble(ulong value)
|
||||
{
|
||||
return (double)value;
|
||||
}
|
||||
}
|
||||
internal class FloatDoubleConverter : IDoubleConverter<float>
|
||||
internal class SingleDoubleConverter : IDoubleConverter<float>
|
||||
{
|
||||
public double GetDouble(float value)
|
||||
{
|
||||
|
@ -831,31 +831,31 @@ namespace Microsoft.Data.Analysis
|
|||
}
|
||||
if (typeof(T) == typeof(short))
|
||||
{
|
||||
return (IDecimalConverter<T>)new ShortDecimalConverter();
|
||||
return (IDecimalConverter<T>)new Int16DecimalConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(ushort))
|
||||
{
|
||||
return (IDecimalConverter<T>)new UShortDecimalConverter();
|
||||
return (IDecimalConverter<T>)new UInt16DecimalConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (IDecimalConverter<T>)new IntDecimalConverter();
|
||||
return (IDecimalConverter<T>)new Int32DecimalConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(uint))
|
||||
{
|
||||
return (IDecimalConverter<T>)new UIntDecimalConverter();
|
||||
return (IDecimalConverter<T>)new UInt32DecimalConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(long))
|
||||
{
|
||||
return (IDecimalConverter<T>)new LongDecimalConverter();
|
||||
return (IDecimalConverter<T>)new Int64DecimalConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(ulong))
|
||||
{
|
||||
return (IDecimalConverter<T>)new ULongDecimalConverter();
|
||||
return (IDecimalConverter<T>)new UInt64DecimalConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(float))
|
||||
{
|
||||
return (IDecimalConverter<T>)new FloatDecimalConverter();
|
||||
return (IDecimalConverter<T>)new SingleDecimalConverter();
|
||||
}
|
||||
if (typeof(T) == typeof(double))
|
||||
{
|
||||
|
@ -882,49 +882,49 @@ namespace Microsoft.Data.Analysis
|
|||
return (decimal)value;
|
||||
}
|
||||
}
|
||||
internal class ShortDecimalConverter : IDecimalConverter<short>
|
||||
internal class Int16DecimalConverter : IDecimalConverter<short>
|
||||
{
|
||||
public decimal GetDecimal(short value)
|
||||
{
|
||||
return (decimal)value;
|
||||
}
|
||||
}
|
||||
internal class UShortDecimalConverter : IDecimalConverter<ushort>
|
||||
internal class UInt16DecimalConverter : IDecimalConverter<ushort>
|
||||
{
|
||||
public decimal GetDecimal(ushort value)
|
||||
{
|
||||
return (decimal)value;
|
||||
}
|
||||
}
|
||||
internal class IntDecimalConverter : IDecimalConverter<int>
|
||||
internal class Int32DecimalConverter : IDecimalConverter<int>
|
||||
{
|
||||
public decimal GetDecimal(int value)
|
||||
{
|
||||
return (decimal)value;
|
||||
}
|
||||
}
|
||||
internal class UIntDecimalConverter : IDecimalConverter<uint>
|
||||
internal class UInt32DecimalConverter : IDecimalConverter<uint>
|
||||
{
|
||||
public decimal GetDecimal(uint value)
|
||||
{
|
||||
return (decimal)value;
|
||||
}
|
||||
}
|
||||
internal class LongDecimalConverter : IDecimalConverter<long>
|
||||
internal class Int64DecimalConverter : IDecimalConverter<long>
|
||||
{
|
||||
public decimal GetDecimal(long value)
|
||||
{
|
||||
return (decimal)value;
|
||||
}
|
||||
}
|
||||
internal class ULongDecimalConverter : IDecimalConverter<ulong>
|
||||
internal class UInt64DecimalConverter : IDecimalConverter<ulong>
|
||||
{
|
||||
public decimal GetDecimal(ulong value)
|
||||
{
|
||||
return (decimal)value;
|
||||
}
|
||||
}
|
||||
internal class FloatDecimalConverter : IDecimalConverter<float>
|
||||
internal class SingleDecimalConverter : IDecimalConverter<float>
|
||||
{
|
||||
public decimal GetDecimal(float value)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Converters.tt</DependentUpon>
|
||||
</None>
|
||||
<None Include="PrimitiveDataFrameColumn.BinaryOperators.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>PrimitiveDataFrameColumn.BinaryOperators.tt</DependentUpon>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -34,9 +39,13 @@
|
|||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Converters.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="DataFrameColumn.BinaryOperations.ExplodedColumns.tt">
|
||||
<None Update="PrimitiveDataFrameColumn.BinaryOperationAPIs.ExplodedColumns.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>DataFrameColumn.BinaryOperations.ExplodedColumns.cs</LastGenOutput>
|
||||
<LastGenOutput>PrimitiveDataFrameColumn.BinaryOperationAPIs.ExplodedColumns.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="PrimitiveDataFrameColumn.BinaryOperationImplementations.Exploded.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>PrimitiveDataFrameColumn.BinaryOperationImplementations.Exploded.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="DataFrameColumn.BinaryOperations.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
|
@ -118,21 +127,26 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="ColumnArithmeticTemplate.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>ColumnArithmeticTemplate.ttinclude</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Converters.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Converters.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="PrimitiveDataFrameColumn.BinaryOperationImplementations.Exploded.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>PrimitiveDataFrameColumn.BinaryOperationImplementations.Exploded.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="DataFrameColumn.BinaryOperations.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>DataFrameColumn.BinaryOperations.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="PrimitiveDataFrameColumn.BinaryOperationAPIs.ExplodedColumns.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>PrimitiveDataFrameColumn.BinaryOperationAPIs.ExplodedColumns.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="DataFrameColumn.BinaryOperators.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
|
|
|
@ -6,6 +6,7 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
|
@ -608,7 +609,16 @@ namespace Microsoft.Data.Analysis
|
|||
DataFrameBuffer<bool> newBuffer = new DataFrameBuffer<bool>();
|
||||
ret.Buffers.Add(newBuffer);
|
||||
newBuffer.EnsureCapacity(buffer.Length);
|
||||
if (typeof(T) == typeof(bool))
|
||||
{
|
||||
var localBuffer = buffer;
|
||||
ReadOnlyDataFrameBuffer<bool> boolLocalBuffer = Unsafe.As<ReadOnlyDataFrameBuffer<T>, ReadOnlyDataFrameBuffer<bool>>(ref localBuffer);
|
||||
boolLocalBuffer.ReadOnlySpan.TryCopyTo(newBuffer.RawSpan);
|
||||
}
|
||||
else
|
||||
{
|
||||
newBuffer.Span.Fill(false);
|
||||
}
|
||||
newBuffer.Length = buffer.Length;
|
||||
ret.Length += buffer.Length;
|
||||
}
|
||||
|
@ -709,7 +719,7 @@ namespace Microsoft.Data.Analysis
|
|||
ReadOnlySpan<T> span = buffer.ReadOnlySpan;
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
newBuffer.Append(ShortConverter<T>.Instance.GetShort(span[i]));
|
||||
newBuffer.Append(Int16Converter<T>.Instance.GetInt16(span[i]));
|
||||
}
|
||||
}
|
||||
ret.NullBitMapBuffers = CloneNullBitMapBuffers();
|
||||
|
@ -729,7 +739,7 @@ namespace Microsoft.Data.Analysis
|
|||
ReadOnlySpan<T> span = buffer.ReadOnlySpan;
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
newBuffer.Append(UShortConverter<T>.Instance.GetUShort(span[i]));
|
||||
newBuffer.Append(UInt16Converter<T>.Instance.GetUInt16(span[i]));
|
||||
}
|
||||
}
|
||||
ret.NullBitMapBuffers = CloneNullBitMapBuffers();
|
||||
|
@ -749,7 +759,7 @@ namespace Microsoft.Data.Analysis
|
|||
ReadOnlySpan<T> span = buffer.ReadOnlySpan;
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
newBuffer.Append(IntConverter<T>.Instance.GetInt(span[i]));
|
||||
newBuffer.Append(Int32Converter<T>.Instance.GetInt32(span[i]));
|
||||
}
|
||||
}
|
||||
ret.NullBitMapBuffers = CloneNullBitMapBuffers();
|
||||
|
@ -769,7 +779,7 @@ namespace Microsoft.Data.Analysis
|
|||
ReadOnlySpan<T> span = buffer.ReadOnlySpan;
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
newBuffer.Append(UIntConverter<T>.Instance.GetUInt(span[i]));
|
||||
newBuffer.Append(UInt32Converter<T>.Instance.GetUInt32(span[i]));
|
||||
}
|
||||
}
|
||||
ret.NullBitMapBuffers = CloneNullBitMapBuffers();
|
||||
|
@ -789,7 +799,7 @@ namespace Microsoft.Data.Analysis
|
|||
ReadOnlySpan<T> span = buffer.ReadOnlySpan;
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
newBuffer.Append(LongConverter<T>.Instance.GetLong(span[i]));
|
||||
newBuffer.Append(Int64Converter<T>.Instance.GetInt64(span[i]));
|
||||
}
|
||||
}
|
||||
ret.NullBitMapBuffers = CloneNullBitMapBuffers();
|
||||
|
@ -809,7 +819,7 @@ namespace Microsoft.Data.Analysis
|
|||
ReadOnlySpan<T> span = buffer.ReadOnlySpan;
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
newBuffer.Append(ULongConverter<T>.Instance.GetULong(span[i]));
|
||||
newBuffer.Append(UInt64Converter<T>.Instance.GetUInt64(span[i]));
|
||||
}
|
||||
}
|
||||
ret.NullBitMapBuffers = CloneNullBitMapBuffers();
|
||||
|
@ -829,7 +839,7 @@ namespace Microsoft.Data.Analysis
|
|||
ReadOnlySpan<T> span = buffer.ReadOnlySpan;
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
newBuffer.Append(FloatConverter<T>.Instance.GetFloat(span[i]));
|
||||
newBuffer.Append(SingleConverter<T>.Instance.GetSingle(span[i]));
|
||||
}
|
||||
}
|
||||
ret.NullBitMapBuffers = CloneNullBitMapBuffers();
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,606 @@
|
|||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".cs" #>
|
||||
<#@ include file="ColumnArithmeticTemplate.ttinclude"#>
|
||||
<#@ include file="PrimitiveDataFrameColumn.BinaryOperations.Combinations.ttinclude" #>
|
||||
// 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.
|
||||
|
||||
// Generated from DataFrameColumn.BinaryOperationAPIs.ExplodedColumns.tt. Do not modify directly
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Data.Analysis
|
||||
{
|
||||
<#
|
||||
bool supportedInPlace(string type1, string type2)
|
||||
{
|
||||
string ret = GetBinaryOperationReturnType(type1, type2);
|
||||
if (ret == type1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllBinaryCombinationsForMethod()
|
||||
{
|
||||
HashSet<string> visited = new HashSet<string> { };
|
||||
foreach (TypeCombination outer in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string outerColumnType = outer.ThisColumnType;
|
||||
if (visited.Contains(outerColumnType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
visited.Add(outerColumnType);
|
||||
string fullOuterColumnType = GetCapitalizedPrimitiveTypes(outerColumnType) + "DataFrameColumn";
|
||||
#>
|
||||
public partial class <#=fullOuterColumnType#>
|
||||
{
|
||||
<#
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations.Where((ACombination) => ACombination.ThisColumnType == outerColumnType))
|
||||
{
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
if (method.MethodType == MethodType.Binary && method.IsNumeric)
|
||||
{
|
||||
string methodName = method.MethodName;
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
#>
|
||||
<#
|
||||
if (supportedInPlace(columnType, otherColumnType))
|
||||
{
|
||||
#>
|
||||
public <#=fullReturnType#> <#=methodName#>(<#=fullOtherColumnType#> column, bool inPlace = false)
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
public <#=fullReturnType#> <#=methodName#>(<#=fullOtherColumnType#> column)
|
||||
<#
|
||||
}
|
||||
#>
|
||||
{
|
||||
<#
|
||||
if (columnType == otherColumnType)
|
||||
{
|
||||
// Handle the straightforward cases such as int + int resulting in int
|
||||
if (fullReturnType == fullColumnType || fullReturnType == fullOtherColumnType)
|
||||
{
|
||||
#>
|
||||
return <#=methodName#>Implementation(column, inPlace);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cases such as byte + byte resulting in int. Needs 2 clones
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
<#=fullReturnType#> other<#=returnType#>Column = column.CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(other<#=returnType#>Column, inPlace: true);
|
||||
<#
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle the straightforward cases
|
||||
if (fullReturnType == fullColumnType || fullReturnType == fullOtherColumnType)
|
||||
{
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(columnType, out int columnTypeLevel);
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(otherColumnType, out int otherColumnTypeLevel);
|
||||
if (otherColumnTypeLevel > columnTypeLevel)
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(column, inPlace: true);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> other<#=returnType#>Column = column.CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=methodName#>Implementation(other<#=returnType#>Column, inPlace);
|
||||
<#
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cases such as byte + short resulting in int. Needs 2 clones
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
<#=fullReturnType#> other<#=returnType#>Column = column.CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(other<#=returnType#>Column, inPlace: true);
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllBinaryScalarCombinationsForMethod()
|
||||
{
|
||||
HashSet<string> visited = new HashSet<string> { };
|
||||
foreach (TypeCombination outer in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string outerColumnType = outer.ThisColumnType;
|
||||
if (visited.Contains(outerColumnType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
visited.Add(outerColumnType);
|
||||
string fullOuterColumnType = GetCapitalizedPrimitiveTypes(outerColumnType) + "DataFrameColumn";
|
||||
#>
|
||||
public partial class <#=fullOuterColumnType#>
|
||||
{
|
||||
<#
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations.Where((ACombination) => ACombination.ThisColumnType == outerColumnType))
|
||||
{
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
if (method.MethodType == MethodType.BinaryScalar && method.IsNumeric)
|
||||
{
|
||||
string methodName = method.MethodName;
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string valueType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
|
||||
#>
|
||||
<#
|
||||
if (supportedInPlace(columnType, valueType))
|
||||
{
|
||||
#>
|
||||
public <#=fullReturnType#> <#=methodName#>(<#=valueType#> value, bool inPlace = false)
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
public <#=fullReturnType#> <#=methodName#>(<#=valueType#> value)
|
||||
<#
|
||||
}
|
||||
#>
|
||||
{
|
||||
<#
|
||||
if (columnType == valueType)
|
||||
{
|
||||
// Handle the straightforward cases such as int + int resulting in int
|
||||
if (fullReturnType == fullColumnType)
|
||||
{
|
||||
#>
|
||||
return <#=methodName#>Implementation(value, inPlace);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cases such as byte + byte resulting in int. Needs 2 clones
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(value, inPlace: true);
|
||||
<#
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle the straightforward cases
|
||||
if (fullReturnType == fullColumnType)
|
||||
{
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(columnType, out int columnTypeLevel);
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(valueType, out int valueTypeLevel);
|
||||
if (valueTypeLevel > columnTypeLevel)
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(value, inPlace: true);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
<#=returnType#> convertedValue = (<#=returnType#>)value;
|
||||
return <#=methodName#>Implementation(convertedValue, inPlace);
|
||||
<#
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cases such as byte + short resulting in int. Needs 2 clones
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(value, inPlace: true);
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
if (method.MethodType == MethodType.BinaryScalar && method.IsNumeric)
|
||||
{
|
||||
string methodName = "Reverse" + method.MethodName;
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string valueType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
|
||||
#>
|
||||
<#
|
||||
if (supportedInPlace(columnType, valueType))
|
||||
{
|
||||
#>
|
||||
public <#=fullReturnType#> <#=methodName#>(<#=valueType#> value, bool inPlace = false)
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
public <#=fullReturnType#> <#=methodName#>(<#=valueType#> value)
|
||||
<#
|
||||
}
|
||||
#>
|
||||
{
|
||||
<#
|
||||
if (columnType == valueType)
|
||||
{
|
||||
// Handle the straightforward cases such as int + int resulting in int
|
||||
if (fullReturnType == fullColumnType)
|
||||
{
|
||||
#>
|
||||
return <#=methodName#>Implementation(value, inPlace);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cases such as byte + byte resulting in int. Needs 2 clones
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(value, inPlace: true);
|
||||
<#
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle the straightforward cases
|
||||
if (fullReturnType == fullColumnType)
|
||||
{
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(columnType, out int columnTypeLevel);
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(valueType, out int valueTypeLevel);
|
||||
if (valueTypeLevel > columnTypeLevel)
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(value, inPlace: true);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
<#=returnType#> convertedValue = (<#=returnType#>)value;
|
||||
return <#=methodName#>Implementation(convertedValue, inPlace);
|
||||
<#
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cases such as byte + short resulting in int. Needs 2 clones
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
return <#=returnType#>Column.<#=methodName#>Implementation(value, inPlace: true);
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllBinaryBitwiseOperationsForMethod(string methodName)
|
||||
{
|
||||
#>
|
||||
public partial class BooleanDataFrameColumn
|
||||
{
|
||||
public BooleanDataFrameColumn <#=methodName#>(BooleanDataFrameColumn column, bool inPlace = false)
|
||||
{
|
||||
if (column.Length != Length)
|
||||
{
|
||||
throw new ArgumentException(Strings.MismatchedColumnLengths, nameof(column));
|
||||
}
|
||||
BooleanDataFrameColumn retColumn = inPlace ? this : CloneAsBooleanColumn();
|
||||
retColumn.ColumnContainer.<#=methodName#>(column.ColumnContainer);
|
||||
return retColumn;
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllBinaryScalarBitwiseOperationsForMethod(string methodName)
|
||||
{
|
||||
#>
|
||||
public partial class BooleanDataFrameColumn
|
||||
{
|
||||
public new BooleanDataFrameColumn <#=methodName#>(bool value, bool inPlace = false)
|
||||
{
|
||||
BooleanDataFrameColumn retColumn = inPlace ? this : CloneAsBooleanColumn();
|
||||
retColumn.ColumnContainer.<#=methodName#>(value);
|
||||
return retColumn;
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
GenerateAllBinaryCombinationsForMethod();
|
||||
GenerateAllBinaryScalarCombinationsForMethod();
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
if (method.MethodType == MethodType.Binary && method.IsBitwise)
|
||||
{
|
||||
GenerateAllBinaryBitwiseOperationsForMethod(method.MethodName);
|
||||
}
|
||||
else if (method.MethodType == MethodType.BinaryScalar && method.IsBitwise)
|
||||
{
|
||||
GenerateAllBinaryScalarBitwiseOperationsForMethod(method.MethodName);
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllComparisonCombinationsForMethod()
|
||||
{
|
||||
HashSet<string> visited = new HashSet<string> { };
|
||||
foreach (TypeCombination outer in ComparisonOperationCombinations.comparisonOperationCombinations)
|
||||
{
|
||||
string outerColumnType = outer.ThisColumnType;
|
||||
if (visited.Contains(outerColumnType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
visited.Add(outerColumnType);
|
||||
string fullOuterColumnType = GetCapitalizedPrimitiveTypes(outerColumnType) + "DataFrameColumn";
|
||||
#>
|
||||
public partial class <#=fullOuterColumnType#>
|
||||
{
|
||||
<#
|
||||
foreach (TypeCombination types in ComparisonOperationCombinations.comparisonOperationCombinations.Where((ACombination) => ACombination.ThisColumnType == outerColumnType))
|
||||
{
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
if (method.MethodType == MethodType.ComparisonScalar)
|
||||
{
|
||||
string methodName = method.MethodName;
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string capitalizedOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType);
|
||||
string capitalizedColumnType = GetCapitalizedPrimitiveTypes(columnType);
|
||||
|
||||
#>
|
||||
public <#=fullReturnType#> <#=methodName#>(<#=fullOtherColumnType#> column)
|
||||
{
|
||||
<#
|
||||
if (columnType == otherColumnType)
|
||||
{
|
||||
#>
|
||||
return <#=methodName#>Implementation(column);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(columnType, out int columnTypeLevel);
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(otherColumnType, out int otherColumnTypeLevel);
|
||||
if (otherColumnTypeLevel > columnTypeLevel)
|
||||
{
|
||||
#>
|
||||
<#=fullOtherColumnType#> <#=otherColumnType#>Column = CloneAs<#=capitalizedOtherColumnType#>Column();
|
||||
return <#=otherColumnType#>Column.<#=methodName#>Implementation(column);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
<#=fullColumnType#> other<#=columnType#>Column = column.CloneAs<#=capitalizedColumnType#>Column();
|
||||
return <#=methodName#>Implementation(other<#=columnType#>Column);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
|
||||
<#
|
||||
void GenerateAllComparisonScalarCombinationsForMethod()
|
||||
{
|
||||
HashSet<string> visited = new HashSet<string> { };
|
||||
foreach (TypeCombination outer in ComparisonOperationCombinations.comparisonOperationCombinations)
|
||||
{
|
||||
string outerColumnType = outer.ThisColumnType;
|
||||
if (visited.Contains(outerColumnType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
visited.Add(outerColumnType);
|
||||
string fullOuterColumnType = GetCapitalizedPrimitiveTypes(outerColumnType) + "DataFrameColumn";
|
||||
#>
|
||||
public partial class <#=fullOuterColumnType#>
|
||||
{
|
||||
<#
|
||||
foreach (TypeCombination types in ComparisonOperationCombinations.comparisonOperationCombinations.Where((ACombination) => ACombination.ThisColumnType == outerColumnType))
|
||||
{
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
if (method.MethodType == MethodType.Comparison)
|
||||
{
|
||||
string methodName = method.MethodName;
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string capitalizedOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType);
|
||||
string capitalizedColumnType = GetCapitalizedPrimitiveTypes(columnType);
|
||||
#>
|
||||
public <#=fullReturnType#> <#=methodName#>(<#=otherColumnType#> value)
|
||||
{
|
||||
<#
|
||||
if (columnType == otherColumnType)
|
||||
{
|
||||
#>
|
||||
return <#=methodName#>Implementation(value);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(columnType, out int columnTypeLevel);
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(otherColumnType, out int otherColumnTypeLevel);
|
||||
if (otherColumnTypeLevel > columnTypeLevel)
|
||||
{
|
||||
#>
|
||||
<#=fullOtherColumnType#> <#=otherColumnType#>Column = CloneAs<#=capitalizedOtherColumnType#>Column();
|
||||
return <#=otherColumnType#>Column.<#=methodName#>Implementation(value);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
<#=columnType#> other<#=columnType#>Value = (<#=columnType#>)value;
|
||||
return <#=methodName#>Implementation(other<#=columnType#>Value);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
GenerateAllComparisonCombinationsForMethod();
|
||||
GenerateAllComparisonScalarCombinationsForMethod();
|
||||
#>
|
||||
|
||||
<#
|
||||
void GenerateAllBinaryShiftCombinationsForMethod(string methodName)
|
||||
{
|
||||
foreach (var type in typeConfiguration)
|
||||
{
|
||||
if (!type.SupportsNumeric || !type.SupportsBitwise || type.TypeName == "char")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string returnType = GetBinaryShiftOperationReturnType(type);
|
||||
if (returnType == string.Empty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(type.TypeName) + "DataFrameColumn";
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
#>
|
||||
public partial class <#=fullColumnType#>
|
||||
{
|
||||
public new <#=fullReturnType#> <#=methodName#>(int value, bool inPlace = false)
|
||||
{
|
||||
<#
|
||||
if (fullColumnType == fullReturnType)
|
||||
{
|
||||
#>
|
||||
var result = (PrimitiveDataFrameColumn<<#=returnType#>>)base.<#=methodName#>(value, inPlace);
|
||||
return new <#=fullReturnType#>(result.Name, result.ColumnContainer);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> <#=returnType#>Column = CloneAs<#=capitalizedReturnType#>Column();
|
||||
var result = (PrimitiveDataFrameColumn<<#=returnType#>>)(<#=returnType#>Column.<#=methodName#>(value, inPlace));
|
||||
return new <#=fullReturnType#>(result.Name, result.ColumnContainer);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
if (method.MethodType == MethodType.BinaryInt)
|
||||
{
|
||||
GenerateAllBinaryShiftCombinationsForMethod(method.MethodName);
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,235 @@
|
|||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ import namespace="System.Diagnostics" #>
|
||||
<#@ output extension=".cs" #>
|
||||
<#@ include file="ColumnArithmeticTemplate.ttinclude"#>
|
||||
<#@ include file="PrimitiveDataFrameColumn.BinaryOperations.Combinations.ttinclude" #>
|
||||
// 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.
|
||||
|
||||
// Generated from DataFrameColumn.BinaryOperationImplementations.ExplodedColumns.tt. Do not modify directly
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Data.Analysis
|
||||
{
|
||||
<#
|
||||
bool supportedInPlace(string type1, string type2)
|
||||
{
|
||||
string ret = GetBinaryOperationReturnType(type1, type2);
|
||||
if (ret == type1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#>
|
||||
<#
|
||||
// This method generates implementations where the arguments are of the same type.
|
||||
void GenerateAllBinaryCombinationsForMethod(string inputMethodName)
|
||||
{
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
if (columnType != otherColumnType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (columnType != returnType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Debug.Assert(returnType == otherColumnType);
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = fullColumnType;
|
||||
string fullOtherColumnType = fullColumnType;
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string methodName = inputMethodName + "Implementation";
|
||||
#>
|
||||
public partial class <#=fullColumnType#>
|
||||
{
|
||||
<#
|
||||
if (supportedInPlace(columnType, otherColumnType))
|
||||
{
|
||||
#>
|
||||
internal <#=fullReturnType#> <#=methodName#>(<#=fullOtherColumnType#> column, bool inPlace = false)
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
internal <#=fullReturnType#> <#=methodName#>(<#=fullOtherColumnType#> column)
|
||||
<#
|
||||
}
|
||||
#>
|
||||
{
|
||||
if (column.Length != Length)
|
||||
{
|
||||
throw new ArgumentException(Strings.MismatchedColumnLengths, nameof(column));
|
||||
}
|
||||
<#=fullReturnType#> newColumn = inPlace ? this : CloneAs<#=capitalizedReturnType#>Column();
|
||||
newColumn.ColumnContainer.<#=inputMethodName#>(column.ColumnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
// This method generates implementations where the arguments are of the same type.
|
||||
void GenerateAllBinaryScalarCombinationsForMethod(string inputMethodName)
|
||||
{
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
if (columnType != otherColumnType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (columnType != returnType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Debug.Assert(returnType == otherColumnType);
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = fullColumnType;
|
||||
string fullOtherColumnType = fullColumnType;
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string methodName = inputMethodName;
|
||||
methodName += "Implementation";
|
||||
#>
|
||||
public partial class <#=fullColumnType#>
|
||||
{
|
||||
<#
|
||||
if (supportedInPlace(columnType, otherColumnType))
|
||||
{
|
||||
#>
|
||||
internal <#=fullReturnType#> <#=methodName#>(<#=otherColumnType#> value, bool inPlace = false)
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
internal <#=fullReturnType#> <#=methodName#>(<#=otherColumnType#> value)
|
||||
<#
|
||||
}
|
||||
#>
|
||||
{
|
||||
<#=fullReturnType#> newColumn = inPlace ? this : CloneAs<#=capitalizedReturnType#>Column();
|
||||
newColumn.ColumnContainer.<#=inputMethodName#>(value);
|
||||
return newColumn;
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllComparisonCombinationsForMethod(string inputMethodName)
|
||||
{
|
||||
foreach (TypeCombination types in ComparisonOperationCombinations.comparisonOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
if (columnType != otherColumnType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Debug.Assert(returnType == otherColumnType);
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string methodName = inputMethodName;
|
||||
methodName += "Implementation";
|
||||
|
||||
#>
|
||||
public partial class <#=fullColumnType#>
|
||||
{
|
||||
internal <#=fullReturnType#> <#=methodName#>(<#=fullOtherColumnType#> column)
|
||||
{
|
||||
BooleanDataFrameColumn newColumn = CloneAsBooleanColumn();
|
||||
ColumnContainer.<#=inputMethodName#>(column.ColumnContainer, newColumn.ColumnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllComparisonScalarCombinationsForMethod(string inputMethodName)
|
||||
{
|
||||
foreach (TypeCombination types in ComparisonOperationCombinations.comparisonOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
if (columnType != otherColumnType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Debug.Assert(returnType == otherColumnType);
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string methodName = inputMethodName;
|
||||
methodName += "Implementation";
|
||||
|
||||
#>
|
||||
public partial class <#=fullColumnType#>
|
||||
{
|
||||
internal <#=fullReturnType#> <#=methodName#>(<#=otherColumnType#> value)
|
||||
{
|
||||
BooleanDataFrameColumn newColumn = CloneAsBooleanColumn();
|
||||
ColumnContainer.<#=inputMethodName#>(value, newColumn.ColumnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
// Don't generate method for Comparison and ComparisonScalar methods here
|
||||
if (method.MethodType == MethodType.Binary && method.IsNumeric)
|
||||
{
|
||||
GenerateAllBinaryCombinationsForMethod(method.MethodName);
|
||||
}
|
||||
else if (method.MethodType == MethodType.BinaryScalar && method.IsNumeric)
|
||||
{
|
||||
GenerateAllBinaryScalarCombinationsForMethod(method.MethodName);
|
||||
GenerateAllBinaryScalarCombinationsForMethod("Reverse" + method.MethodName);
|
||||
}
|
||||
else if (method.MethodType == MethodType.Comparison)
|
||||
{
|
||||
GenerateAllComparisonCombinationsForMethod(method.MethodName);
|
||||
}
|
||||
else if (method.MethodType == MethodType.ComparisonScalar)
|
||||
{
|
||||
GenerateAllComparisonScalarCombinationsForMethod(method.MethodName);
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic"#>
|
||||
<#@ output extension=".ttinclude"#>
|
||||
<#@ include file="ColumnArithmeticTemplate.ttinclude"#>
|
||||
\<#+
|
||||
// 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.
|
||||
|
||||
// Generated from PrimitiveDataFrameColumn.BinaryOperations.Combinations.tt. Do not modify directly
|
||||
|
||||
public class TypeCombination
|
||||
{
|
||||
private string _thisColumnType;
|
||||
private string _otherColumnType;
|
||||
private string _returnColumnType;
|
||||
|
||||
public TypeCombination(string thisColumnType, string otherColumnType, string returnColumnType)
|
||||
{
|
||||
_thisColumnType = thisColumnType;
|
||||
_otherColumnType = otherColumnType;
|
||||
_returnColumnType = returnColumnType;
|
||||
}
|
||||
public string ThisColumnType => _thisColumnType;
|
||||
public string OtherColumnType => _otherColumnType;
|
||||
public string ReturnColumnType => _returnColumnType;
|
||||
}
|
||||
|
||||
public static class BinaryOperationCombinations
|
||||
{
|
||||
|
||||
public static List<TypeCombination> binaryOperationCombinations = new List<TypeCombination>
|
||||
{
|
||||
<#
|
||||
foreach (TypeConfiguration type in typeConfiguration)
|
||||
{
|
||||
if(!type.SupportsNumeric || type.TypeName == "char")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (TypeConfiguration type2 in typeConfiguration)
|
||||
{
|
||||
if (!type2.SupportsNumeric || type2.TypeName == "char")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#>
|
||||
<#
|
||||
// We won't support binary operations on pairs of signed and unsigned types yet. For users, there is a simple work around of cloning the columns to higher types(short -> int, int -> long etc) and then performing binary ops on them
|
||||
if (IsMixedSignedAndUnsignedTypePair(type.TypeName, type2.TypeName)) {
|
||||
// continue;
|
||||
}
|
||||
|
||||
// If the C# spec doesn't allow some implicit conversions, don't define that API
|
||||
string returnType = GetBinaryOperationReturnType(type, type2);
|
||||
if (returnType == string.Empty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#>
|
||||
new TypeCombination("<#=type.TypeName#>", "<#=type2.TypeName#>", "<#=returnType#>"),
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
};
|
||||
}
|
||||
|
||||
public static class ComparisonOperationCombinations
|
||||
{
|
||||
public static List<TypeCombination> comparisonOperationCombinations = new List<TypeCombination>
|
||||
{
|
||||
<#
|
||||
foreach (TypeConfiguration type in typeConfiguration)
|
||||
{
|
||||
if (type.TypeName == "char")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (TypeConfiguration innerType in typeConfiguration)
|
||||
{
|
||||
if (innerType.TypeName == "char")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (type.TypeName == "bool" && innerType.TypeName != "bool")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (type.SupportsNumeric != innerType.SupportsNumeric)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// For comparison, we don't exclude mixed signed and unsigned types since the result is always a bool
|
||||
|
||||
if (type.SupportsNumeric)
|
||||
{
|
||||
// If the C# spec doesn't allow some implicit conversions, don't define that API. For ex: float == decimal or long == ulong are not allowed
|
||||
string returnType = GetBinaryOperationReturnType(type, innerType);
|
||||
if (returnType == string.Empty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#>
|
||||
new TypeCombination("<#=type.TypeName#>", "<#=innerType.TypeName#>", "bool"),
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
};
|
||||
}
|
||||
\#>
|
|
@ -0,0 +1,271 @@
|
|||
|
||||
<#+
|
||||
// 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.
|
||||
|
||||
// Generated from PrimitiveDataFrameColumn.BinaryOperations.Combinations.tt. Do not modify directly
|
||||
|
||||
public class TypeCombination
|
||||
{
|
||||
private string _thisColumnType;
|
||||
private string _otherColumnType;
|
||||
private string _returnColumnType;
|
||||
|
||||
public TypeCombination(string thisColumnType, string otherColumnType, string returnColumnType)
|
||||
{
|
||||
_thisColumnType = thisColumnType;
|
||||
_otherColumnType = otherColumnType;
|
||||
_returnColumnType = returnColumnType;
|
||||
}
|
||||
public string ThisColumnType => _thisColumnType;
|
||||
public string OtherColumnType => _otherColumnType;
|
||||
public string ReturnColumnType => _returnColumnType;
|
||||
}
|
||||
|
||||
public static class BinaryOperationCombinations
|
||||
{
|
||||
|
||||
public static List<TypeCombination> binaryOperationCombinations = new List<TypeCombination>
|
||||
{
|
||||
new TypeCombination("byte", "byte", "int"),
|
||||
new TypeCombination("byte", "decimal", "decimal"),
|
||||
new TypeCombination("byte", "double", "double"),
|
||||
new TypeCombination("byte", "float", "float"),
|
||||
new TypeCombination("byte", "int", "int"),
|
||||
new TypeCombination("byte", "long", "long"),
|
||||
new TypeCombination("byte", "sbyte", "int"),
|
||||
new TypeCombination("byte", "short", "int"),
|
||||
new TypeCombination("byte", "uint", "uint"),
|
||||
new TypeCombination("byte", "ulong", "ulong"),
|
||||
new TypeCombination("byte", "ushort", "int"),
|
||||
new TypeCombination("decimal", "byte", "decimal"),
|
||||
new TypeCombination("decimal", "decimal", "decimal"),
|
||||
new TypeCombination("decimal", "int", "decimal"),
|
||||
new TypeCombination("decimal", "long", "decimal"),
|
||||
new TypeCombination("decimal", "sbyte", "decimal"),
|
||||
new TypeCombination("decimal", "short", "decimal"),
|
||||
new TypeCombination("decimal", "uint", "decimal"),
|
||||
new TypeCombination("decimal", "ulong", "decimal"),
|
||||
new TypeCombination("decimal", "ushort", "decimal"),
|
||||
new TypeCombination("double", "byte", "double"),
|
||||
new TypeCombination("double", "double", "double"),
|
||||
new TypeCombination("double", "float", "double"),
|
||||
new TypeCombination("double", "int", "double"),
|
||||
new TypeCombination("double", "long", "double"),
|
||||
new TypeCombination("double", "sbyte", "double"),
|
||||
new TypeCombination("double", "short", "double"),
|
||||
new TypeCombination("double", "uint", "double"),
|
||||
new TypeCombination("double", "ulong", "double"),
|
||||
new TypeCombination("double", "ushort", "double"),
|
||||
new TypeCombination("float", "byte", "float"),
|
||||
new TypeCombination("float", "double", "double"),
|
||||
new TypeCombination("float", "float", "float"),
|
||||
new TypeCombination("float", "int", "float"),
|
||||
new TypeCombination("float", "long", "float"),
|
||||
new TypeCombination("float", "sbyte", "float"),
|
||||
new TypeCombination("float", "short", "float"),
|
||||
new TypeCombination("float", "uint", "float"),
|
||||
new TypeCombination("float", "ulong", "float"),
|
||||
new TypeCombination("float", "ushort", "float"),
|
||||
new TypeCombination("int", "byte", "int"),
|
||||
new TypeCombination("int", "decimal", "decimal"),
|
||||
new TypeCombination("int", "double", "double"),
|
||||
new TypeCombination("int", "float", "float"),
|
||||
new TypeCombination("int", "int", "int"),
|
||||
new TypeCombination("int", "long", "long"),
|
||||
new TypeCombination("int", "sbyte", "int"),
|
||||
new TypeCombination("int", "short", "int"),
|
||||
new TypeCombination("int", "uint", "long"),
|
||||
new TypeCombination("int", "ulong", "float"),
|
||||
new TypeCombination("int", "ushort", "int"),
|
||||
new TypeCombination("long", "byte", "long"),
|
||||
new TypeCombination("long", "decimal", "decimal"),
|
||||
new TypeCombination("long", "double", "double"),
|
||||
new TypeCombination("long", "float", "float"),
|
||||
new TypeCombination("long", "int", "long"),
|
||||
new TypeCombination("long", "long", "long"),
|
||||
new TypeCombination("long", "sbyte", "long"),
|
||||
new TypeCombination("long", "short", "long"),
|
||||
new TypeCombination("long", "uint", "long"),
|
||||
new TypeCombination("long", "ushort", "long"),
|
||||
new TypeCombination("sbyte", "byte", "int"),
|
||||
new TypeCombination("sbyte", "decimal", "decimal"),
|
||||
new TypeCombination("sbyte", "double", "double"),
|
||||
new TypeCombination("sbyte", "float", "float"),
|
||||
new TypeCombination("sbyte", "int", "int"),
|
||||
new TypeCombination("sbyte", "long", "long"),
|
||||
new TypeCombination("sbyte", "sbyte", "int"),
|
||||
new TypeCombination("sbyte", "short", "int"),
|
||||
new TypeCombination("sbyte", "uint", "long"),
|
||||
new TypeCombination("sbyte", "ulong", "float"),
|
||||
new TypeCombination("sbyte", "ushort", "int"),
|
||||
new TypeCombination("short", "byte", "int"),
|
||||
new TypeCombination("short", "decimal", "decimal"),
|
||||
new TypeCombination("short", "double", "double"),
|
||||
new TypeCombination("short", "float", "float"),
|
||||
new TypeCombination("short", "int", "int"),
|
||||
new TypeCombination("short", "long", "long"),
|
||||
new TypeCombination("short", "sbyte", "int"),
|
||||
new TypeCombination("short", "short", "int"),
|
||||
new TypeCombination("short", "uint", "long"),
|
||||
new TypeCombination("short", "ulong", "float"),
|
||||
new TypeCombination("short", "ushort", "int"),
|
||||
new TypeCombination("uint", "byte", "uint"),
|
||||
new TypeCombination("uint", "decimal", "decimal"),
|
||||
new TypeCombination("uint", "double", "double"),
|
||||
new TypeCombination("uint", "float", "float"),
|
||||
new TypeCombination("uint", "int", "long"),
|
||||
new TypeCombination("uint", "long", "long"),
|
||||
new TypeCombination("uint", "sbyte", "long"),
|
||||
new TypeCombination("uint", "short", "long"),
|
||||
new TypeCombination("uint", "uint", "uint"),
|
||||
new TypeCombination("uint", "ulong", "ulong"),
|
||||
new TypeCombination("uint", "ushort", "uint"),
|
||||
new TypeCombination("ulong", "byte", "ulong"),
|
||||
new TypeCombination("ulong", "decimal", "decimal"),
|
||||
new TypeCombination("ulong", "double", "double"),
|
||||
new TypeCombination("ulong", "float", "float"),
|
||||
new TypeCombination("ulong", "int", "float"),
|
||||
new TypeCombination("ulong", "sbyte", "float"),
|
||||
new TypeCombination("ulong", "short", "float"),
|
||||
new TypeCombination("ulong", "uint", "ulong"),
|
||||
new TypeCombination("ulong", "ulong", "ulong"),
|
||||
new TypeCombination("ulong", "ushort", "ulong"),
|
||||
new TypeCombination("ushort", "byte", "int"),
|
||||
new TypeCombination("ushort", "decimal", "decimal"),
|
||||
new TypeCombination("ushort", "double", "double"),
|
||||
new TypeCombination("ushort", "float", "float"),
|
||||
new TypeCombination("ushort", "int", "int"),
|
||||
new TypeCombination("ushort", "long", "long"),
|
||||
new TypeCombination("ushort", "sbyte", "int"),
|
||||
new TypeCombination("ushort", "short", "int"),
|
||||
new TypeCombination("ushort", "uint", "uint"),
|
||||
new TypeCombination("ushort", "ulong", "ulong"),
|
||||
new TypeCombination("ushort", "ushort", "int"),
|
||||
};
|
||||
}
|
||||
|
||||
public static class ComparisonOperationCombinations
|
||||
{
|
||||
public static List<TypeCombination> comparisonOperationCombinations = new List<TypeCombination>
|
||||
{
|
||||
new TypeCombination("bool", "bool", "bool"),
|
||||
new TypeCombination("byte", "byte", "bool"),
|
||||
new TypeCombination("byte", "decimal", "bool"),
|
||||
new TypeCombination("byte", "double", "bool"),
|
||||
new TypeCombination("byte", "float", "bool"),
|
||||
new TypeCombination("byte", "int", "bool"),
|
||||
new TypeCombination("byte", "long", "bool"),
|
||||
new TypeCombination("byte", "sbyte", "bool"),
|
||||
new TypeCombination("byte", "short", "bool"),
|
||||
new TypeCombination("byte", "uint", "bool"),
|
||||
new TypeCombination("byte", "ulong", "bool"),
|
||||
new TypeCombination("byte", "ushort", "bool"),
|
||||
new TypeCombination("decimal", "byte", "bool"),
|
||||
new TypeCombination("decimal", "decimal", "bool"),
|
||||
new TypeCombination("decimal", "int", "bool"),
|
||||
new TypeCombination("decimal", "long", "bool"),
|
||||
new TypeCombination("decimal", "sbyte", "bool"),
|
||||
new TypeCombination("decimal", "short", "bool"),
|
||||
new TypeCombination("decimal", "uint", "bool"),
|
||||
new TypeCombination("decimal", "ulong", "bool"),
|
||||
new TypeCombination("decimal", "ushort", "bool"),
|
||||
new TypeCombination("double", "byte", "bool"),
|
||||
new TypeCombination("double", "double", "bool"),
|
||||
new TypeCombination("double", "float", "bool"),
|
||||
new TypeCombination("double", "int", "bool"),
|
||||
new TypeCombination("double", "long", "bool"),
|
||||
new TypeCombination("double", "sbyte", "bool"),
|
||||
new TypeCombination("double", "short", "bool"),
|
||||
new TypeCombination("double", "uint", "bool"),
|
||||
new TypeCombination("double", "ulong", "bool"),
|
||||
new TypeCombination("double", "ushort", "bool"),
|
||||
new TypeCombination("float", "byte", "bool"),
|
||||
new TypeCombination("float", "double", "bool"),
|
||||
new TypeCombination("float", "float", "bool"),
|
||||
new TypeCombination("float", "int", "bool"),
|
||||
new TypeCombination("float", "long", "bool"),
|
||||
new TypeCombination("float", "sbyte", "bool"),
|
||||
new TypeCombination("float", "short", "bool"),
|
||||
new TypeCombination("float", "uint", "bool"),
|
||||
new TypeCombination("float", "ulong", "bool"),
|
||||
new TypeCombination("float", "ushort", "bool"),
|
||||
new TypeCombination("int", "byte", "bool"),
|
||||
new TypeCombination("int", "decimal", "bool"),
|
||||
new TypeCombination("int", "double", "bool"),
|
||||
new TypeCombination("int", "float", "bool"),
|
||||
new TypeCombination("int", "int", "bool"),
|
||||
new TypeCombination("int", "long", "bool"),
|
||||
new TypeCombination("int", "sbyte", "bool"),
|
||||
new TypeCombination("int", "short", "bool"),
|
||||
new TypeCombination("int", "uint", "bool"),
|
||||
new TypeCombination("int", "ulong", "bool"),
|
||||
new TypeCombination("int", "ushort", "bool"),
|
||||
new TypeCombination("long", "byte", "bool"),
|
||||
new TypeCombination("long", "decimal", "bool"),
|
||||
new TypeCombination("long", "double", "bool"),
|
||||
new TypeCombination("long", "float", "bool"),
|
||||
new TypeCombination("long", "int", "bool"),
|
||||
new TypeCombination("long", "long", "bool"),
|
||||
new TypeCombination("long", "sbyte", "bool"),
|
||||
new TypeCombination("long", "short", "bool"),
|
||||
new TypeCombination("long", "uint", "bool"),
|
||||
new TypeCombination("long", "ushort", "bool"),
|
||||
new TypeCombination("sbyte", "byte", "bool"),
|
||||
new TypeCombination("sbyte", "decimal", "bool"),
|
||||
new TypeCombination("sbyte", "double", "bool"),
|
||||
new TypeCombination("sbyte", "float", "bool"),
|
||||
new TypeCombination("sbyte", "int", "bool"),
|
||||
new TypeCombination("sbyte", "long", "bool"),
|
||||
new TypeCombination("sbyte", "sbyte", "bool"),
|
||||
new TypeCombination("sbyte", "short", "bool"),
|
||||
new TypeCombination("sbyte", "uint", "bool"),
|
||||
new TypeCombination("sbyte", "ulong", "bool"),
|
||||
new TypeCombination("sbyte", "ushort", "bool"),
|
||||
new TypeCombination("short", "byte", "bool"),
|
||||
new TypeCombination("short", "decimal", "bool"),
|
||||
new TypeCombination("short", "double", "bool"),
|
||||
new TypeCombination("short", "float", "bool"),
|
||||
new TypeCombination("short", "int", "bool"),
|
||||
new TypeCombination("short", "long", "bool"),
|
||||
new TypeCombination("short", "sbyte", "bool"),
|
||||
new TypeCombination("short", "short", "bool"),
|
||||
new TypeCombination("short", "uint", "bool"),
|
||||
new TypeCombination("short", "ulong", "bool"),
|
||||
new TypeCombination("short", "ushort", "bool"),
|
||||
new TypeCombination("uint", "byte", "bool"),
|
||||
new TypeCombination("uint", "decimal", "bool"),
|
||||
new TypeCombination("uint", "double", "bool"),
|
||||
new TypeCombination("uint", "float", "bool"),
|
||||
new TypeCombination("uint", "int", "bool"),
|
||||
new TypeCombination("uint", "long", "bool"),
|
||||
new TypeCombination("uint", "sbyte", "bool"),
|
||||
new TypeCombination("uint", "short", "bool"),
|
||||
new TypeCombination("uint", "uint", "bool"),
|
||||
new TypeCombination("uint", "ulong", "bool"),
|
||||
new TypeCombination("uint", "ushort", "bool"),
|
||||
new TypeCombination("ulong", "byte", "bool"),
|
||||
new TypeCombination("ulong", "decimal", "bool"),
|
||||
new TypeCombination("ulong", "double", "bool"),
|
||||
new TypeCombination("ulong", "float", "bool"),
|
||||
new TypeCombination("ulong", "int", "bool"),
|
||||
new TypeCombination("ulong", "sbyte", "bool"),
|
||||
new TypeCombination("ulong", "short", "bool"),
|
||||
new TypeCombination("ulong", "uint", "bool"),
|
||||
new TypeCombination("ulong", "ulong", "bool"),
|
||||
new TypeCombination("ulong", "ushort", "bool"),
|
||||
new TypeCombination("ushort", "byte", "bool"),
|
||||
new TypeCombination("ushort", "decimal", "bool"),
|
||||
new TypeCombination("ushort", "double", "bool"),
|
||||
new TypeCombination("ushort", "float", "bool"),
|
||||
new TypeCombination("ushort", "int", "bool"),
|
||||
new TypeCombination("ushort", "long", "bool"),
|
||||
new TypeCombination("ushort", "sbyte", "bool"),
|
||||
new TypeCombination("ushort", "short", "bool"),
|
||||
new TypeCombination("ushort", "uint", "bool"),
|
||||
new TypeCombination("ushort", "ulong", "bool"),
|
||||
new TypeCombination("ushort", "ushort", "bool"),
|
||||
};
|
||||
}
|
||||
#>
|
|
@ -1710,7 +1710,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBooleanColumn();
|
||||
(this as PrimitiveDataFrameColumn<U>)._columnContainer.ElementwiseEquals(column._columnContainer, retColumn._columnContainer);
|
||||
return retColumn;
|
||||
case Type decimalType when decimalType == typeof(decimal):
|
||||
|
@ -1722,13 +1722,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseEquals(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseEquals(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -1752,7 +1752,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseEquals(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -1760,14 +1760,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseEquals((column as PrimitiveDataFrameColumn<decimal>)._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseEquals(column.CloneAsDoubleColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -1786,7 +1786,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBooleanColumn();
|
||||
(this as PrimitiveDataFrameColumn<bool>)._columnContainer.ElementwiseEquals(Unsafe.As<U, bool>(ref value), retColumn._columnContainer);
|
||||
return retColumn;
|
||||
case Type decimalType when decimalType == typeof(decimal):
|
||||
|
@ -1798,13 +1798,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseEquals(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseEquals(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -1828,7 +1828,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseEquals(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -1836,14 +1836,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseEquals(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseEquals(DoubleConverter<U>.Instance.GetDouble(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -1867,7 +1867,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBooleanColumn();
|
||||
(this as PrimitiveDataFrameColumn<U>)._columnContainer.ElementwiseNotEquals(column._columnContainer, retColumn._columnContainer);
|
||||
return retColumn;
|
||||
case Type decimalType when decimalType == typeof(decimal):
|
||||
|
@ -1879,13 +1879,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseNotEquals(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseNotEquals(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -1909,7 +1909,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseNotEquals(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -1917,14 +1917,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseNotEquals((column as PrimitiveDataFrameColumn<decimal>)._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseNotEquals(column.CloneAsDoubleColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -1943,7 +1943,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBooleanColumn();
|
||||
(this as PrimitiveDataFrameColumn<bool>)._columnContainer.ElementwiseNotEquals(Unsafe.As<U, bool>(ref value), retColumn._columnContainer);
|
||||
return retColumn;
|
||||
case Type decimalType when decimalType == typeof(decimal):
|
||||
|
@ -1955,13 +1955,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseNotEquals(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseNotEquals(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -1985,7 +1985,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseNotEquals(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -1993,14 +1993,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseNotEquals(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseNotEquals(DoubleConverter<U>.Instance.GetDouble(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2030,13 +2030,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseGreaterThanOrEqual(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseGreaterThanOrEqual(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2060,7 +2060,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseGreaterThanOrEqual(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -2068,14 +2068,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseGreaterThanOrEqual((column as PrimitiveDataFrameColumn<decimal>)._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseGreaterThanOrEqual(column.CloneAsDoubleColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2100,13 +2100,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseGreaterThanOrEqual(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseGreaterThanOrEqual(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2130,7 +2130,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseGreaterThanOrEqual(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -2138,14 +2138,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseGreaterThanOrEqual(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseGreaterThanOrEqual(DoubleConverter<U>.Instance.GetDouble(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2175,13 +2175,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseLessThanOrEqual(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseLessThanOrEqual(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2205,7 +2205,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseLessThanOrEqual(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -2213,14 +2213,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseLessThanOrEqual((column as PrimitiveDataFrameColumn<decimal>)._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseLessThanOrEqual(column.CloneAsDoubleColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2245,13 +2245,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseLessThanOrEqual(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseLessThanOrEqual(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2275,7 +2275,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseLessThanOrEqual(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -2283,14 +2283,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseLessThanOrEqual(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseLessThanOrEqual(DoubleConverter<U>.Instance.GetDouble(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2320,13 +2320,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseGreaterThan(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseGreaterThan(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2350,7 +2350,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseGreaterThan(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -2358,14 +2358,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseGreaterThan((column as PrimitiveDataFrameColumn<decimal>)._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseGreaterThan(column.CloneAsDoubleColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2390,13 +2390,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseGreaterThan(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseGreaterThan(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2420,7 +2420,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseGreaterThan(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -2428,14 +2428,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseGreaterThan(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseGreaterThan(DoubleConverter<U>.Instance.GetDouble(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2465,13 +2465,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseLessThan(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseLessThan(column.CloneAsDecimalColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2495,7 +2495,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseLessThan(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -2503,14 +2503,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseLessThan((column as PrimitiveDataFrameColumn<decimal>)._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseLessThan(column.CloneAsDoubleColumn()._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2535,13 +2535,13 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseLessThan(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseLessThan(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
@ -2565,7 +2565,7 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
// No conversions
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.ElementwiseLessThan(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
|
@ -2573,14 +2573,14 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.ElementwiseLessThan(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.ElementwiseLessThan(DoubleConverter<U>.Instance.GetDouble(value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace Microsoft.Data.Analysis
|
|||
throw new NotSupportedException();
|
||||
}
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar || method.MethodType == MethodType.Comparison) { #>
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> retColumn = CloneAsBooleanColumn();
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar) { #>
|
||||
(this as PrimitiveDataFrameColumn<bool>)._columnContainer.<#=method.MethodName#>(Unsafe.As<U, bool>(ref value), retColumn._columnContainer);
|
||||
<# } else { #>
|
||||
|
@ -202,12 +202,12 @@ namespace Microsoft.Data.Analysis
|
|||
<# if (method.MethodType == MethodType.ComparisonScalar || method.MethodType == MethodType.Comparison) { #>
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar) { #>
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.<#=method.MethodName#>(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
<# } else { #>
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.<#=method.MethodName#>(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
<# } #>
|
||||
|
@ -239,7 +239,7 @@ namespace Microsoft.Data.Analysis
|
|||
}
|
||||
<# } #>
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar || method.MethodType == MethodType.Comparison) { #>
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar) { #>
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.<#=method.MethodName#>(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
|
@ -285,12 +285,12 @@ namespace Microsoft.Data.Analysis
|
|||
<# if (method.MethodType == MethodType.ComparisonScalar || method.MethodType == MethodType.Comparison) { #>
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar) { #>
|
||||
PrimitiveDataFrameColumn<T> primitiveColumn = this;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.<#=method.MethodName#>(Unsafe.As<U, T>(ref value), newColumn._columnContainer);
|
||||
return newColumn;
|
||||
<# } else { #>
|
||||
PrimitiveDataFrameColumn<U> primitiveColumn = this as PrimitiveDataFrameColumn<U>;
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
primitiveColumn._columnContainer.<#=method.MethodName#>(column._columnContainer, newColumn._columnContainer);
|
||||
return newColumn;
|
||||
<# } #>
|
||||
|
@ -324,7 +324,7 @@ namespace Microsoft.Data.Analysis
|
|||
if (typeof(U) == typeof(decimal))
|
||||
{
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar || method.MethodType == MethodType.Comparison) { #>
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar) { #>
|
||||
PrimitiveDataFrameColumn<decimal> decimalColumn = CloneAsDecimalColumn();
|
||||
decimalColumn._columnContainer.<#=method.MethodName#>(DecimalConverter<U>.Instance.GetDecimal(value), newColumn._columnContainer);
|
||||
|
@ -349,7 +349,7 @@ namespace Microsoft.Data.Analysis
|
|||
else
|
||||
{
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar || method.MethodType == MethodType.Comparison) { #>
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBoolColumn();
|
||||
PrimitiveDataFrameColumn<bool> newColumn = CloneAsBooleanColumn();
|
||||
<# if (method.MethodType == MethodType.ComparisonScalar) { #>
|
||||
PrimitiveDataFrameColumn<double> doubleColumn = CloneAsDoubleColumn();
|
||||
doubleColumn._columnContainer.<#=method.MethodName#>(DoubleConverter<U>.Instance.GetDouble(value), newColumn._columnContainer);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,236 @@
|
|||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".cs" #>
|
||||
<#@ include file="ColumnArithmeticTemplate.ttinclude" #>
|
||||
<#@ include file="PrimitiveDataFrameColumn.BinaryOperations.Combinations.ttinclude" #>
|
||||
// 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
|
||||
{
|
||||
<#
|
||||
void GenerateAllBinaryCombinationsForOperator(string op, string methodName)
|
||||
{
|
||||
HashSet<string> visited = new HashSet<string> { };
|
||||
foreach (TypeCombination outer in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string outerColumnType = outer.ThisColumnType;
|
||||
if (visited.Contains(outerColumnType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
visited.Add(outerColumnType);
|
||||
string fullOuterColumnType = GetCapitalizedPrimitiveTypes(outerColumnType) + "DataFrameColumn";
|
||||
#>
|
||||
public partial class <#=fullOuterColumnType#>
|
||||
{
|
||||
<#
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations.Where((ACombination) => ACombination.ThisColumnType == outerColumnType))
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
#>
|
||||
public static <#=fullReturnType#> operator <#=op#>(<#=fullColumnType#> left, <#=fullOtherColumnType#> right)
|
||||
{
|
||||
return left.<#=methodName#>(right);
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllBinaryScalarCombinationsForOperator(string op, string methodName)
|
||||
{
|
||||
HashSet<string> visited = new HashSet<string> { };
|
||||
foreach (TypeCombination outer in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string outerColumnType = outer.ThisColumnType;
|
||||
if (visited.Contains(outerColumnType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
visited.Add(outerColumnType);
|
||||
string fullOuterColumnType = GetCapitalizedPrimitiveTypes(outerColumnType) + "DataFrameColumn";
|
||||
#>
|
||||
public partial class <#=fullOuterColumnType#>
|
||||
{
|
||||
<#
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations.Where((ACombination) => ACombination.ThisColumnType == outerColumnType))
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
#>
|
||||
public static <#=fullReturnType#> operator <#=op#>(<#=fullColumnType#> left, <#=otherColumnType#> right)
|
||||
{
|
||||
return left.<#=methodName#>(right);
|
||||
}
|
||||
public static <#=fullReturnType#> operator <#=op#>(<#=otherColumnType#> left, <#=fullColumnType#> right)
|
||||
{
|
||||
return right.Reverse<#=methodName#>(left);
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllBinaryBitwiseCombinationsForOperator(string op, string methodName)
|
||||
{
|
||||
#>
|
||||
public partial class BooleanDataFrameColumn
|
||||
{
|
||||
public static BooleanDataFrameColumn operator <#=op#>(BooleanDataFrameColumn left, BooleanDataFrameColumn right)
|
||||
{
|
||||
return left.<#=methodName#>(right);
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllBinaryScalarBitwiseCombinationsForOperator(string op, string methodName)
|
||||
{
|
||||
#>
|
||||
public partial class BooleanDataFrameColumn
|
||||
{
|
||||
public static BooleanDataFrameColumn operator <#=op#>(BooleanDataFrameColumn left, bool right)
|
||||
{
|
||||
return left.<#=methodName#>(right);
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllBinaryIntBitwiseCombinationsForOperator(string op, string methodName)
|
||||
{
|
||||
foreach (var type in typeConfiguration)
|
||||
{
|
||||
if (!type.SupportsNumeric || !type.SupportsBitwise || type.TypeName == "char")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string returnType = GetBinaryShiftOperationReturnType(type);
|
||||
if (returnType == string.Empty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(type.TypeName) + "DataFrameColumn";
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
#>
|
||||
public partial class <#=fullColumnType#>
|
||||
{
|
||||
public static <#=fullReturnType#> operator <#=op#>(<#=fullColumnType#> left, int value)
|
||||
{
|
||||
return left.<#=methodName#>(value);
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllComparisonCombinationsForOperator(string op, string methodName)
|
||||
{
|
||||
foreach (TypeCombination types in ComparisonOperationCombinations.comparisonOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
|
||||
#>
|
||||
public partial class <#=fullColumnType#>
|
||||
{
|
||||
public static <#=fullReturnType#> operator <#=op#>(<#=fullColumnType#> left, <#=fullOtherColumnType#> right)
|
||||
{
|
||||
return left.<#=methodName#>(right);
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateAllComparisonScalarCombinationsForOperator(string op, string methodName)
|
||||
{
|
||||
foreach (TypeCombination types in ComparisonOperationCombinations.comparisonOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
|
||||
#>
|
||||
public partial class <#=fullColumnType#>
|
||||
{
|
||||
public static <#=fullReturnType#> operator <#=op#>(<#=fullColumnType#> left, <#=otherColumnType#> right)
|
||||
{
|
||||
return left.<#=methodName#>(right);
|
||||
}
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
// Don't generate method for Comparison and ComparisonScalar methods here
|
||||
if (method.MethodType == MethodType.Binary && method.IsNumeric)
|
||||
{
|
||||
GenerateAllBinaryCombinationsForOperator(method.Operator, method.MethodName);
|
||||
}
|
||||
else if (method.MethodType == MethodType.BinaryScalar && method.IsNumeric)
|
||||
{
|
||||
GenerateAllBinaryScalarCombinationsForOperator(method.Operator, method.MethodName);
|
||||
}
|
||||
else if (method.MethodType == MethodType.Binary && method.IsBitwise)
|
||||
{
|
||||
GenerateAllBinaryBitwiseCombinationsForOperator(method.Operator, method.MethodName);
|
||||
}
|
||||
else if (method.MethodType == MethodType.BinaryScalar && method.IsBitwise)
|
||||
{
|
||||
GenerateAllBinaryScalarBitwiseCombinationsForOperator(method.Operator, method.MethodName);
|
||||
}
|
||||
else if (method.MethodType == MethodType.BinaryInt)
|
||||
{
|
||||
GenerateAllBinaryIntBitwiseCombinationsForOperator(method.Operator, method.MethodName);
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
|
@ -22,6 +22,8 @@ namespace Microsoft.Data.Analysis
|
|||
{
|
||||
private PrimitiveColumnContainer<T> _columnContainer;
|
||||
|
||||
internal PrimitiveColumnContainer<T> ColumnContainer => _columnContainer;
|
||||
|
||||
internal PrimitiveDataFrameColumn(string name, PrimitiveColumnContainer<T> column) : base(name, column.Length, typeof(T))
|
||||
{
|
||||
_columnContainer = column;
|
||||
|
@ -429,7 +431,7 @@ namespace Microsoft.Data.Analysis
|
|||
return ret;
|
||||
}
|
||||
|
||||
internal BooleanDataFrameColumn CloneAsBoolColumn()
|
||||
internal BooleanDataFrameColumn CloneAsBooleanColumn()
|
||||
{
|
||||
PrimitiveColumnContainer<bool> newColumnContainer = _columnContainer.CloneAsBoolContainer();
|
||||
return new BooleanDataFrameColumn(Name, newColumnContainer);
|
||||
|
@ -459,44 +461,44 @@ namespace Microsoft.Data.Analysis
|
|||
return new DecimalDataFrameColumn(Name, newColumnContainer);
|
||||
}
|
||||
|
||||
internal Int16DataFrameColumn CloneAsShortColumn()
|
||||
internal Int16DataFrameColumn CloneAsInt16Column()
|
||||
{
|
||||
PrimitiveColumnContainer<short> newColumnContainer = _columnContainer.CloneAsShortContainer();
|
||||
return new Int16DataFrameColumn(Name, newColumnContainer);
|
||||
}
|
||||
|
||||
|
||||
internal UInt16DataFrameColumn CloneAsUShortColumn()
|
||||
internal UInt16DataFrameColumn CloneAsUInt16Column()
|
||||
{
|
||||
PrimitiveColumnContainer<ushort> newColumnContainer = _columnContainer.CloneAsUShortContainer();
|
||||
return new UInt16DataFrameColumn(Name, newColumnContainer);
|
||||
}
|
||||
|
||||
internal Int32DataFrameColumn CloneAsIntColumn()
|
||||
internal Int32DataFrameColumn CloneAsInt32Column()
|
||||
{
|
||||
PrimitiveColumnContainer<int> newColumnContainer = _columnContainer.CloneAsIntContainer();
|
||||
return new Int32DataFrameColumn(Name, newColumnContainer);
|
||||
}
|
||||
|
||||
internal UInt32DataFrameColumn CloneAsUIntColumn()
|
||||
internal UInt32DataFrameColumn CloneAsUInt32Column()
|
||||
{
|
||||
PrimitiveColumnContainer<uint> newColumnContainer = _columnContainer.CloneAsUIntContainer();
|
||||
return new UInt32DataFrameColumn(Name, newColumnContainer);
|
||||
}
|
||||
|
||||
internal Int64DataFrameColumn CloneAsLongColumn()
|
||||
internal Int64DataFrameColumn CloneAsInt64Column()
|
||||
{
|
||||
PrimitiveColumnContainer<long> newColumnContainer = _columnContainer.CloneAsLongContainer();
|
||||
return new Int64DataFrameColumn(Name, newColumnContainer);
|
||||
}
|
||||
|
||||
internal UInt64DataFrameColumn CloneAsULongColumn()
|
||||
internal UInt64DataFrameColumn CloneAsUInt64Column()
|
||||
{
|
||||
PrimitiveColumnContainer<ulong> newColumnContainer = _columnContainer.CloneAsULongContainer();
|
||||
return new UInt64DataFrameColumn(Name, newColumnContainer);
|
||||
}
|
||||
|
||||
internal SingleDataFrameColumn CloneAsFloatColumn()
|
||||
internal SingleDataFrameColumn CloneAsSingleColumn()
|
||||
{
|
||||
PrimitiveColumnContainer<float> newColumnContainer = _columnContainer.CloneAsFloatContainer();
|
||||
return new SingleDataFrameColumn(Name, newColumnContainer);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,626 @@
|
|||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".cs" #>
|
||||
<#@ include file="..\..\src\Microsoft.Data.Analysis\ColumnArithmeticTemplate.ttinclude"#>
|
||||
<#@ include file="..\..\src\Microsoft.Data.Analysis\PrimitiveDataFrameColumn.BinaryOperations.Combinations.ttinclude" #>
|
||||
// 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.
|
||||
|
||||
// Generated from DataFrameColumn.BinaryOperationTests.tt. Do not modify directly
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Data.Analysis.Tests
|
||||
{
|
||||
public partial class DataFrameColumnTests
|
||||
{
|
||||
<#
|
||||
bool supportedInPlace(string type1, string type2)
|
||||
{
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(type1, out int columnTypeLevel);
|
||||
primitiveTypeToPrimitivityLevelMap.TryGetValue(type2, out int otherColumnTypeLevel);
|
||||
if (columnTypeLevel < otherColumnTypeLevel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateBinaryVerify(string methodName, string fullReturnType, string returnType)
|
||||
{
|
||||
#>
|
||||
<#
|
||||
if (methodName == "Add")
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)(2 * x));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName == "Subtract")
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)0);
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName == "Multiply")
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)(x * x));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName == "Divide")
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)(1));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName == "Modulo")
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)(0));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
// Only generate the tests for ByteDataFrameColumn. It exercises all the possible paths since it includes cloning the non byte columns and keeps the number of tests low enough.
|
||||
void GenerateAllBinaryTestsForMethod(string methodName, string methodOperator)
|
||||
{
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
if (columnType != "byte")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string capitalizedColumnType = GetCapitalizedPrimitiveTypes(columnType);
|
||||
string capitalizedOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType);
|
||||
#>
|
||||
[Fact]
|
||||
public void <#=methodName#><#=fullOtherColumnType#>To<#=fullColumnType#>()
|
||||
{
|
||||
var columnEnumerable = Enumerable.Range(1, 10).Select(x => (<#=columnType#>)x);
|
||||
<#=fullColumnType#> column = new <#=fullColumnType#>("<#=capitalizedColumnType#>", columnEnumerable);
|
||||
var otherColumnEnumerable = Enumerable.Range(1, 10).Select(x => (<#=otherColumnType#>)x);
|
||||
<#=fullOtherColumnType#> otherColumn = new <#=fullOtherColumnType#>("<#=capitalizedOtherColumnType#>", otherColumnEnumerable);
|
||||
<#=fullReturnType#> columnResult = column <#=methodOperator#> otherColumn;
|
||||
<#GenerateBinaryVerify(methodName, fullReturnType, returnType); #>
|
||||
Assert.Equal(columnResult.Length, verify.Count());
|
||||
Assert.True(columnResult.ElementwiseEquals(verifyColumn).All());
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateBinaryScalarVerify(string methodName, string fullReturnType, string returnType, int value, bool isReverse)
|
||||
{
|
||||
if (methodName.Contains("Add"))
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x + (<#=returnType#>)value));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Subtract"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x - (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value - (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Multiply"))
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x * (<#=returnType#>)value));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Divide"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x / (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value / (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Modulo"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x % (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value % (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateBinaryComparisonScalarVerify(string methodName, string fullReturnType, string returnType, int value, bool isReverse)
|
||||
{
|
||||
if (methodName.Contains("ElementwiseEquals"))
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)(false));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("ElementwiseNotEquals"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)(false));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)(false));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Multiply"))
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x * (<#=returnType#>)value));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Divide"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x / (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value / (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Modulo"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x % (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value % (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateBinaryComparisonVerify(string methodName, string fullReturnType, string returnType, int value, bool isReverse)
|
||||
{
|
||||
if (methodName.Contains("ElementwiseEquals"))
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => true);
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("ElementwiseNotEquals"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => true);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => true);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Multiply"))
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x * (<#=returnType#>)value));
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Divide"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x / (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value / (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Modulo"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x % (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value % (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
void GenerateBinaryBitwiseScalarVerify(string methodName, string fullReturnType, string returnType, bool value, bool isReverse)
|
||||
{
|
||||
if (methodName.Contains("And"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x & (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value & (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Or"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x | (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value | (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
else if (methodName.Contains("Xor"))
|
||||
{
|
||||
if (!isReverse)
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)x ^ (<#=returnType#>)value));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
var verify = Enumerable.Range(1, 10).Select(x => (<#=returnType#>)((<#=returnType#>)value ^ (<#=returnType#>)x));
|
||||
<#
|
||||
}
|
||||
#>
|
||||
var verifyColumn = new <#=fullReturnType#>("Verify", verify);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
// Only generate the tests for ByteDataFrameColumn. It exercises all the possible paths since it includes cloning the non byte columns and keeps the number of tests low enough.
|
||||
void GenerateAllBinaryScalarTestsForMethod(string methodName, string methodOperator)
|
||||
{
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
if (columnType != "byte")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string capitalizedColumnType = GetCapitalizedPrimitiveTypes(columnType);
|
||||
string capitalizedOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType);
|
||||
#>
|
||||
[Fact]
|
||||
public void <#=methodName#><#=capitalizedOtherColumnType#>To<#=fullColumnType#>()
|
||||
{
|
||||
var columnEnumerable = Enumerable.Range(1, 10).Select(x => (<#=columnType#>)x);
|
||||
<#=fullColumnType#> column = new <#=fullColumnType#>("<#=capitalizedColumnType#>", columnEnumerable);
|
||||
<#=otherColumnType#> value = 5;
|
||||
<#
|
||||
if (methodName.Contains("Reverse"))
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> columnResult = value <#=methodOperator#> column;
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> columnResult = column <#=methodOperator#> value;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#GenerateBinaryScalarVerify(methodName, fullReturnType, returnType, (byte)5, methodName.Contains("Reverse") ? true : false); #>
|
||||
Assert.Equal(columnResult.Length, verify.Count());
|
||||
Assert.True(columnResult.ElementwiseEquals(verifyColumn).All());
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
// Only generate the tests for BooleanDataFrameColumn.
|
||||
void GenerateAllBinaryScalarBitwiseTestsForMethod(string methodName, string methodOperator)
|
||||
{
|
||||
foreach (TypeCombination types in BinaryOperationCombinations.binaryOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
if (columnType != "byte")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string capitalizedColumnType = GetCapitalizedPrimitiveTypes(columnType);
|
||||
string capitalizedOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType);
|
||||
#>
|
||||
[Fact]
|
||||
public void TestScalar<#=methodName#>On<#=fullColumnType#>()
|
||||
{
|
||||
var columnEnumerable = Enumerable.Range(1, 10).Select(x => (<#=columnType#>)false);
|
||||
<#=fullColumnType#> column = new <#=fullColumnType#>("<#=capitalizedColumnType#>", columnEnumerable);
|
||||
<#=otherColumnType#> value = true;
|
||||
<#
|
||||
if (methodName.Contains("Reverse"))
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> columnResult = value <#=methodOperator#> column;
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
<#=fullReturnType#> columnResult = column <#=methodOperator#> value;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#GenerateBinaryBitwiseScalarVerify(methodName, fullReturnType, returnType, true, methodName.Contains("Reverse") ? true : false); #>
|
||||
Assert.Equal(columnResult.Length, verify.Count());
|
||||
Assert.True(columnResult.ElementwiseEquals(verifyColumn).All());
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
// Only generate the tests for ByteDataFrameColumn. It exercises all the possible paths since it includes cloning the non byte columns and keeps the number of tests low enough.
|
||||
void GenerateAllBinaryScalarComparisonTestsForMethod(string methodName, string methodOperator)
|
||||
{
|
||||
foreach (TypeCombination types in ComparisonOperationCombinations.comparisonOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
if (columnType != "byte")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string capitalizedColumnType = GetCapitalizedPrimitiveTypes(columnType);
|
||||
string capitalizedOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType);
|
||||
#>
|
||||
[Fact]
|
||||
public void <#=methodName#><#=capitalizedReturnType#>ToScalar<#=capitalizedOtherColumnType#>()
|
||||
{
|
||||
var columnEnumerable = Enumerable.Range(1, 10).Select(x => (<#=columnType#>)x);
|
||||
<#=fullColumnType#> column = new <#=fullColumnType#>("<#=capitalizedColumnType#>", columnEnumerable);
|
||||
<#=otherColumnType#> value = 100;
|
||||
BooleanDataFrameColumn columnResult = column.<#=methodName#>(value);
|
||||
<#GenerateBinaryComparisonScalarVerify(methodName, fullReturnType, returnType, (byte)5, methodName.Contains("Reverse") ? true : false); #>
|
||||
Assert.Equal(columnResult.Length, verify.Count());
|
||||
<# if (!methodName.Contains("Not")) { #>
|
||||
Assert.True(columnResult.ElementwiseEquals(verifyColumn).All());
|
||||
<# } else { #>
|
||||
Assert.True(columnResult.ElementwiseNotEquals(verifyColumn).All());
|
||||
<# } #>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
// Only generate the tests for ByteDataFrameColumn. It exercises all the possible paths since it includes cloning the non byte columns and keeps the number of tests low enough.
|
||||
void GenerateAllBinaryComparisonTestsForMethod(string methodName, string methodOperator)
|
||||
{
|
||||
foreach (TypeCombination types in ComparisonOperationCombinations.comparisonOperationCombinations)
|
||||
{
|
||||
string returnType = types.ReturnColumnType;
|
||||
string columnType = types.ThisColumnType;
|
||||
if (columnType != "byte")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string otherColumnType = types.OtherColumnType;
|
||||
|
||||
string fullColumnType = GetCapitalizedPrimitiveTypes(columnType) + "DataFrameColumn";
|
||||
string fullReturnType = GetCapitalizedPrimitiveTypes(returnType) + "DataFrameColumn";
|
||||
string fullOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType) + "DataFrameColumn";
|
||||
|
||||
string capitalizedReturnType = GetCapitalizedPrimitiveTypes(returnType);
|
||||
string capitalizedColumnType = GetCapitalizedPrimitiveTypes(columnType);
|
||||
string capitalizedOtherColumnType = GetCapitalizedPrimitiveTypes(otherColumnType);
|
||||
#>
|
||||
[Fact]
|
||||
public void <#=methodName#><#=capitalizedReturnType#>To<#=capitalizedOtherColumnType#>()
|
||||
{
|
||||
var columnEnumerable = Enumerable.Range(1, 10).Select(x => (<#=columnType#>)x);
|
||||
<#=fullColumnType#> column = new <#=fullColumnType#>("<#=capitalizedColumnType#>", columnEnumerable);
|
||||
var otherColumnEnumerable = Enumerable.Range(1, 10).Select(x => (<#=otherColumnType#>)x);
|
||||
<#=fullOtherColumnType#> otherColumn = new <#=fullOtherColumnType#>("<#=capitalizedOtherColumnType#>", otherColumnEnumerable);
|
||||
BooleanDataFrameColumn columnResult = column.<#=methodName#>(otherColumn);
|
||||
<#GenerateBinaryComparisonVerify(methodName, fullReturnType, returnType, (byte)5, methodName.Contains("Reverse") ? true : false); #>
|
||||
Assert.Equal(columnResult.Length, verify.Count());
|
||||
|
||||
// If this is equals, change thisx to false
|
||||
<# if (!methodName.Contains("Not")) { #>
|
||||
Assert.True(columnResult.ElementwiseEquals(verifyColumn).All());
|
||||
<# } else { #>
|
||||
Assert.True(columnResult.ElementwiseNotEquals(verifyColumn).All());
|
||||
<# } #>
|
||||
}
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
<#
|
||||
foreach (MethodConfiguration method in methodConfiguration)
|
||||
{
|
||||
if (method.MethodType == MethodType.Binary && method.IsNumeric)
|
||||
{
|
||||
GenerateAllBinaryTestsForMethod(method.MethodName, method.Operator);
|
||||
}
|
||||
else if (method.MethodType == MethodType.BinaryScalar && method.IsNumeric)
|
||||
{
|
||||
GenerateAllBinaryScalarTestsForMethod(method.MethodName, method.Operator);
|
||||
GenerateAllBinaryScalarTestsForMethod("Reverse" + method.MethodName, method.Operator);
|
||||
}
|
||||
else if (method.MethodType == MethodType.ComparisonScalar)
|
||||
{
|
||||
// Test only the ElementwiseEquals and ElementwiseNotEquals methods to reduce the number of unit tests
|
||||
if ((method.MethodName == "ElementwiseEquals") || (method.MethodName == "ElementwiseNotEquals"))
|
||||
{
|
||||
GenerateAllBinaryScalarComparisonTestsForMethod(method.MethodName, method.Operator);
|
||||
}
|
||||
}
|
||||
else if (method.MethodType == MethodType.Comparison)
|
||||
{
|
||||
// Test only the ElementwiseEquals and ElementwiseNotEquals methods to reduce the number of unit tests
|
||||
if ((method.MethodName == "ElementwiseEquals") || (method.MethodName == "ElementwiseNotEquals"))
|
||||
{
|
||||
GenerateAllBinaryComparisonTestsForMethod(method.MethodName, method.Operator);
|
||||
}
|
||||
}
|
||||
/*
|
||||
else if (method.MethodType == MethodType.BinaryScalar && method.IsBitwise)
|
||||
{
|
||||
GenerateAllBinaryScalarBitwiseTestsForMethod(method.MethodName, method.Operator);
|
||||
}
|
||||
*/
|
||||
}
|
||||
#>
|
||||
}
|
||||
}
|
|
@ -92,12 +92,15 @@ namespace Microsoft.Data.Analysis.Tests
|
|||
return df;
|
||||
}
|
||||
|
||||
public static DataFrame MakeDataFrameWithNumericAndBoolColumns(int length)
|
||||
public static DataFrame MakeDataFrameWithNumericAndBoolColumns(int length, bool withNulls = true)
|
||||
{
|
||||
DataFrame df = MakeDataFrameWithNumericColumns(length);
|
||||
DataFrame df = MakeDataFrameWithNumericColumns(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)
|
||||
{
|
||||
boolColumn[length / 2] = null;
|
||||
}
|
||||
return df;
|
||||
}
|
||||
|
||||
|
@ -2128,5 +2131,53 @@ namespace Microsoft.Data.Analysis.Tests
|
|||
DataFrameColumn ushortColumn = DataFrameColumn.Create("Ushort", Enumerable.Range(0, length).Select(x => (ushort)x));
|
||||
AssertLengthTypeAndValues(ushortColumn, typeof(ushort));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestBinaryOperationsOnExplodedNumericColumns()
|
||||
{
|
||||
DataFrame df = MakeDataFrameWithNumericAndBoolColumns(10, withNulls: false);
|
||||
Int32DataFrameColumn ints = df.Columns["Int"] as Int32DataFrameColumn;
|
||||
Int32DataFrameColumn res = ints.Add(1).Subtract(1).Multiply(10).Divide(10).LeftShift(2).RightShift(2);
|
||||
Assert.True(res.ElementwiseEquals(ints).All());
|
||||
Assert.True(res.ElementwiseGreaterThanOrEqual(ints).All());
|
||||
Assert.True(res.ElementwiseLessThanOrEqual(ints).All());
|
||||
Assert.False(res.ElementwiseNotEquals(ints).All());
|
||||
Assert.False(res.ElementwiseGreaterThan(ints).All());
|
||||
Assert.False(res.ElementwiseLessThan(ints).All());
|
||||
|
||||
// Test inPlace
|
||||
Int32DataFrameColumn inPlace = ints.Add(1, inPlace: true).Subtract(1, inPlace: true).Multiply(10, inPlace: true).Divide(10, inPlace: true).LeftShift(2, inPlace: true).RightShift(2, inPlace: true).Add(100, inPlace: true);
|
||||
Assert.True(inPlace.ElementwiseEquals(ints).All());
|
||||
Assert.True(inPlace.ElementwiseGreaterThanOrEqual(ints).All());
|
||||
Assert.True(inPlace.ElementwiseLessThanOrEqual(ints).All());
|
||||
Assert.False(inPlace.ElementwiseNotEquals(ints).All());
|
||||
Assert.False(inPlace.ElementwiseGreaterThan(ints).All());
|
||||
Assert.False(inPlace.ElementwiseLessThan(ints).All());
|
||||
|
||||
Assert.False(inPlace.ElementwiseEquals(res).All());
|
||||
Assert.True(inPlace.ElementwiseGreaterThanOrEqual(res).All());
|
||||
Assert.False(inPlace.ElementwiseLessThanOrEqual(res).All());
|
||||
Assert.True(inPlace.ElementwiseNotEquals(res).All());
|
||||
Assert.True(inPlace.ElementwiseGreaterThan(res).All());
|
||||
Assert.False(inPlace.ElementwiseLessThan(res).All());
|
||||
|
||||
// Test Bool column
|
||||
BooleanDataFrameColumn bools = df.Columns["Bool"] as BooleanDataFrameColumn;
|
||||
BooleanDataFrameColumn allFalse = bools.Or(true).And(true).Xor(true);
|
||||
Assert.True(allFalse.ElementwiseEquals(false).All());
|
||||
|
||||
// Test inPlace
|
||||
BooleanDataFrameColumn inPlaceAllFalse = bools.Or(true, inPlace: true).And(true, inPlace: true).Xor(true, inPlace: true);
|
||||
Assert.True(inPlaceAllFalse.ElementwiseEquals(bools).All());
|
||||
|
||||
// Test Reverse Operations
|
||||
Int32DataFrameColumn reverse = ints.ReverseAdd(1).ReverseSubtract(1).ReverseMultiply(-1);
|
||||
Assert.True(reverse.ElementwiseEquals(ints).All());
|
||||
|
||||
// Test inPlace
|
||||
Int32DataFrameColumn reverseInPlace = ints.ReverseAdd(1, inPlace: true).ReverseSubtract(1, inPlace: true).ReverseMultiply(-1, inPlace: true).ReverseDivide(100, inPlace: true);
|
||||
Assert.True(reverseInPlace.ElementwiseEquals(ints).All());
|
||||
Assert.False(reverseInPlace.ElementwiseEquals(reverse).All());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,23 @@
|
|||
<ProjectReference Include="..\..\src\Microsoft.Data.Analysis\Microsoft.Data.Analysis.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="DataFrameColumn.BinaryOperationTests.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>DataFrameColumn.BinaryOperationTests.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="DataFrameColumn.BinaryOperationTests.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>DataFrameColumn.BinaryOperationTests.tt</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Загрузка…
Ссылка в новой задаче