chaoyli commented on a change in pull request #1561: Unify Field and
ColumnSchema in Storage
URL: https://github.com/apache/incubator-doris/pull/1561#discussion_r308290412
##########
File path: be/src/olap/schema.h
##########
@@ -81,58 +99,51 @@ class Schema {
reset(cols, num_key_columns);
}
- Schema(const std::vector<ColumnSchema>& cols, size_t num_key_columns) {
+ Schema(const std::vector<TabletColumn>& columns, const
std::vector<ColumnId>& col_ids) {
+ std::vector<Field> cols;
+ size_t num_key_columns = 0;
+ for (int i = 0; i < columns.size(); ++i) {
+ const TabletColumn& column = columns[i];
+ cols.emplace_back(column.aggregation(), column.type(),
column.index_length(), column.is_nullable());
+ if (column.is_key()) {
+ num_key_columns++;
+ }
+ }
+
+ reset(cols, col_ids, num_key_columns);
+ }
+
+ Schema(const std::vector<Field>& cols, size_t num_key_columns) {
reset(cols, num_key_columns);
}
- void reset(const std::vector<ColumnSchema>& cols, size_t num_key_columns);
+ Schema(const Schema&);
+ Schema& operator=(const Schema& other);
- const std::vector<ColumnSchema>& columns() const { return _cols; }
- const ColumnSchema& column(int idx) const { return _cols[idx]; }
+ void copy_from(const Schema& other);
- int compare(const RowBlockRow& lhs, const RowBlockRow& rhs) const;
- int compare(const char* left , const char* right) const {
- for (size_t i = 0; i < _num_key_columns; ++i) {
- auto col_offset = _col_offsets[i];
+ ~Schema();
- bool l_null = *reinterpret_cast<const bool*>(left + col_offset);
- bool r_null = *reinterpret_cast<const bool*>(right + col_offset);
- if (l_null != r_null) {
- return l_null ? -1 : 1;
- } else if (l_null) {
- continue;
- }
+ void reset(const std::vector<Field>& cols, size_t num_key_columns);
- // skip null byte
- col_offset += 1;
- int cmp = _cols[i].compare(left + col_offset, right + col_offset);
- if (cmp != 0) {
- return cmp;
- }
- }
- return 0;
- }
+ void reset(const std::vector<Field>& cols,
+ const std::vector<ColumnId>& col_ids,
+ size_t num_key_columns);
- void aggregate(char* left, const char* right, Arena* arena) const {
- for (size_t i = _num_key_columns; i < _cols.size(); ++i) {
- auto col_offset = _col_offsets[i];
- _cols[i].aggregate(left + col_offset, right + col_offset, arena);
- }
- }
+ const std::vector<Field*>& columns() const { return _cols; }
+ const Field* column(int idx) const { return _cols[idx]; }
- void finalize(char* data) const {
- for (int col_id : _hll_col_ids) {
- auto col_offset = _col_offsets[col_id];
- _cols[col_id].finalize(data + col_offset);
- }
- }
+ size_t num_key_columns() const { return _num_key_columns; }
- int get_col_offset(int index) const {
- return _col_offsets[index];
+ size_t column_offset(ColumnId cid) const {
+ return _col_offsets[cid];
}
- size_t get_col_size(int index) const {
- return _cols[index].size();
+ size_t column_size(ColumnId cid) const {
+ return _cols[cid]->size();
+ }
Review comment:
new line
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]