Skip to content

Commit 4656cfe

Browse files
committed
fix InMemoryIndex Lookup
Signed-off-by: sagiahrac <[email protected]> Signed-off-by: Sage Ahrac <[email protected]>
1 parent a3f61a0 commit 4656cfe

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pkg/kvcache/kvblock/in_memory.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ type PodCache struct {
8989
// If the podIdentifierSet is empty, all pods are returned.
9090
//
9191
// It returns:
92-
// 1. A slice of the hit keys.
93-
// 2. A map where the keys are those in (1) and the values are pod-identifiers.
94-
// 3. An error if any occurred during the operation.
92+
// 1. A map where the keys are those in (1) and the values are pod-identifiers.
93+
// 2. An error if any occurred during the operation.
9594
func (m *InMemoryIndex) Lookup(ctx context.Context, keys []Key,
9695
podIdentifierSet sets.Set[string],
97-
) ([]Key, map[Key][]string, error) {
96+
) (map[Key][]string, error) {
9897
if len(keys) == 0 {
99-
return nil, nil, fmt.Errorf("no keys provided for lookup")
98+
return nil, fmt.Errorf("no keys provided for lookup")
10099
}
101100

102101
traceLogger := klog.FromContext(ctx).V(logging.TRACE).WithName("kvblock.InMemoryIndex.Lookup")
@@ -108,7 +107,7 @@ func (m *InMemoryIndex) Lookup(ctx context.Context, keys []Key,
108107
if pods, found := m.data.Get(key); found { //nolint:nestif // TODO: can this be optimized?
109108
if pods == nil || pods.cache.Len() == 0 {
110109
traceLogger.Info("no pods found for key, cutting search", "key", key)
111-
return keys[:idx], podsPerKey, nil // early stop since prefix-chain breaks here
110+
return podsPerKey, nil // early stop since prefix-chain breaks here
112111
}
113112

114113
highestHitIdx = idx
@@ -135,7 +134,7 @@ func (m *InMemoryIndex) Lookup(ctx context.Context, keys []Key,
135134
traceLogger.Info("lookup completed", "highest-hit-index", highestHitIdx,
136135
"pods-per-key", podsPerKeyPrintHelper(podsPerKey))
137136

138-
return keys[:highestHitIdx+1], podsPerKey, nil
137+
return podsPerKey, nil
139138
}
140139

141140
// Add adds a set of keys and their associated pod entries to the index backend.

0 commit comments

Comments
 (0)