Skip to content

Commit

Permalink
Whitespaces #2429
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed Jun 6, 2018
1 parent 15e96c0 commit 37bd5f1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions dbms/src/Functions/FunctionsString.cpp
Expand Up @@ -1082,7 +1082,7 @@ class FunctionAppendTrailingCharIfAbsent : public IFunction
ErrorCodes::ILLEGAL_COLUMN};
}
};


template <typename Name>
class FunctionStartsEndsWith : public IFunction
Expand All @@ -1093,49 +1093,49 @@ class FunctionStartsEndsWith : public IFunction
{
return std::make_shared<FunctionStartsEndsWith>();
}

String getName() const override
{
return name;
}

size_t getNumberOfArguments() const override
{
return 2;
}

bool useDefaultImplementationForConstants() const override
{
return true;
}

DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{
if (!arguments[0]->isStringOrFixedString())
throw Exception(
"Illegal type " + arguments[0]->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);

if (!arguments[1]->isStringOrFixedString())
throw Exception(
"Illegal type " + arguments[1]->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);

return std::make_shared<DataTypeNumber<UInt8>>();
}

void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t /*input_rows_count*/) override
{
const IColumn * string_columns = block.getByPosition(arguments[0]).column.get();
const IColumn * template_columns = block.getByPosition(arguments[1]).column.get();

const ColumnString * strings = checkAndGetColumn<ColumnString>(string_columns);
const ColumnString * templates = checkAndGetColumn<ColumnString>(template_columns);
const ColumnFixedString * fixed_strings = checkAndGetColumn<ColumnFixedString>(string_columns);
const ColumnFixedString * fixed_templates = checkAndGetColumn<ColumnFixedString>(template_columns);
const ColumnConst * const_templates = checkAndGetColumn<ColumnConst>(template_columns);

auto col_res = ColumnVector<UInt8>::create();
typename ColumnVector<UInt8>::Container & vec_res = col_res->getData();

FunctionName functionName;
if (name == static_cast<std::string>("startsWith"))
{
Expand All @@ -1145,7 +1145,7 @@ class FunctionStartsEndsWith : public IFunction
{
functionName = FunctionName::EndsWith;
}

if (strings && templates)
{
vec_res.resize(strings->size());
Expand Down Expand Up @@ -1179,23 +1179,23 @@ class FunctionStartsEndsWith : public IFunction
execute<FixedStringSource, ConstSource<StringSource>>(
FixedStringSource(*fixed_strings), ConstSource<StringSource>(*const_templates), vec_res, functionName);
}

block.getByPosition(result).column = std::move(col_res);
}

private:
enum FunctionName
{
StartsWith,
EndsWith
};

template <typename StringType, typename TemplateType>
static void execute(StringType str, TemplateType str_template, PaddedPODArray<UInt8> & res_data, FunctionName functionName)
{
size_t ind = 0;
size_t start_pos;

while (!str.isEnd())
{
if (str_template.getElementSize() == 1)
Expand All @@ -1218,7 +1218,7 @@ class FunctionStartsEndsWith : public IFunction
{
start_pos = str.getElementSize() - str_template.getElementSize();
}

StringRef str_ref(str.getWhole().data + start_pos, str_template.getElementSize() - 1);
StringRef template_ref(str_template.getWhole().data, str_template.getElementSize() - 1);
if (str_ref == template_ref)
Expand Down

0 comments on commit 37bd5f1

Please sign in to comment.