-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add merging to V3 resolve and node search #1518
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
result := allResp[i].Results[counter] | ||
|
||
// Check if result was already added. | ||
key, err := proto.Marshal(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering how expensive this check is and whether we need to check all? If we do, can we base it on result.Node.Dcid
?
complete := map[int]bool{} | ||
counter := 0 | ||
loop: | ||
for { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit and optional: I prompted gemini on different ways of merging arrays based on our requirements and it came up with the following. Feel free to use it and perfectly fine to ignore (the logic in the PR works):
func mergeArraysClean(arrays [][]int, maxNumResults int) []int {
merged := make([]int, 0, maxNumResults)
for len(merged) < maxNumResults && len(arrays) > 0 {
newArrays := make([][]int, 0, len(arrays)) // Create a new slice for remaining arrays
added := false
for _, arr := range arrays {
if len(arr) > 0 {
merged = append(merged, arr[0])
added = true
if len(merged) >= maxNumResults {
return merged
}
if len(arr) > 1 {
newArrays = append(newArrays, arr[1:]) // Add remaining elements to the new slice
}
}
}
if !added {
break;
}
arrays = newArrays // Update arrays with the remaining sub-arrays
}
return merged
}
No description provided.