@@ -28,7 +28,7 @@ import org.apache.spark.serializer.KryoSerializer
2828import org .apache .spark .sql .catalyst .InternalRow
2929import org .apache .spark .sql .catalyst .expressions ._
3030import 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 ._
3232import org .apache .spark .unsafe .map .BytesToBytesMap
3333import org .apache .spark .unsafe .types .UTF8String
3434import 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