MB-60400: Do not walk document if vector is processed successfully #1984
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the walkDocument function is called after processing every vector, regardless of whether the vector was processed successfully or not. This results in the execution of the following code:
In this code, val.Len() will be equal to the dimension of the vector, which could potentially be very high (up to 2048). For each iteration of the loop, processProperty() is called on each float value extracted from the vector. Within processProperty(), it attempts to add a numeric field and creates a new array using append().
If the property has already been successfully processed as a vector, then each individual float value within the vector cannot be processed as a separate numeric field. This is because the same path variable is passed, ensuring that the fieldMapping will always be of type vector, not number.
The check introduced here ensures that if the vector is successfully processed and a vector field is added, we skip calling walkDocument on it.
This assertion is supported by the memory profiles obtained while indexing 1528-dimensional vectors, where approximately 65 GB (8% of the total allocated space) was dedicated to this process. The check introduced here allows us to avoid such excessive allocation.