BTree implements Closeable { public byte[] insert(byte[] value) throws IOException { btreeLock.writeLock().lock(); try { Node rootNode = readRootNode(); if (rootNode == null) { rootNode = createNewNode(); rootNodeID = rootNode.getID(); writeFileHeader(); height = 1; } InsertResult insertResult = insertInTree(value, 0, rootNode); if (insertResult.overflowValue != null) { Node newRootNode = createNewNode(); newRootNode.setChildNodeID(0, rootNode.getID()); newRootNode.insertValueNodeIDPair(0, insertResult.overflowValue, insertResult.overflowNodeID); rootNodeID = newRootNode.getID(); writeFileHeader(); newRootNode.release(); if (height >= 0) { height++; } } rootNode.release(); return insertResult.oldValue; } finally { btreeLock.writeLock().unlock(); } } BTree(File dataDir, String filenamePrefix, int blockSize, int valueSize);  BTree(File dataDir, String filenamePrefix, int blockSize, int valueSize, boolean forceSync);  BTree(File dataDir, String filenamePrefix, int blockSize, int valueSize, RecordComparator comparator);  BTree(File dataDir, String filenamePrefix, int blockSize, int valueSize, RecordComparator comparator,
			boolean forceSync); File getFile(); boolean delete(); @Override void close(); void sync(); byte[] get(byte[] key); RecordIterator iterateAll(); RecordIterator iterateRange(byte[] minValue, byte[] maxValue); RecordIterator iterateValues(byte[] searchKey, byte[] searchMask); RecordIterator iterateRangedValues(byte[] searchKey, byte[] searchMask, byte[] minValue, byte[] maxValue); long getValueCountEstimate(); long getValueCountEstimate(byte[] minValue, byte[] maxValue); byte[] insert(byte[] value); byte[] remove(byte[] key); void clear(); void print(PrintStream out);  }
@Test public void testAddAscending() throws Exception { for (byte[] value : TEST_VALUES) { btree.insert(value); } }
@Test public void testAddRandom() throws Exception { for (byte[] value : RANDOMIZED_TEST_VALUES) { btree.insert(value); } }