mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-15 04:20:39 +00:00
perf: avoid boundary checks on accessing array items (#7570)
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -453,8 +453,8 @@ impl Accumulator for CountHashAccumulator {
|
||||
);
|
||||
};
|
||||
let hash_array = inner_array.as_any().downcast_ref::<UInt64Array>().unwrap();
|
||||
for i in 0..hash_array.len() {
|
||||
self.values.insert(hash_array.value(i));
|
||||
for &hash in hash_array.values().iter().take(hash_array.len()) {
|
||||
self.values.insert(hash);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -152,9 +152,9 @@ impl DfAccumulator for JsonEncodePathAccumulator {
|
||||
let lng_array = lng_array.as_primitive::<Float64Type>();
|
||||
|
||||
let mut coords = Vec::with_capacity(len);
|
||||
for i in 0..len {
|
||||
let lng = lng_array.value(i);
|
||||
let lat = lat_array.value(i);
|
||||
let lng_values = lng_array.values();
|
||||
let lat_values = lat_array.values();
|
||||
for (&lng, &lat) in lng_values.iter().zip(lat_values.iter()).take(len) {
|
||||
coords.push(vec![lng, lat]);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,9 +208,9 @@ fn decode_dictionary(
|
||||
|
||||
let mut rows = Vec::with_capacity(number_rows);
|
||||
let keys = dict.keys();
|
||||
for i in 0..number_rows {
|
||||
let dict_index = keys.value(i) as usize;
|
||||
rows.push(decoded_values[dict_index].clone());
|
||||
let dict_indices = keys.values();
|
||||
for &dict_index in dict_indices[..number_rows].iter() {
|
||||
rows.push(decoded_values[dict_index as usize].clone());
|
||||
}
|
||||
|
||||
Ok(rows)
|
||||
|
||||
Reference in New Issue
Block a user