I have a very large binary and I need to create separate files based on the identifier inside the input file. There are 146 output files, and I use cstdlibboth fopenand fwrite. FOPEN_MAXis 20, so I cannot open all 146 output files at the same time. I also want to minimize the number of openings and closures of the output file.
cstdlib
fopen
fwrite
FOPEN_MAX
How can I efficiently write output files?
I also have to use the library cstdlibdue to legacy code.
The executable must also be compatible with UNIX and Windows.
A few possible approaches you can take are:
keep a cache of open output file descriptors that are smaller than FOPEN_MAX - if recording should occur in already open files, then just write. Otherwise, close one of the pens in the cache and open the output file. If your data is usually grouped in terms of data for a specific set of files, grouped in the input file, this should work well with the LRU policy for the file descriptor cache.
, , : 146 ( ) , open/flush/, . , /.
, , .
, , file1, file2 ..
max FOPEN_MAX - , , .
.
- N , N FOPEN_MAX. N . , .
, , . , . , thomask, . , , , .
, . .
, , , , . / , . , , / , .
2 .
1) 19 , 19 .. , 8 ( ).
2) 19 ( 13 ) .
, ID- , 163 . , , .
, .
- , , . , , . , .
std::map std::vector FILE. map . , vector, . . .
std::map
std::vector
FILE
map
vector
. , 10, 11- .
- . , ( ), ( fwrite), . , , . , . - , ( , ). , .
, OP, 146 , / .
, . - , . - , . , 8 , 19-20 .
( ).
- . , ? ? ? "" ? ...
- . , , ? / .
, * nix, , . , , , . FOPEN_MAX .
, . , , .
:
fseek()
, . , . , .
, . (). , :
fwrite()
. , 200 , ?
Source: https://habr.com/ru/post/1750323/More articles:MySQL Query that can pull the data I'm looking for? - sqlIndependent Row Level Security Solution - javaCan MSM (Merge Module) files be used in Inno-Setup? - soapHow to change the JAR icon on Mac? - javaJTable weird getAccessibleChild () method behavior leading to null pointer in client code - javaPreferred Menus for C # Application - c #Make system for ActionScript? - compiler-constructionproblem with ruby ββscript / delayed_job start. delayed_job and daemon on windows - ruby ββ| fooobar.comTSQL Check Database Instance Online - sql-serverASP Stored Procedure for GridView - asp.netAll Articles