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 9, 2024
1 parent e8427f7 commit 1bb78a5
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tools/analysis/trace-tools/src/lib/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use std::{
collections::{btree_map::Entry, BTreeMap},
error::Error,
fs::File,
io::Error as IoError,
io::{Error as IoError, Write as _},
rc::Rc,
sync::Arc,
path::PathBuf,
};

use arrow2::{
Expand Down Expand Up @@ -390,6 +391,7 @@ where
eprintln!("COUNT {count}");

let mut handles = Vec::new();
let mut events_path = Vec::new();

while let Some((id, read_state)) = state_map.pop_first() {
let read_state = read_state.into_inner().unwrap();
Expand All @@ -404,6 +406,11 @@ where
drop(read_state.sender);
handles.push(read_state.handle);
eprintln!("FILE WRITTEN SUCCESSFULLY {}", read_state.name);
events_path.push(serde_json::json!({
"event": read_state.name,
"path": read_state.path,
"format": "parquet",
}))
}
}
Err(err) => {
Expand All @@ -417,15 +424,18 @@ where
}
}

let json_value = serde_json::json!({
"test": "foo",
});

println!("{}", json_value.to_string());

for handle in handles {
handle.join().expect("Writer thread panicked")?;
}

{
let json_value = serde_json::json!({
"events": events_path,
});

let mut meta = File::create("meta.json")?;
meta.write_all(json_value.to_string().as_bytes())?
}
res
})
.unwrap()?;
Expand Down Expand Up @@ -1010,6 +1020,7 @@ where
#[derive(Debug)]
struct TableState<'scope> {
name: String,
path: PathBuf,
fields_schema: Schema,
fixed_cols: FixedCols,
field_cols: Vec<FieldArray>,
Expand All @@ -1035,7 +1046,8 @@ impl<'scope> TableState<'scope> {
) -> Result<Self, MainError> {
let (fixed_cols, field_cols) = Self::make_cols(&fields_schema)?;

let file = File::create(format!("{}.parquet", name))?;
let path = PathBuf::from(format!("{}.parquet", name));
let file = File::create(&path)?;
let writer = FileWriter::try_new(file, full_schema.clone(), options)?;
let (sender, receiver) = bounded(128);

Expand All @@ -1062,6 +1074,7 @@ impl<'scope> TableState<'scope> {
sender,
name: name.to_string(),
handle,
path,
})
}

Expand Down

0 comments on commit 1bb78a5

Please sign in to comment.