Skip to content

Implement topic resolver and optimize cache loading#1908

Open
keyurva wants to merge 7 commits into
datacommonsorg:masterfrom
keyurva:resolve-topics
Open

Implement topic resolver and optimize cache loading#1908
keyurva wants to merge 7 commits into
datacommonsorg:masterfrom
keyurva:resolve-topics

Conversation

@keyurva
Copy link
Copy Markdown
Contributor

@keyurva keyurva commented May 22, 2026

  • Adds support for the new resolver = "topic" option inside the /v2/resolve API and a parameter to request expanding topic hierarchies.
  • Integrates dynamic, incremental SV metadata caching into the topic cache manager.
  • Excludes topics and SVPGs that lack populated list properties in the database.
  • Prunes dangling parent-child tree references recursively when child targets are empty or skipped.
  • Bypasses Spanner's edge pagination truncation limit globally by parallelizing multi-node requests in chunked partitions.

Verification / Testing Reference

1. Topic Resolver (expand_topics = false)

Returns immediate sub-topic and variable candidates:

curl -X POST -H "Content-Type: application/json" -H "X-Skip-Cache: true" -d '{
  "nodes": ["dc/topic/Root"],
  "resolver": "topic",
  "expand_topics": false
}' http://localhost:8081/v2/resolve | jq

2. Topic Resolver (expand_topics = true)

Recursively expands the entire nested hierarchy cache:

curl -X POST -H "Content-Type: application/json" -H "X-Skip-Cache: true" -d '{
  "nodes": ["dc/topic/Root"],
  "resolver": "topic",
  "expand_topics": true
}' http://localhost:8081/v2/resolve | jq

3. Embeddings/Indicator Resolver (expand_topics = false)

Performs semantic embeddings search and returns immediate candidates:

curl -X POST -H "Content-Type: application/json" -H "X-Skip-Cache: true" -d '{
  "nodes": ["health"],
  "resolver": "indicator",
  "expand_topics": false
}' http://localhost:8081/v2/resolve | jq

4. Embeddings/Indicator Resolver (expand_topics = true)

Performs semantic search and recursively expands matched topic hierarchies:

curl -X POST -H "Content-Type: application/json" -H "X-Skip-Cache: true" -d '{
  "nodes": ["health"],
  "resolver": "indicator",
  "expand_topics": true
}' http://localhost:8081/v2/resolve | jq

@keyurva keyurva changed the title Implement topic resolver and optimize Spanner cache loading Implement topic resolver and optimize cache loading May 22, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new topic resolver for explicit topic tree navigation and enhances the indicator resolver to support recursive topic expansion. Key changes include the implementation of a TopicExpander interface, a read-through cache for Statistical Variable metadata in TopicCacheManager, and parallelized node fetching in the datasource layer to improve performance and avoid database limits. Feedback focuses on optimizing the cache implementation to prevent stampedes, improving recursive slice allocations, and ensuring robust error handling and logging across the new topic expansion logic.

Comment thread internal/server/topic/topic_cache.go
Comment thread internal/server/topic/topic_cache.go Outdated
Comment thread internal/server/topic/expansion.go Outdated
Comment thread internal/server/topic/expansion.go Outdated
Comment thread internal/server/topic/expansion.go Outdated
Comment thread internal/server/v2/resolve/embeddings.go Outdated
@keyurva keyurva requested a review from clincoln8 May 22, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant