Skip to content

Commit

Permalink
update for peppi changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hohav committed May 31, 2021
1 parent 79dc710 commit 212f847
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ arrow = "4.1"
clap = "2.33"
parquet = { version = "4.1", default-features = false, features = ["arrow", "base64"] }
parquet-format = "4.0"
peppi = "1.0.0-alpha"
peppi = "1.0.0-alpha.1"
pretty_env_logger = "0.4"
serde_json = "1.0"

Expand Down
25 changes: 17 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::{error::Error, fs, io, path};

use ::arrow::record_batch::RecordBatch;
use ::arrow::{
array::StructArray,
record_batch::RecordBatch,
};
use clap::{App, Arg};
use parquet::{
arrow::arrow_writer::ArrowWriter,
Expand Down Expand Up @@ -46,20 +49,26 @@ fn write_peppi<P: AsRef<path::Path>>(game: &Game, dir: P, skip_frames: bool) ->
.set_compression(Compression::UNCOMPRESSED)
.build();

if let Some(items) = arrow::items(&game)? {
let items = RecordBatch::from(&items);
if let Some(items) = arrow::items(&game, None) {
let batch = RecordBatch::from(
items.as_any().downcast_ref::<StructArray>().unwrap());
let buf = fs::File::create(dir.join("items.parquet"))?;
let mut writer = ArrowWriter::try_new(
buf, items.schema(), Some(props.clone()))?;
writer.write(&items)?;
buf, batch.schema(), Some(props.clone()))?;
writer.write(&batch)?;
writer.close()?;
}

let frames = RecordBatch::from(&arrow::frames(&game)?);
let frames = arrow::frames(&game, Some(arrow::Opts {
avro_compatible: true,
skip_items: true,
}));
let batch = RecordBatch::from(
frames.as_any().downcast_ref::<StructArray>().unwrap());
let buf = fs::File::create(dir.join("frames.parquet"))?;
let mut writer = ArrowWriter::try_new(
buf, frames.schema(), Some(props))?;
writer.write(&frames)?;
buf, batch.schema(), Some(props))?;
writer.write(&batch)?;
writer.close()?;
}

Expand Down

0 comments on commit 212f847

Please sign in to comment.