-
Notifications
You must be signed in to change notification settings - Fork 329
Use pattern matching in PayloadHelper.cs to improve readability #1003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,15 +323,6 @@ internal static byte[] GetTypeId(Type type) | |
case TypeCode.Double: | ||
return s_doubleTypeId; | ||
case TypeCode.Object: | ||
if (typeof(IJvmObjectReferenceProvider).IsAssignableFrom(type)) | ||
{ | ||
return s_jvmObjectTypeId; | ||
} | ||
|
||
if (type == typeof(byte[])) | ||
{ | ||
return s_byteArrayTypeId; | ||
} | ||
|
||
if (type == typeof(int[]) || | ||
type == typeof(long[]) || | ||
|
@@ -343,36 +334,17 @@ internal static byte[] GetTypeId(Type type) | |
return s_arrayTypeId; | ||
} | ||
|
||
if (IsDictionary(type)) | ||
{ | ||
return s_dictionaryTypeId; | ||
} | ||
|
||
if (typeof(IEnumerable<IJvmObjectReferenceProvider>).IsAssignableFrom(type)) | ||
{ | ||
return s_arrayTypeId; | ||
} | ||
|
||
if (typeof(IEnumerable<GenericRow>).IsAssignableFrom(type)) | ||
{ | ||
return s_rowArrTypeId; | ||
} | ||
|
||
if (typeof(IEnumerable<object>).IsAssignableFrom(type)) | ||
return type switch | ||
{ | ||
return s_objectArrTypeId; | ||
} | ||
|
||
if (typeof(Date).IsAssignableFrom(type)) | ||
{ | ||
return s_dateTypeId; | ||
} | ||
|
||
if (typeof(Timestamp).IsAssignableFrom(type)) | ||
{ | ||
return s_timestampTypeId; | ||
} | ||
break; | ||
_ when typeof(IJvmObjectReferenceProvider).IsAssignableFrom(type) => s_jvmObjectTypeId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think some of these lines are too long. Can you check https://github.com/dotnet/spark/blob/main/docs/coding-guidelines/csharp-coding-style.md ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
_ when type == typeof(byte[]) => s_byteArrayTypeId, | ||
_ when IsDictionary(type) => s_dictionaryTypeId, | ||
_ when typeof(IEnumerable<IJvmObjectReferenceProvider>).IsAssignableFrom(type) => s_arrayTypeId, | ||
_ when typeof(IEnumerable<GenericRow>).IsAssignableFrom(type) => s_rowArrTypeId, | ||
_ when typeof(IEnumerable<object>).IsAssignableFrom(type) => s_objectArrTypeId, | ||
_ when typeof(Date).IsAssignableFrom(type) => s_dateTypeId, | ||
_ when typeof(Timestamp).IsAssignableFrom(type) => s_timestampTypeId, | ||
}; | ||
} | ||
|
||
// TODO: Support other types. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be included in the switch expression ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a super long logical expression that would not fit well into that format
