Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSimonForsman

Posted 05 May 2012 - 07:22 AM

You could try storing the sectors in a binary format instead of a text format, use one file for all sectors and have the first 16x16x256 bytes be the first sector etc.

Edit oops: java, no istream. , you can use FileInputStreams skip method ( filestream.skip(sectornumber*16*16*256); )
if your sectors are laid out in a 2D grid your sector number can be y*width+x;

This way you get one file (opening files are fairly slow) that you can keep open all the time. (each sector will only require you to do a skip and then a read of 64KiB data (Which really is nothing)).

If that is still too slow you can keep nearby sectors in RAM and load new ones in a background thread before they are needed.

#2SimonForsman

Posted 05 May 2012 - 07:18 AM

You could try storing the sectors in a binary format instead of a text format, use one file for all sectors and have the first 16x16x256 bytes be the first sector etc.

Edit oops: java, no istream.
if your sectors are laid out in a 2D grid your sector number can be y*width+x;

This way you get one file (opening files are fairly slow) that you can keep open all the time. (each sector will only require you to do a seekg and then a read of 64KiB data (Which really is nothing)).

If that is still too slow you can keep nearby sectors in RAM and load new ones in a background thread before they are needed.

#1SimonForsman

Posted 05 May 2012 - 07:17 AM

You could try storing the sectors in a binary format instead of a text format, use one file for all sectors and have the first 16x16x256 bytes be the first sector etc.

You can then choose a sector using istream::seekg(sectornumber*16*16*256);
if your sectors are laid out in a 2D grid your sector number can be y*width+x;

This way you get one file (opening files are fairly slow) that you can keep open all the time. (each sector will only require you to do a seekg and then a read of 64KiB data (Which really is nothing)).

If that is still too slow you can keep nearby sectors in RAM and load new ones in a background thread before they are needed.

PARTNERS