Example #1
0
// Compare two tiles (expensive !)
bool Tile::operator==(const Tile &other) const {
  if (!(GetColumnCount() == other.GetColumnCount())) return false;

  if (!(database_id == other.database_id)) return false;

  catalog::Schema other_schema = other.schema;
  if (schema != other_schema) return false;

  TupleIterator tile_itr(this);
  TupleIterator other_tile_itr(&other);

  Tuple tuple(&schema);
  Tuple other_tuple(&other_schema);

  while (tile_itr.Next(tuple)) {
    if (!(other_tile_itr.Next(other_tuple))) return false;

    if (!(tuple == other_tuple)) return false;
  }

  tuple.SetNull();
  other_tuple.SetNull();

  return true;
}
Example #2
0
const std::string Tile::GetInfo() const {
    std::ostringstream os;

    os << "\t-----------------------------------------------------------\n";

    os << "\tTILE\n";
    os << "\tCatalog ::"
       << " DB: " << database_id << " Table: " << table_id
       << " Tile Group:  " << tile_group_id << " Tile:  " << tile_id << "\n";

    // Tuples
    os << "\t-----------------------------------------------------------\n";
    os << "\tDATA\n";

    TupleIterator tile_itr(this);
    Tuple tuple(&schema);

    std::string last_tuple = "";

    while (tile_itr.Next(tuple)) {
        os << "\t" << tuple;
    }

    os << "\t-----------------------------------------------------------\n";

    tuple.SetNull();

    return os.str();
}
Example #3
0
bool Tile::SerializeTo(SerializeOutput &output, oid_t num_tuples) {
  /**
   * The table is serialized as:
   *
   * [(int) total size]
   * [(int) header size] [num columns] [column types] [column names]
   * [(int) num tuples] [tuple data]
   *
   */

  // A placeholder for the total table size written at the end
  std::size_t pos = output.Position();
  output.WriteInt(-1);

  // Serialize the header
  if (!SerializeHeaderTo(output)) return false;

  // Active tuple count
  output.WriteInt(static_cast<int>(num_tuples));

  oid_t written_count = 0;
  TupleIterator tile_itr(this);
  Tuple tuple(&schema);

  while (tile_itr.Next(tuple) && written_count < num_tuples) {
    tuple.SerializeTo(output);
    ++written_count;
  }

  tuple.SetNull();

  PL_ASSERT(written_count == num_tuples);

  // Length prefix is non-inclusive
  int32_t sz = static_cast<int32_t>(output.Position() - pos - sizeof(int32_t));
  PL_ASSERT(sz > 0);
  output.WriteIntAt(pos, sz);

  return true;
}
Example #4
0
const std::string Tile::GetInfo() const {
  std::ostringstream os;

  os << "TILE[#" << tile_id << "]" << std::endl;
  os << "Database[" << database_id << "] // ";
  os << "Table[" << table_id << "] // ";
  os << "TileGroup[" << tile_group_id << "]" << std::endl;

  // Tuples
  os << GETINFO_SINGLE_LINE << std::endl;

  TupleIterator tile_itr(this);
  Tuple tuple(&schema);

  int tupleCtr = 0;
  while (tile_itr.Next(tuple)) {
    if (tupleCtr > 0) os << std::endl;
    os << std::setfill('0') << std::setw(TUPLE_ID_WIDTH) << tupleCtr++ << ": ";
    os << tuple;
  }
  tuple.SetNull();

  return os.str();
}