/** * Loads only tuple data, not schema, from the serialized tile. * Used for initial data loading. * @param allow_export if false, export enabled is overriden for this load. */ void Tile::DeserializeTuplesFrom(SerializeInput &input, type::AbstractPool *pool) { /* * Directly receives a Tile buffer. * [00 01] [02 03] [04 .. 0x] * rowstart colcount colcount * 1 byte (column types) * * [0x+1 .. 0y] * colcount * strings (column names) * * [0y+1 0y+2 0y+3 0y+4] * rowcount * * [0y+5 .. end] * rowdata */ input.ReadInt(); // rowstart input.ReadByte(); oid_t column_count = input.ReadShort(); PL_ASSERT(column_count > 0); // Store the following information so that we can provide them to the user on // failure type::Type::TypeId types[column_count]; std::vector<std::string> names; // Skip the column types for (oid_t column_itr = 0; column_itr < column_count; ++column_itr) { types[column_itr] = (type::Type::TypeId)input.ReadEnumInSingleByte(); } // Skip the column names for (oid_t column_itr = 0; column_itr < column_count; ++column_itr) { names.push_back(input.ReadTextString()); } // Check if the column count matches what the temp table is expecting if (column_count != schema.GetColumnCount()) { std::stringstream message(std::stringstream::in | std::stringstream::out); message << "Column count mismatch. Expecting " << schema.GetColumnCount() << ", but " << column_count << " given" << std::endl; message << "Expecting the following columns:" << std::endl; message << schema.GetColumnCount() << std::endl; message << "The following columns are given:" << std::endl; for (oid_t column_itr = 0; column_itr < column_count; column_itr++) { message << "column " << column_itr << ": " << names[column_itr] << ", type = " << types[column_itr] << std::endl; } throw SerializationException(message.str()); } // Use the deserialization routine skipping header DeserializeTuplesFromWithoutHeader(input, pool); }
/** * Therefore a SeqScanPlan is serialized as: * [(int) total size] * [(int8_t) plan type] * [(int) database_id] * [(int) table_id] * [(int) num column_id] * [(int) column id...] * [(int8_t) expr type] : if invalid, predicate is null * [(bytes) predicate] : predicate is Expression * [(int8_t) plan type] : if invalid, parent is null * [(bytes) parent] : parent is also a plan */ bool SeqScanPlan::DeserializeFrom(SerializeInput &input) { // Read the size of SeqScanPlan class input.ReadInt(); // Read the type UNUSED_ATTRIBUTE PlanNodeType plan_type = (PlanNodeType)input.ReadEnumInSingleByte(); PL_ASSERT(plan_type == GetPlanNodeType()); // Read database id oid_t database_oid = input.ReadInt(); // Read table id oid_t table_oid = input.ReadInt(); // Get table and set it to the member storage::DataTable *target_table = static_cast<storage::DataTable *>( catalog::Catalog::GetInstance()->GetTableWithOid(database_oid, table_oid)); SetTargetTable(target_table); // Read the number of column_id and set them to column_ids_ oid_t columnid_count = input.ReadInt(); for (oid_t it = 0; it < columnid_count; it++) { oid_t column_id = input.ReadInt(); SetColumnId(column_id); } // Read the type ExpressionType expr_type = (ExpressionType)input.ReadEnumInSingleByte(); // Predicate deserialization if (expr_type != EXPRESSION_TYPE_INVALID) { switch (expr_type) { // case EXPRESSION_TYPE_COMPARE_IN: // predicate_ = // std::unique_ptr<EXPRESSION_TYPE_COMPARE_IN>(new // ComparisonExpression (101)); // predicate_.DeserializeFrom(input); // break; default: { LOG_ERROR( "Expression deserialization :: Unsupported EXPRESSION_TYPE: %u ", expr_type); break; } } } // Read the type of parent PlanNodeType parent_type = (PlanNodeType)input.ReadEnumInSingleByte(); // Parent deserialization if (parent_type != PLAN_NODE_TYPE_INVALID) { switch (expr_type) { // case EXPRESSION_TYPE_COMPARE_IN: // predicate_ = // std::unique_ptr<EXPRESSION_TYPE_COMPARE_IN>(new // ComparisonExpression (101)); // predicate_.DeserializeFrom(input); // break; default: { LOG_ERROR("Parent deserialization :: Unsupported PlanNodeType: %u ", expr_type); break; } } } return true; }