What would be the fastest way to write a Vec < Vec< String > > to a file? You are free…
- User
What would be the fastest way to write a Vec < Vec< String > > to a file? You are free to use any algorithm, trick, unsafe code, parallelization, crate, etc
- Assistant
- User
the data looks like this:
[["chr1\tbed2gtf\tgene\t65419\t71585\t.\t+\t.\tgene_id "ENSG00000186092.7" ;\n", "chr1\tbed2gtf\ttranscript\t65419\t71585\t.\t+\t.\tgene_id "ENSG00000 186092.7"; transcript_id "ENST00000641515.2"; exon_number "-1"; exon_id "ENST00000641515.2.0";\n", "chr1\tbed2gtf\texon\t65419\t65433\t.\t+\t.\tg ene_id "ENSG00000186092.7"; transcript_id "ENST00000641515.2"; exon_numb er "0"; exon_id "ENST00000641515.2.1";\n", "chr1\tbed2gtf\tfive_prime_ut r\t65419\t65433\t.\t+\t.\tgene_id "ENSG00000186092.7"; transcript_id "ENS T00000641515.2"; exon_number "-1"; exon_id "ENST00000641515.2.0";\n", " chr1\tbed2gtf\texon\t65520\t65573\t.\t+\t.\tgene_id "ENSG00000186092.7"; t ranscript_id "ENST00000641515.2"; exon_number "1"; exon_id "ENST0000064 1515.2.2";\n", "chr1\tbed2gtf\tfive_prime_utr\t65520\t65564\t.\t+\t0\tgene_ id "ENSG00000186092.7"; transcript_id "ENST00000641515.2"; exon_number "-1"; exon_id "ENST00000641515.2.0";\n", "chr1\tbed2gtf\tCDS\t65565\t6557 3\t.\t+\t0\tgene_id "ENSG00000186092.7"; transcript_id "ENST00000641515.2 "; exon_number "1"; exon_id "ENST00000641515.2.2";\n", "chr1\tbed2gtf\t exon\t69037\t71585\t.\t+\t.\tgene_id "ENSG00000186092.7"; transcript_id " ENST00000641515.2"; exon_number "2"; exon_id "ENST00000641515.2.3";\n", "chr1\tbed2gtf\tCDS\t69037\t70005\t.\t+\t0\tgene_id "ENSG00000186092.7"; transcript_id "ENST00000641515.2"; exon_number "2"; exon_id "ENST000006 41515.2.3";\n", "chr1\tbed2gtf\tthree_prime_utr\t70009\t71585\t.\t+\t0\tgen e_id "ENSG00000186092.7"; transcript_id "ENST00000641515.2"; exon_number "-1"; exon_id "ENST00000641515.2.0";\n", "chr1\tbed2gtf\tstop_codon\t70 006\t70008\t.\t+\t0\tgene_id "ENSG00000186092.7"; transcript_id "ENST0000 0641515.2"; exon_number "2"; exon_id "ENST00000641515.2.3";\n"], ["chr1 \tbed2gtf\tgene\t89295\t120932\t.\t-\t.\tgene_id "ENSG00000238009.6";\n", "chr1\tbed2gtf\ttranscript\t89295\t120932\t.\t-\t.\tgene_id "ENSG0000023800 9.6"; transcript_id "ENST00000466430.5"; exon_number "-1"; exon_i
- Assistant
Given that your data is already in the form of strings and just needs to be written to a file, you do not need serialization. Instead, you will want to write these strings directly to a file with minimal processing.
Here's how you can do this efficiently:
- Use for efficient buffered IO. This minimizes the number of system calls, which can be a bottleneck.
- User
remember that this needs to be fastest and more efficient way and you are able to use any trick, algorithm, crate you want
- Assistant