Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions crates/fluss/src/row/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl InternalRow for ColumnarRow {
.value(self.row_id)
}

fn get_char(&self, pos: usize, length: usize) -> String {
fn get_char(&self, pos: usize, _length: usize) -> &str {
let array = self
.record_batch
.column(pos)
Expand All @@ -135,16 +135,8 @@ impl InternalRow for ColumnarRow {
.expect("Expected fixed-size binary array for char type");

let bytes = array.value(self.row_id);
if bytes.len() != length {
panic!(
"Length mismatch for fixed-size char: expected {}, got {}",
length,
bytes.len()
);
}

String::from_utf8(bytes.to_vec())
.unwrap_or_else(|_| String::from_utf8_lossy(bytes).into_owned())
// don't check length, following java client
std::str::from_utf8(bytes).expect("Invalid UTF-8 in char field")
Comment thread
luoyuxia marked this conversation as resolved.
}

fn get_string(&self, pos: usize) -> &str {
Expand Down
15 changes: 4 additions & 11 deletions crates/fluss/src/row/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait InternalRow {
fn get_double(&self, pos: usize) -> f64;

/// Returns the string value at the given position with fixed length
fn get_char(&self, pos: usize, length: usize) -> String;
fn get_char(&self, pos: usize, length: usize) -> &str;
Comment thread
luoyuxia marked this conversation as resolved.

/// Returns the string value at the given position
fn get_string(&self, pos: usize) -> &str;
Expand Down Expand Up @@ -116,16 +116,9 @@ impl<'a> InternalRow for GenericRow<'a> {
self.values.get(pos).unwrap().try_into().unwrap()
}

fn get_char(&self, pos: usize, length: usize) -> String {
let value = self.get_string(pos);
if value.len() != length {
panic!(
"Length mismatch for fixed-size char: expected {}, got {}",
length,
value.len()
);
}
value.to_string()
fn get_char(&self, pos: usize, _length: usize) -> &str {
// don't check length, following java client
self.get_string(pos)
}

fn get_string(&self, pos: usize) -> &str {
Expand Down
Loading