Skip to content

Commit f83fd31

Browse files
committed
refactor: remove dependency on arrow_ord
1 parent c149027 commit f83fd31

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

arrow-cast/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ force_validate = []
4343
arrow-array = { workspace = true }
4444
arrow-buffer = { workspace = true }
4545
arrow-data = { workspace = true }
46-
arrow-ord = { workspace = true }
4746
arrow-schema = { workspace = true }
4847
arrow-select = { workspace = true }
4948
chrono = { workspace = true }

arrow-cast/src/cast/run_array.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use std::vec;
19+
1820
use crate::cast::*;
19-
use arrow_ord::partition::partition;
21+
use arrow_array::Array;
2022

2123
/// Attempts to cast a `RunArray` with index type K into
2224
/// `to_type` for supported types.
@@ -134,16 +136,19 @@ pub(crate) fn cast_to_run_end_encoded<K: RunEndIndexType>(
134136
));
135137
}
136138

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
139140
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+
}
146150
}
151+
run_ends.push(cast_array.len());
147152

148153
// Build the run_ends array
149154
for run_end in run_ends {

0 commit comments

Comments
 (0)