Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I know that for every integer in file.txt one can perform a binary search in "mapping.txt"</p> </blockquote> <p>As you said binary search is not useful here, besides the reason that you exposed you also have the challenge that mapping.txt is not in a friendly format to perform searching or indexing. </p> <p>If possible I would recommend to change the format of the mapping file to one more suitable to do direct seek calls. For instance, you could think in a file containing fixed length strings so you can calculate the position of each entry ( that would be constant in the number of fseek calls but keep in mind that the function itself wouldn't be constant)</p> <p>[EDIT]:</p> <p>Other thing you could do to minimize access to the mapping.txt is the following:</p> <ul> <li>Load the "order" file into an array in memory but in a way where the position is the actual line on mapping.txt and the element is the desired position on the new file, for instance the first element of that array would be 4 because 1 is on the 4th position (in your example).</li> <li>For convenience split the new array into N buckets files so if an element would go to the 200th position that would be the first position on the 4th bucket (for example).</li> <li>Now you can access the mapping file in a sequential fashion, you would for each line check on your array for the actual position in your new file and put then in the corresponding bucket.</li> <li>Once you passed the whole mapping file (you only have to checked it once), you only need to append the N buckets into your desired file.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload