[
https://issues.apache.org/jira/browse/AVRO-2249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666341#comment-16666341
]
ASF GitHub Bot commented on AVRO-2249:
--------------------------------------
Fokko closed pull request #360: AVRO-2249 Fix for C++ build failures
URL: https://github.com/apache/avro/pull/360
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/lang/c++/api/DataFile.hh b/lang/c++/api/DataFile.hh
index d95f09bbc..30cae5ada 100644
--- a/lang/c++/api/DataFile.hh
+++ b/lang/c++/api/DataFile.hh
@@ -183,7 +183,7 @@ public:
*/
class AVRO_DECL DataFileReaderBase : boost::noncopyable {
const std::string filename_;
- const std::auto_ptr<SeekableInputStream> stream_;
+ const std::auto_ptr<InputStream> stream_;
const DecoderPtr decoder_;
int64_t objectCount_;
bool eof_;
@@ -207,6 +207,7 @@ class AVRO_DECL DataFileReaderBase : boost::noncopyable {
void readHeader();
bool readDataBlock();
+ void doSeek(int64_t position);
public:
/**
* Returns the current decoder for this reader.
diff --git a/lang/c++/impl/DataFile.cc b/lang/c++/impl/DataFile.cc
index fdfd5b97a..56ec6195b 100644
--- a/lang/c++/impl/DataFile.cc
+++ b/lang/c++/impl/DataFile.cc
@@ -90,12 +90,12 @@ DataFileWriterBase::DataFileWriterBase(const char*
filename, const ValidSchema&
DataFileWriterBase::DataFileWriterBase(std::auto_ptr<OutputStream>
outputStream,
const ValidSchema& schema, size_t syncInterval, Codec codec) :
- filename_(nullptr),
+ filename_(NULL),
schema_(schema),
encoderPtr_(binaryEncoder()),
syncInterval_(syncInterval),
codec_(codec),
- stream_(std::move(outputStream)),
+ stream_(outputStream),
buffer_(memoryOutputStream()),
sync_(makeSync()),
objectCount_(0)
@@ -281,7 +281,7 @@ DataFileReaderBase::DataFileReaderBase(const char*
filename) :
}
DataFileReaderBase::DataFileReaderBase(std::auto_ptr<InputStream> inputStream)
:
- filename_(nullptr), stream_(inputStream),
+ filename_(NULL), stream_(inputStream),
decoder_(binaryDecoder()), objectCount_(0), eof_(false)
{
readHeader();
@@ -527,25 +527,27 @@ void DataFileReaderBase::readHeader()
blockStart_ = stream_->byteCount();
}
-void DataFileReaderBase::seek(int64_t position) {
- if (!eof_) {
- dataDecoder_->init(*dataStream_);
- drain(*dataStream_);
+void DataFileReaderBase::doSeek(int64_t position) {
+ if (SeekableInputStream *ss = dynamic_cast<SeekableInputStream
*>(stream_.get())) {
+ if (!eof_) {
+ dataDecoder_->init(*dataStream_);
+ drain(*dataStream_);
+ }
+ decoder_->init(*stream_);
+ ss->seek(position);
+ eof_ = false;
+ } else {
+ throw Exception("seek not supported on non-SeekableInputStream");
}
- decoder_->init(*stream_);
- stream_->seek(position);
- eof_ = false;
+}
+
+void DataFileReaderBase::seek(int64_t position) {
+ doSeek(position);
readDataBlock();
}
void DataFileReaderBase::sync(int64_t position) {
- if (!eof_) {
- dataDecoder_->init(*dataStream_);
- drain(*dataStream_);
- }
- decoder_->init(*stream_);
- stream_->seek(position);
- eof_ = false;
+ doSeek(position);
DataFileSync sync_buffer;
const uint8_t *p = 0;
size_t n = 0;
diff --git a/lang/c++/impl/NodeImpl.cc b/lang/c++/impl/NodeImpl.cc
index 435d2ef5d..1969406da 100644
--- a/lang/c++/impl/NodeImpl.cc
+++ b/lang/c++/impl/NodeImpl.cc
@@ -28,7 +28,8 @@ namespace {
std::string escape(const std::string &unescaped) {
std::string s;
s.reserve(unescaped.length());
- for (auto c : unescaped) {
+ for (std::string::const_iterator it = unescaped.begin(); it !=
unescaped.end(); ++it) {
+ char c = *it;
switch (c) {
case '\\':
case '"':
@@ -289,10 +290,10 @@ void NodePrimitive::printDefaultToJson(const GenericDatum
&g, std::ostream &os,
os << g.value<int64_t>();
break;
case AVRO_FLOAT:
- os << std::to_string(g.value<float>());
+ os << g.value<float>();
break;
case AVRO_DOUBLE:
- os << std::to_string(g.value<double>());
+ os << g.value<double>();
break;
case AVRO_STRING:
os << "\"" << escape(g.value<std::string>()) << "\"";
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Fix the C++ tests
> -----------------
>
> Key: AVRO-2249
> URL: https://issues.apache.org/jira/browse/AVRO-2249
> Project: Avro
> Issue Type: Task
> Components: c++
> Affects Versions: 1.8.2
> Reporter: Fokko Driesprong
> Assignee: Thiruvalluvan M. G.
> Priority: Major
> Fix For: 1.8.4
>
>
> Currently the C++ tests are failing:
> ```
> Scanning dependencies of target avrocpp_s
> [ 1%] Building CXX object CMakeFiles/avrocpp_s.dir/impl/Compiler.cc.o
> /testptch/unknown/lang/c++/impl/Compiler.cc:174:15: warning: ‘std::string
> avro::nameof(const NodePtr&)’ defined but not used [-Wunused-function]
> static string nameof(const NodePtr& n)
> ^
> [ 2%] Building CXX object CMakeFiles/avrocpp_s.dir/impl/Node.cc.o
> [ 4%] Building CXX object CMakeFiles/avrocpp_s.dir/impl/NodeImpl.cc.o
> /testptch/unknown/lang/c++/impl/NodeImpl.cc: In function ‘std::string
> avro::{anonymous}::escape(const string&)’:
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:31:8: warning: ‘auto’ changes
> meaning in C++11; please remove it [-Wc++0x-compat]
> for (auto c : unescaped) {
> ^
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:31:13: error: ‘c’ does not
> name a type
> for (auto c : unescaped) {
> ^
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:67:3: error: expected ‘;’
> before ‘return’
> return s;
> ^
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:67:3: error: expected
> primary-expression before ‘return’
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:67:3: error: expected ‘;’
> before ‘return’
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:67:3: error: expected
> primary-expression before ‘return’
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:67:3: error: expected ‘)’
> before ‘return’
> In file included from /usr/include/boost/assert.hpp:51:0,
> from /usr/include/boost/format/parsing.hpp:21,
> from /usr/include/boost/format.hpp:50,
> from /testptch/unknown/lang/c++/api/Exception.hh:24,
> from /testptch/unknown/lang/c++/api/Node.hh:28,
> from /testptch/unknown/lang/c++/api/GenericDatum.hh:29,
> from /testptch/unknown/lang/c++/api/NodeImpl.hh:23,
> from /testptch/unknown/lang/c++/impl/NodeImpl.cc:21:
> /testptch/unknown/lang/c++/impl/NodeImpl.cc: In member function ‘virtual
> void avro::NodeRecord::printJson(std::ostream&, int) const’:
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:247:59: warning: comparison
> between signed and unsigned integer expressions [-Wsign-compare]
> assert(defaultValues.empty() || (defaultValues.size() == fields));
> ^
> /testptch/unknown/lang/c++/impl/NodeImpl.cc: In member function ‘virtual
> void avro::NodePrimitive::printDefaultToJson(const avro::GenericDatum&,
> std::ostream&, int) const’:
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:292:13: error: ‘to_string’ is
> not a member of ‘std’
> os << std::to_string(g.value<float>());
> ^
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:295:13: error: ‘to_string’ is
> not a member of ‘std’
> os << std::to_string(g.value<double>());
> ^
> /testptch/unknown/lang/c++/impl/NodeImpl.cc: In function ‘std::string
> avro::{anonymous}::escape(const string&)’:
> /testptch/unknown/lang/c++/impl/NodeImpl.cc:68:1: warning: control reaches
> end of non-void function [-Wreturn-type]
> }
> ^
> CMakeFiles/avrocpp_s.dir/build.make:100: recipe for target
> 'CMakeFiles/avrocpp_s.dir/impl/NodeImpl.cc.o' failed
> make[2]: *** [CMakeFiles/avrocpp_s.dir/impl/NodeImpl.cc.o] Error 1
> make[1]: *** [CMakeFiles/avrocpp_s.dir/all] Error 2
> CMakeFiles/Makefile2:425: recipe for target 'CMakeFiles/avrocpp_s.dir/all'
> failed
> make: *** [all] Error 2
> Makefile:147: recipe for target 'all' failed
> ```
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)