/** * @brief Serialize given data * @return true if we serialize data otherwise false */ bool TupleRecord::Serialize(CopySerializeOutput &output) { bool status = true; output.Reset(); // Serialize the common variables such as database oid, table oid, etc. SerializeHeader(output); // Serialize other parts depends on type switch (GetType()) { case LOGRECORD_TYPE_ARIES_TUPLE_INSERT: case LOGRECORD_TYPE_ARIES_TUPLE_UPDATE: { storage::Tuple *tuple = (storage::Tuple *)data; tuple->SerializeTo(output); break; } case LOGRECORD_TYPE_ARIES_TUPLE_DELETE: // Nothing to do here ! break; case LOGRECORD_TYPE_PELOTON_TUPLE_INSERT: case LOGRECORD_TYPE_PELOTON_TUPLE_DELETE: case LOGRECORD_TYPE_PELOTON_TUPLE_UPDATE: // Nothing to do here ! break; default: { LOG_WARN("Unsupported TUPLE RECORD TYPE\n"); status = false; break; } } message_length = output.Size(); message = new char[message_length]; std::memcpy(message, output.Data(), message_length); return status; }
/** * @brief Serialize given data * @return true if we serialize data otherwise false */ bool TransactionRecord::Serialize(CopySerializeOutput &output) { bool status = true; output.Reset(); // First, write out the log record type output.WriteEnumInSingleByte(log_record_type); // Then reserve 4 bytes for the header size to be written later size_t start = output.Position(); output.WriteInt(0); output.WriteLong(cid); // Write out the header now int32_t header_length = static_cast<int32_t>(output.Position() - start - sizeof(int32_t)); output.WriteIntAt(start, header_length); message_length = output.Size(); message = new char[message_length]; PL_MEMCPY(message, output.Data(), message_length); return status; }