Skip to content

Commit 10677de

Browse files
authored
Reduce trials that getting same object type (#636)
1 parent c629439 commit 10677de

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/csharp/Microsoft.Spark/Sql/ArrowArrayHelpers.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,55 +112,56 @@ private static ArrayData BuildEmptyArrayDataFromArrayType<T>()
112112
{
113113
IArrowType arrowType = null;
114114

115-
if (typeof(T) == typeof(BooleanArray))
115+
Type type = typeof(T);
116+
if (type == typeof(BooleanArray))
116117
{
117118
arrowType = BooleanType.Default;
118119
}
119-
else if (typeof(T) == typeof(Int8Array))
120+
else if (type == typeof(Int8Array))
120121
{
121122
arrowType = Int8Type.Default;
122123
}
123-
else if (typeof(T) == typeof(UInt8Array))
124+
else if (type == typeof(UInt8Array))
124125
{
125126
arrowType = UInt8Type.Default;
126127
}
127-
else if (typeof(T) == typeof(Int16Array))
128+
else if (type == typeof(Int16Array))
128129
{
129130
arrowType = Int16Type.Default;
130131
}
131-
else if (typeof(T) == typeof(UInt16Array))
132+
else if (type == typeof(UInt16Array))
132133
{
133134
arrowType = UInt16Type.Default;
134135
}
135-
else if (typeof(T) == typeof(Int32Array))
136+
else if (type == typeof(Int32Array))
136137
{
137138
arrowType = Int32Type.Default;
138139
}
139-
else if (typeof(T) == typeof(UInt32Array))
140+
else if (type == typeof(UInt32Array))
140141
{
141142
arrowType = UInt32Type.Default;
142143
}
143-
else if (typeof(T) == typeof(Int64Array))
144+
else if (type == typeof(Int64Array))
144145
{
145146
arrowType = Int64Type.Default;
146147
}
147-
else if (typeof(T) == typeof(UInt64Array))
148+
else if (type == typeof(UInt64Array))
148149
{
149150
arrowType = UInt64Type.Default;
150151
}
151-
else if (typeof(T) == typeof(FloatArray))
152+
else if (type == typeof(FloatArray))
152153
{
153154
arrowType = FloatType.Default;
154155
}
155-
else if (typeof(T) == typeof(DoubleArray))
156+
else if (type == typeof(DoubleArray))
156157
{
157158
arrowType = DoubleType.Default;
158159
}
159-
else if (typeof(T) == typeof(Date64Array))
160+
else if (type == typeof(Date64Array))
160161
{
161162
arrowType = Date64Type.Default;
162163
}
163-
else if (typeof(T) == typeof(TimestampArray))
164+
else if (type == typeof(TimestampArray))
164165
{
165166
arrowType = TimestampType.Default;
166167
}
@@ -171,18 +172,18 @@ private static ArrayData BuildEmptyArrayDataFromArrayType<T>()
171172
buffers: new[] { ArrowBuffer.Empty, ArrowBuffer.Empty });
172173
}
173174

174-
if (typeof(T) == typeof(StringArray))
175+
if (type == typeof(StringArray))
175176
{
176177
return new ArrayData(StringType.Default, 0,
177178
buffers: new[] { ArrowBuffer.Empty, ArrowBuffer.Empty, ArrowBuffer.Empty });
178179
}
179-
else if (typeof(T) == typeof(BinaryArray))
180+
else if (type == typeof(BinaryArray))
180181
{
181182
return new ArrayData(BinaryType.Default, 0,
182183
buffers: new[] { ArrowBuffer.Empty, ArrowBuffer.Empty, ArrowBuffer.Empty });
183184
}
184185

185-
throw new NotSupportedException($"Unknown type: {typeof(T)}");
186+
throw new NotSupportedException($"Unknown type: {type}");
186187
}
187188

188189
private static ArrayData BuildEmptyArrayDataFromArrowType(IArrowType arrowType)

0 commit comments

Comments
 (0)