How to use the cog.core.Index function in cog

To help you get started, weโ€™ve selected a few cog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arun1729 / cog / cog / core.py View on Github external
def put(self, key, store_position, store):

        while(True):
            if(self.live_index.get_load() * 100.0 / self.config.INDEX_CAPACITY > self.config.INDEX_LOAD_FACTOR):
                self.live_index.flush()
                self.index_id += 1
                self.logger.info("Index load reached, creating new index file: "+str(self.index_id))
                self.index_list.append(Index(self.table, self.config, self.logger, self.index_id))
                self.live_index = self.index_list[self.index_id]
                self.live_index_usage = self.live_index.get_load()

            resp = self.live_index.put(key, store_position, store)

            if(resp != None):
                self.logger.debug("Key: "+key+" indexed in: "+self.live_index.name)
                break
github arun1729 / cog / cog / core.py View on Github external
def __init__(self, table, config, logger):
        self.table = table
        self.config = config
        self.logger = logger
        self.index_list = []
        self.index_id = 0
        self.load_indexes()
        #if no index currenlty exist, create new live index.
        if(len(self.index_list) == 0 ):
            self.index_list.append(Index(table, config, logger, self.index_id))
            self.live_index = self.index_list[self.index_id]
github arun1729 / cog / cog / core.py View on Github external
def load_indexes(self):
        for f in os.listdir(self.config.cog_data_dir(self.table.db_name)):
            if(self.config.INDEX in f):
                self.logger.info("Loading index "+f)
                id = self.config.index_id(f)
                index = Index(self.table, self.config, self.logger, id)
                self.index_list.append(index)
                #make the latest index the live index.
                if(id >= self.index_id):
                    self.index_id = id
                    self.live_index = index