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

Commit cc8751a

Browse files
Changed after Prashanth's review
1 parent 6630805 commit cc8751a

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

src/catalog/catalog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ std::shared_ptr<const storage::Layout> Catalog::CreateLayout(
579579
bool result =
580580
pg_layout->InsertLayout(table_oid, new_layout, pool_.get(), txn);
581581
if (!result) {
582-
LOG_DEBUG("Failed to create a new layout for table %u", table_oid);
582+
LOG_ERROR("Failed to create a new layout for table %u", table_oid);
583583
return nullptr;
584584
}
585585
return new_layout;

src/include/common/exception.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ enum class ExceptionType {
5959
SETTINGS = 23, // settings related
6060
BINDER = 24, // binder related
6161
NETWORK = 25, // network related
62-
OPTIMIZER = 26 // optimizer related
62+
OPTIMIZER = 26, // optimizer related
63+
NULL_POINTER = 27 // nullptr exception
6364
};
6465

6566
class Exception : public std::runtime_error {
@@ -132,6 +133,8 @@ class Exception : public std::runtime_error {
132133
return "Settings";
133134
case ExceptionType::OPTIMIZER:
134135
return "Optimizer";
136+
case ExceptionType::NULL_POINTER:
137+
return "NullPointer";
135138
default:
136139
return "Unknown";
137140
}
@@ -467,4 +470,12 @@ class OptimizerException : public Exception {
467470
: Exception(ExceptionType::OPTIMIZER, msg) {}
468471
};
469472

473+
class NullPointerException : public Exception {
474+
NullPointerException() = delete;
475+
476+
public:
477+
NullPointerException(std::string msg)
478+
: Exception(ExceptionType::NULL_POINTER, msg) {}
479+
};
480+
470481
} // namespace peloton

src/include/storage/layout.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace storage {
3434
/** @brief used to store the mapping between a tile and its columns
3535
* <tile index> to vector{<original column index, tile column offset>}
3636
*/
37-
typedef std::map<oid_t, std::vector<std::pair<oid_t, oid_t>>> tile_map_type;
37+
typedef std::map<oid_t, std::vector<std::pair<oid_t, oid_t>>> TileToColumnMap;
3838

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

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

105105
/** @brief Constructs the schema for the given layout. This function
106106
* is used only in TempTables and LogicalTiles.

src/storage/layout.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ oid_t Layout::GetTileIdFromColumnId(oid_t column_id) const {
137137
return tile_offset;
138138
}
139139

140-
tile_map_type Layout::GetTileMap() const {
141-
tile_map_type tile_map;
140+
TileToColumnMap Layout::GetTileMap() const {
141+
TileToColumnMap tile_map;
142142

143143
if (layout_type_ == LayoutType::ROW) {
144144
// Row store layout, hence all columns are contained in tile 0.

src/storage/tile_group_factory.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ TileGroup *TileGroupFactory::GetTileGroup(
3131
// Allocate the data on appropriate backend
3232
BackendType backend_type = BackendType::MM;
3333
// logging::LoggingUtil::GetBackendType(peloton_logging_mode);
34+
// Ensure that the layout of the new TileGroup is not null.
35+
if (layout == nullptr) {
36+
throw NullPointerException("Layout of the TileGroup must be non-null.");
37+
}
3438

3539
TileGroupHeader *tile_header = new TileGroupHeader(backend_type, tuple_count);
3640
TileGroup *tile_group = new TileGroup(backend_type, tile_header, table,

0 commit comments

Comments
 (0)