pub struct ExecutionLimit {
pub output_rows: Option<usize>,
}Fields§
§output_rows: Option<usize>Implementations§
Source§impl ExecutionLimit
impl ExecutionLimit
Sourcepub const fn unlimited() -> Self
pub const fn unlimited() -> Self
Examples found in repository?
examples/spill_resource_probe.rs (line 167)
115fn query(
116 index: usize,
117 rows: usize,
118 width: usize,
119 blocking: usize,
120 barrier: &Barrier,
121 governor: Option<&RuntimeGovernor>,
122) -> Result<Measurement> {
123 let directory =
124 std::env::temp_dir().join(format!("hawdb-spill-probe-{}-{index}", std::process::id()));
125 let memory = ExecutionMemoryConfig {
126 query_memory_bytes: NonZeroUsize::new(16 * 1024 * 1024).unwrap(),
127 blocking_operator_bytes: NonZeroUsize::new(blocking).unwrap(),
128 batch_payload_bytes: NonZeroUsize::new(64 * 1024).unwrap(),
129 max_spill_runs: NonZeroUsize::new(4096).unwrap(),
130 max_total_spill_runs: NonZeroUsize::new(16384).unwrap(),
131 max_spill_bytes: NonZeroU64::new(1024 * 1024 * 1024).unwrap(),
132 min_spill_free_bytes: NonZeroU64::MIN,
133 spill_directory: directory.clone(),
134 ..ExecutionMemoryConfig::default()
135 };
136 let permit = governor.map(|governor| {
137 governor
138 .try_admit(RuntimeWorkRequest::foreground_query(16 * 1024 * 1024, 0))
139 .unwrap()
140 });
141 let task = permit
142 .as_ref()
143 .map(|permit| permit.bind_task_context(RuntimeTaskContext::default()));
144 let ledger = QueryMemoryLedger::for_query(&memory, task.as_ref())?;
145 let observer = QueryExecutionObserver::default();
146 let catalog = Catalog::default();
147 let items = [SortItem {
148 key: SortKey::Column("key".into()),
149 direction: SortDirection::Asc,
150 }];
151 let mut source = Rows { count: rows, width };
152 let mut measurement = Measurement::default();
153 let mut previous = None;
154 barrier.wait();
155 barrier.wait();
156 stream_sort_batches(
157 &PhysicalPlan::EmptyExec,
158 &items,
159 &mut source,
160 BatchExecutionContext {
161 catalog: &catalog,
162 memory: &memory,
163 memory_ledger: &ledger,
164 task_context: task.as_ref(),
165 observer: &observer,
166 },
167 ExecutionLimit::unlimited(),
168 &mut |batch| {
169 for binding in batch {
170 let Value::Int(key) = binding.values["key"] else {
171 panic!("missing key")
172 };
173 let Value::Int(ordinal) = binding.values["ordinal"] else {
174 panic!("missing ordinal")
175 };
176 assert!(
177 previous.is_none_or(|previous| previous < (key, ordinal)),
178 "stable ordering changed"
179 );
180 previous = Some((key, ordinal));
181 let Value::List(payload) = &binding.values["payload"] else {
182 panic!("missing payload")
183 };
184 let Value::Map(payload) = &payload[0] else {
185 panic!("missing payload map")
186 };
187 let Value::String(body) = &payload["body"] else {
188 panic!("missing body")
189 };
190 assert_eq!(body.len(), width);
191 measurement.checksum = measurement.checksum.wrapping_add(ordinal as u64);
192 measurement.rows += 1;
193 }
194 Ok(BatchControl::Continue)
195 },
196 )?;
197 assert_eq!(measurement.rows, rows);
198 assert_eq!(measurement.checksum, (rows as u64) * (rows as u64 - 1) / 2);
199 assert_eq!(ledger.snapshot().used_bytes, 0);
200 assert_eq!(memory.spill_pool_snapshot()?.active_bytes, 0);
201 measurement.ledger_peak = ledger.snapshot().peak_bytes;
202 for report in observer.into_reports().blocking_memory {
203 measurement.spill_bytes += report.spilled_bytes;
204 measurement.runs += report.spill_run_count;
205 }
206 if directory.exists() {
207 std::fs::remove_dir_all(directory).unwrap();
208 }
209 Ok(measurement)
210}pub fn from_user_max_rows(max_rows: Option<usize>) -> Result<Self>
pub fn child_for_limit(self, offset: usize, limit: Option<usize>) -> Self
pub fn is_reached(self, len: usize) -> bool
Trait Implementations§
Source§impl Clone for ExecutionLimit
impl Clone for ExecutionLimit
impl Copy for ExecutionLimit
Source§impl Debug for ExecutionLimit
impl Debug for ExecutionLimit
impl Eq for ExecutionLimit
Source§impl PartialEq for ExecutionLimit
impl PartialEq for ExecutionLimit
impl StructuralPartialEq for ExecutionLimit
Auto Trait Implementations§
impl Freeze for ExecutionLimit
impl RefUnwindSafe for ExecutionLimit
impl Send for ExecutionLimit
impl Sync for ExecutionLimit
impl Unpin for ExecutionLimit
impl UnsafeUnpin for ExecutionLimit
impl UnwindSafe for ExecutionLimit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more