Skip to main content

sqlload_python_host/crossing/
constants.rs

1use crate::crossing::models::DictCrossing;
2
3/// Dict rows gathered before they cross into Rust (and the most rows per batch parsed from bytes): as fast as 10,000 in the crossing benchmark, with a third of the memory.
4pub const DEFAULT_BATCH_ROWS: usize = 1_000;
5
6/// Batches queued between the generator, the parser and the consumer.
7pub const DEFAULT_MAX_QUEUED: usize = 4;
8
9/// How dicts cross by default: serialised by orjson and parsed in parallel without the GIL, which the crossing benchmark found faster than walking them and holding the GIL a third as long.
10pub const DEFAULT_DICT_CROSSING: DictCrossing = DictCrossing::Serialise;
11
12/// The most threads parsing one table's batches by default.
13pub const MAX_DEFAULT_PARSE_THREADS: usize = 4;
14
15/// Bytes of crossed data waiting to be parsed before the generator pauses.
16pub const DEFAULT_MAX_QUEUED_BYTES: usize = 256 * 1024 * 1024;
17
18/// The module of numpy's scalar and array types, which orjson writes by their own rules.
19pub(crate) const NUMPY_MODULE: &str = "numpy";
20
21/// numpy's array type, written as a list when its values are numbers or booleans.
22pub(crate) const NUMPY_ARRAY: &str = "ndarray";
23
24/// `date(1970, 1, 1).toordinal()`.
25pub(crate) const EPOCH_ORDINAL: i64 = 719_163;
26
27/// Microseconds in a day.
28pub(crate) const MICROS_PER_DAY: i64 = 86_400_000_000;
29
30/// Microseconds in a second.
31pub(crate) const MICROS_PER_SECOND: i64 = 1_000_000;
32
33/// The `sqlload_api._host` function orjson calls for values it cannot write itself.
34pub(crate) const CROSSING_DEFAULT: &str = "crossing_default";
35
36/// How long a page `transform`'s crossing is waited on at a time; it polls again until the function's output ends.
37pub(crate) const PAGE_POLL: std::time::Duration = std::time::Duration::from_secs(3600);