Skip to content

Conversation

@mn-mikke
Copy link
Collaborator

No description provided.

@mn-mikke mn-mikke force-pushed the mn/SW-2646b branch 3 times, most recently from 89d3df6 to e679aea Compare April 6, 2022 17:31
@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.

4 participants