Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

Commit

Permalink
fix to pass vulnerabilities check
Browse files Browse the repository at this point in the history
  • Loading branch information
yma11 authored and zhixingheyi-tian committed Apr 9, 2021
1 parent 31b19de commit bec76cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ private void dumpPageToPMem(MemoryBlock page) {
MemoryBlock pMemBlock = pageMap.get(page);
if (pMemBlock == null) {
logger.error("Fail to copy data to PMem as no corresponding PMem page found.");
} else {
PersistentMemoryPlatform.copyMemory(
page.getBaseObject(), page.getBaseOffset(),
null, pMemBlock.getBaseOffset(), page.size(),
pMemClflushEnabled);
writeMetrics.incBytesWritten(page.size());
}
PersistentMemoryPlatform.copyMemory(
page.getBaseObject(), page.getBaseOffset(),
null, pMemBlock.getBaseOffset(), page.size(),
pMemClflushEnabled);
writeMetrics.incBytesWritten(page.size());
}

public void updateLongArray(LongArray sortedArray, int numRecords, int position) {
Expand All @@ -186,22 +187,27 @@ public void updateLongArray(LongArray sortedArray, int numRecords, int position)
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);
position += 2;
if (pMemBlock == null) {
logger.error("No PMem page found corresponding with LongArrayPage");
} else {
long pMemOffset = pMemBlock.getBaseOffset() + offset;
sortedArray.set(position, pMemOffset);
position += 2;
}
}
// copy the LongArray to PMem
MemoryBlock arrayBlock = sortedArray.memoryBlock();
MemoryBlock pMemBlock = pageMap.get(arrayBlock);
if (pMemBlock == null) {
logger.error("failed to update LongArray as no pair PMem page found.");
} else {
PersistentMemoryPlatform.copyMemory(
arrayBlock.getBaseObject(), arrayBlock.getBaseOffset(),
null, pMemBlock.getBaseOffset(), arrayBlock.size(),
pMemClflushEnabled);
writeMetrics.incBytesWritten(pMemBlock.size());
this.sortedArray = new LongArray(pMemBlock);
}
PersistentMemoryPlatform.copyMemory(
arrayBlock.getBaseObject(), arrayBlock.getBaseOffset(),
null, pMemBlock.getBaseOffset(), arrayBlock.size(),
pMemClflushEnabled);
writeMetrics.incBytesWritten(pMemBlock.size());
this.sortedArray = new LongArray(pMemBlock);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,12 @@ public SpillWriterForUnsafeSorter spillWithWriter(
isSorted);
if (spillWriter == null) {
logger.error("failed to get SpillWriter, please check related configuration.");
return null;
} else {
spillWriter.write();
spillWriters.add(spillWriter);
return spillWriter;
}
spillWriter.write();
spillWriters.add(spillWriter);
return spillWriter;
}

/**
Expand Down Expand Up @@ -549,7 +551,7 @@ public long spill() throws IOException {
long released = 0L;
SpillWriterForUnsafeSorter spillWriter = spillWithWriter(inMemIterator, numRecords, writeMetrics, true);
nextUpstream = spillWriter.getSpillReader();

assert(nextUpstream != null);
synchronized (UnsafeExternalSorter.this) {
// release the pages except the one that is used. There can still be a caller that
// is accessing the current record. We free this page in that caller's next loadNext()
Expand Down

0 comments on commit bec76cf

Please sign in to comment.