Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
douglas-raillard-arm committed Jan 5, 2024
1 parent 59256dd commit 6778051
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions tools/analysis/trace-tools/src/lib/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ where
}
)?;

// If there was any error, some columns might have been appended to but others not, so we
// cannot finalize the files and we should just bail out.
events.collect::<Result<_, MainError>>()?;
// Even if there were some errors, we should have pushed some None values so that all
// columns are of the same length, so the file can be finalized.
let res = last_err(events);
eprintln!("COUNT {count}");

let mut handles = Vec::new();
Expand Down Expand Up @@ -421,7 +421,7 @@ where
for handle in handles {
handle.join().expect("Writer thread panicked")?;
}
Ok(())
res
})
.unwrap()?;
Ok(())
Expand Down Expand Up @@ -673,27 +673,15 @@ where
}
};

// We want to go through all the columns so that we have a chance to append None values in
// places we had an error, and when we are done we return the last error. This way, all
// columns should have the same length and we will still be able to dump to parquet.
fn last_err<E, I: Iterator<Item=Result<(), E>>>(iter: I) -> Result<(), E> {
let mut res = Ok(());
for x in iter {
match x {
Err(err) => {
res = Err(err);
}
_ => {}
}
}
res
}

macro_rules! generic_iter {
($table_state:expr, $visitor:expr) => {{
let table_state = $table_state;
let visitor = $visitor;

// We want to go through all the columns so that we have a chance to append None
// values in places we had an error, and when we are done we return the last error.
// This way, all columns should have the same length and we will still be able to
// dump to parquet.
let res = last_err(visitor
.fields()?
.into_iter()
Expand Down Expand Up @@ -1171,6 +1159,21 @@ impl EventWriteState {
}
}


fn last_err<E, I: Iterator<Item=Result<(), E>>>(iter: I) -> Result<(), E> {
let mut res = Ok(());
for x in iter {
match x {
Err(err) => {
res = Err(err);
}
_ => {}
}
}
res
}


// fn main2() -> Result<(), ArrowError> {
// // declare arrays
// let a = Int8Array::from(&[Some(1), None, Some(3)]);
Expand Down

0 comments on commit 6778051

Please sign in to comment.