@@ -626,17 +626,21 @@ class DumpWriter : public AbstractDumpWriter {
626
626
DumpWriter (const char * path, bool overwrite, AbstractCompressor* compressor);
627
627
~DumpWriter ();
628
628
julong bytes_written () const override { return (julong) _bytes_written; }
629
- void set_bytes_written (julong bytes_written) { _bytes_written = bytes_written; }
630
629
char const * error () const override { return _error; }
631
630
void set_error (const char * error) { _error = (char *)error; }
632
631
bool has_error () const { return _error != nullptr ; }
633
632
const char * get_file_path () const { return _writer->get_file_path (); }
634
633
AbstractCompressor* compressor () { return _compressor; }
635
- void set_compressor (AbstractCompressor* p) { _compressor = p; }
636
634
bool is_overwrite () const { return _writer->is_overwrite (); }
637
- int get_fd () const { return _writer->get_fd (); }
638
635
639
636
void flush () override ;
637
+
638
+ private:
639
+ // internals for DumpMerger
640
+ friend class DumpMerger ;
641
+ void set_bytes_written (julong bytes_written) { _bytes_written = bytes_written; }
642
+ int get_fd () const { return _writer->get_fd (); }
643
+ void set_compressor (AbstractCompressor* p) { _compressor = p; }
640
644
};
641
645
642
646
DumpWriter::DumpWriter (const char * path, bool overwrite, AbstractCompressor* compressor) :
@@ -2126,13 +2130,14 @@ void DumpMerger::merge_file(const char* path) {
2126
2130
2127
2131
jlong total = 0 ;
2128
2132
size_t cnt = 0 ;
2129
- char read_buf[4096 ];
2130
- while ((cnt = segment_fs.read (read_buf, 1 , 4096 )) != 0 ) {
2131
- _writer->write_raw (read_buf, cnt);
2133
+
2134
+ // Use _writer buffer for reading.
2135
+ while ((cnt = segment_fs.read (_writer->buffer (), 1 , _writer->buffer_size ())) != 0 ) {
2136
+ _writer->set_position (cnt);
2137
+ _writer->flush ();
2132
2138
total += cnt;
2133
2139
}
2134
2140
2135
- _writer->flush ();
2136
2141
if (segment_fs.fileSize () != total) {
2137
2142
set_error (" Merged heap dump is incomplete" );
2138
2143
}
0 commit comments