[Kst] branches/work/kst/portto4/kst/src/datasources/ascii

Peter Kümmel syntheticpp at gmx.net
Tue Oct 16 14:48:03 UTC 2012


SVN commit 1320709 by kuemmel:

remove obsolete code

 M  +1 -1      asciifilebuffer.cpp  
 M  +5 -38     asciisource.cpp  
 M  +2 -1      asciisource.h  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciifilebuffer.cpp #1320708:1320709
@@ -114,7 +114,7 @@
     chunk.setRowsRead(lastRow - rowBegin);
     chunks << chunk;
   }
-  qDebug() << "File splitted into " << chunks.size() << " chunks:"; logData(chunks);
+  //qDebug() << "File splitted into " << chunks.size() << " chunks:"; logData(chunks);
   return chunks;
 }
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1320708:1320709
@@ -216,46 +216,15 @@
 int AsciiSource::readField(double *v, const QString& field, int s, int n) 
 {
   bool succcess;
-  int n_read = readField(v, field, s, n, succcess);
-  if (succcess) {
-    // file is now buffered in memory
-    return n_read;
-  }
-  
-  // reading whole file into memory failed
-  
-  /*
-  // find a smaller allocatable size
-  _fileBuffer.clear();
-  int realloc_size = n / 4;
-  while (!_fileBuffer.resize(realloc_size) && realloc_size > 0) {
-    realloc_size /= 2;
-  }
-  _fileBuffer.clear();
-  if (realloc_size == 0) {
-    QMessageBox::warning(0, "Error while reading ascii file", "File could not be read because not enough memory is available.");
-    return 0;      
-  }
-  
-  // read in 
-  int start = s;
-  n_read = 0;
-  while (n_read < n) {
-    _fileBuffer.clear();
-    int to_read = n_read + realloc_size < n ? realloc_size : n - n_read;
-    n_read += readField(v + start, field, n_read, to_read, succcess);
+  int read = readField(v, field, s, n, succcess);
     if (!succcess) {
-      _fileBuffer.clear();
+    if (read == 0) {
+      QMessageBox::warning(0, "Error while reading ascii file", "File could not be read because not enough memory is available.");
+    } else if ( read != n) {
       QMessageBox::warning(0, "Error while reading ascii file", "The file was only read partially not enough memory is available.");
-      return n_read; 
     }
-    start += to_read;
   }
-  // don't buffer partial files
-  _fileBuffer.clear();
-  return n_read;
-  */
-  return 0;
+  return read;
 }
 
 
@@ -304,9 +273,7 @@
   
   int sRead = 0;
   const QVector<AsciiFileData>& data = _fileBuffer.data();
-  qDebug() << "Reading vector:";
   foreach (const AsciiFileData& chunk, data) {
-    chunk.logData();
     sRead += _reader.readField(chunk, col, v + sRead, field, chunk.rowBegin(), chunk.rowsRead());
   }
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1320708:1320709
@@ -39,7 +39,6 @@
     virtual UpdateType internalDataSourceUpdate();
 
     int readField(double *v, const QString &field, int s, int n);
-    int readField(double *v, const QString &field, int s, int n, bool& success);
 
     QString fileType() const;
 
@@ -84,6 +83,8 @@
     QStringList _fieldList;
     QMap<QString, QString> _fieldUnits;
 
+    int readField(double *v, const QString &field, int s, int n, bool& success);
+
     int columnOfField(const QString& field) const;
     static QStringList splitHeaderLine(const QByteArray& line, AsciiSourceConfig* cfg);
 


More information about the Kst mailing list