Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
Changed after Prashanth's review
Browse files Browse the repository at this point in the history
  • Loading branch information
poojanilangekar committed May 14, 2018
1 parent 6630805 commit cc8751a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/catalog/catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ std::shared_ptr<const storage::Layout> Catalog::CreateLayout(
bool result =
pg_layout->InsertLayout(table_oid, new_layout, pool_.get(), txn);
if (!result) {
LOG_DEBUG("Failed to create a new layout for table %u", table_oid);
LOG_ERROR("Failed to create a new layout for table %u", table_oid);
return nullptr;
}
return new_layout;
Expand Down
13 changes: 12 additions & 1 deletion src/include/common/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ enum class ExceptionType {
SETTINGS = 23, // settings related
BINDER = 24, // binder related
NETWORK = 25, // network related
OPTIMIZER = 26 // optimizer related
OPTIMIZER = 26, // optimizer related
NULL_POINTER = 27 // nullptr exception
};

class Exception : public std::runtime_error {
Expand Down Expand Up @@ -132,6 +133,8 @@ class Exception : public std::runtime_error {
return "Settings";
case ExceptionType::OPTIMIZER:
return "Optimizer";
case ExceptionType::NULL_POINTER:
return "NullPointer";
default:
return "Unknown";
}
Expand Down Expand Up @@ -467,4 +470,12 @@ class OptimizerException : public Exception {
: Exception(ExceptionType::OPTIMIZER, msg) {}
};

class NullPointerException : public Exception {
NullPointerException() = delete;

public:
NullPointerException(std::string msg)
: Exception(ExceptionType::NULL_POINTER, msg) {}
};

} // namespace peloton
4 changes: 2 additions & 2 deletions src/include/storage/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace storage {
/** @brief used to store the mapping between a tile and its columns
* <tile index> to vector{<original column index, tile column offset>}
*/
typedef std::map<oid_t, std::vector<std::pair<oid_t, oid_t>>> tile_map_type;
typedef std::map<oid_t, std::vector<std::pair<oid_t, oid_t>>> TileToColumnMap;

/**
* @brief Class to store the physical layout of a TileGroup.
Expand Down Expand Up @@ -100,7 +100,7 @@ class Layout : public Printable {
uint32_t GetColumnCount() const { return num_columns_; }

/** @brief Returns the tile-columns map for each tile in the TileGroup. */
tile_map_type GetTileMap() const;
TileToColumnMap GetTileMap() const;

/** @brief Constructs the schema for the given layout. This function
* is used only in TempTables and LogicalTiles.
Expand Down
4 changes: 2 additions & 2 deletions src/storage/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ oid_t Layout::GetTileIdFromColumnId(oid_t column_id) const {
return tile_offset;
}

tile_map_type Layout::GetTileMap() const {
tile_map_type tile_map;
TileToColumnMap Layout::GetTileMap() const {
TileToColumnMap tile_map;

if (layout_type_ == LayoutType::ROW) {
// Row store layout, hence all columns are contained in tile 0.
Expand Down
4 changes: 4 additions & 0 deletions src/storage/tile_group_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ TileGroup *TileGroupFactory::GetTileGroup(
// Allocate the data on appropriate backend
BackendType backend_type = BackendType::MM;
// logging::LoggingUtil::GetBackendType(peloton_logging_mode);
// Ensure that the layout of the new TileGroup is not null.
if (layout == nullptr) {
throw NullPointerException("Layout of the TileGroup must be non-null.");
}

TileGroupHeader *tile_header = new TileGroupHeader(backend_type, tuple_count);
TileGroup *tile_group = new TileGroup(backend_type, tile_header, table,
Expand Down

0 comments on commit cc8751a

Please sign in to comment.