• Create Account

### #ActualAntheus

Posted 05 May 2012 - 07:26 AM

But my write time is about 65ms and read time 135ms wich is quite long since a scene is composed of 900 sectors..

1 sector is 64kB. 900 will be ~56MB. That takes time either way.

To write a sector:
byte sector[] = new byte[65536];
FileOutputStream fs = new FileOutputStream("sector413.dat");
fs.close();
No magic here.

How long this takes depends on disk and file system, especially if there are many files. 64/130 ms sounds a lot, but not impossible.

64k in a single file is very convenient since it doesn't cause overhead, storing the coordinates causes just about maximum overhead possible (99.7%
overhead for the coordinates due to typical 4k disk page size).

Serializable could be used for the above, but doesn't bring much to the table beyond.

One way is to keep index separate as a file which contains only:
class Index {
float x, y;
int filename;
}

List<Index> indices;
File is represented as a number, so '485.dat', '0.dat', ....

### #1Antheus

Posted 05 May 2012 - 07:25 AM

But my write time is about 65ms and read time 135ms wich is quite long since a scene is composed of 900 sectors..

1 sector is 64kB. 900 will be ~56MB. That takes time either way.

To write a sector:
byte sector[] = new byte[65536];
FileOutputStream fs = new FileOutputStream("sector413.dat");
fs.close();
No magic here.

How long this takes depends on disk and file system, especially if there are many files. 64/130 ms sounds a lot, but not impossible.

64k in a single file is very convenient since it doesn't cause overhead, storing the coordinates causes just about maximum overhead possible (99.7% overhead for the coordinates due to typical 4k disk page size).

One way is to keep index separate as a file which contains only:
class Index {
float x, y;
int filename;
}

List<Index> indices;
File is represented as a number, so '485.dat', '0.dat', ....

PARTNERS