Try to implement mongodb internal data structure including index and extents. First of all,
I implement a BTreeMap instead of applying JDK TreeMap. The JDK TreeMap is implemented using
red-black tree, and it will have a large height if we have many, many nodes. Next, I will use
google's in-memory file system to store data. Each document
is saved within an extent which is a logical container of a file. An index point to the position
of a document which resides in an extent.
B-Tree
Entry and Node are two important classes inside the map. Entry holds key/value pair, and
we compare each key to put entry objects into Node in the right order. If Node is full, it's
splitted into two children nodes which are stored in Node.children array.
CopyEntryIterator
The returned iterator provides a snapshot of the entries of this map when it's created. That is,
copy entries of every node and return. If the map structure is changed while iterating, it'll throw
ConcurrentModificationException.