Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
liukun4515 committed Sep 1, 2022
1 parent eacb730 commit 137e2c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions arrow-flight/src/lib.rs
Expand Up @@ -452,16 +452,16 @@ mod tests {
Field::new("c5", DataType::Timestamp(TimeUnit::Millisecond, None), true),
Field::new("c6", DataType::Time32(TimeUnit::Second), false),
]);
// V5
// V5 with write_legacy_ipc_format = false
// this will write the continuation marker
let option = IpcWriteOptions::default();
let schema_ipc = SchemaAsIpc::new(&schema, &option);
let result: SchemaResult = schema_ipc.try_into().unwrap();
//
let des_schema: Schema = (&result).try_into().unwrap();
assert_eq!(schema, des_schema);

// V4 with write_legacy_ipc_format = true
// This will write the continuation marker
// this will not write the continuation marker
let option = IpcWriteOptions::try_new(8, true, MetadataVersion::V4).unwrap();
let schema_ipc = SchemaAsIpc::new(&schema, &option);
let result: SchemaResult = schema_ipc.try_into().unwrap();
Expand Down
13 changes: 9 additions & 4 deletions arrow/src/ipc/convert.rs
Expand Up @@ -156,7 +156,7 @@ pub fn try_schema_from_flatbuffer_bytes(bytes: &[u8]) -> Result<Schema> {

/// Try deserialize the IPC format bytes into a schema
pub fn try_schema_from_ipc_buffer(buffer: &[u8]) -> Result<Schema> {
// There are two type of protocal: https://issues.apache.org/jira/browse/ARROW-6313
// There are two protocal types: https://issues.apache.org/jira/browse/ARROW-6313
// The original protocal is:
// 4 bytes - the byte length of the payload
// a flatbuffer Message whose header is the Schema
Expand All @@ -169,9 +169,14 @@ pub fn try_schema_from_ipc_buffer(buffer: &[u8]) -> Result<Schema> {
// check continuation maker
let continuation_maker = &buffer[0..4];
let begin_offset: usize = if continuation_maker.eq(&CONTINUATION_MARKER) {
// 4 bytes: CONTINUATION_MARKER
// 4 bytes: length
// buffer
4
} else {
// backward compatibility for buffer without the continuation maker
// 4 bytes: length
// buffer
0
};
let msg =
Expand All @@ -188,9 +193,9 @@ pub fn try_schema_from_ipc_buffer(buffer: &[u8]) -> Result<Schema> {
})?;
Ok(fb_to_schema(ipc_schema))
} else {
Err(ArrowError::ParseError(format!(
"The buffer length is less than 4, parser buffer to Schema"
)))
Err(ArrowError::ParseError(
"The buffer length is less than 4 and missing the continuation maker or length of buffer".to_string()
))
}
}

Expand Down

0 comments on commit 137e2c1

Please sign in to comment.