Skip to main content

Crate spatialbench

Crate spatialbench 

Source
Expand description

Rust Spatial Bench Data Generator

This crate provides a native Rust implementation of functions and utilities necessary for generating the SpatialBench benchmark dataset in several popular formats.

§Example: TBL output format

// Create Generator for the TRIP table at Scale Factor 0.01 (SF 0.01)
let scale_factor = 0.01;
let part = 1;
let num_parts = 1;
let generator = TripGenerator::new(scale_factor, part, num_parts);

// Output the first 3 rows in classic Spatial Bench TBL format
// (the generators are normal rust iterators and combine well with the Rust ecosystem)
let trips: Vec<_> = generator.iter()
   .take(3)
   .map(|trips| trips.to_string()) // use Display impl to get TBL format
   .collect::<Vec<_>>();
 assert_eq!(
  trips.join("\n"),"\
    1|215|1|1|1997-07-24 06:58:22|1997-07-24 13:59:54|0.34|0.02|0.37|0.14|POINT(21.218087029 8.013230662)|POINT(21.20426295 7.8734025)|\n\
    2|172|1|1|1997-12-24 08:47:14|1997-12-24 09:28:57|0.03|0.00|0.04|0.01|POINT(94.423867952 29.887250009)|POINT(94.43760277 29.88940658)|\n\
    3|46|1|1|1993-06-27 13:27:07|1993-06-27 13:34:51|0.00|0.00|0.00|0.00|POINT(109.719117916 1.988484212)|POINT(109.717325 1.98663399)|"
 );

The SpatialBench dataset is composed of several tables with foreign key relations between them. For each table we implement and expose a generator that uses the iterator API to produce structs e.g Trip that represent a single row.

For each struct type we expose several facilities that allow fast conversion to Tbl and Csv formats but can also be extended to support other output formats.

This crate currently supports the following output formats:

  • TBL: The Display impl of the row structs produces the Spatial Bench TBL format.
  • CSV: the csv module has formatters for CSV output (e.g. TripCsv).

The library was designed to be easily integrated in existing Rust projects as such it avoids exposing a malleable API and purposely does not have any dependencies on other Rust crates. It is focused entire on the core generation logic.

If you want an easy way to generate the SpatialBench dataset for usage with external systems you can use CLI tool instead.

Modules§

csv
CSV formatting support for the row struct objects generated by the library.
dates
TPCHDate and date handling
decimal
TPCHDecimal and decimal handling
distribution
generators
Generators for each Spatial Bench Tables
kde
q_and_a
TPC-H Queries and Answers.
random
Implementation of the core random number generators.
spatial
text
Implementation of text pool and text generation.