Skip to content
Snippets Groups Projects
Commit 26330549 authored by Michael Davis's avatar Michael Davis
Browse files

[catalogue] Uses getBytes() instead of byteAt() to get blob from OCCI

Should be more efficient as it's a single copy operation instead of one
character at-a-time, but still requires 2 copies of the blob to convert
it from occi::Bytes to std::string (as it needs an intermediate char*
array).
parent a06f3970
No related branches found
No related tags found
No related merge requests found
......@@ -130,9 +130,9 @@ std::string OcciRset::columnBlob(const std::string &colName) const {
try {
const int colIdx = m_colNameToIdx.getIdx(colName);
auto raw = m_rset->getBytes(colIdx);
std::string ret;
for(unsigned i = 0; i < raw.length(); ++i) ret.push_back(raw.byteAt(i));
return ret;
std::unique_ptr<unsigned char[]> bytearray(new unsigned char[raw.length()]());
raw.getBytes(bytearray.get(), raw.length());
return std::string(reinterpret_cast<char*>(bytearray.get()), raw.length());
} catch(exception::Exception &ne) {
throw exception::Exception(std::string(__FUNCTION__) + " failed for SQL statement " + m_stmt.getSql() + ": " +
ne.getMessage().str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment