lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 4cc9f66: Merge tables in sorted order


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 4cc9f66: Merge tables in sorted order
Date: Wed, 4 Jan 2017 00:24:01 +0000 (UTC)

branch: master
commit 4cc9f6659215871b12e821e567be9bac3cbf8fa8
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Merge tables in sorted order
---
 rate_table_tool.cpp |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/rate_table_tool.cpp b/rate_table_tool.cpp
index 3f34f20..1eb7dd7 100644
--- a/rate_table_tool.cpp
+++ b/rate_table_tool.cpp
@@ -137,12 +137,27 @@ void merge
 
     if(fs::is_directory(path_to_merge))
         {
+        // Merge tables in sorted order, so that adding identical sets
+        // of tables to identical databases yields identical results.
+        // An entire database may thus be sorted by extracting all its
+        // tables and merging them into a new database in a single
+        // operation. The only real benefit is that identity is easier
+        // to verify than equivalence: databases created this way from
+        // the same data on different machines have identical md5sums.
+        std::vector<fs::path> table_names;
         fs::directory_iterator i(path_to_merge);
         fs::directory_iterator const eod;
         for(; i != eod; ++i)
             {
-            if(".rates" != fs::extension(*i)) continue;
-            table const& t = table::read_from_text(*i);
+            if(".rates" == fs::extension(*i))
+                {
+                table_names.push_back(*i);
+                }
+            }
+        std::sort(table_names.begin(), table_names.end());
+        for(auto const& j: table_names)
+            {
+            table const& t = table::read_from_text(j);
             table_file->add_or_replace_table(t);
             ++count;
             }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]