Copilot commented on code in PR #138:
URL: https://github.com/apache/fluss-rust/pull/138#discussion_r2679231696
##########
crates/fluss/src/row/compacted/compacted_row.rs:
##########
@@ -64,85 +50,76 @@ impl CompactedRow {
offset: 0,
size_in_bytes: size,
decoded: false,
Review Comment:
The decoded field is set to false but is no longer used since OnceLock
handles the initialization state internally. Remove this line since the field
should be removed.
##########
crates/fluss/src/row/compacted/compacted_row.rs:
##########
@@ -24,38 +24,24 @@ use crate::row::{GenericRow, InternalRow};
// Reference implementation:
//
https://github.com/apache/fluss/blob/main/fluss-common/src/main/java/org/apache/fluss/row/compacted/CompactedRow.java
#[allow(dead_code)]
-pub struct CompactedRow {
+pub struct CompactedRow<'a> {
arity: usize,
- segment: Bytes,
+ segment: &'a [u8],
offset: usize,
size_in_bytes: usize,
decoded: bool,
Review Comment:
The decoded field is no longer used since OnceLock handles the
initialization state internally. This field should be removed from the struct.
##########
crates/fluss/src/row/compacted/compacted_row_reader.rs:
##########
@@ -71,38 +66,30 @@ impl CompactedRowDeserializer {
// Reference implementation:
//
https://github.com/apache/fluss/blob/main/fluss-common/src/main/java/org/apache/fluss/row/compacted/CompactedRowReader.java
#[allow(dead_code)]
-pub struct CompactedRowReader {
- segment: Bytes,
+pub struct CompactedRowReader<'a> {
+ segment: &'a [u8],
offset: usize,
- position: usize,
+ position: Cell<usize>,
limit: usize,
header_size_in_bytes: usize,
}
#[allow(dead_code)]
-impl CompactedRowReader {
- pub fn new(field_count: usize) -> Self {
- let header =
CompactedRow::calculate_bit_set_width_in_bytes(field_count);
- Self {
- header_size_in_bytes: header,
- segment: Bytes::new(),
- offset: 0,
- position: 0,
- limit: 0,
- }
- }
-
- pub fn point_to(&mut self, data: Bytes, offset: usize, length: usize) {
+impl<'a> CompactedRowReader<'a> {
+ pub fn new(field_count: usize, data: &'a [u8], offset: usize, length:
usize) -> Self {
+ let header_size_in_bytes =
CompactedRow::calculate_bit_set_width_in_bytes(field_count);
let limit = offset + length;
- let position = offset + self.header_size_in_bytes;
-
+ let position = offset + header_size_in_bytes;
debug_assert!(limit <= data.len());
debug_assert!(position <= limit);
- self.segment = data;
- self.offset = offset;
- self.position = position;
- self.limit = limit;
+ CompactedRowReader {
+ segment: data,
+ offset,
+ position: Cell::new(0),
Review Comment:
The position field is incorrectly initialized to 0 instead of the calculated
position value. This will cause the reader to start reading from the beginning
of the data instead of after the header. Change `Cell::new(0)` to
`Cell::new(position)`.
```suggestion
position: Cell::new(position),
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]