# Path: featureflow/data.py
# class Database(object):
#     """
#     Marker class for a datastore
#     """
# 
#     def __init__(self, key_builder=None):
#         super(Database, self).__init__()
#         self.key_builder = key_builder
# 
#     # TODO: Maybe this should just be open(), since it returns a file-like 
#     # object
#     def write_stream(self, key, content_type):
#         raise NotImplemented()
# 
#     # TODO: Maybe this should just be open(), since it returns a file-like
#     # object
#     def read_stream(self, key):
#         raise NotImplementedError()
# 
#     def random(self):
#         """
#         Return the read stream of a random key
#         """
#         raise NotImplementedError()
# 
#     def size(self, key):
#         raise NotImplementedError()
# 
#     def iter_ids(self):
#         raise NotImplementedError()
# 
#     def __iter__(self):
#         return self.iter_ids()
# 
#     def __contains__(self, key):
#         raise NotImplementedError()
# 
#     def __delitem__(self, key):
#         raise NotImplementedError()


import lmdb
import os
from .data import Database
from io import BytesIO
        # maybe another process has written data
        self._init_db_cache()

        try:
            return list(self.dbs.values())[0]
        except IndexError:
            return None

    def iter_ids(self):
        db = self._get_any_db()
        if db is None:
            return

        seen = set()
        with self.env.begin(db) as txn:
            cursor = txn.cursor(db)
            for _id in cursor.iternext(keys=True, values=False):
                _id, version = self.key_builder.decompose(_id.decode('utf-8'))
                if _id in seen:
                    continue
                yield _id
                seen.add(_id)

    def __contains__(self, key):
        try:
            _id, db = self._get_read_db(key)
        except KeyError:
            return False
        with self.env.begin(buffers=True) as txn:
            buf = txn.get(to_bytes(_id), db=db)

# Path: featureflow/data.py
# class Database(object):
#     """
#     Marker class for a datastore
#     """
# 
#     def __init__(self, key_builder=None):
#         super(Database, self).__init__()
#         self.key_builder = key_builder
# 
#     # TODO: Maybe this should just be open(), since it returns a file-like 
#     # object
#     def write_stream(self, key, content_type):
#         raise NotImplemented()
# 
#     # TODO: Maybe this should just be open(), since it returns a file-like
#     # object
#     def read_stream(self, key):
#         raise NotImplementedError()
# 
#     def random(self):
#         """
#         Return the read stream of a random key
#         """
#         raise NotImplementedError()
# 
#     def size(self, key):
#         raise NotImplementedError()
# 
#     def iter_ids(self):
#         raise NotImplementedError()
# 
#     def __iter__(self):
#         return self.iter_ids()
# 
#     def __contains__(self, key):
#         raise NotImplementedError()
# 
#     def __delitem__(self, key):
#         raise NotImplementedError()


# Path: featureflow/lmdbstore.py
import lmdb
import os
from .data import Database
from io import BytesIO

        # maybe another process has written data
        self._init_db_cache()

        try:
            return list(self.dbs.values())[0]
        except IndexError:
            return None

    def iter_ids(self):
        db = self._get_any_db()
        if db is None:
            return

        seen = set()
        with self.env.begin(db) as txn:
            cursor = txn.cursor(db)
            for _id in cursor.iternext(keys=True, values=False):
                _id, version = self.key_builder.decompose(_id.decode('utf-8'))
                if _id in seen:
                    continue
                yield _id
                seen.add(_id)

    def __contains__(self, key):
        try:
            _id, db = self._get_read_db(key)
        except KeyError:
            return False
        with self.env.begin(buffers=True) as txn:
            buf = txn.get(to_bytes(_id), db=db)

        return buf is not None