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

Commit 0c97e2b

Browse files
committed
Fix some reviewed stuff
1 parent d0ccb48 commit 0c97e2b

File tree

9 files changed

+25
-27
lines changed

9 files changed

+25
-27
lines changed

src/catalog/catalog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,22 @@ void Catalog::BootstrapSystemCatalogs(storage::Database *database,
169169
// pg_database record is shared across different databases
170170
system_catalogs->GetTableCatalog()->InsertTable(
171171
DATABASE_CATALOG_OID, DATABASE_CATALOG_NAME, CATALOG_SCHEMA_NAME,
172-
CATALOG_DATABASE_OID, 0, pool_.get(), txn);
172+
CATALOG_DATABASE_OID, ROW_STORE_LAYOUT_OID, pool_.get(), txn);
173173
system_catalogs->GetTableCatalog()->InsertTable(
174174
SCHEMA_CATALOG_OID, SCHEMA_CATALOG_NAME, CATALOG_SCHEMA_NAME,
175-
database_oid, 0, pool_.get(), txn);
175+
database_oid, ROW_STORE_LAYOUT_OID, pool_.get(), txn);
176176
system_catalogs->GetTableCatalog()->InsertTable(
177177
TABLE_CATALOG_OID, TABLE_CATALOG_NAME, CATALOG_SCHEMA_NAME, database_oid,
178-
0, pool_.get(), txn);
178+
ROW_STORE_LAYOUT_OID, pool_.get(), txn);
179179
system_catalogs->GetTableCatalog()->InsertTable(
180180
INDEX_CATALOG_OID, INDEX_CATALOG_NAME, CATALOG_SCHEMA_NAME, database_oid,
181-
0, pool_.get(), txn);
181+
ROW_STORE_LAYOUT_OID, pool_.get(), txn);
182182
system_catalogs->GetTableCatalog()->InsertTable(
183183
COLUMN_CATALOG_OID, COLUMN_CATALOG_NAME, CATALOG_SCHEMA_NAME,
184-
database_oid, 0, pool_.get(), txn);
184+
database_oid, ROW_STORE_LAYOUT_OID, pool_.get(), txn);
185185
system_catalogs->GetTableCatalog()->InsertTable(
186186
LAYOUT_CATALOG_OID, LAYOUT_CATALOG_NAME, CATALOG_SCHEMA_NAME,
187-
database_oid, 0, pool_.get(), txn);
187+
database_oid, ROW_STORE_LAYOUT_OID, pool_.get(), txn);
188188
}
189189

190190
void Catalog::Bootstrap() {

src/catalog/column_catalog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ColumnCatalogObject::ColumnCatalogObject(executor::LogicalTile *tile,
3939
.ToString())),
4040
column_length(
4141
tile->GetValue(tupleId, ColumnCatalog::ColumnId::COLUMN_LENGTH)
42-
.GetAs<size_t>()),
42+
.GetAs<uint32_t>()),
4343
is_inlined(tile->GetValue(tupleId, ColumnCatalog::ColumnId::IS_INLINED)
4444
.GetAs<bool>()),
4545
is_primary(tile->GetValue(tupleId, ColumnCatalog::ColumnId::IS_PRIMARY)
@@ -113,7 +113,7 @@ std::unique_ptr<catalog::Schema> ColumnCatalog::InitializeSchema() {
113113
catalog::Constraint(ConstraintType::NOTNULL, not_null_constraint_name));
114114

115115
auto column_length_column = catalog::Column(
116-
type::TypeId::BIGINT, type::Type::GetTypeSize(type::TypeId::BIGINT),
116+
type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER),
117117
"column_length", true);
118118
column_length_column.AddConstraint(
119119
catalog::Constraint(ConstraintType::NOTNULL, not_null_constraint_name));
@@ -162,7 +162,7 @@ bool ColumnCatalog::InsertColumn(oid_t table_oid,
162162
auto val3 = type::ValueFactory::GetIntegerValue(column_offset);
163163
auto val4 =
164164
type::ValueFactory::GetVarcharValue(TypeIdToString(column_type), nullptr);
165-
auto val5 = type::ValueFactory::GetBigIntValue(column_length);
165+
auto val5 = type::ValueFactory::GetIntegerValue(column_length);
166166
auto val6 = type::ValueFactory::GetBooleanValue(is_inlined);
167167
bool is_primary = false, is_not_null = false;
168168
for (auto constraint : constraints) {

src/catalog/system_catalogs.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ void SystemCatalogs::Bootstrap(const std::string &database_name,
114114
pg_namespace_->UpdateOid(OID_FOR_USER_OFFSET);
115115
pg_table_->UpdateOid(OID_FOR_USER_OFFSET);
116116
pg_index_->UpdateOid(OID_FOR_USER_OFFSET);
117-
// pg_layout_->UpdateOid(OID_FOR_USER_OFFSET);
118117
pg_trigger_->UpdateOid(OID_FOR_USER_OFFSET);
119118
// pg_proc->UpdateOid(OID_FOR_USER_OFFSET);
120119
}

src/catalog/table_catalog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ bool TableCatalog::UpdateVersionId(oid_t update_val, oid_t table_oid,
696696
*/
697697
bool TableCatalog::UpdateDefaultLayoutOid(oid_t update_val, oid_t table_oid,
698698
concurrency::TransactionContext *txn) {
699-
std::vector<oid_t> update_columns({ColumnId::DEFAULT_LAYOUT_OID}); // defalut_layou_oid
699+
std::vector<oid_t> update_columns({ColumnId::DEFAULT_LAYOUT_OID}); // defalut_layout_oid
700700
oid_t index_offset = IndexId::PRIMARY_KEY; // Index of table_oid
701701
// values to execute index scan
702702
std::vector<type::Value> scan_values;

src/include/catalog/catalog_defaults.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ namespace catalog {
5858
#define CATALOG_SCHEMA_NAME "pg_catalog"
5959
#define DEFAULT_SCHEMA_NAME "public"
6060

61+
// Reserved layout oid
62+
#define ROW_STORE_LAYOUT_OID 0
63+
#define COLUMN_STORE_LAYOUT_OID 1
64+
6165
// Reserved pg_xxx table oid
6266
#define DATABASE_CATALOG_OID (0 | TABLE_OID_MASK)
6367
#define SCHEMA_CATALOG_OID (1 | TABLE_OID_MASK)

src/include/storage/layout.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
#include "common/internal_types.h"
1818
#include "common/printable.h"
1919

20-
//@{
21-
/** @brief Pre-defined OIDs for ROW and COLUMN store. */
22-
#define ROW_STORE_OID 0
23-
#define COLUMN_STORE_OID 1
24-
//@}
25-
2620
namespace peloton {
2721

2822
namespace catalog {

src/storage/data_table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ DataTable::DataTable(catalog::Schema *schema, const std::string &table_name,
6767
database_oid(database_oid),
6868
table_name(table_name),
6969
tuples_per_tilegroup_(tuples_per_tilegroup),
70-
current_layout_oid_(ATOMIC_VAR_INIT(COLUMN_STORE_OID)),
70+
current_layout_oid_(ATOMIC_VAR_INIT(COLUMN_STORE_LAYOUT_OID)),
7171
adapt_table_(adapt_table),
7272
trigger_list_(new trigger::TriggerList()) {
7373
if (is_catalog == true) {

src/storage/layout.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <sstream>
1414
#include <string>
1515

16+
#include "catalog/catalog_defaults.h"
1617
#include "catalog/column.h"
1718
#include "catalog/schema.h"
1819
#include "storage/layout.h"
@@ -27,9 +28,9 @@ Layout::Layout(const oid_t num_columns, LayoutType layout_type)
2728
: num_columns_(num_columns), layout_type_(layout_type) {
2829
// Assign the oid
2930
if (layout_type == LayoutType::ROW) {
30-
layout_oid_ = ROW_STORE_OID;
31+
layout_oid_ = ROW_STORE_LAYOUT_OID;
3132
} else if (layout_type == LayoutType::COLUMN) {
32-
layout_oid_ = COLUMN_STORE_OID;
33+
layout_oid_ = COLUMN_STORE_LAYOUT_OID;
3334
} else {
3435
layout_oid_ = INVALID_OID;
3536
}
@@ -53,10 +54,10 @@ Layout::Layout(const column_map_type &column_map)
5354
// If a table has one column, it would be LayoutType::Row
5455
if (row_layout) {
5556
layout_type_ = LayoutType::ROW;
56-
layout_oid_ = ROW_STORE_OID;
57+
layout_oid_ = ROW_STORE_LAYOUT_OID;
5758
} else if (column_layout) {
5859
layout_type_ = LayoutType::COLUMN;
59-
layout_oid_ = COLUMN_STORE_OID;
60+
layout_oid_ = COLUMN_STORE_LAYOUT_OID;
6061
} else {
6162
// layout_oid_ is set to INVALID_OID, indicating that this
6263
// layout is not stored in the catalog and thus not persistent.
@@ -77,9 +78,9 @@ Layout::Layout(const column_map_type &column_map, const oid_t num_columns,
7778
: layout_oid_(layout_id),
7879
num_columns_(num_columns),
7980
column_layout_(column_map) {
80-
if (layout_oid_ == ROW_STORE_OID) {
81+
if (layout_oid_ == ROW_STORE_LAYOUT_OID) {
8182
layout_type_ = LayoutType::ROW;
82-
} else if (layout_oid_ == COLUMN_STORE_OID) {
83+
} else if (layout_oid_ == COLUMN_STORE_LAYOUT_OID) {
8384
layout_type_ = LayoutType::COLUMN;
8485
} else {
8586
layout_type_ = LayoutType::HYBRID;

test/catalog/catalog_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ TEST_F(CatalogTests, LayoutCatalogTest) {
385385

386386
// Check the first default layout
387387
auto first_default_layout = table->GetDefaultLayout();
388-
EXPECT_EQ(0, first_default_layout->GetOid());
388+
EXPECT_EQ(ROW_STORE_LAYOUT_OID, first_default_layout->GetOid());
389389
EXPECT_TRUE(first_default_layout->IsRowStore());
390390

391391
// Check the first default layout in pg_layout and pg_table
@@ -465,13 +465,13 @@ TEST_F(CatalogTests, LayoutCatalogTest) {
465465
// Check that default layout is reset and set to row_store.
466466
EXPECT_NE(default_layout, table->GetDefaultLayout());
467467
EXPECT_TRUE(table->GetDefaultLayout()->IsRowStore());
468-
EXPECT_EQ(0, table->GetDefaultLayout()->GetOid());
468+
EXPECT_EQ(ROW_STORE_LAYOUT_OID, table->GetDefaultLayout()->GetOid());
469469

470470
// Query pg_layout and pg_table to ensure that the entry is dropped
471471
txn = txn_manager.BeginTransaction();
472472
EXPECT_EQ(nullptr,
473473
pg_layout->GetLayoutWithOid(table_oid, default_layout_oid, txn));
474-
EXPECT_EQ(0,
474+
EXPECT_EQ(ROW_STORE_LAYOUT_OID,
475475
catalog->GetTableObject(database_oid, table_oid, txn)->GetDefaultLayoutOid());
476476

477477
// The additional layout must be present in pg_layout

0 commit comments

Comments
 (0)