[
https://issues.apache.org/jira/browse/MESOS-2814?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15131244#comment-15131244
]
Cody Maloney edited comment on MESOS-2814 at 2/3/16 10:17 PM:
--------------------------------------------------------------
In master there are currently three implementations of the function:
https://github.com/apache/mesos/blob/master/3rdparty/libprocess/3rdparty/stout/include/stout/os/read.hpp#L42
https://github.com/apache/mesos/blob/master/3rdparty/libprocess/3rdparty/stout/include/stout/os/read.hpp#L82
https://github.com/apache/mesos/blob/master/3rdparty/libprocess/3rdparty/stout/include/stout/os/read.hpp#L42
All of them have fairly radically different implementations (One uses C read(),
one uses c++ ifstream, one uses c fopen)
The read(fd, size) I'd argue should be the underpinning of all three. When
we're given a filename rather than an fd, should do an open() of the filename,
then read() the whole thing (Which we could get get the length by doing a stat
of the file), or make a second implementation of read(int fd) which stops at
EOF rather than a fixed number of bytes.
All three overloads of the function can currently produce surprisingly
different results in their independent implementations
was (Author: cmaloney):
In master there are currently three implementations of the function:
https://github.com/apache/mesos/blob/master/3rdparty/libprocess/3rdparty/stout/include/stout/os/read.hpp#L42
https://github.com/apache/mesos/blob/master/3rdparty/libprocess/3rdparty/stout/include/stout/os/read.hpp#L82
https://github.com/apache/mesos/blob/master/3rdparty/libprocess/3rdparty/stout/include/stout/os/read.hpp#L42
All of them have fairly radically different implementations (One uses C read(),
one uses c++ ifstream, one uses c fopen)
> os::read should have one implementation
> ---------------------------------------
>
> Key: MESOS-2814
> URL: https://issues.apache.org/jira/browse/MESOS-2814
> Project: Mesos
> Issue Type: Improvement
> Components: stout
> Reporter: Cody Maloney
> Assignee: Isabel Jimenez
> Labels: mesosphere, tech-debt
>
> Currently stout os::read() has two radically different implementations when
> you give it a {{std::string}} vs. a {{const char *}}. Ideally these have one
> implementation that does things like intelligently size the buffer that it
> writes into rather than re-allocating repeatedly with every time it lengthens
> the string (resulting in copious copying).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)