Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b03851
Init
Bill-hbrhbr Aug 27, 2026
dbc1986
Change search to query; Add msgpack tests
Bill-hbrhbr Aug 27, 2026
d8f992e
Merge branch 'main' into query-coordinator-tdl
Bill-hbrhbr Aug 27, 2026
0ba6fe5
docs(clp-tdl-package): Clarify package task scope
Bill-hbrhbr Aug 27, 2026
1198719
Merge branch 'main' into query-coordinator-tdl
Bill-hbrhbr Aug 28, 2026
6298f54
polish
Bill-hbrhbr Aug 28, 2026
ff5bc49
Update components/clp-rust-utils/src/task_io/query.rs
Bill-hbrhbr Aug 29, 2026
37396cd
Update components/clp-rust-utils/src/task_io/query.rs
Bill-hbrhbr Aug 29, 2026
da02988
Change to milliseconds
Bill-hbrhbr Aug 30, 2026
bf2ebc0
Update components/clp-tdl-package/src/task/query/mod.rs
Bill-hbrhbr Aug 30, 2026
ba425f5
Merge branch 'main' into query-coordinator-tdl
Bill-hbrhbr Aug 30, 2026
3cb68c5
feat(clp-tdl-package): Add the `clp-s` query task that writes archive…
LinZhihao-723 Aug 31, 2026
2ce8882
refactor(clp-tdl-package): Move `clp_binary_path` and `s3_credential_…
LinZhihao-723 Aug 31, 2026
344281d
Merge branch 'tdl-task-utils-mod' into tdl-task-impl
LinZhihao-723 Aug 31, 2026
0c9157c
refactor(clp-tdl-package): Polish the `clp-s` search task:
LinZhihao-723 Aug 31, 2026
df784e1
refactor(clp-tdl-package): Use singular "result cache" naming in the …
LinZhihao-723 Aug 31, 2026
1df4e42
Done with the search task implementation.
LinZhihao-723 Aug 31, 2026
0296f0c
Remove task redundant description
Bill-hbrhbr Aug 31, 2026
2096e9b
Add query job ID type
Bill-hbrhbr Aug 31, 2026
cb87c6e
Make query task dataset optional
Bill-hbrhbr Aug 31, 2026
f8a68a6
Require non-empty query task strings
Bill-hbrhbr Aug 31, 2026
d5c0450
Use shared default for query result limit
Bill-hbrhbr Aug 31, 2026
ca2ebe2
Lint fix remove unused
Bill-hbrhbr Aug 31, 2026
9429396
Remove unused query task output
Bill-hbrhbr Aug 31, 2026
323acfc
Rename task
Bill-hbrhbr Aug 31, 2026
8f509ef
Add query task output handle
Bill-hbrhbr Aug 31, 2026
b67cb70
Fix todo uppercase
Bill-hbrhbr Aug 31, 2026
61fd27e
Merge branch 'main' into query-coordinator-tdl
Bill-hbrhbr Aug 31, 2026
3bee52b
Document Python mirror for query result limit default
Bill-hbrhbr Aug 31, 2026
c39b086
Name query task output handle parameter after its type
Bill-hbrhbr Sep 1, 2026
3cee914
Fix symbol ordering
Bill-hbrhbr Sep 1, 2026
789f671
Use clp-s default query result limit
Bill-hbrhbr Sep 1, 2026
184d940
Apply batched suggestions from code review
Bill-hbrhbr Sep 1, 2026
c479fad
Propagate rename
Bill-hbrhbr Sep 1, 2026
3b6bc31
Merge PR #2503 into tdl-task-impl
LinZhihao-723 Sep 1, 2026
672af8b
Done.
LinZhihao-723 Sep 1, 2026
e40fcbb
Apply review comments.
LinZhihao-723 Sep 11, 2026
e724c84
Update components/clp-tdl-package/README.md
LinZhihao-723 Sep 11, 2026
6d1dfde
Merge branch 'main' into tdl-task-impl
LinZhihao-723 Sep 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions components/clp-rust-utils/src/clp_config/package/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,20 @@ impl ArchiveOutput {
.to_string_lossy()
.into_owned()
}

/// Derives the S3 object key of an archive in a dataset.
///
/// # Returns
///
/// The dataset's archive storage directory joined with `archive_id`, where a `None` dataset
/// resolves to `default`.
#[must_use]
pub fn dataset_archive_object_key(&self, dataset: Option<&str>, archive_id: &str) -> String {
Comment thread
Bill-hbrhbr marked this conversation as resolved.
format!(
"{}/{archive_id}",
self.dataset_archive_storage_directory(dataset)
)
}
}

impl Default for ArchiveOutput {
Expand Down Expand Up @@ -699,6 +713,38 @@ mod tests {
);
}

#[test]
fn dataset_archive_object_key_joins_prefix_dataset_and_id() {
use non_empty_string::NonEmptyString;

use crate::clp_config::AwsAuthentication;
use crate::clp_config::S3Config;
use crate::types::non_empty_string::ExpectedNonEmpty;

let archive_output = ArchiveOutput {
storage: ArchiveOutputStorage::S3 {
staging_directory: "var/data/staged-archives".to_owned(),
s3_config: S3Config {
bucket: NonEmptyString::from_static_str("bucket"),
region_code: None,
key_prefix: NonEmptyString::from_static_str("LIB1/"),
endpoint_url: None,
aws_authentication: AwsAuthentication::Default,
},
},
..ArchiveOutput::default()
};

assert_eq!(
archive_output.dataset_archive_object_key(None, "abc"),
"LIB1/default/abc"
);
assert_eq!(
archive_output.dataset_archive_object_key(Some("mydataset"), "abc"),
"LIB1/mydataset/abc"
);
}

#[test]
fn deserialize_database_ignores_provided_table_prefix() {
let database_json = serde_json::json!({
Expand Down
2 changes: 2 additions & 0 deletions components/clp-rust-utils/src/job_config/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use serde::Serialize;

pub const QUERY_JOBS_TABLE_NAME: &str = "query_jobs";

pub type QueryJobId = i32;

/// Mirror of `job_orchestration.scheduler.job_config.AggregationConfig`. Must be kept in sync.
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(default)]
Expand Down
1 change: 1 addition & 0 deletions components/clp-rust-utils/src/task_io.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod compression;
pub mod query;
128 changes: 128 additions & 0 deletions components/clp-rust-utils/src/task_io/query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
//! Protocol types exchanged with the Spider (Huntsman) tasks that run CLP query jobs.

use std::num::NonZeroU32;

use non_empty_string::NonEmptyString;
use serde::Deserialize;
use serde::Serialize;

/// `clp-s` options for a query job.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ClpSQueryOption {
/// The query string passed positionally to `clp-s`.
pub query_string: NonEmptyString,

/// The per-archive result limit. When absent, the task omits `--max-num-results` and uses the
/// `clp-s` default.
pub max_num_results: Option<NonZeroU32>,

/// Inclusive `--tge` bound in Unix epoch milliseconds.
pub begin_timestamp_millisecs: Option<i64>,

/// Inclusive `--tle` bound in Unix epoch milliseconds.
pub end_timestamp_millisecs: Option<i64>,

/// Whether `clp-s` performs a case-insensitive search.
pub ignore_case: bool,
}

/// The output handler that `clp-s` writes a query task's results to.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields, tag = "type")]
pub enum OutputHandle {
/// The results cache, addressed by a MongoDB URI whose path names the database. The collection
/// is the query job's ID.
#[serde(rename = "results_cache")]
ResultsCache { uri: NonEmptyString },

/// A file per archive. Not yet supported by the Spider query flow.
#[serde(rename = "file")]
File,
}

#[cfg(test)]
mod tests {
use std::num::NonZeroU32;

use non_empty_string::NonEmptyString;

use super::ClpSQueryOption;
use super::OutputHandle;
use crate::types::non_empty_string::ExpectedNonEmpty;

#[test]
fn clp_s_query_option_with_timestamp_bounds_round_trips_through_msgpack() {
let expected = ClpSQueryOption {
query_string: NonEmptyString::from_static_str("level:error"),
max_num_results: Some(NonZeroU32::new(1_000).expect("1,000 is nonzero")),
begin_timestamp_millisecs: Some(1_700_000_000_001),
end_timestamp_millisecs: Some(1_700_000_000_999),
ignore_case: true,
};

let serialized = rmp_serde::to_vec(&expected).expect("query options should serialize");
let actual: ClpSQueryOption =
rmp_serde::from_slice(&serialized).expect("query options should deserialize");

assert_eq!(expected, actual);
}

#[test]
fn clp_s_query_option_without_timestamp_bounds_round_trips_through_msgpack() {
let expected = ClpSQueryOption {
query_string: NonEmptyString::from_static_str("*"),
max_num_results: Some(NonZeroU32::new(1).expect("1 is nonzero")),
begin_timestamp_millisecs: None,
end_timestamp_millisecs: None,
ignore_case: false,
};

let serialized = rmp_serde::to_vec(&expected).expect("query options should serialize");
let actual: ClpSQueryOption =
rmp_serde::from_slice(&serialized).expect("query options should deserialize");

assert_eq!(expected, actual);
}

#[test]
fn clp_s_query_option_without_max_num_results_round_trips_through_msgpack() {
let expected = ClpSQueryOption {
query_string: NonEmptyString::from_static_str("*"),
max_num_results: None,
begin_timestamp_millisecs: None,
end_timestamp_millisecs: None,
ignore_case: false,
};

let serialized = rmp_serde::to_vec(&expected).expect("query options should serialize");
let actual: ClpSQueryOption =
rmp_serde::from_slice(&serialized).expect("query options should deserialize");

assert_eq!(expected, actual);
}

#[test]
fn output_handle_results_cache_round_trips_through_msgpack() {
let expected = OutputHandle::ResultsCache {
uri: NonEmptyString::from_static_str("mongodb://results-cache:27017/clp-query-results"),
};

let serialized = rmp_serde::to_vec(&expected).expect("output handle should serialize");
let actual: OutputHandle =
rmp_serde::from_slice(&serialized).expect("output handle should deserialize");

assert_eq!(expected, actual);
}

#[test]
fn output_handle_file_round_trips_through_msgpack() {
let expected = OutputHandle::File;

let serialized = rmp_serde::to_vec(&expected).expect("output handle should serialize");
let actual: OutputHandle =
rmp_serde::from_slice(&serialized).expect("output handle should deserialize");

assert_eq!(expected, actual);
}
}
4 changes: 4 additions & 0 deletions components/clp-tdl-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ documented below.

* `compression::clp_s_s3_compress`: Compress inputs from S3 using `clp-s`.
* `compression::commit`: Commit compression task outcomes to the CLP metadata database.

### Query

* `query::clp_s_search`: Search a single archive using the `clp-s` engine.
8 changes: 6 additions & 2 deletions components/clp-tdl-package/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Spider TDL task package `clp`: the CLP compression tasks the Spider task executor loads.
//! Spider TDL package `clp`, providing CLP compression and query tasks for Spider task executors.

pub mod common;
mod task;
Expand Down Expand Up @@ -28,5 +28,9 @@ fn package_init() -> Result<(), TdlError> {
spider_tdl::register_tdl_package! {
package_name: "clp",
init: package_init,
tasks: [task::compression::s3_compress_task, task::compression::commit_task],
tasks: [
task::compression::s3_compress_task,
task::compression::commit_task,
task::query::clp_s_search_task,
],
}
Loading
Loading