From f56028883a15b232e8788af6579a1bc4c8cc1330 Mon Sep 17 00:00:00 2001 From: yan ma Date: Thu, 25 Mar 2021 09:41:59 +0800 Subject: [PATCH] [POAE7-961] fix null pointer issue when offheap enabled. --- .../apache/spark/util/collection/unsafe/sort/PMemWriter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/spark/util/collection/unsafe/sort/PMemWriter.java b/src/main/java/org/apache/spark/util/collection/unsafe/sort/PMemWriter.java index 906ab506..df39035c 100644 --- a/src/main/java/org/apache/spark/util/collection/unsafe/sort/PMemWriter.java +++ b/src/main/java/org/apache/spark/util/collection/unsafe/sort/PMemWriter.java @@ -180,7 +180,8 @@ public void updateLongArray(LongArray sortedArray, int numRecords, int position) // update recordPointer in this array long originalRecordPointer = sortedArray.get(position); MemoryBlock page = taskMemoryManager.getOriginalPage(originalRecordPointer); - long offset = taskMemoryManager.getOffsetInPage(originalRecordPointer) - page.getBaseOffset(); + long baseOffset = page == null? 0: page.getBaseOffset(); + long offset = taskMemoryManager.getOffsetInPage(originalRecordPointer) - baseOffset; MemoryBlock pMemBlock = pageMap.get(page); long pMemOffset = pMemBlock.getBaseOffset() + offset; sortedArray.set(position, pMemOffset);