summary refs log tree commit diff stats
path: root/generator/generator.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-11-08 14:53:26 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-11-08 14:53:26 -0500
commit350bfdb5ea9b4f7e50746c50a46d8032cbc5a104 (patch)
treee339d118669f85de1afb858828a7affd0b47c745 /generator/generator.cpp
parentb92db337bf7cbe2ea0564be6c63c336d2bcd4567 (diff)
downloadverbly-350bfdb5ea9b4f7e50746c50a46d8032cbc5a104.tar.gz
verbly-350bfdb5ea9b4f7e50746c50a46d8032cbc5a104.tar.bz2
verbly-350bfdb5ea9b4f7e50746c50a46d8032cbc5a104.zip
Created database versioning system d1.0
Also added an ANALYZE statement to the end of the datafile generation
process. This generates information that allows sqlite to sometimes come
up with a better query plan, and in many cases can significant speed up
queries. This constitutes a minor database update, but because this is
the first version that uses the database versioning system, older
versions are essentially incompatible.

refs #2
Diffstat (limited to 'generator/generator.cpp')
-rw-r--r--generator/generator.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/generator/generator.cpp b/generator/generator.cpp index e125b4a..d774bd9 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp
@@ -11,6 +11,7 @@
11#include "part.h" 11#include "part.h"
12#include "field.h" 12#include "field.h"
13#include "../lib/util.h" 13#include "../lib/util.h"
14#include "../lib/version.h"
14 15
15namespace verbly { 16namespace verbly {
16 namespace generator { 17 namespace generator {
@@ -112,6 +113,9 @@ namespace verbly {
112 // Writes the database schema 113 // Writes the database schema
113 writeSchema(); 114 writeSchema();
114 115
116 // Writes the database version
117 writeVersion();
118
115 // Dumps data to the database 119 // Dumps data to the database
116 dumpObjects(); 120 dumpObjects();
117 121
@@ -154,6 +158,9 @@ namespace verbly {
154 158
155 // Populates the adjective similarity relationship from WordNet 159 // Populates the adjective similarity relationship from WordNet
156 readWordNetSimilarity(); 160 readWordNetSimilarity();
161
162 // Generates analysis data to assist in query planning.
163 analyzeDatabase();
157 } 164 }
158 165
159 void generator::readWordNetSynsets() 166 void generator::readWordNetSynsets()
@@ -581,6 +588,15 @@ namespace verbly {
581 } 588 }
582 } 589 }
583 590
591 void generator::writeVersion()
592 {
593 std::list<field> fields;
594 fields.emplace_back("major", DATABASE_MAJOR_VERSION);
595 fields.emplace_back("minor", DATABASE_MINOR_VERSION);
596
597 db_.insertIntoTable("version", std::move(fields));
598 }
599
584 void generator::dumpObjects() 600 void generator::dumpObjects()
585 { 601 {
586 { 602 {
@@ -1110,6 +1126,13 @@ namespace verbly {
1110 } 1126 }
1111 } 1127 }
1112 1128
1129 void generator::analyzeDatabase()
1130 {
1131 std::cout << "Analyzing data..." << std::endl;
1132
1133 db_.runQuery("ANALYZE");
1134 }
1135
1113 std::list<std::string> generator::readFile(std::string path) 1136 std::list<std::string> generator::readFile(std::string path)
1114 { 1137 {
1115 std::ifstream file(path); 1138 std::ifstream file(path);