chore: change encode raw values signature (#6869)

* chore/change-encode-raw-values-sig:
 ### Update Sparse Encoding to Use Byte Slices

 - **`bench_sparse_encoding.rs`**: Modified the `encode_raw_tag_value` function to use byte slices instead of `Bytes` for tag values.
 - **`sparse.rs`**: Updated the `encode_raw_tag_value` method in `SparsePrimaryKeyCodec` to accept byte slices (`&[u8]`) instead of `Bytes`. Adjusted related test cases to reflect this change.

Signed-off-by: Lei, HUANG <mrsatangel@gmail.com>

* chore/change-encode-raw-values-sig:
 ### Add `Clear` Trait Implementation for Byte Slices

 - Implemented the `Clear` trait for byte slices (`&[u8]`) in `repeated_field.rs` to enhance trait coverage and provide a default clear operation for byte slice types.

Signed-off-by: Lei, HUANG <mrsatangel@gmail.com>

---------

Signed-off-by: Lei, HUANG <mrsatangel@gmail.com>
This commit is contained in:
Lei, HUANG
2025-09-01 17:53:08 +08:00
committed by GitHub
parent ab96703d8f
commit dd3432e6ca
3 changed files with 9 additions and 5 deletions

View File

@@ -72,7 +72,7 @@ fn encode_sparse(c: &mut Criterion) {
.unwrap();
codec
.encode_raw_tag_value(
tags.iter().map(|(c, b)| (*c, b)),
tags.iter().map(|(c, b)| (*c, &b[..])),
&mut buffer_by_raw_encoding,
)
.unwrap();

View File

@@ -15,7 +15,7 @@
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use bytes::{BufMut, Bytes};
use bytes::BufMut;
use common_recordbatch::filter::SimpleFilterEvaluator;
use datatypes::prelude::ConcreteDataType;
use datatypes::value::{Value, ValueRef};
@@ -179,7 +179,7 @@ impl SparsePrimaryKeyCodec {
pub fn encode_raw_tag_value<'a, I>(&self, row: I, buffer: &mut Vec<u8>) -> Result<()>
where
I: Iterator<Item = (ColumnId, &'a Bytes)>,
I: Iterator<Item = (ColumnId, &'a [u8])>,
{
for (tag_column_id, tag_value) in row {
let value_len = tag_value.len();
@@ -568,11 +568,11 @@ mod tests {
.unwrap();
let tags: Vec<_> = tags
.into_iter()
.map(|(col_id, tag_value)| (col_id, Bytes::from_static(tag_value.as_bytes())))
.map(|(col_id, tag_value)| (col_id, tag_value.as_bytes()))
.collect();
codec
.encode_raw_tag_value(
tags.iter().map(|(c, b)| (*c, b)),
tags.iter().map(|(c, b)| (*c, *b)),
&mut buffer_by_raw_encoding,
)
.unwrap();

View File

@@ -38,6 +38,10 @@ pub trait Clear {
fn clear(&mut self);
}
impl Clear for &[u8] {
fn clear(&mut self) {}
}
impl<T> Clear for Option<T> {
fn clear(&mut self) {
self.take();