Skip to content

Commit 4b269e8

Browse files
rust(feat): adding hdf5 imports (#565)
Co-authored-by: Brandon Shippy <brandon.shippy@siftstack.com>
1 parent 5de76ef commit 4b269e8

10 files changed

Lines changed: 751 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ reqwest = "0.13"
5959
serde = { version = "^1.0" }
6060
serde_json = { version = "^1.0" }
6161
tdms = "0.3.0"
62+
hdf5 = { package = "hdf5-metno", version = "0.12", features = ["static"] }
6263
tempdir = "0.3"
6364
tokio = { version = "1" }
6465
tokio-stream = "0.1"

rust/crates/sift_cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pbjson-types = { workspace = true }
3232
reqwest = { workspace = true }
3333
sift_pbfs = { workspace = true }
3434
tdms = { workspace = true }
35+
hdf5 = { workspace = true }
3536
sift_rs = { workspace = true }
3637
tokio = { workspace = true, features = ["full", "net", "time"] }
3738
tokio-stream = { workspace = true }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::fmt::{self, Display};
2+
3+
use clap::ValueEnum;
4+
5+
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
6+
pub enum Hdf5Schema {
7+
OneD,
8+
TwoD,
9+
Compound,
10+
}
11+
12+
impl Display for Hdf5Schema {
13+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14+
match self {
15+
Self::OneD => write!(f, "one-d"),
16+
Self::TwoD => write!(f, "two-d"),
17+
Self::Compound => write!(f, "compound"),
18+
}
19+
}
20+
}

rust/crates/sift_cli/src/cli/mod.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use clap::{Parser, Subcommand, crate_description, crate_version};
22
use clap_complete::Shell;
33
use parquet::ComplexTypesMode;
4+
pub mod hdf5;
45
pub mod tdms;
6+
use hdf5::Hdf5Schema;
57
use std::path::PathBuf;
68
use tdms::TdmsFallbackMethod;
79

@@ -161,6 +163,11 @@ pub enum ImportCmd {
161163
/// Import a Tdms file into Sift.
162164
Tdms(ImportTdmsArgs),
163165

166+
/// Import an HDF5 file into Sift. Supported channel types: bool,
167+
/// int8/16/32/64, uint8/16/32/64, float32, float64. Datasets with other
168+
/// types will produce a client-side error.
169+
Hdf5(ImportHdf5Args),
170+
164171
/// Import backup files generated by sift_stream into Sift.
165172
#[command(name = "backups")]
166173
Backup(BackupArgs),
@@ -420,3 +427,31 @@ pub struct ImportTdmsArgs {
420427
#[arg(long)]
421428
pub import_file_properties: bool,
422429
}
430+
431+
#[derive(clap::Args)]
432+
pub struct ImportHdf5Args {
433+
#[command(flatten)]
434+
pub common: CommonImportArgs,
435+
436+
/// Schema type for the HDF5 file. Supported channel types across all
437+
/// schemas: bool, int8/16/32/64, uint8/16/32/64, float32, float64.
438+
#[arg(long)]
439+
pub schema: Hdf5Schema,
440+
441+
/// Time format used in the time dataset/column
442+
#[arg(long)]
443+
pub time_format: Option<TimeFormat>,
444+
445+
/// Start time (RFC3339) if the time format is relative
446+
#[arg(short = 's', long)]
447+
pub relative_start_time: Option<String>,
448+
449+
/// (two-d / compound) Index of the time column or field. Defaults to 0.
450+
/// Mutually exclusive with --time-field.
451+
#[arg(long, conflicts_with = "time_field")]
452+
pub time_index: Option<u64>,
453+
454+
/// (compound) Name of the time field. Mutually exclusive with --time-index.
455+
#[arg(long)]
456+
pub time_field: Option<String>,
457+
}

0 commit comments

Comments
 (0)