summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-08-05 10:52:18 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-08-05 10:52:36 (GMT)
commit1079ee4911712504c2fdffca29db25a21c1dcc54 (patch)
tree1c092a175b5d1de711e5588291d8c933e215cdcf
parent0957c91931e53e2449ba8388c273519d9959ddb8 (diff)
Config option for transaction commit interval
-rw-r--r--tools/mbtile-import/MbTileWriter.cpp10
-rw-r--r--tools/mbtile-import/MbTileWriter.h2
-rw-r--r--tools/mbtile-import/mbtile-import.cpp2
3 files changed, 12 insertions, 2 deletions
diff --git a/tools/mbtile-import/MbTileWriter.cpp b/tools/mbtile-import/MbTileWriter.cpp
index 7a0ce0d..5cc702a 100644
--- a/tools/mbtile-import/MbTileWriter.cpp
+++ b/tools/mbtile-import/MbTileWriter.cpp
@@ -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");
}
diff --git a/tools/mbtile-import/MbTileWriter.h b/tools/mbtile-import/MbTileWriter.h
index bc3d19a..7285b26 100644
--- a/tools/mbtile-import/MbTileWriter.h
+++ b/tools/mbtile-import/MbTileWriter.h
@@ -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;
};
}
diff --git a/tools/mbtile-import/mbtile-import.cpp b/tools/mbtile-import/mbtile-import.cpp
index b848a8a..9ab8fc2 100644
--- a/tools/mbtile-import/mbtile-import.cpp
+++ b/tools/mbtile-import/mbtile-import.cpp
@@ -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;