Commit e43a843
committed
Inflate included pointers in-place
I'd like to parallelize the fetching of included documents, but it would
be tricky to do in the world where these methods are cloning the
response. Instead of trying to do tricky processing on the responses to
merge all the pointers, we can mutate the response in-place.
This kind of in-place mutation can be viewed as more dangerous,
particularly with multiple promises trying to run this kind of
replacement in a row. However, we have some nice guarantees here:
- Each path passed is unique; we don't need to worry about multiple
calls each trying to replace the same documents.
- When we start doing a replacement, all the path prefixes have already
been replaced. In the current implementation this is known because we
sort the include paths by path length, so if a path `a.b.c` is being
processed, then the prefix paths `a` and `a.b` must have already been
processed.
This in-place mutation might also have a nice benefit in terms of memory
usage; queries with lots of includes would have been rebuilding the
result tree multiple times, causing extra allocations. The in-place
method avoids this, and so might reduce memory usage for those queries.1 parent cc5f14e commit e43a843
1 file changed
+18
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
763 | | - | |
764 | | - | |
| 763 | + | |
765 | 764 | | |
766 | 765 | | |
767 | 766 | | |
768 | 767 | | |
769 | 768 | | |
770 | 769 | | |
771 | 770 | | |
772 | | - | |
773 | | - | |
774 | 771 | | |
775 | 772 | | |
776 | 773 | | |
| |||
821 | 818 | | |
822 | 819 | | |
823 | 820 | | |
824 | | - | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
| |||
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
| 908 | + | |
915 | 909 | | |
916 | 910 | | |
917 | 911 | | |
918 | 912 | | |
919 | 913 | | |
920 | | - | |
921 | 914 | | |
922 | 915 | | |
923 | 916 | | |
| |||
951 | 944 | | |
952 | 945 | | |
953 | 946 | | |
954 | | - | |
955 | | - | |
| 947 | + | |
| 948 | + | |
956 | 949 | | |
957 | 950 | | |
958 | 951 | | |
| |||
964 | 957 | | |
965 | 958 | | |
966 | 959 | | |
| 960 | + | |
967 | 961 | | |
968 | 962 | | |
969 | 963 | | |
970 | 964 | | |
971 | 965 | | |
972 | 966 | | |
973 | 967 | | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
974 | 975 | | |
975 | 976 | | |
976 | 977 | | |
977 | 978 | | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
| 979 | + | |
| 980 | + | |
988 | 981 | | |
989 | 982 | | |
990 | 983 | | |
| |||
0 commit comments