Commit b2919fa
authored
[native] Save 1 memcpy in parsing message body (#24941)
## Description
In our HTTP callbacks, we parse the vector of iobufs into a string;
however, we assume that each iobuf is singularly chained. This is not
guaranteed to be the case.
This diff resolves two issues:
- Correctly consumes the vector of iobufs by taking each buffer chain
into account
- Saves 1 memcopy. The previous code path would copy each iobuf into a
stream, and then use.c_str(), which also is a copy
([https://en.cppreference.com/w/cpp/io/basic_ostringstream/str](https://l.facebook.com/l.php?u=https%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fio%2Fbasic_ostringstream%2Fstr&h=AT2RH-TyloQE5MPfdcxYizn__by-8eZd_7-9saGWz05YOZfunpxrYWFq0lHU6WVhx1zpPwW_rnjI9dtanJo1HqBKf5SDv96S4UZBgEOE02Jzb2MevW9chO9bBLeyNU4g7pEs9yMea4EnPqVa9h_K4QrRx_c)).
This diff will just copy once into the string buffer
## Test Plan
Added Unit test
## Contributor checklist
- [X] Please make sure your submission complies with our [contributing
guide](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md),
in particular [code
style](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#code-style)
and [commit
standards](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#commit-standards).
- [ ] PR description addresses the issue accurately and concisely. If
the change is non-trivial, a GitHub Issue is referenced.
- [ ] Documented new properties (with its default value), SQL syntax,
functions, or other functionality.
- [ ] If release notes are required, they follow the [release notes
guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines).
- [ ] Adequate tests were added if applicable.
- [ ] CI passed.1 parent e76f5a5 commit b2919fa
File tree
2 files changed
+27
-6
lines changed- presto-native-execution/presto_cpp/main/common
- tests
2 files changed
+27
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
76 | 85 | | |
77 | 86 | | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
0 commit comments