-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Reduce memory usage for raster source handling. #5572
Changes from 1 commit
d8d9ac8
62c8b70
d316ff9
e4aaf07
432d49e
a9fce74
eef0722
f9ee74d
a587b14
f36707d
542c3ba
17f32f4
9c1c842
fd0f1b6
ee177ef
9da6cf8
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 |
---|---|---|
|
@@ -50,13 +50,13 @@ class RasterGrid | |
xdim = _xdim; | ||
ydim = _ydim; | ||
_data.reserve(ydim * xdim); | ||
BOOST_ASSERT(_data.capacity() >= ydim * xdim); | ||
BOOST_ASSERT(ydim * xdim <= _data.capacity()); | ||
|
||
// Construct FileReader | ||
storage::io::FileReader file_reader(filepath, storage::io::FileReader::HasNoFingerprint); | ||
std::string buf; | ||
buf.resize(xdim * 11); // INT32_MAX = 2147483647 = 10 chars + 1 white space = 11 | ||
BOOST_ASSERT(buf.size() >= xdim * 11); | ||
BOOST_ASSERT(xdim * 11 <= buf.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. Does this check relevant? Can 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. Thanks for your comment. Best Regards, |
||
|
||
for (unsigned int y = 0 ; y < ydim ; y++) { | ||
// read one line from file. | ||
|
@@ -74,37 +74,6 @@ class RasterGrid | |
} | ||
BOOST_ASSERT(x == xdim); | ||
} | ||
/* | ||
std::string buffer; | ||
buffer.resize(file_reader.GetSize()); | ||
|
||
BOOST_ASSERT(buffer.size() > 1); | ||
|
||
file_reader.ReadInto(&buffer[0], buffer.size()); | ||
|
||
boost::algorithm::trim(buffer); | ||
|
||
auto itr = buffer.begin(); | ||
auto end = buffer.end(); | ||
|
||
bool r = false; | ||
try | ||
{ | ||
r = boost::spirit::qi::parse( | ||
itr, end, +boost::spirit::qi::int_ % +boost::spirit::qi::space, _data); | ||
} | ||
catch (std::exception const &ex) | ||
{ | ||
throw util::exception("Failed to read from raster source " + filepath.string() + ": " + | ||
ex.what() + SOURCE_REF); | ||
} | ||
|
||
if (!r || itr != end) | ||
{ | ||
throw util::exception("Failed to parse raster source: " + filepath.string() + | ||
SOURCE_REF); | ||
} | ||
*/ | ||
} | ||
|
||
RasterGrid(const RasterGrid &) = default; | ||
|
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.
please use the whole word
buffer
. In previous version it wasbuffer
.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.
Hi, Thanks for your review and comment.
I will fix as your comment. (buf --> buffer)