Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions query/outputnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,15 @@ func (enc *encoder) merge(parent, child []fastJsonNode) ([]fastJsonNode, error)
return child, nil
}

// Here we merge two slices of maps.
mergedList := make([]fastJsonNode, 0)
// Here we merge two slices of maps. The final size is len(parent) * len(child),
// but the loop below bails out once cnt exceeds LimitNormalizeNode, so cap the
// pre-allocation at that limit to avoid a huge (or overflowing) up-front alloc
// for queries that are going to be rejected anyway.
c := len(parent) * len(child)
if lim := x.Config.LimitNormalizeNode; lim > 0 && c > lim {
c = lim
}
mergedList := make([]fastJsonNode, 0, c)
cnt := 0
for _, pa := range parent {
for _, ca := range child {
Expand Down
Loading