Title: How can I do block-oriented disk I/O with Java? Or similar for a B+ tree
Tags: java;io;backend;b-tree
Question: I would like to implement an B+ tree in Java and try to optimize it for disk based I/O. Is there an API for accessing individual disk blocks from Java? or is there an API that can do similar block-oriented access that fits my purpose? 

I would like to create something like Tokyo Cabinet in 100% Java. Is there anyone that knows what Java only databases like JavaDB is using in the back-end for this?

I know that there are probably other languages than Java that can do this better, but I do this in a learning purpose only.


Here is the accepted answer: Off the top of my head I think that MappedByteBuffer in NIO could be your best bet. It's basically as-direct-as-possible mapping between HDD and Java.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:04/03/10', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<java><io><backend><b-tree>', 'Title': 'How can I do block-oriented disk I/O with Java? Or similar for a B+ tree', 'ViewCount': 625, 'id': 2570711, 'user_AboutMe': '<p>Passionated Software Developer interested in Distributed Systems</p>\n', 'user_AccountId': 74184.0, 'user_DisplayName': 'Jonas', 'user_Reputation': 113096.0, 'user_Views': 12111.0, 'user_id': 213269.0}}