Skip to content
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

[SW-2646] Calculate Metrics on Arbitrary Dataset #2745

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open

Conversation

mn-mikke
Copy link
Collaborator

No description provided.

@mn-mikke mn-mikke marked this pull request as ready for review April 12, 2022 09:32

override protected def getPredictionValues(dataType: DataType, domain: Array[String], row: Row): Array[Double] = {
dataType match {
case StructType(fields)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: matching like StructType(Array(firstField, secondField)) would also ensure the field counts and avoid calling by index later on

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, the original approach is more readable. The pattern for the suggested approach would be:

StructType(Array(StructField(_, StringType, _, _), StructField(_, StructType(Array(StructField(_, DoubleType, _, _), StructField(_, DoubleType, _, _))), _, _)))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following "long" predicate appears several times in code. Would it be possible to define an auxiliary function that describes the condition and use it, e.g.
def isSomeSpecialType(fields: Array[StructField]): Boolean = fields(0).dataType == StringType && fields(1).dataType.isInstanceOf[StructType] && fields(1).dataType.asInstanceOf[StructType].fields.forall(_.dataType == DoubleType) && fields(1).dataType.asInstanceOf[StructType].fields.length == 2

@krasinski
Copy link
Contributor

LGTM, great piece of work 👍

@mn-mikke
Copy link
Collaborator Author

@krasinski thanks for your review, much appreciated! I've tried address the vast majority of your comments.

Copy link
Contributor

@kanech kanech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


override protected def getPredictionValues(dataType: DataType, domain: Array[String], row: Row): Array[Double] = {
dataType match {
case StructType(fields)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following "long" predicate appears several times in code. Would it be possible to define an auxiliary function that describes the condition and use it, e.g.
def isSomeSpecialType(fields: Array[StructField]): Boolean = fields(0).dataType == StringType && fields(1).dataType.isInstanceOf[StructType] && fields(1).dataType.asInstanceOf[StructType].fields.forall(_.dataType == DoubleType) && fields(1).dataType.asInstanceOf[StructType].fields.length == 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants