Skip to main content

feldera_types/transport/
nexmark.rs

1use enum_map::Enum;
2use serde::{Deserialize, Serialize};
3use utoipa::ToSchema;
4
5/// Configuration for generating Nexmark input data.
6///
7/// This connector must be used exactly three times in a pipeline if it is used
8/// at all, once for each [`NexmarkTable`].
9#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
10pub struct NexmarkInputConfig {
11    /// Which table is this?
12    ///
13    /// Each table must appear in one connector.
14    pub table: NexmarkTable,
15
16    /// Overall behavior of the three linked input connectors.
17    ///
18    /// This may be specified only on one of the connectors and applies to all
19    /// them as a whole.
20    #[serde(default)]
21    pub options: Option<NexmarkInputOptions>,
22}
23
24/// Table in Nexmark.
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema, Enum)]
26#[serde(rename_all = "snake_case")]
27pub enum NexmarkTable {
28    /// 92% of the events.
29    Bid,
30
31    /// 6% of the events.
32    Auction,
33
34    /// 2% of the events.
35    Person,
36}
37
38/// Configuration for generating Nexmark input data.
39#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
40#[serde(default)]
41pub struct NexmarkInputOptions {
42    /// Number of events to generate.
43    pub events: u64,
44
45    /// Number of event generator threads.
46    ///
47    /// It's reasonable to choose the same number of generator threads as worker
48    /// threads.
49    pub threads: usize,
50
51    /// Number of events to generate and submit together, per thread.
52    ///
53    /// Each thread generates this many records, which are then combined with
54    /// the records generated by the other threads, to form combined input
55    /// batches of size `threads × batch_size_per_thread`.
56    pub batch_size_per_thread: u64,
57
58    /// Maximum number of events to submit in a single step, per thread.
59    ///
60    /// This should really be per worker thread, not per generator thread, but
61    /// the connector does not know how many worker threads there are.
62    ///
63    /// This stands in for `max_batch_size` from the connector configuration
64    /// because it must be a constant across all three of the nexmark tables.
65    pub max_step_size_per_thread: u64,
66}
67
68impl Default for NexmarkInputOptions {
69    fn default() -> Self {
70        Self {
71            events: 100_000_000,
72            threads: 4,
73            batch_size_per_thread: 1_000,
74            max_step_size_per_thread: 10_000,
75        }
76    }
77}