def get_sample_window(self, type_tag, size=10):
        """Get a window of samples not to exceed size (in MB).

        Args:
            type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...).
            size: Size of samples in MBs.

        Returns:
            a list of md5s.
        """

        # Convert size to MB
        size = size * 1024 * 1024

        # Grab all the samples of type=type_tag, sort by import_time (newest to oldest)
        cursor = self.database[self.sample_collection].find({'type_tag': type_tag},
            {'md5': 1,'length': 1}).sort('import_time',pymongo.DESCENDING)
        total_size = 0
        md5_list = []
        for item in cursor:
            if total_size > size:
                return md5_list
            md5_list.append(item['md5'])
            total_size += item['length']

        # If you get this far you don't have 'size' amount of data
        # so just return what you've got
        return md5_list
dataset/ETHPy150Open SuperCowPowers/workbench/workbench/server/data_store.py/DataStore.get_sample_window/original