Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

io.MappedBuffer miss : unMap() and ...

Moderators: kris

Posted: 06/05/08 08:56:00 Modified: 06/05/08 10:14:08

subject : database implementation using memory mapped file. The problem is that the relational algebra database uses memory mapped files to access the database. The database file can be bigger than the available address space so the file is mapped in chunks and the least recently used chunks are unmapped. (LRU Cache) ... it seems that io.MappedBuffer? has no unMap! However : close() seems to do the same job. In case that I am right I'd like to suggest to alias close unMap.

Further : I think you tango folks should have a look at the phobos 2 std.mmfile source, which is IMO more flexible. ie: void[] opSlice(); Returns entire file contents as an array.

void[] opSlice(ulong i1, ulong i2); Returns slice of file contents as an array. Bjoern (a Tango consumer)

Author Message

Posted: 06/06/08 01:16:40

Yes, an unMap() would likely be useful. MappedBuffer? extends Buffer ... there's lots of functionality in there that you may not be aware of? The method slice() is one of those.

Posted: 06/06/08 11:08:36

Thanks Kris, I know about buffer slice() but Tango lacks of :

void[] opSlice(ulong i1, ulong i2)

please note the use of ulong too.

Next and again Tango.io.Buffer as well as io.MappedBuffer? have no support for absolute access.

Here phobos std.mmfile:

ubyte opIndex(ulong i); Returns byte at index i in file.

ubyte opIndexAssign(ubyte value, ulong i); Sets and returns byte at index i in file to value.

Java : The the java.nio package -> ByteBuffer? has methods to get/put primitive types and has "views" that allow you to treat binary data as an array of primitives.

Indeed, Tango should support this too. (and it will not break the existing code-base)

Bjoern

Posted: 06/07/08 02:08:56

agreed