本文整理汇总了C++中SerializeOutput::data方法的典型用法代码示例。如果您正苦于以下问题:C++ SerializeOutput::data方法的具体用法?C++ SerializeOutput::data怎么用?C++ SerializeOutput::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializeOutput
的用法示例。
在下文中一共展示了SerializeOutput::data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serializeColumnHeaderTo
bool Table::serializeColumnHeaderTo(SerializeOutput &serialize_io) {
/* NOTE:
VoltDBEngine uses a binary template to create tables of single integers.
It's called m_templateSingleLongTable and if you are seeing a serialization
bug in tables of single integers, make sure that's correct.
*/
// skip header position
std::size_t start;
// use a cache
if (m_columnHeaderData) {
assert(m_columnHeaderSize != -1);
serialize_io.writeBytes(m_columnHeaderData, m_columnHeaderSize);
return true;
}
assert(m_columnHeaderSize == -1);
start = serialize_io.position();
// skip header position
serialize_io.writeInt(-1);
//status code
serialize_io.writeByte(-128);
// column counts as a short
serialize_io.writeShort(static_cast<int16_t>(m_columnCount));
// write an array of column types as bytes
for (int i = 0; i < m_columnCount; ++i) {
ValueType type = m_schema->columnType(i);
serialize_io.writeByte(static_cast<int8_t>(type));
}
// write the array of column names as voltdb strings
// NOTE: strings are ASCII only in metadata (UTF-8 in table storage)
for (int i = 0; i < m_columnCount; ++i) {
// column name: write (offset, length) for column definition, and string to string table
const string& name = columnName(i);
// column names can't be null, so length must be >= 0
int32_t length = static_cast<int32_t>(name.size());
assert(length >= 0);
// this is standard string serialization for voltdb
serialize_io.writeInt(length);
serialize_io.writeBytes(name.data(), length);
}
// write the header size which is a non-inclusive int
size_t position = serialize_io.position();
m_columnHeaderSize = static_cast<int32_t>(position - start);
int32_t nonInclusiveHeaderSize = static_cast<int32_t>(m_columnHeaderSize - sizeof(int32_t));
serialize_io.writeIntAt(start, nonInclusiveHeaderSize);
// cache the results
m_columnHeaderData = new char[m_columnHeaderSize];
memcpy(m_columnHeaderData, static_cast<const char*>(serialize_io.data()) + start, m_columnHeaderSize);
return true;
}