Commit 1079ee49 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Config option for transaction commit interval

parent 0957c919
......@@ -24,7 +24,8 @@ namespace Marble
MbTileWriter::MbTileWriter(const QString &filename, const QString &extension) :
m_overwriteTiles(true),
m_reportProgress(true),
m_tileCounter(0)
m_tileCounter(0),
m_commitInterval(10000)
{
bool const exists = QFileInfo(filename).exists();
......@@ -69,6 +70,11 @@ void MbTileWriter::setReportProgress(bool report)
m_reportProgress = report;
}
void MbTileWriter::setCommitInterval(int interval)
{
m_commitInterval = interval;
}
void MbTileWriter::addTile(const QFileInfo &file, qint32 x, qint32 y, qint32 z)
{
if (!m_overwriteTiles && haveTile(x, y, z)) {
......@@ -86,7 +92,7 @@ void MbTileWriter::addTile(const QFileInfo &file, qint32 x, qint32 y, qint32 z)
std::cout.flush();
}
if (m_tileCounter % 10000 == 0) {
if (m_commitInterval > 0 && m_tileCounter % m_commitInterval == 0) {
execQuery("END TRANSACTION");
execQuery("BEGIN TRANSACTION");
}
......
......@@ -25,6 +25,7 @@ public:
void setOverwriteTiles(bool overwrite);
void setReportProgress(bool report);
void setCommitInterval(int interval);
void addTile(const QFileInfo &file, qint32 x, qint32 y, qint32 z);
......@@ -37,6 +38,7 @@ private:
bool m_overwriteTiles;
bool m_reportProgress;
int m_tileCounter;
int m_commitInterval;
};
}
......
......@@ -74,6 +74,7 @@ int main(int argc, char** argv)
{{"o", "overwrite"}, "Overwrite existing tiles in the database"},
{{"q", "quiet"}, "No progress report to stdout"},
{{"t", "tilelevels"}, "Restrict tile levels to <tilelevels>", "tilelevels", "0-20"},
{{"i", "interval"}, "Commit each <interval> tiles (0: single transaction)", "interval", "10000"},
});
if (!parser.parse(QCoreApplication::arguments())) {
......@@ -120,6 +121,7 @@ int main(int argc, char** argv)
MbTileWriter tileWriter(mbTilesFile);
tileWriter.setOverwriteTiles(parser.isSet("overwrite"));
tileWriter.setReportProgress(!parser.isSet("quiet"));
tileWriter.setCommitInterval(parser.value("interval").toInt());
importTiles(tileDirectory, tileWriter, tileLevelRange);
return 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment