Skip to content

Conversation

@techaddict
Copy link
Contributor

@techaddict techaddict commented May 20, 2016

What changes were proposed in this pull request?

Using longValue() and then checking whether the value is in the range for a long manually.

How was this patch tested?

Existing tests

@techaddict
Copy link
Contributor Author

cc: @srowen

this.decimalVal = null
this.longVal = bigintval.longValueExact()
// TODO: Remove this once we migrate to java8 and use longValueExact() instead.
val isExactLong = bigintval.compareTo(BigInteger.valueOf(JLong.MAX_VALUE)) <= 0 &&
Copy link
Member

Choose a reason for hiding this comment

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

Maybe extract constants for a BigInteger representation of the max/min values rather than compute each time? Also is this all uses of java.util.Long that can be JLong?

def toScalaBigInt: BigInt = BigInt(toLong)

def toJavaBigInteger: java.math.BigInteger = java.math.BigInteger.valueOf(toLong)
def toJavaBigInteger: BigInteger = BigInteger.valueOf(toLong)
Copy link
Member

Choose a reason for hiding this comment

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

Although I support removing the redundant qualified name, I wonder if we should also un-qualify scala.math.BigInt, or else leave both qualified even though they're not ambiguous. BigDecimal is used unqualified while the Java version is always qualified, to disambiguate. I guess it would become consistent if BigInt were not qualified.

@SparkQA
Copy link

SparkQA commented May 20, 2016

Test build #58977 has finished for PR 13223 at commit 29f5adb.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 20, 2016

Test build #58978 has finished for PR 13223 at commit c0766f0.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 20, 2016

Test build #58979 has finished for PR 13223 at commit a1e54c2.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 20, 2016

Test build #58980 has finished for PR 13223 at commit 90f2cdc.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 20, 2016

Test build #58987 has finished for PR 13223 at commit e5a5839.

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

@techaddict
Copy link
Contributor Author

techaddict commented May 20, 2016

@srowen Comments addressed.

@gatorsmile
Copy link
Member

cc @kevinyu98

@kevinyu98
Copy link
Contributor

@techaddict @srowen @cloud-fan @gatorsmile : Hi Sandeep , thanks for fixing this. I didn't realize the method is java 1.8 only. The code looks good to me.

case d: BigDecimal => apply(d)
case k: scala.math.BigInt => apply(k)
case l: java.math.BigInteger => apply(l)
case k: BigInt => apply(k)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is too confusing. please keep the qualifiers. i'd actually keep qualifiers everywhere.

Copy link
Member

Choose a reason for hiding this comment

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

The code is inconsistent in this regard though. I thought it worth cleaning up but don't feel strongly about it. Alternative is to qualify both classes everywhere consistently

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree it's better to make it consistent, but let's not mix it into a simple fix for java 7 ...

@rxin
Copy link
Contributor

rxin commented May 20, 2016

@techaddict thanks for doing this. Can you be more surgical in fixes like this? i.e. just fix the line that is causing problem.

@rxin
Copy link
Contributor

rxin commented May 20, 2016

Also I think you can remove "HOTFIX" -- those are for master build breaking changes, which isn't happening here yet. (fwiw we don't run java 7 on master)

private[sql] val ZERO = Decimal(0)
private[sql] val ONE = Decimal(1)

private[types] val LONG_MAX_BIG_INT = BigInteger.valueOf(JLong.MAX_VALUE)
Copy link
Contributor

Choose a reason for hiding this comment

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

this can just be private

@techaddict techaddict changed the title [HOTFIX][SPARK-15445] Build fails for java 1.7 after adding java.mathBigInteger support [SPARK-15445][SQL] Build fails for java 1.7 after adding java.mathBigInteger support May 20, 2016
@SparkQA
Copy link

SparkQA commented May 20, 2016

Test build #59022 has finished for PR 13223 at commit 35da7c2.

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

@techaddict
Copy link
Contributor Author

techaddict commented May 21, 2016

@rxin @srowen I've added qualifiers back.

@SparkQA
Copy link

SparkQA commented May 21, 2016

Test build #59048 has finished for PR 13223 at commit faff787.

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

@srowen
Copy link
Member

srowen commented May 21, 2016

Merged to master/2.0

asfgit pushed a commit that referenced this pull request May 21, 2016
…Integer support

## What changes were proposed in this pull request?
Using longValue() and then checking whether the value is in the range for a long manually.

## How was this patch tested?
Existing tests

Author: Sandeep Singh <[email protected]>

Closes #13223 from techaddict/SPARK-15445.

(cherry picked from commit 666bf2e)
Signed-off-by: Sean Owen <[email protected]>
@asfgit asfgit closed this in 666bf2e May 21, 2016
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