-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE-455] Lazily create uncompressedData #457
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
public class RssShuffleDataIterator<K, C> extends AbstractIterator<Product2<K, C>> { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(RssShuffleDataIterator.class); | ||
private final RssConf rssConf; | ||
|
||
private Iterator<Tuple2<Object, Object>> recordsIterator = null; | ||
private SerializerInstance serializerInstance; | ||
|
@@ -69,13 +70,7 @@ public RssShuffleDataIterator( | |
this.shuffleReadClient = shuffleReadClient; | ||
this.shuffleReadMetrics = shuffleReadMetrics; | ||
this.codec = Codec.newInstance(rssConf); | ||
// todo: support off-heap bytebuffer | ||
this.uncompressedData = ByteBuffer.allocate( | ||
(int) rssConf.getSizeAsBytes( | ||
RssClientConfig.RSS_WRITER_BUFFER_SIZE, | ||
xianjingfeng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
RssSparkConfig.RSS_WRITER_BUFFER_SIZE.defaultValueString() | ||
) | ||
); | ||
this.rssConf = rssConf; | ||
} | ||
|
||
public Iterator<Tuple2<Object, Object>> createKVIterator(ByteBuffer data, int size) { | ||
|
@@ -120,10 +115,20 @@ public boolean hasNext() { | |
shuffleReadMetrics.incRemoteBytesRead(compressedDataLength); | ||
|
||
int uncompressedLen = compressedBlock.getUncompressLength(); | ||
if (uncompressedData == null || uncompressedData.capacity() < uncompressedLen) { | ||
if (uncompressedData == null) { | ||
// todo: support off-heap bytebuffer | ||
uncompressedData = ByteBuffer.allocate( | ||
(int) rssConf.getSizeAsBytes( | ||
RssClientConfig.RSS_WRITER_BUFFER_SIZE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be Could you add a test case for this scenario? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the purpose of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The initial |
||
RssSparkConfig.RSS_WRITER_BUFFER_SIZE.defaultValueString() | ||
) | ||
); | ||
} else if (uncompressedData.capacity() < uncompressedLen) { | ||
uncompressedData = ByteBuffer.allocate(uncompressedLen); | ||
} else { | ||
uncompressedData.clear(); | ||
} | ||
uncompressedData.clear(); | ||
|
||
long startDecompress = System.currentTimeMillis(); | ||
codec.decompress(compressedData, uncompressedLen, uncompressedData, 0); | ||
unCompressedBytesLength += compressedBlock.getUncompressLength(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would better not remove this
todo
comment.