public void Commit()
        {
            if (BtreeRoot == null)
            {
                throw new BTDBException("Transaction already commited or disposed");
            }
            InvalidateCurrentKey();
            var currentBtreeRoot = _btreeRoot;

            _btreeRoot = null;
            if (_preapprovedWriting)
            {
                _preapprovedWriting = false;
                _keyValueDB.RevertWritingTransaction();
            }
            else if (_writing)
            {
                _keyValueDB.CommitWritingTransaction(currentBtreeRoot);
                _writing = false;
            }
        }