SPARK-1076: Convert Int to Long to avoid overflow

Patch for PR #578.