Mercurial > hg > svcore
changeset 512:e7a39c45a7a4
* close output streams a little sooner when writing features for more
than one file (doesn't affect eventual output though)
author | Chris Cannam |
---|---|
date | Tue, 09 Dec 2008 16:53:37 +0000 |
parents | 7207e3eba44f |
children | 06a6612e7cf1 |
files | rdf/RDFFeatureWriter.cpp transform/FileFeatureWriter.cpp transform/FileFeatureWriter.h |
diffstat | 3 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/rdf/RDFFeatureWriter.cpp Mon Dec 08 15:08:39 2008 +0000 +++ b/rdf/RDFFeatureWriter.cpp Tue Dec 09 16:53:37 2008 +0000 @@ -118,11 +118,16 @@ // combination QTextStream *stream = getOutputStream(trackId, transform.getIdentifier()); - if (!stream) return; //!!! this is probably better handled with an exception + if (!stream) { + std::cerr << "RDFFeatureWriter::write: ERROR: No output stream for track id \"" + << trackId.toStdString() << "\" and transform \"" + << transform.getIdentifier().toStdString() << "\"" << std::endl; + return; + } if (m_startedStreamTransforms.find(stream) == m_startedStreamTransforms.end()) { - cerr << "This stream is new, writing prefixes" << endl; +// cerr << "This stream is new, writing prefixes" << endl; writePrefixes(stream); if (m_singleFileName == "" && !m_stdout) { writeSignalDescription(stream, trackId); @@ -410,6 +415,8 @@ PluginRDFDescription &desc, QString timelineURI) { +// std::cerr << "RDFFeatureWriter::writeSparseRDF: have " << featureList.size() << " features" << std::endl; + if (featureList.empty()) return; QTextStream &stream = *sptr; @@ -656,7 +663,7 @@ for (map<StringTransformPair, StreamBuffer>::iterator i = m_openDenseFeatures.begin(); i != m_openDenseFeatures.end(); ++i) { - cerr << "closing a stream" << endl; +// cerr << "closing a stream" << endl; StreamBuffer &b = i->second; *(b.first) << b.second << "\" ." << endl; }
--- a/transform/FileFeatureWriter.cpp Mon Dec 08 15:08:39 2008 +0000 +++ b/transform/FileFeatureWriter.cpp Tue Dec 09 16:53:37 2008 +0000 @@ -32,6 +32,7 @@ FileFeatureWriter::FileFeatureWriter(int support, QString extension) : + m_prevstream(0), m_support(support), m_extension(extension), m_manyFiles(false), @@ -258,6 +259,13 @@ } } - return m_streams[file]; + QTextStream *stream = m_streams[file]; + + if (m_prevstream && stream != m_prevstream) { + m_prevstream->flush(); + } + m_prevstream = stream; + + return stream; }
--- a/transform/FileFeatureWriter.h Mon Dec 08 15:08:39 2008 +0000 +++ b/transform/FileFeatureWriter.h Tue Dec 09 16:53:37 2008 +0000 @@ -57,6 +57,7 @@ typedef map<QFile *, QTextStream *> FileStreamMap; FileMap m_files; FileStreamMap m_streams; + QTextStream *m_prevstream; QString getOutputFilename(QString, TransformId); QFile *getOutputFile(QString, TransformId);