partition_cache.go ×6

Frontier kind: Code frontier

unlabeled · c_c42787b6e5c6

24 tests · 1842 LOC · 76 files · introduces 0 tests · 19 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges19 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
250 ranges1842 lines · 76 files · Browse complete extent
All tests (intent)
24 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 19 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/client/matching/partition_cache.go 19 introduced LOC · 6 ranges

Open complete file

77 func (*partitionCache) makeKey(
78 nsid, tqname string, tqtype enumspb.TaskQueueType,
79 > ) string { partition_cache.go
80 > // note we don't need delimiters to make unambiguous keys: nsid is always the same length,
81 > // the last byte is tqtype, and everything in between is the name.
82 > nsidBytes, err := uuid.Parse(nsid)
83 > if err != nil {
84 // this shouldn't fail, but use the string form as a backup, append a 0xff to differentiate
85 return nsid + string([]byte{0xff}) + tqname + string([]byte{byte(tqtype), 0xff})
86 }
87 > return string(nsidBytes[:]) + tqname + string([]byte{byte(tqtype)}) partition_cache.go
88 }
89
90 > func (*partitionCache) shardFromKey(key string) int { partition_cache.go
91 > // mix a few bits to pick a shard
92 > l := len(key)
93 > shard := int(key[min(14, l-3)] ^ key[l-2] ^ key[l-1])
94 > return shard % partitionCacheNumShards
95 > }
96
97 > func (c *partitionCache) lookup(key string) PartitionCounts { partition_cache.go
98 > return c.shards[c.shardFromKey(key)].lookup(key)
99 > }
100
101 func (c *partitionCache) put(key string, pc PartitionCounts) {
103 }
104
105 > func (s *partitionCacheShard) lookup(key string) PartitionCounts { partition_cache.go
106 > s.lock.RLock()
107 > if pc, ok := s.active[key]; ok {
108 s.lock.RUnlock()
109 return pc
110 > } else if pc, ok := s.prev[key]; ok { partition_cache.go
111 s.lock.RUnlock()
112 s.put(key, pc) // promote to active