def __init__(self, path, map_size=1000000000, code_size=8, writeonly=False):
        super(HammingDb, self).__init__()

        self.writeonly = writeonly

        if not os.path.exists(path):
            os.makedirs(path)

        self.path = path
        self.env = lmdb.open(
            self.path,
            max_dbs=10,
            map_size=map_size,
            writemap=True,
            map_async=True,
            metasync=True)
        self.env.reader_check()

        self.metadata = self.env.open_db(b'metadata')
        try:
            self.code_size = int(self.get_metadata(b'codesize'))
            if code_size and code_size != self.code_size:
                raise ValueError(
                    'Database is already initialized with code size {code_size}'
                    ', but {self.code_size} was passed to __init__'
                        .format(**locals()))
        except TypeError:
            if code_size is None:
                raise ValueError(
                    'You must supply a code size for an uninitialized database')
            if code_size % 8:
                raise ValueError('code_size must be a multiple of 8')
            self.set_metadata(b'codesize', str(code_size).encode())
            self.code_size = code_size

        self.index = self.env.open_db(b'index')
        self._append_buffer = self._recarray(1)
        self._code_bytearray = bytearray(b'a' * self.code_size)
        self._code_buffer = np.frombuffer(self._code_bytearray, dtype=np.uint64)
        self._codes = None
        self._ids = set()
        self._catch_up_on_in_memory_store()

        self._thread_count = cpu_count()
        self._pool = ThreadPool(processes=self._thread_count)