Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Davies Liu committed Jun 19, 2015
1 parent 634b9f5 commit 8e2d56f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ class DateTimeUtilsSuite extends SparkFunSuite {
val now = new Timestamp(System.currentTimeMillis())
now.setNanos(100)
val ns = DateTimeUtils.fromJavaTimestamp(now)
assert(ns % 10000000L == 1)
assert(DateTimeUtils.toJavaTimestamp(ns) == now)
assert(ns % 10000000L === 1)
assert(DateTimeUtils.toJavaTimestamp(ns) === now)

List(-111111111111L, -1L, 0, 1L, 111111111111L).foreach { t =>
val ts = DateTimeUtils.toJavaTimestamp(t)
assert(DateTimeUtils.fromJavaTimestamp(ts) == t)
assert(DateTimeUtils.toJavaTimestamp(DateTimeUtils.fromJavaTimestamp(ts)) == ts)
assert(DateTimeUtils.fromJavaTimestamp(ts) === t)
assert(DateTimeUtils.toJavaTimestamp(DateTimeUtils.fromJavaTimestamp(ts)) === ts)
}
}

test("100ns and julian day") {
val (d, ns) = DateTimeUtils.toJulianDay(0)
assert(d == 2440587)
assert(ns == DateTimeUtils.SECONDS_PER_DAY / 2 * DateTimeUtils.NANOS_PER_SECOND)
assert(d === DateTimeUtils.JULIAN_DAY_OF_EPOCH)
assert(ns === DateTimeUtils.SECONDS_PER_DAY / 2 * DateTimeUtils.NANOS_PER_SECOND)
assert(DateTimeUtils.fromJulianDay(d, ns) == 0L)

val t = new Timestamp(61394778610000L) // (2015, 6, 11, 10, 10, 10, 100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private[parquet] class RowWriteSupport extends WriteSupport[InternalRow] with Lo
}

// Scratch array used to write decimals as fixed-length binary
private val scratchBytes = new Array[Byte](8)
private[this] val scratchBytes = new Array[Byte](8)

private[parquet] def writeDecimal(decimal: Decimal, precision: Int): Unit = {
val numBytes = ParquetTypesConverter.BYTES_FOR_PRECISION(precision)
Expand All @@ -315,7 +315,7 @@ private[parquet] class RowWriteSupport extends WriteSupport[InternalRow] with Lo
}

// array used to write Timestamp as Int96 (fixed-length binary)
private val int96buf = new Array[Byte](12)
private[this] val int96buf = new Array[Byte](12)

private[parquet] def writeTimestamp(ts: Long): Unit = {
val (julianDay, timeOfDayNanos) = DateTimeUtils.toJulianDay(ts)
Expand Down

0 comments on commit 8e2d56f

Please sign in to comment.