[Kst] branches/work/kst/portto4/kst/src/datasources/ascii
Peter Kümmel
syntheticpp at gmx.net
Mon Jan 24 13:20:34 CET 2011
SVN commit 1216727 by kuemmel:
AsciiSource: Add option to speedup by a priori information of data.
When columns have ALWAYS the same with skip the searching for a column start after it was found the first time.
M +8 -8 asciiconfig.ui
M +2 -0 asciiplugin.cpp
M +11 -0 asciisource.cpp
M +11 -1 asciisourceconfig.cpp
M +3 -0 asciisourceconfig.h
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfig.ui #1216726:1216727
@@ -209,13 +209,8 @@
<property name="title">
<string>Data Format</string>
</property>
- <layout class="QHBoxLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <layout class="QGridLayout">
- <item row="0" column="0" colspan="2">
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
<widget class="QRadioButton" name="_whitespace">
<property name="text">
<string>Whitespace delimited</string>
@@ -262,7 +257,12 @@
</property>
</widget>
</item>
- </layout>
+ <item row="3" column="0" colspan="2">
+ <widget class="QCheckBox" name="_columnWidthIsConst">
+ <property name="text">
+ <string>All column widths doesn't change</string>
+ </property>
+ </widget>
</item>
</layout>
</widget>
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiplugin.cpp #1216726:1216727
@@ -58,6 +58,7 @@
config._columnType = ct;
config._columnDelimiter = _columnDelimiter->text();
config._columnWidth = _columnWidth->value();
+ config._columnWidthIsConst = _columnWidthIsConst->isChecked();
config._dataLine = _startLine->value();
config._readFields = _readFields->isChecked();
config._useDot = _useDot->isChecked();
@@ -73,6 +74,7 @@
_fileNamePattern->setText(config._fileNamePattern);
_columnDelimiter->setText(config._columnDelimiter);
_columnWidth->setValue(config._columnWidth);
+ _columnWidthIsConst->setChecked(config._columnWidthIsConst);
_startLine->setValue(config._dataLine);
_readFields->setChecked(config._readFields);
_useDot->setChecked(config._useDot);
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1216726:1216727
@@ -282,6 +282,8 @@
#define MAXBUFREADLEN 32768
Kst::Object::UpdateType AsciiSource::internalDataSourceUpdate()
{
+ MeasureTime t("internalDataSourceUpdate");
+
if (!_haveHeader) {
_haveHeader = initRowIndex();
if (!_haveHeader) {
@@ -468,10 +470,16 @@
commentDelemiterFunction = &AsciiSource::isInCommentDelimiterString;
}
+ int col_start = -1;
for (int i = 0; i < n; i++, s++) {
bool incol = false;
int i_col = 0;
+ if (_config._columnWidthIsConst && col_start != -1) {
+ v[i] = lexc.toDouble(&buffer[0] + _rowIndex[s] + col_start);
+ continue;
+ }
+
v[i] = Kst::NOPOINT;
int ch;
for (ch = _rowIndex[s] - bufstart; ch < bufread; ++ch) {
@@ -487,6 +495,9 @@
++i_col;
if (i_col == col) {
toDouble(lexc, buffer, bufread, ch, &v[i], i);
+ if (col_start == -1) {
+ col_start = ch - _rowIndex[s] + 1;
+ }
break;
}
}
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.cpp #1216726:1216727
@@ -45,6 +45,8 @@
const char AsciiSourceConfig::Tag_columnDelimiter[] = "columndelimiter";
const char AsciiSourceConfig::Key_columnWidth[] = "Column Width";
const char AsciiSourceConfig::Tag_columnWidth[] = "columnwidth";
+const char AsciiSourceConfig::Key_columnWidthIsConst[] = "Column Width is const";
+const char AsciiSourceConfig::Tag_columnWidthIsConst[] = "columnwidthisconst";
const char AsciiSourceConfig::Key_dataLine[] = "Data Start";
const char AsciiSourceConfig::Tag_dataLine[] = "headerstart";
const char AsciiSourceConfig::Key_readFields[] = "Read Fields";
@@ -63,6 +65,7 @@
_columnType(Whitespace),
_columnDelimiter(","),
_columnWidth(DEFAULT_COLUMN_WIDTH),
+ _columnWidthIsConst(false),
_dataLine(0),
_readFields(false),
_fieldsLine(0),
@@ -85,6 +88,7 @@
_readFields >> cfg;
_useDot >> cfg;
_fieldsLine >> cfg;
+ _columnWidthIsConst >> cfg;
}
@@ -113,6 +117,7 @@
_readFields << cfg;
_useDot << cfg;
_fieldsLine << cfg;
+ _columnWidthIsConst << cfg;
}
@@ -148,6 +153,7 @@
_fieldsLine >> s;
_readFields >> s;
_useDot >> s;
+ _columnWidthIsConst >> s;
s.writeEndElement();
}
@@ -165,11 +171,12 @@
_readFields << attributes;
_useDot << attributes;
_fieldsLine << attributes;
+ _columnWidthIsConst << attributes;
}
void AsciiSourceConfig::load(const QDomElement& e) {
- // TODO use tags
+ // TODO use tags, isn't this code torally buggy, because trings and tags doesn't match?
QDomNode n = e.firstChild();
while (!n.isNull()) {
QDomElement e = n.toElement();
@@ -192,6 +199,9 @@
if (e.hasAttribute("width")) {
_columnWidth = e.attribute("width").toInt();
}
+ if (e.hasAttribute(Key_columnWidthIsConst)) {
+ _columnWidthIsConst = e.attribute(Key_columnWidthIsConst).toInt();
+ }
if (e.hasAttribute("delimiters")) {
_columnDelimiter = e.attribute("delimiters").toLatin1();
}
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.h #1216726:1216727
@@ -39,6 +39,8 @@
static const char Tag_columnDelimiter[];
static const char Key_columnWidth[];
static const char Tag_columnWidth[];
+ static const char Key_columnWidthIsConst[];
+ static const char Tag_columnWidthIsConst[];
static const char Key_dataLine[];
static const char Tag_dataLine[];
static const char Key_readFields[];
@@ -69,6 +71,7 @@
NamedParameter<int, Key_columnType, Tag_columnType> _columnType;
NamedParameter<QString, Key_columnDelimiter, Tag_columnDelimiter> _columnDelimiter;
NamedParameter<int, Key_columnWidth, Tag_columnWidth> _columnWidth;
+ NamedParameter<bool, Key_columnWidthIsConst, Tag_columnWidthIsConst> _columnWidthIsConst;
NamedParameter<int, Key_dataLine, Tag_dataLine> _dataLine;
NamedParameter<bool, Key_readFields, Tag_readFields> _readFields;
NamedParameter<int, Key_fieldsLine, Tag_fieldsLine> _fieldsLine;
More information about the Kst
mailing list