Skip to content

Conversation

@mgaido91
Copy link
Contributor

@mgaido91 mgaido91 commented Dec 5, 2017

What changes were proposed in this pull request?

CreateNamedStruct and InSet are using a global variable which is not needed. This can generate some unneeded entries in the constant pool.

The PR removes the unnecessary mutable states and makes them local variables.

How was this patch tested?

added UT

@SparkQA
Copy link

SparkQA commented Dec 5, 2017

Test build #84484 has finished for PR 19896 at commit ac7131f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mgaido91
Copy link
Contributor Author

mgaido91 commented Dec 6, 2017

@cloud-fan @kiszk @viirya may you please review this? Thanks

})
valCodes,
"createNamedStruct",
"Object[]" -> values :: Nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: please keep the parameter name

ctx.splitExpressionsWithCurrentInputs(
  expressions = valCodes,
  funcName = ...

ev.copy(code =
s"""
|$values = new Object[${valExprs.size}];
|Object[] $values = new Object[${valExprs.size}];
Copy link
Contributor

Choose a reason for hiding this comment

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

actually I'm not very sure about this. The previous code can avoid creating this array every time.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh it didn't, but it can, you know my point...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why? It is creating it every time (new Object[${valExprs.size}]), the only thing which is reused is the pointer to the array.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean it can reuse the array...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean now. Since currently this is not done, what should we do? Should I create a new PR to reuse the array and remove this from here?

Copy link
Contributor

Choose a reason for hiding this comment

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

yea sounds good

@SparkQA
Copy link

SparkQA commented Dec 6, 2017

Test build #84546 has finished for PR 19896 at commit 91565d1.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class ReqAndHandler(req: Request, handler: MemberHandler)
  • trait TypeCoercionRule extends Rule[LogicalPlan] with Logging
  • case class AnalysisBarrier(child: LogicalPlan) extends LeafNode

@mgaido91 mgaido91 changed the title [SPARK-22693][SQL] InSet and CreateNamedStruct should not use global variables [SPARK-22693][SQL] InSet should not use global variables Dec 6, 2017
@cloud-fan
Copy link
Contributor

LGTM

@viirya
Copy link
Member

viirya commented Dec 6, 2017

LGTM

1 similar comment
@kiszk
Copy link
Member

kiszk commented Dec 6, 2017

LGTM

@mgaido91
Copy link
Contributor Author

mgaido91 commented Dec 6, 2017

thank you all, please wait for #19910 because if it is not feasible to reuse the array object as @viirya
says, I will add back here the change to avoid that global variable. Thanks.

@SparkQA
Copy link

SparkQA commented Dec 6, 2017

Test build #84552 has finished for PR 19896 at commit b5bd951.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mgaido91 mgaido91 changed the title [SPARK-22693][SQL] InSet should not use global variables [SPARK-22693][SQL] CreateNamedStruct and InSet should not use global variables Dec 6, 2017
@mgaido91
Copy link
Contributor Author

mgaido91 commented Dec 6, 2017

I added back the changes for CreateNamedStruct. May you review this part again too? Thanks.

@cloud-fan
Copy link
Contributor

LGTM

@SparkQA
Copy link

SparkQA commented Dec 6, 2017

Test build #84564 has finished for PR 19896 at commit 36537d8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member

Thanks! Merged to master.

@asfgit asfgit closed this in f110a7f Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants