Skip to content

Commit

Permalink
this?
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopi committed Jun 17, 2024
1 parent ecfb089 commit 5a21931
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/duckdb-wasm-shell/crate/src/arrow_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'buf> Reader<'buf> {
if available < n {
Err(arrow::error::ArrowError::IoError(
"insufficient bytes available".to_string(),
std::io::Error
std::io::Error(ErrorKind::Other)
))
} else {
let result = &self.buffer[self.position..(self.position + n)];
Expand Down Expand Up @@ -96,11 +96,11 @@ impl ArrowStreamReader {

let meta_buffer = reader.next(meta_len as usize)?;
let message = arrow::ipc::root_as_message(meta_buffer).map_err(|err| {
ArrowError::IoError(format!("Unable to get root as message: {:?}", err),std::io::Error)
ArrowError::IoError(format!("Unable to get root as message: {:?}", err),std::io::Error(ErrorKind::Other))
})?;
// message header is a Schema, so read it
let ipc_schema: arrow::ipc::Schema = message.header_as_schema().ok_or_else(|| {
ArrowError::IoError("Unable to read IPC message as schema".to_string(),std::io::Error)
ArrowError::IoError("Unable to read IPC message as schema".to_string(),std::io::Error(ErrorKind::Other))
})?;
let schema = arrow::ipc::convert::fb_to_schema(ipc_schema);

Expand Down Expand Up @@ -158,16 +158,16 @@ impl ArrowStreamReader {

let meta_buffer = reader.next(meta_len as usize)?;
let message = arrow::ipc::root_as_message(meta_buffer).map_err(|err| {
ArrowError::IoError(format!("Unable to get root as message: {:?}", err),std::io::Error)
ArrowError::IoError(format!("Unable to get root as message: {:?}", err),std::io::Error(ErrorKind::Other))
})?;

match message.header_type() {
arrow::ipc::MessageHeader::Schema => Err(ArrowError::IoError(
"Not expecting a schema when messages are read".to_string(),
std::io::Error)),
std::io::Error(ErrorKind::Other))),
arrow::ipc::MessageHeader::RecordBatch => {
let batch = message.header_as_record_batch().ok_or_else(|| {
ArrowError::IoError("Unable to read IPC message as record batch".to_string(),std::io::Error)
ArrowError::IoError("Unable to read IPC message as record batch".to_string(),std::io::Error(ErrorKind::Other))
})?;
let buf = reader.next(message.bodyLength() as usize)?;
len arrow_ipc::gen::Schema::MetadataVersion metadata;
Expand All @@ -184,7 +184,7 @@ impl ArrowStreamReader {
arrow::ipc::MessageHeader::DictionaryBatch => {
let batch = message.header_as_dictionary_batch().ok_or_else(|| {
ArrowError::IoError(
"Unable to read IPC message as dictionary batch".to_string(),std::io::Error
"Unable to read IPC message as dictionary batch".to_string(),std::io::Error(ErrorKind::Other)
)
})?;
let buf = reader.next(message.bodyLength() as usize)?;
Expand All @@ -202,7 +202,7 @@ impl ArrowStreamReader {
t => Err(ArrowError::IoError(format!(
"Reading types other than record batches not yet supported, unable to read {:?} ",
t
)), std::io::Error),
)), std::io::Error(ErrorKind::Other)),
}
}
}

0 comments on commit 5a21931

Please sign in to comment.