This repository was archived by the owner on Sep 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 618
/
Copy pathcolumn.cpp
77 lines (64 loc) · 1.62 KB
/
column.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//===----------------------------------------------------------------------===//
//
// Peloton
//
// column.cpp
//
// Identification: src/catalog/column.cpp
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#include "catalog/column.h"
#include <sstream>
#include "common/internal_types.h"
namespace peloton {
namespace catalog {
void Column::SetLength(size_t column_length) {
// Set the column length based on whether it is inlined
if (is_inlined) {
fixed_length = column_length;
variable_length = 0;
} else {
fixed_length = sizeof(uintptr_t);
variable_length = column_length;
}
}
void Column::SetInlined() {
switch (column_type) {
case type::TypeId::VARCHAR:
case type::TypeId::VARBINARY:
is_inlined = false;
break; // No change of inlined setting
default:
is_inlined = true;
break;
}
}
const std::string Column::GetInfo() const {
std::ostringstream os;
os << "Column[" << column_name << ", " << TypeIdToString(column_type) << ", "
<< "Offset:" << column_offset << ", ";
if (is_inlined) {
os << "FixedLength:" << fixed_length;
} else {
os << "VarLength:" << variable_length;
}
if (constraints.empty() == false) {
os << ", {";
bool first = true;
for (auto constraint : constraints) {
if (first) {
first = false;
} else {
os << ", ";
}
os << constraint.GetInfo();
}
os << "}";
}
os << "]";
return (os.str());
}
} // namespace catalog
} // namespace peloton