I have this data in Rust: 9941: Chain { score: 2592, reference: ChainHead { chr:…
- User
I have this data in Rust:
9941: Chain { score: 2592, reference: ChainHead { chr: "chr17", size: 83257441, strand: '+', start: 64783368, end: 64783434 }, query: ChainHead { chr: "chr9", size: 62002293, strand: '-', start: 43164030, end: 43164114 }, alignment: [AlignmentRecord { size: 44, dt: 0, dq: 18 }, AlignmentRecord { size: 22, dt: 0, dq: 0 }] }, 10130: Chain { score: 2503, reference: ChainHead { chr: "chr17", size: 83257441, strand: '+', start: 39029631, end: 39029704 }, query: ChainHead { chr: "chr9", size: 62002293, strand: '-', start: 51453581, end: 51453665 }, alignment: [AlignmentRecord { size: 64, dt: 0, dq: 11 }, AlignmentRecord { size: 9, dt: 0, dq: 0 }] }, 9996: Chain { score: 2566, reference: ChainHead { chr: "chr17", size: 83257441, strand: '+', start: 41167675, end: 41167834 }, query: ChainHead { chr: "chr9", size: 62002293, strand: '-', start: 39828598, end: 39828757 }, alignment: [AlignmentRecord { size: 159, dt: 0, dq: 0 }] }, 10051: Chain { score: 2540, reference: ChainHead { chr: "chr17", size: 83257441, strand: '+', start: 47018469, end: 47018559 }, query: ChainHead { chr: "chr9", size: 62002293, strand: '+', start: 11881500, end: 11881590 }, alignment: [AlignmentRecord { size: 90, dt: 0, dq: 0 }] }}
Is a FxHashMap of the type FxHashMap<u32, Chain>. I want to write all this to a file, like a json file. I've read about a phf_codegen crate but I do not understand how to use it. Help me.
- Assistant
- User
this is my code:
codelet file = File::create("output.json").expect("Failed to create file"); serde_json::to_writer_pretty(&file, &data).expect("Failed to write to file");is there any way to make this a lot faster? currently is taking so long to write
- Assistant
- User
if I use this choice: formats like binary serialization (e.g., using bincode)
do I still preserve the data structure? So if read the data again, I could read it as a HashMap?
- Assistant