MCPcopy Create free account
hub / github.com/apache/cloudberry / lookup_ts_config_cache

Function lookup_ts_config_cache

src/backend/utils/cache/ts_cache.c:384–547  ·  view source on GitHub ↗

* Fetch configuration cache entry */

Source from the content-addressed store, hash-verified

382 * Fetch configuration cache entry
383 */
384TSConfigCacheEntry *
385lookup_ts_config_cache(Oid cfgId)
386{
387 TSConfigCacheEntry *entry;
388
389 if (TSConfigCacheHash == NULL)
390 {
391 /* First time through: initialize the hash table */
392 init_ts_config_cache();
393 }
394
395 /* Check single-entry cache */
396 if (lastUsedConfig && lastUsedConfig->cfgId == cfgId &&
397 lastUsedConfig->isvalid)
398 return lastUsedConfig;
399
400 /* Try to look up an existing entry */
401 entry = (TSConfigCacheEntry *) hash_search(TSConfigCacheHash,
402 (void *) &cfgId,
403 HASH_FIND, NULL);
404 if (entry == NULL || !entry->isvalid)
405 {
406 /*
407 * If we didn't find one, we want to make one. But first look up the
408 * object to be sure the OID is real.
409 */
410 HeapTuple tp;
411 Form_pg_ts_config cfg;
412 Relation maprel;
413 Relation mapidx;
414 ScanKeyData mapskey;
415 SysScanDesc mapscan;
416 HeapTuple maptup;
417 ListDictionary maplists[MAXTOKENTYPE + 1];
418 Oid mapdicts[MAXDICTSPERTT];
419 int maxtokentype;
420 int ndicts;
421 int i;
422
423 tp = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfgId));
424 if (!HeapTupleIsValid(tp))
425 elog(ERROR, "cache lookup failed for text search configuration %u",
426 cfgId);
427 cfg = (Form_pg_ts_config) GETSTRUCT(tp);
428
429 /*
430 * Sanity checks
431 */
432 if (!OidIsValid(cfg->cfgparser))
433 elog(ERROR, "text search configuration %u has no parser", cfgId);
434
435 if (entry == NULL)
436 {
437 bool found;
438
439 /* Now make the cache entry */
440 entry = (TSConfigCacheEntry *)
441 hash_search(TSConfigCacheHash,

Callers 5

parsetextFunction · 0.85
hlparsetextFunction · 0.85
ts_headline_byid_optFunction · 0.85

Calls 15

init_ts_config_cacheFunction · 0.85
hash_searchFunction · 0.85
SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
ReleaseSysCacheFunction · 0.85
ScanKeyInitFunction · 0.85
table_openFunction · 0.85
index_openFunction · 0.85
systable_getnext_orderedFunction · 0.85
MemoryContextAllocFunction · 0.85
systable_endscan_orderedFunction · 0.85

Tested by

no test coverage detected