Add support for dataset versionning.

This also updates to the latest mercator_db API which adds
multi-dataset support.
This commit is contained in:
2019-10-04 15:41:06 +02:00
parent 1912a5f092
commit 06f8ca71f2
3 changed files with 23 additions and 8 deletions

View File

@@ -24,7 +24,6 @@ structopt = "^0.3"
mercator_db = "^0.1"
# Logging macros API
#log = { version = "^0.4", features = ["max_level_trace", "release_max_level_info"] }
log = { version = "^0.4", features = ["max_level_trace", "release_max_level_trace"] }
pretty_env_logger = "^0.3" # Logger implementation

View File

@@ -47,7 +47,7 @@ For 3 datasets, `setA`, `setB`, `setC`, the following files are expected to be i
Run (and build if necessary) the indexer:
```sh
cargo run --release -- setA, setB, setC
cargo run --release -- setA setB setC
```
This will produce the following files:
@@ -63,6 +63,14 @@ This will produce the following files:
- setC.objects.bin
- setC.spaces.bin
- setC.index
By default, each dataset will have a version set to the empty string, if you want to specify the dataset version you can like this:
```sh
cargo run --release -- setA:v0.1 setB setC:MyAwesomeVersion
```
With the above, `setA` will have its version set to `v0.1`, `setB` to the empty string and `setC` to `MyAwesomeVersion`.
## Acknowledgements

View File

@@ -1,8 +1,6 @@
#[macro_use]
extern crate measure_time;
use std::process::exit;
use mercator_db::json::storage;
use structopt::StructOpt;
@@ -23,19 +21,29 @@ fn main() {
for dataset in opt.datasets {
println!();
warn!("Indexing dataset: {}", dataset);
warn_time!("Indexed dataset: {}", dataset);
let v = dataset.split(':').collect::<Vec<_>>();
if v.len() > 2 {
warn!("Invalid dataset definition, too many fields: '{:?}'", v);
continue;
}
let title = v[0];
let version = if v.len() == 2 { v[1] } else { "" };
warn!("Indexing dataset: {}", title);
warn_time!("Indexed dataset: {}", title);
// Convert to binary the JSON data:
{
info_time!("Converting to binary JSON data");
storage::convert(&dataset);
storage::convert(&title);
}
// Build a Database Index:
{
info_time!("Building database index");
storage::build(&dataset);
storage::build(&title, version);
}
}
}