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 168)
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 graph: None,
167 },
168 ExecutionLimit::unlimited(),
169 &mut |batch| {
170 for binding in batch {
171 let Value::Int(key) = binding.values["key"] else {
172 panic!("missing key")
173 };
174 let Value::Int(ordinal) = binding.values["ordinal"] else {
175 panic!("missing ordinal")
176 };
177 assert!(
178 previous.is_none_or(|previous| previous < (key, ordinal)),
179 "stable ordering changed"
180 );
181 previous = Some((key, ordinal));
182 let Value::List(payload) = &binding.values["payload"] else {
183 panic!("missing payload")
184 };
185 let Value::Map(payload) = &payload[0] else {
186 panic!("missing payload map")
187 };
188 let Value::String(body) = &payload["body"] else {
189 panic!("missing body")
190 };
191 assert_eq!(body.len(), width);
192 measurement.checksum = measurement.checksum.wrapping_add(ordinal as u64);
193 measurement.rows += 1;
194 }
195 Ok(BatchControl::Continue)
196 },
197 )?;
198 assert_eq!(measurement.rows, rows);
199 assert_eq!(measurement.checksum, (rows as u64) * (rows as u64 - 1) / 2);
200 assert_eq!(ledger.snapshot().used_bytes, 0);
201 assert_eq!(memory.spill_pool_snapshot()?.active_bytes, 0);
202 measurement.ledger_peak = ledger.snapshot().peak_bytes;
203 for report in observer.into_reports().blocking_memory {
204 measurement.spill_bytes += report.spilled_bytes;
205 measurement.runs += report.spill_run_count;
206 }
207 if directory.exists() {
208 std::fs::remove_dir_all(directory).unwrap();
209 }
210 Ok(measurement)
211}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 Forget for ExecutionLimit
impl Freeze for ExecutionLimit
impl Move 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