MCPcopy Create free account
hub / github.com/apache/impala / EncodeVectorPOD

Function EncodeVectorPOD

be/src/gutil/strings/serialize.h:216–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214// Verifies the given data type is a POD and copies the bytes of each value
215// in the vector into a newly created string.
216template <typename T> inline string EncodeVectorPOD(const vector<T>& vec) {
217 ENFORCE_POD(T);
218 string s;
219 STLStringResizeUninitialized(&s, vec.size() * sizeof(T));
220 typename vector<T>::const_iterator iter;
221 char* ptr;
222 for (iter = vec.begin(), ptr = string_as_array(&s);
223 iter != vec.end();
224 ++iter, ptr += sizeof(T)) {
225 memcpy(ptr, &(*iter), sizeof(T));
226 }
227 return s;
228}
229
230// Reconstructs a vector of a plain old data type values from a C++ string.
231// Verifies the given data type is a POD and copies the bytes of each value

Callers

nothing calls this directly

Calls 5

string_as_arrayFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected