File debug.patch of Package soprano
--- a/tools/onto2vocabularyclass.cpp 2024-01-09 20:50:06.000000000 +0100
+++ b/tools/onto2vocabularyclass.cpp 2024-01-09 20:49:45.000000000 +0100
@@ -191,6 +191,9 @@
int main( int argc, char *argv[] )
{
+ QTextStream wolfiout( stdout );
+ wolfiout << "onto2vocabularyclass " << VERSION << endl;
+
QCoreApplication app( argc, argv );
QStringList args = app.arguments();
@@ -258,12 +261,14 @@
if ( encoding.isEmpty() ) {
return usage();
}
+ wolfiout << "trying to open file " << fileName << endl;
if ( !QFile::exists( fileName ) ) {
QTextStream s( stderr );
s << "Could not find file " << fileName << endl;
return 1;
}
+ wolfiout << "file exists" << endl;
const Parser* parser = PluginManager::instance()->discoverParserForSerialization( mimeTypeToSerialization( encoding ), encoding );
if ( !parser ) {
@@ -271,13 +276,16 @@
s << "Could not find parser plugin for encoding " << encoding << endl;
return 1;
}
+ wolfiout << "created parser " << parser->pluginName() << endl;
StatementIterator it = parser->parseFile( fileName, QUrl( "http://dummybaseuri.org" ), mimeTypeToSerialization( encoding ), encoding );
+ wolfiout << "parseFile() returned." << endl;
if ( parser->lastError() ) {
QTextStream s( stderr );
s << "Failed to parse file" << fileName << "(" << parser->lastError() << ")" << endl;
return 1;
}
+ wolfiout << "parsed file successfully." << endl;
Graph graph;
while ( it.next() ) {
@@ -301,6 +305,7 @@
QTextStream headerStream( &headerFile );
QTextStream sourceStream( &sourceFile );
+ wolfiout << "files opened " << endl;
// select all relevant resource, try to be intelligent about it...
QList<Node> allResources = extractRelevantResources( graph );
--- a/parsers/raptor/raptorparser.cpp 2013-10-09 19:22:28.000000000 +0200
+++ b/parsers/raptor/raptorparser.cpp 2024-01-10 07:50:27.000000000 +0100
@@ -194,6 +194,8 @@
RdfSerialization serialization,
const QString& userSerialization ) const
{
+QTextStream wolfiout( stdout );
+wolfiout << "Soprano::Raptor::Parser::parseFile() called." << endl;
QFile f( filename );
if ( f.open( QIODevice::ReadOnly ) ) {
QTextStream s( &f );
@@ -222,18 +224,23 @@
RdfSerialization serialization,
const QString& userSerialization ) const
{
+QTextStream wolfiout( stdout );
+wolfiout << "Soprano::Raptor::Parser::parseStream() called." << endl;
QMutexLocker lock( &d->mutex );
clearError();
+wolfiout << "creating parser...";
raptor_parser* parser = createParser( serialization, userSerialization );
if ( !parser ) {
return StatementIterator();
}
+wolfiout << "done." << endl;
// prepare the container for the parsed data
ParserData data;
raptor_parser_set_statement_handler( parser, &data, raptorTriplesHandler );
+wolfiout << "raptor_parser_set_statement_handler() returned." << endl;
// start the atual parsing
raptor_uri* raptorBaseUri = 0;
@@ -243,6 +250,7 @@
else {
raptorBaseUri = raptor_new_uri( d->world, (unsigned char *) "http://soprano.sourceforge.net/dummyBaseUri" );
}
+wolfiout << "raptorBaseUri created." << endl;
clearError();
if ( raptor_parser_parse_start( parser, raptorBaseUri ) != 0 ) {
@@ -255,47 +263,57 @@
}
return StatementIterator();
}
+wolfiout << "raptor_parser_parse_start() was successful." << endl;
- static const int bufSize = 1024;
+// static const int bufSize = 102400;
+wolfiout << "stream=" << &stream << endl;
// if possible let raptor do the decoding
if ( QIODevice* dev = stream.device() ) {
- QByteArray buf( bufSize, 0 );
- while ( !dev->atEnd() ) {
- qint64 r = dev->read( buf.data(), buf.size() );
- if ( r <= 0 ||
- raptor_parser_parse_chunk( parser, ( const unsigned char* )buf.data(), r, 0 ) ) {
+wolfiout << "letting raptor do the decoding..." << endl;
+// QByteArray buf( bufSize, 0 );
+// while ( !dev->atEnd() ) {
+// qint64 r = dev->read( buf.data(), buf.size() );
+//wolfiout << "Read " << r << "bytes. " << endl;
+ QByteArray buf = dev->readAll();
+// if ( r <= 0 ||
+ if ( buf.isEmpty() ||
+ raptor_parser_parse_chunk( parser, ( const unsigned char* )buf.data(), buf.size(), 0 ) ) {
// parse_chunck return failure code.
// Call it with END=true and then free
raptor_parser_parse_chunk(parser,0,0,/*END=*/1);
- raptor_free_parser( parser );
+wolfiout << "Skipped raptor_free_parser( parser ) #1" << endl;
if ( raptorBaseUri ) {
raptor_free_uri( raptorBaseUri );
}
return StatementIterator();
}
- }
+// }
}
else {
- while ( !stream.atEnd() ) {
- QString buf = stream.read( bufSize );
+wolfiout << "decoding ourselves..." << endl;
+// while ( !stream.atEnd() ) {
+ QString buf = stream.readAll(); //stream.read( bufSize );
+wolfiout << "Read: " << endl;
QByteArray utf8Data = buf.toUtf8();
+wolfiout << "length=" << utf8Data.length() << endl;
if ( raptor_parser_parse_chunk( parser, ( const unsigned char* )utf8Data.data(), utf8Data.length(), 0 ) ) {
// parse_chunck return failure code.
// Call it with END=true and then free
raptor_parser_parse_chunk(parser,0,0,/*END=*/1);
- raptor_free_parser( parser );
+wolfiout << "Skipped raptor_free_parser( parser ) #2" << endl;
if ( raptorBaseUri ) {
raptor_free_uri( raptorBaseUri );
}
return StatementIterator();
}
- }
+// }
}
+wolfiout << "finished." << endl;
// Call parse_chunk with END=true
raptor_parser_parse_chunk( parser, 0, 0, 1 );
- raptor_free_parser( parser );
+wolfiout << "Skipped raptor_free_parser( parser ) #3" << endl;
if ( raptorBaseUri ) {
raptor_free_uri( raptorBaseUri );
}