MCPcopy Create free account
hub / github.com/apache/datafusion / generate_range_values

Function generate_range_values

datafusion/functions-nested/src/range.rs:559–610  ·  view source on GitHub ↗
(
    start: i64,
    stop: i64,
    step: i64,
    include_upper: bool,
    values: &mut Vec<i64>,
)

Source from the content-addressed store, hash-verified

557/// Generate integer range values directly into the provided buffer.
558#[inline]
559fn generate_range_values(
560 start: i64,
561 stop: i64,
562 step: i64,
563 include_upper: bool,
564 values: &mut Vec<i64>,
565) -> Result<()> {
566 if !include_upper && start == stop {
567 return Ok(());
568 }
569
570 if step > 0 {
571 let limit = if include_upper {
572 stop
573 } else {
574 stop.saturating_sub(1)
575 };
576 if start > limit {
577 return Ok(());
578 }
579 let count = (start.abs_diff(limit) / step.unsigned_abs()).saturating_add(1);
580 reserve_range_capacity(values, count)?;
581 let mut current = start;
582 while current <= limit {
583 values.push(current);
584 match current.checked_add(step) {
585 Some(next) => current = next,
586 None => break,
587 }
588 }
589 } else if step < 0 {
590 let limit = if include_upper {
591 stop
592 } else {
593 stop.saturating_add(1)
594 };
595 if start < limit {
596 return Ok(());
597 }
598 let count = (start.abs_diff(limit) / step.unsigned_abs()).saturating_add(1);
599 reserve_range_capacity(values, count)?;
600 let mut current = start;
601 while current >= limit {
602 values.push(current);
603 match current.checked_add(step) {
604 Some(next) => current = next,
605 None => break,
606 }
607 }
608 }
609 Ok(())
610}
611
612fn parse_tz(tz: &Option<&str>) -> Result<Tz> {
613 let tz = tz.unwrap_or_else(|| "+00");

Callers 1

gen_range_innerMethod · 0.85

Calls 2

reserve_range_capacityFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…