Skip to content

Commit

Permalink
[enhancement][diagnostics] Add a diagnostic: detect unused includes (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
adonis0147 authored Jun 8, 2022
1 parent b15b1a9 commit fc9afda
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 45 deletions.
20 changes: 20 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

Diagnostics:
UnusedIncludes: Strict

2 changes: 1 addition & 1 deletion be/src/exprs/agg_fn_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ bool AggFnEvaluator::count_distinct_data_filter(TupleRow* row, Tuple* dst) {
total_len += string_len;
}

total_len += get_real_byte_size(input_expr_ctxs()[i]->root()->type().type);
total_len += get_byte_size(input_expr_ctxs()[i]->root()->type().type);
}

int32_t vec_size = vec_string_len.size();
Expand Down
43 changes: 0 additions & 43 deletions be/src/runtime/primitive_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,49 +158,6 @@ int get_byte_size(PrimitiveType type) {
return 0;
}

int get_real_byte_size(PrimitiveType type) {
switch (type) {
case TYPE_OBJECT:
case TYPE_QUANTILE_STATE:
case TYPE_HLL:
case TYPE_VARCHAR:
case TYPE_STRING:
case TYPE_ARRAY:
return 0;

case TYPE_NULL:
case TYPE_BOOLEAN:
case TYPE_TINYINT:
return 1;

case TYPE_SMALLINT:
return 2;

case TYPE_INT:
case TYPE_FLOAT:
return 4;

case TYPE_BIGINT:
case TYPE_TIME:
case TYPE_DOUBLE:
return 8;

case TYPE_DATETIME:
case TYPE_DATE:
case TYPE_DECIMALV2:
return 16;

case TYPE_LARGEINT:
return 16;

case INVALID_TYPE:
default:
DCHECK(false);
}

return 0;
}

bool is_type_compatible(PrimitiveType lhs, PrimitiveType rhs) {
if (lhs == TYPE_VARCHAR) {
return rhs == TYPE_CHAR || rhs == TYPE_VARCHAR || rhs == TYPE_HLL || rhs == TYPE_OBJECT ||
Expand Down
1 change: 0 additions & 1 deletion be/src/runtime/primitive_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ bool has_variable_type(PrimitiveType type);

// Returns the byte size of 'type' Returns 0 for variable length types.
int get_byte_size(PrimitiveType type);
int get_real_byte_size(PrimitiveType type);
// Returns the byte size of type when in a tuple
int get_slot_size(PrimitiveType type);

Expand Down

0 comments on commit fc9afda

Please sign in to comment.