|
15 | 15 | // specific language governing permissions and limitations |
16 | 16 | // under the License. |
17 | 17 |
|
| 18 | +use std::vec; |
| 19 | + |
18 | 20 | use crate::cast::*; |
19 | | -use arrow_ord::partition::partition; |
| 21 | +use arrow_array::Array; |
20 | 22 |
|
21 | 23 | /// Attempts to cast a `RunArray` with index type K into |
22 | 24 | /// `to_type` for supported types. |
@@ -134,16 +136,19 @@ pub(crate) fn cast_to_run_end_encoded<K: RunEndIndexType>( |
134 | 136 | )); |
135 | 137 | } |
136 | 138 |
|
137 | | - // Partition the array to identify runs of consecutive equal values |
138 | | - let partitions = partition(&[Arc::clone(cast_array)])?; |
| 139 | + // Identify run boundaries by comparing consecutive values |
139 | 140 | let mut run_ends = Vec::new(); |
140 | | - let mut values_indexes = Vec::new(); |
141 | | - let mut last_partition_end = 0; |
142 | | - for partition in partitions.ranges() { |
143 | | - values_indexes.push(last_partition_end); |
144 | | - run_ends.push(partition.end); |
145 | | - last_partition_end = partition.end; |
| 141 | + let mut values_indexes = vec![0usize]; // Always include the first index |
| 142 | + let mut current_data = cast_array.slice(0, 1).to_data(); |
| 143 | + for idx in 1..cast_array.len() { |
| 144 | + let next_data = cast_array.slice(idx, 1).to_data(); |
| 145 | + if current_data != next_data { |
| 146 | + run_ends.push(idx); |
| 147 | + values_indexes.push(idx); |
| 148 | + current_data = next_data; |
| 149 | + } |
146 | 150 | } |
| 151 | + run_ends.push(cast_array.len()); |
147 | 152 |
|
148 | 153 | // Build the run_ends array |
149 | 154 | for run_end in run_ends { |
|
0 commit comments