comparison rdf/RDFFeatureWriter.cpp @ 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 af7b6e55895b
children 06a6612e7cf1
comparison
equal deleted inserted replaced
511:7207e3eba44f 512:e7a39c45a7a4
116 116
117 // Need to select appropriate output file for our track/transform 117 // Need to select appropriate output file for our track/transform
118 // combination 118 // combination
119 119
120 QTextStream *stream = getOutputStream(trackId, transform.getIdentifier()); 120 QTextStream *stream = getOutputStream(trackId, transform.getIdentifier());
121 if (!stream) return; //!!! this is probably better handled with an exception 121 if (!stream) {
122 std::cerr << "RDFFeatureWriter::write: ERROR: No output stream for track id \""
123 << trackId.toStdString() << "\" and transform \""
124 << transform.getIdentifier().toStdString() << "\"" << std::endl;
125 return;
126 }
122 127
123 if (m_startedStreamTransforms.find(stream) == 128 if (m_startedStreamTransforms.find(stream) ==
124 m_startedStreamTransforms.end()) { 129 m_startedStreamTransforms.end()) {
125 cerr << "This stream is new, writing prefixes" << endl; 130 // cerr << "This stream is new, writing prefixes" << endl;
126 writePrefixes(stream); 131 writePrefixes(stream);
127 if (m_singleFileName == "" && !m_stdout) { 132 if (m_singleFileName == "" && !m_stdout) {
128 writeSignalDescription(stream, trackId); 133 writeSignalDescription(stream, trackId);
129 } 134 }
130 } 135 }
408 const Plugin::OutputDescriptor& od, 413 const Plugin::OutputDescriptor& od,
409 const Plugin::FeatureList& featureList, 414 const Plugin::FeatureList& featureList,
410 PluginRDFDescription &desc, 415 PluginRDFDescription &desc,
411 QString timelineURI) 416 QString timelineURI)
412 { 417 {
418 // std::cerr << "RDFFeatureWriter::writeSparseRDF: have " << featureList.size() << " features" << std::endl;
419
413 if (featureList.empty()) return; 420 if (featureList.empty()) return;
414 QTextStream &stream = *sptr; 421 QTextStream &stream = *sptr;
415 422
416 bool plain = (m_plain || !desc.haveDescription()); 423 bool plain = (m_plain || !desc.haveDescription());
417 424
654 // close any open dense feature literals 661 // close any open dense feature literals
655 662
656 for (map<StringTransformPair, StreamBuffer>::iterator i = 663 for (map<StringTransformPair, StreamBuffer>::iterator i =
657 m_openDenseFeatures.begin(); 664 m_openDenseFeatures.begin();
658 i != m_openDenseFeatures.end(); ++i) { 665 i != m_openDenseFeatures.end(); ++i) {
659 cerr << "closing a stream" << endl; 666 // cerr << "closing a stream" << endl;
660 StreamBuffer &b = i->second; 667 StreamBuffer &b = i->second;
661 *(b.first) << b.second << "\" ." << endl; 668 *(b.first) << b.second << "\" ." << endl;
662 } 669 }
663 670
664 m_openDenseFeatures.clear(); 671 m_openDenseFeatures.clear();