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

Commit 6630805

Browse files
Address Pervaze's review comments.
1 parent ecb95bb commit 6630805

File tree

11 files changed

+48
-46
lines changed

11 files changed

+48
-46
lines changed

src/catalog/catalog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ ResultType Catalog::CreateTable(const std::string &database_name,
299299
const std::string &table_name,
300300
std::unique_ptr<catalog::Schema> schema,
301301
concurrency::TransactionContext *txn,
302-
bool is_catalog, oid_t tuples_per_tilegroup,
302+
bool is_catalog, uint32_t tuples_per_tilegroup,
303303
peloton::LayoutType layout_type) {
304304
if (txn == nullptr)
305305
throw CatalogException("Do not have transaction to create table " +

src/gc/gc_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ namespace gc {
2525
// Check a tuple and reclaim all varlen field
2626
void GCManager::CheckAndReclaimVarlenColumns(storage::TileGroup *tile_group,
2727
oid_t tuple_id) {
28-
oid_t tile_count = tile_group->tile_count_;
29-
oid_t tile_col_count;
28+
uint32_t tile_count = tile_group->tile_count_;
29+
uint32_t tile_col_count;
3030
type::TypeId type_id;
3131
char *tuple_location;
3232
char *field_location;

src/include/catalog/catalog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Catalog {
100100
const std::string &database_name, const std::string &schema_name,
101101
const std::string &table_name, std::unique_ptr<catalog::Schema>,
102102
concurrency::TransactionContext *txn, bool is_catalog = false,
103-
oid_t tuples_per_tilegroup = DEFAULT_TUPLES_PER_TILEGROUP,
103+
uint32_t tuples_per_tilegroup = DEFAULT_TUPLES_PER_TILEGROUP,
104104
peloton::LayoutType layout_type = LayoutType::ROW);
105105

106106
// Create index for a table

src/include/storage/layout.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,15 @@ class Layout : public Printable {
7575
/** @brief Return the layout_oid_ of this object. */
7676
oid_t GetOid() const { return layout_oid_; }
7777

78-
/** @brief Sets the tile id and column id w.r.t. of the tile corresponding
79-
* to the specified tile group column id.
78+
/** @brief Locates the tile and column to which the specified
79+
* specified tile group column_id.
80+
* It updates the tile_id and tile_column_id references.
81+
* @param column_id The Id of the column to be located.
82+
* @param tile_id A reference to update the tile_id.
83+
* @param tile_column_id A reference to update the tile_column_id.
8084
*/
81-
void LocateTileAndColumn(oid_t column_offset, oid_t &tile_offset,
82-
oid_t &tile_column_offset) const;
85+
void LocateTileAndColumn(oid_t column_id, oid_t &tile_id,
86+
oid_t &tile_column_id) const;
8387

8488
/** @brief Returns the layout difference w.r.t. the other Layout.
8589
* @double The delta between the layouts. Used by LayoutTuner class.
@@ -93,7 +97,7 @@ class Layout : public Printable {
9397
oid_t GetTileColumnOffset(oid_t column_id) const;
9498

9599
/** @brief Returns the number of columns in the layout. */
96-
oid_t GetColumnCount() const { return num_columns_; }
100+
uint32_t GetColumnCount() const { return num_columns_; }
97101

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

src/include/storage/tile_group.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ class TileGroup : public Printable {
118118
// this function is called only when building tile groups for aggregation
119119
// operations.
120120
// FIXME: GC has recycled some of the tuples, so this count is not accurate
121-
oid_t GetActiveTupleCount() const;
121+
uint32_t GetActiveTupleCount() const;
122122

123-
oid_t GetAllocatedTupleCount() const { return num_tuple_slots; }
123+
uint32_t GetAllocatedTupleCount() const { return num_tuple_slots_; }
124124

125125
TileGroupHeader *GetHeader() const { return tile_group_header; }
126126

@@ -187,10 +187,10 @@ class TileGroup : public Printable {
187187
AbstractTable *table; // this design is fantastic!!!
188188

189189
// number of tuple slots allocated
190-
oid_t num_tuple_slots;
190+
uint32_t num_tuple_slots_;
191191

192192
// number of tiles
193-
oid_t tile_count_;
193+
uint32_t tile_count_;
194194

195195
std::mutex tile_group_mutex;
196196

src/optimizer/stats/tuple_sampler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool TupleSampler::GetTupleInTileGroup(storage::TileGroup *tile_group,
9898

9999
storage::Tile *tile = tile_group->GetTile(tile_itr);
100100
const catalog::Schema &schema = *(tile->GetSchema());
101-
oid_t tile_column_count = schema.GetColumnCount();
101+
uint32_t tile_column_count = schema.GetColumnCount();
102102

103103
char *tile_tuple_location = tile->GetTupleLocation(tuple_offset);
104104
storage::Tuple tile_tuple(&schema, tile_tuple_location);

src/storage/data_table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ std::vector<catalog::Schema> TransformTileGroupSchema(
12031203
// First, get info from the original tile group's schema
12041204
std::map<oid_t, std::map<oid_t, catalog::Column>> schemas;
12051205

1206-
oid_t column_count = layout.GetColumnCount();
1206+
uint32_t column_count = layout.GetColumnCount();
12071207
for (oid_t col_id = 0; col_id < column_count; col_id++) {
12081208
// Get TileGroup layout's tile and offset for col_id.
12091209
tile_group_layout.LocateTileAndColumn(col_id, orig_tile_offset,

src/storage/layout.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,32 @@ Layout::Layout(const column_map_type &column_map, oid_t layout_id)
8181
}
8282
}
8383

84-
// Sets the tile id and column id w.r.t that tile corresponding to
85-
// the specified tile group column id.
86-
void Layout::LocateTileAndColumn(oid_t column_offset, oid_t &tile_offset,
87-
oid_t &tile_column_offset) const {
84+
void Layout::LocateTileAndColumn(oid_t column_id, oid_t &tile_id,
85+
oid_t &tile_column_id) const {
8886
// Ensure that the column_offset is not out of bound
89-
PELOTON_ASSERT(num_columns_ > column_offset);
87+
PELOTON_ASSERT(num_columns_ > column_id);
9088

91-
// For row store layout, tile id is always 0 and the tile
92-
// column_id and tile column_id is the same.
89+
// For row store layout, tile_id is always 0 and the
90+
// column_id and tile column_id are the same.
9391
if (layout_type_ == LayoutType::ROW) {
94-
tile_offset = 0;
95-
tile_column_offset = column_offset;
92+
tile_id = 0;
93+
tile_column_id = column_id;
9694
return;
9795
}
9896

99-
// For column store layout, tile_id is always same as column_id
100-
// and the tile column_id is always 0.
97+
// For column store layout, tile_id is same as column_id
98+
// and the tile_column_id is always 0.
10199
if (layout_type_ == LayoutType::COLUMN) {
102-
tile_offset = column_offset;
103-
tile_column_offset = 0;
100+
tile_id = column_id;
101+
tile_column_id = 0;
104102
return;
105103
}
106104

107105
// For other layouts, fetch the layout and
108106
// get the entry in the column map
109-
auto entry = column_layout_.at(column_offset);
110-
tile_offset = entry.first;
111-
tile_column_offset = entry.second;
107+
auto entry = column_layout_.at(column_id);
108+
tile_id = entry.first;
109+
tile_column_id = entry.second;
112110
}
113111

114112
double Layout::GetLayoutDifference(const storage::Layout &other) const {

src/storage/tile_group.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ TileGroup::TileGroup(BackendType backend_type,
3939
backend_type(backend_type),
4040
tile_group_header(tile_group_header),
4141
table(table),
42-
num_tuple_slots(tuple_count),
42+
num_tuple_slots_(tuple_count),
4343
tile_group_layout_(layout) {
4444
tile_count_ = schemas.size();
4545
for (oid_t tile_itr = 0; tile_itr < tile_count_; tile_itr++) {
@@ -102,7 +102,7 @@ oid_t TileGroup::GetActiveTupleCount() const {
102102
*/
103103
void TileGroup::CopyTuple(const Tuple *tuple, const oid_t &tuple_slot_id) {
104104
LOG_TRACE("Tile Group Id :: %u status :: %u out of %u slots ", tile_group_id,
105-
tuple_slot_id, num_tuple_slots);
105+
tuple_slot_id, num_tuple_slots_);
106106

107107
oid_t tile_column_count;
108108
oid_t column_itr = 0;
@@ -136,7 +136,7 @@ oid_t TileGroup::InsertTuple(const Tuple *tuple) {
136136
oid_t tuple_slot_id = tile_group_header->GetNextEmptyTupleSlot();
137137

138138
LOG_TRACE("Tile Group Id :: %u status :: %u out of %u slots ", tile_group_id,
139-
tuple_slot_id, num_tuple_slots);
139+
tuple_slot_id, num_tuple_slots_);
140140

141141
// No more slots
142142
if (tuple_slot_id == INVALID_OID) {
@@ -183,7 +183,7 @@ oid_t TileGroup::InsertTupleFromRecovery(cid_t commit_id, oid_t tuple_slot_id,
183183
}
184184

185185
LOG_TRACE("Tile Group Id :: %u status :: %u out of %u slots ", tile_group_id,
186-
tuple_slot_id, num_tuple_slots);
186+
tuple_slot_id, num_tuple_slots_);
187187

188188
oid_t tile_column_count;
189189
oid_t column_itr = 0;
@@ -282,7 +282,7 @@ oid_t TileGroup::InsertTupleFromCheckpoint(oid_t tuple_slot_id,
282282
if (status == false) return INVALID_OID;
283283

284284
LOG_TRACE("Tile Group Id :: %u status :: %u out of %u slots ", tile_group_id,
285-
tuple_slot_id, num_tuple_slots);
285+
tuple_slot_id, num_tuple_slots_);
286286

287287
oid_t tile_column_count;
288288
oid_t column_itr = 0;

test/codegen/table_scan_translator_test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,9 @@ TEST_F(TableScanTranslatorTest, ScanRowLayout) {
634634
// Creates a table with LayoutType::ROW and
635635
// invokes the TableScanTranslator
636636
//
637-
oid_t tuples_per_tilegroup = 100;
638-
oid_t tilegroup_count = 5;
639-
oid_t column_count = 100;
637+
uint32_t tuples_per_tilegroup = 100;
638+
uint32_t tilegroup_count = 5;
639+
uint32_t column_count = 100;
640640
bool is_inlined = true;
641641
CreateAndLoadTableWithLayout(LayoutType::ROW, tuples_per_tilegroup,
642642
tilegroup_count, column_count, is_inlined);
@@ -648,9 +648,9 @@ TEST_F(TableScanTranslatorTest, ScanColumnLayout) {
648648
// Creates a table with LayoutType::COLUMN and
649649
// invokes the TableScanTranslator
650650
//
651-
oid_t tuples_per_tilegroup = 100;
652-
oid_t tilegroup_count = 5;
653-
oid_t column_count = 100;
651+
uint32_t tuples_per_tilegroup = 100;
652+
uint32_t tilegroup_count = 5;
653+
uint32_t column_count = 100;
654654
bool is_inlined = true;
655655
CreateAndLoadTableWithLayout(LayoutType::COLUMN, tuples_per_tilegroup,
656656
tilegroup_count, column_count, is_inlined);
@@ -670,7 +670,7 @@ TEST_F(TableScanTranslatorTest, MultiLayoutScan) {
670670
const int tuples_per_tilegroup = 100;
671671
const int col_count = 6;
672672
const bool is_inlined = true;
673-
oid_t tuple_count = 100;
673+
uint32_t tuple_count = 100;
674674

675675
/////////////////////////////////////////////////////////
676676
// Define the schema.

0 commit comments

Comments
 (0)