Beispiel #1
0
/**
 * 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(SerializeInputBE &input, VarlenPool *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();
  assert(column_count > 0);

  // Store the following information so that we can provide them to the user on
  // failure
  ValueType 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] = (ValueType) 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 = " << ValueTypeToString(types[column_itr])
              << std::endl;
    }

    throw SerializationException(message.str());
  }

  // Use the deserialization routine skipping header
  DeserializeTuplesFromWithoutHeader(input, pool);
}
Beispiel #2
0
/**
 * Loads only tuple data and assumes there is no schema present.
 * Used for recovery where the schema is not sent.
 * @param allow_export if false, export enabled is overriden for this load.
 */
void Tile::DeserializeTuplesFromWithoutHeader(SerializeInputBE &input,
                                              VarlenPool *pool) {
  oid_t tuple_count = input.ReadInt();
  assert(tuple_count > 0);

  // First, check if we have required space
  assert(tuple_count <= num_tuple_slots);
  storage::Tuple *temp_tuple = new storage::Tuple(&schema, true);

  for (oid_t tuple_itr = 0; tuple_itr < tuple_count; ++tuple_itr) {
    temp_tuple->Move(GetTupleLocation(tuple_itr));
    temp_tuple->DeserializeFrom(input, pool);
    // TRACE("Loaded new tuple #%02d\n%s", tuple_itr,
    // temp_target1.debug(Name()).c_str());
  }
}
Beispiel #3
0
void Tuple::DeserializeWithHeaderFrom(SerializeInputBE &input) {
  PL_ASSERT(tuple_schema);
  PL_ASSERT(tuple_data);

  input.ReadInt();  // Read in the tuple size, discard

  const int column_count = tuple_schema->GetColumnCount();

  for (int column_itr = 0; column_itr < column_count; column_itr++) {
    const ValueType type = tuple_schema->GetType(column_itr);

    const bool is_inlined = tuple_schema->IsInlined(column_itr);
    char *data_ptr = GetDataPtr(column_itr);
    const int32_t column_length = tuple_schema->GetLength(column_itr);

    // TODO: Not sure about arguments
    const bool is_in_bytes = false;
    Value::DeserializeFrom(input, NULL, data_ptr, type, is_inlined,
                           column_length, is_in_bytes);
  }
}
Beispiel #4
0
void Tuple::DeserializeFrom(SerializeInputBE &input, VarlenPool *dataPool) {
  PL_ASSERT(tuple_schema);
  PL_ASSERT(tuple_data);

  input.ReadInt();
  const int column_count = tuple_schema->GetColumnCount();

  for (int column_itr = 0; column_itr < column_count; column_itr++) {
    const ValueType type = tuple_schema->GetType(column_itr);

    /**
     * DeserializeFrom is only called when we serialize/deserialize tables.
     * The serialization format for Strings/Objects in a serialized table
     * happens to have the same in memory representation as the Strings/Objects
     * in a Tuple. The goal here is to wrap the serialized representation of
     * the value in an Value and then serialize that into the tuple from the
     * Value. This makes it possible to push more value specific functionality
     * out of Tuple. The memory allocation will be performed when serializing
     * to tuple storage.
     */
    const bool is_inlined = tuple_schema->IsInlined(column_itr);
    int32_t column_length;
    char *data_ptr = GetDataPtr(column_itr);

    if (is_inlined) {
      column_length = tuple_schema->GetLength(column_itr);
    } else {
      column_length = tuple_schema->GetVariableLength(column_itr);
    }

    // TODO: Not sure about arguments
    const bool is_in_bytes = false;
    Value::DeserializeFrom(input, dataPool, data_ptr, type, is_inlined,
                           column_length, is_in_bytes);
  }
}