check if maybe index needs rebuilding in the time span
492745
def __check_index(self, start_date, end_date):
        """"""
        index_query = """SELECT id
                           FROM facts
                          WHERE (end_time >= ? OR end_time IS NULL)
                            AND start_time <= ?
                            AND id not in(select id from fact_index)"""

        rebuild_ids = ",".join([str(res[0]) for res in self.fetchall(index_query, (start_date, end_date))])

        if rebuild_ids:
            query = """
                       SELECT a.id AS id,
                              a.start_time AS start_time,
                              a.end_time AS end_time,
                              a.description as description,
                              b.name AS name, b.id as activity_id,
                              coalesce(c.name, ?) as category,
                              e.name as tag
                         FROM facts a
                    LEFT JOIN activities b ON a.activity_id = b.id
                    LEFT JOIN categories c ON b.category_id = c.id
                    LEFT JOIN fact_tags d ON d.fact_id = a.id
                    LEFT JOIN tags e ON e.id = d.tag_id
                        WHERE a.id in (%s)
                     ORDER BY a.id
            """ % rebuild_ids

            facts = self.__group_tags(self.fetchall(query, (self._unsorted_localized, )))

            insert = """INSERT INTO fact_index (id, name, category, description, tag)
                             VALUES (?, ?, ?, ?, ?)"""
            params = [(fact['id'], fact['name'], fact['category'], fact['description'], " ".join(fact['tags'])) for fact in facts]

            self.executemany(insert, params)
738119
public function rebuildIndex()
    {
        $this->rowsIndexByLabel = array();
        $this->rebuildIndexContinuously = true;

        foreach ($this->rows as $id => $row) {
            $label = $row->getColumn('label');
            if ($label !== false) {
                $this->rowsIndexByLabel[$label] = $id;
            }
        }

        if ($this->summaryRow) {
            $label = $this->summaryRow->getColumn('label');
            if ($label !== false) {
                $this->rowsIndexByLabel[$label] = DataTable::ID_SUMMARY_ROW;
            }
        }

        $this->indexNotUpToDate = false;
    }
557041
public static boolean updatingIndexNecessesary(CmsObject cms) {

        // Set request to the offline project.
        setCmsOfflineProject(cms);

        // Check whether the spellcheck index directories are empty.
        // If they are, the index has to be built obviously.
        if (isSolrSpellcheckIndexDirectoryEmpty()) {
            return true;
        }

        // Compare the most recent date of a dictionary with the oldest timestamp
        // that determines when an index has been built.
        long dateMostRecentDictionary = getMostRecentDate(cms);
        long dateOldestIndexWrite = getOldestIndexDate(cms);

        return dateMostRecentDictionary > dateOldestIndexWrite;
    }
1196019
public synchronized void refreshIndexes() {
		/*
		 * cache index by Bin name
		 */
		if (this.indexCache == null)
			this.indexCache = new TreeMap<String, Index>();

		Node[] nodes = client.getNodes();
		for (Node node : nodes) {
			if (node.isActive()) {
				try {
					String indexString = Info.request(getInfoPolicy(), node, "sindex");
					if (!indexString.isEmpty()) {
						String[] indexList = indexString.split(";");
						for (String oneIndexString : indexList) {
							Index index = new Index(oneIndexString);
							this.indexCache.put(index.toKeyString(), index);
						}
					}
					break;
				} catch (AerospikeException e) {
					log.error("Error geting Index informaton", e);
				}
			}
		}
	}
837555
public boolean checkRepeatMove ()
    {
        long now = System.currentTimeMillis();
        if (now - _lastRequestTime < STALE_REQUEST_DURATION) {
            return true;

        } else {
            _lastRequestTime = now;
            return false;
        }
    }
785471
def _ensure_like_indices(time, panels):
    
    n_time = len(time)
    n_panel = len(panels)
    u_panels = np.unique(panels)  # this sorts!
    u_time = np.unique(time)
    if len(u_time) == n_time:
        time = np.tile(u_time, len(u_panels))
    if len(u_panels) == n_panel:
        panels = np.repeat(u_panels, len(u_time))
    return time, panels
704110
def needs_refresh(self, source):
        
        now = time.time()
        if source._tok in self:
            s0 = self[source._tok]
            if self[source._tok].metadata.get('ttl', None):
                then = s0.metadata['timestamp']
                if s0.metadata['ttl'] < then - now:
                    return True
            return False
        return True
1334165
function(error, newIndex) {
  if (error) {
    console.log('Data error for ' + dataurl + '\n' + error)
  }
  if (!error) {
    index = newIndex
    var timeStart = Date.now()
    request(dataurl)
      .pipe(JSONStream.parse())
      .pipe(index.defaultPipeline())
      .pipe(index.add())
      .on('data', function(data) {
        //console.dir(data) // What's going on in the indexing process
      })
      .on('end', () => {
        var timeEnd = Date.now()
        var timeUsed = Math.trunc((timeEnd - timeStart) / 1000)
        console.log('Indexed in ' +  timeUsed + ' seconds')
      })
  }
}
679672
def _every(times, step_size, index):
        
        current = index * step_size
        step = current // times * times
        reached = current >= step
        overshot = current >= step + step_size
        return current and reached and not overshot
1135858
private void ensureNext() {
        // Check if the current scan result has more keys (i.e. the index did not reach the end of the result list)
        if (resultIndex < scanResult.getResult().size()) {
            return;
        }
        // Since the current scan result was fully iterated,
        // if there is another cursor scan it and ensure next key (recursively)
        if (!FIRST_CURSOR.equals(scanResult.getStringCursor())) {
            scanResult = scan(scanResult.getStringCursor(), scanParams);
            resultIndex = 0;
            ensureNext();
        }
    }
249109
def _check_inv_operation_for_date(self, item, timestamp, data_dict, data_index_dict):
        

        if item in data_index_dict:
            for item in data_index_dict[item]:

                # startdate < timestamp
                if const.START in data_dict[item] and not const.END in data_dict[item]:
                    if data_dict[item][const.START] < timestamp:
                        return True

                # enddate > timestamp
                elif not const.START in data_dict[item] and const.END in data_dict[item]:
                    if data_dict[item][const.END] > timestamp:
                        return True

                # startdate > timestamp > enddate
                elif const.START in data_dict[item] and const.END in data_dict[item]:
                    if data_dict[item][const.START] < timestamp \
                            and data_dict[item][const.END] > timestamp:
                        return True

                # no startdate or enddate available
                elif not const.START in data_dict[item] and not const.END in data_dict[item]:
                    return True

        raise KeyError
75004
def rm(self, index):
        
        if self.model.exists(index):
            self.model.remove(index)
1361518
public void resetIndex(long index, long timestamp) {
    currentOperation = OperationType.COMMAND;
    operationIndex = index;
    currentIndex = index;
    currentTimestamp = timestamp;
    setCommitIndex(index);
    service.tick(new WallClockTimestamp(currentTimestamp));
  }
434253
private boolean isRefreshIndexes()
    {

        if (clientProperties != null)
        {

            Object refreshIndexes = clientProperties.get(ESConstants.ES_REFRESH_INDEXES);

            if (refreshIndexes != null && refreshIndexes instanceof Boolean)
            {
                return (boolean) refreshIndexes;
            }
            else
            {
                return Boolean.parseBoolean((String) refreshIndexes);
            }

        }
        else
        {
            return this.setRereshIndexes;
        }
    }
391542
def check_indexes(self):
        """"""
        for collection_name in INDEXES:
            existing_indexes = self.indexes(collection_name)
            indexes = INDEXES[collection_name]
            for index in indexes:
                index_name = index.document.get('name')
                if not index_name in existing_indexes:
                    logger.warning("Index {0} missing. Run command `loqusdb index`".format(index_name))
                    return
        logger.info("All indexes exists")
1213605
def _need_update(self, project_name, updatetime=None, md5sum=None):
        ''''''
        if project_name not in self.projects:
            return True
        elif md5sum and md5sum != self.projects[project_name]['info'].get('md5sum'):
            return True
        elif updatetime and updatetime > self.projects[project_name]['info'].get('updatetime', 0):
            return True
        elif time.time() - self.projects[project_name]['load_time'] > self.RELOAD_PROJECT_INTERVAL:
            return True
        return False
33221
def index(self, index):
        
        if self._index != index:
            self._dirty = True
        self._index = index