Get index with given name from cache. Create if it doesn't exists.
976927
def get_or_create_index(self, paths=None, name=None, refresh=False):
        
        if not paths:
            paths = sys.path
        if not name:
            name = 'default'
        self._name = name

        idx_dir = get_cache_dir()
        idx_file = os.path.join(idx_dir, name + '.json')

        if os.path.exists(idx_file) and not refresh:
            with open(idx_file) as fd:
                self.deserialize(fd)
        else:
            self.build_index(paths)
            with open(idx_file, 'w') as fd:
                self.serialize(fd)

        return self
463609
def _get_index_for_insert(self, key, instance):
        """"""
        if instance == 0:
            # Index method will return the first occurence of the key
            index = self.keys().index(key)
        else:
            occurrence = -1
            for index, k in enumerate(self.keys()):
                if k == key:
                    occurrence += 1
                    if occurrence == instance:
                        # Found the key and the correct occurence of the key
                        break

            if occurrence != instance:
                # Gone through the entire list of keys and the instance number
                # given is too high for the number of occurences of the key
                raise ValueError(
                    (
                        "Cannot insert before/after the %d "
                        "instance of the key '%s' since there are "
                        "only %d occurences of the key" % (
                            instance, key, occurrence)
                    ))
        return index
6816
def get_name(self, key):
        '''
        '''
        try:
            return self.nameDict[key]
        except IndexError as e:
            print 'IndexError {0}: {1}'.format(e.errno, e.strerror)
632247
def get_index_by_name(self, name):
        """"""
        for i in range(len(self.vertices)):
            if self.vertices[i].name == name:
                return i
        raise ValueError('Reverse look up of name failed.')
453613
public boolean createIndex(String indexName) {
        CreateIndexResponse response =
                getClient().admin().indices().prepareCreate(indexName).execute().actionGet();
        return response.isAcknowledged();
    }
608398
int getIndex (Name name) {
            int h = name.hashCode();
            int i = h & hashMask;
            // The expression below is always odd, so it is guaranteed
            // to be mutually prime with table.length, a power of 2.
            int x = hashMask - ((h + (h >> 16)) << 1);
            int d = -1; // Index of a deleted item.
            for (;;) {
                Entry e = table[i];
                if (e == null)
                    return d >= 0 ? d : i;
                if (e == sentinel) {
                    // We have to keep searching even if we see a deleted item.
                    // However, remember the index in case we fail to find the name.
                    if (d < 0)
                        d = i;
                } else if (e.sym.name == name)
                    return i;
                i = (i + x) & hashMask;
            }
        }
74313
def load_index_from_cache(self):
        '''  '''

        cache = open(self.cache_path_index, 'r')
        json_index = cache.read()
        self.index = json.loads(json_index)
704273
def _read_cache(self):
        """"""
        if os.path.exists(self.filepath):
            with open(self.filepath, 'rt', encoding='utf8') as fh:
                lines = [x.strip() for x in fh]
        else:
            logger.debug("Index not found, starting empty")
            lines = []
        return lines
996668
def cache_index(index)
      # TODO: atomic rename. Right now we just hope.
      File.open(CACHE_PATH, 'w' ) do |out|
        YAML::dump( index, out )
      end
    end
881897
def get_records(self, name):
        
        if name in self._cache:
            return self._cache[name].values()
        else:
            return []
945848
public static Term create(long index) {
        Term res = createLongCache.get(index);
        if (res == null) {
            checkNumericIndex(index);

            // Generate a new property.
            res = (Term) LongProperty.getInstance(index);
            createLongCache.put(index, res);
            return res;
        }

        // no clone/copy needed for cached result
        return res;
	}
659718
def encode(self, name, as_map_key=False):
        """"""
        if name in self.key_to_value:
            return self.key_to_value[name]
        return self.encache(name) if is_cacheable(name, as_map_key) else name
420958
def create(index_name, body, force, verbose):
    """"""
    result = current_search_client.indices.create(
        index=index_name,
        body=json.load(body),
        ignore=[400] if force else None,
    )
    if verbose:
        click.echo(json.dumps(result))
632590
int getIndexIndex(String indexName) {

        Index[] indexes = indexList;

        for (int i = 0; i < indexes.length; i++) {
            if (indexName.equals(indexes[i].getName().name)) {
                return i;
            }
        }

        // no such index
        return -1;
    }
662123
def getaddress(name)
      unless @cache[name]
        @mutex.synchronize do
          @cache[name] ||= CachedValue.new(@ttl)
        end
      end
      @cache[name].get_or_refresh{ resolve(name) }
    end
162550
def get_unique_name(self, name):
        

        if name not in self._db:
            self._db[name] = 0
            return name
        else:
            index = self._db[name]
            self._db[name] = index + 1
            return f"{name}_{index}"
133586
def index(self, name=None):  # pylint: disable=C6409
    
    try:
      return self.header.index(name)
    except ValueError:
      raise TableError('Unknown index name %s.' % name)