Skip to content

Commit d7da8ae

Browse files
committed
Remove unnecessary import and simplify test case
1 parent f3916e7 commit d7da8ae

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import org.apache.spark.sql.catalyst.expressions._
3030
import org.apache.spark.sql.catalyst.plans.physical.BroadcastMode
3131
import org.apache.spark.sql.types.LongType
3232
import org.apache.spark.unsafe.Platform
33-
import org.apache.spark.unsafe.array.ByteArrayMethods
3433
import org.apache.spark.unsafe.map.BytesToBytesMap
3534
import org.apache.spark.util.{KnownSizeEstimation, Utils}
3635

sql/core/src/test/scala/org/apache/spark/sql/execution/joins/HashedRelationSuite.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import org.apache.spark.serializer.KryoSerializer
2828
import org.apache.spark.sql.catalyst.InternalRow
2929
import org.apache.spark.sql.catalyst.expressions._
3030
import org.apache.spark.sql.test.SharedSQLContext
31-
import org.apache.spark.sql.types.{IntegerType, LongType, StringType, StructField, StructType}
31+
import org.apache.spark.sql.types._
3232
import org.apache.spark.unsafe.map.BytesToBytesMap
3333
import org.apache.spark.unsafe.types.UTF8String
3434
import org.apache.spark.util.collection.CompactBuffer
@@ -262,19 +262,19 @@ class HashedRelationSuite extends SparkFunSuite with SharedSQLContext {
262262
Long.MaxValue,
263263
1),
264264
0)
265-
val unsafeProj = UnsafeProjection.create(Seq(BoundReference(0, StringType, false)))
266-
val keys = Seq(0L)
265+
val unsafeProj = UnsafeProjection.create(Array[DataType](StringType))
267266
val map = new LongToUnsafeRowMap(taskMemoryManager, 1)
267+
268+
val key = 0L
269+
// the page array is initialized with length 1 << 17,
270+
// so here we need a value larger than 1 << 18
268271
val bigStr = UTF8String.fromString("x" * 1024 * 1024 * 2)
269-
keys.foreach { k =>
270-
map.append(k, unsafeProj(InternalRow(bigStr)))
271-
}
272+
273+
map.append(key, unsafeProj(InternalRow(bigStr)))
272274
map.optimize()
273-
val row = unsafeProj(InternalRow(bigStr)).copy()
274-
keys.foreach { k =>
275-
assert(map.getValue(k, row) eq row)
276-
assert(row.getUTF8String(0) === bigStr)
277-
}
275+
276+
val resultRow = new UnsafeRow(1)
277+
assert(map.getValue(key, resultRow).getUTF8String(0) === bigStr)
278278
map.free()
279279
}
280280

0 commit comments

Comments
 (0)