Skip to content

Commit

Permalink
fix(tianmu): fix format using clang-format #792
Browse files Browse the repository at this point in the history
  • Loading branch information
hustjieke committed Mar 8, 2023
1 parent e8f0794 commit 7d8a032
Show file tree
Hide file tree
Showing 9 changed files with 3,664 additions and 2 deletions.
2 changes: 1 addition & 1 deletion storage/tianmu/core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ common::TianmuError Engine::RunLoader(THD *thd, sql_exchange *ex, TABLE_LIST *ta
}

// if (thd->transaction.stmt.cannot_safely_rollback())
// thd->transaction.all.mark_modified_non_trans_table();
// thd->transaction.all.mark_modified_non_trans_table();

if (transactional_table) {
if (tianmu_e == common::ErrorCode::SUCCESS)
Expand Down
131 changes: 131 additions & 0 deletions storage/tianmu/core/rc_attr_typeinfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/* Copyright (c) 2022 StoneAtom, Inc. All rights reserved.
Use is subject to license terms
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
*/
#ifndef TIANMU_CORE_RC_ATTR_TYPEINFO_H_
#define TIANMU_CORE_RC_ATTR_TYPEINFO_H_
#pragma once

#include <bitset>

#include "common/common_definitions.h"

namespace Tianmu {
namespace types {
class RCDataType;
} // namespace types
namespace core {
class ATI {
public:
static int TextSize(common::CT attrt, uint precision, int scale, DTCollation col = DTCollation());

static bool IsInteger32Type(common::CT attr_type) {
return attr_type == common::CT::INT || attr_type == common::CT::BYTEINT || attr_type == common::CT::SMALLINT ||
attr_type == common::CT::MEDIUMINT;
}

static bool IsIntegerType(common::CT attr_type) {
return IsInteger32Type(attr_type) || attr_type == common::CT::BIGINT;
}
static bool IsFixedNumericType(common::CT attr_type) {
return IsInteger32Type(attr_type) || attr_type == common::CT::BIGINT || attr_type == common::CT::NUM;
}

static bool IsRealType(common::CT attr_type) {
return attr_type == common::CT::FLOAT || attr_type == common::CT::REAL;
}
static bool IsNumericType(common::CT attr_type) {
return IsInteger32Type(attr_type) || attr_type == common::CT::BIGINT || attr_type == common::CT::NUM ||
attr_type == common::CT::FLOAT || attr_type == common::CT::REAL;
}

static bool IsBinType(common::CT attr_type) {
return attr_type == common::CT::BYTE || attr_type == common::CT::VARBYTE || attr_type == common::CT::BIN;
}

static bool IsTxtType(common::CT attr_type) {
return attr_type == common::CT::STRING || attr_type == common::CT::VARCHAR || attr_type == common::CT::LONGTEXT;
}

static bool IsCharType(common::CT attr_type) { return attr_type == common::CT::STRING; }
static bool IsStringType(common::CT attr_type) {
return attr_type == common::CT::STRING || attr_type == common::CT::VARCHAR || attr_type == common::CT::LONGTEXT ||
IsBinType(attr_type);
}

static bool IsDateTimeType(common::CT attr_type) {
return attr_type == common::CT::DATE || attr_type == common::CT::TIME || attr_type == common::CT::YEAR ||
attr_type == common::CT::DATETIME || attr_type == common::CT::TIMESTAMP;
}

static bool IsDateTimeNType(common::CT attr_type) {
return attr_type == common::CT::TIME_N || attr_type == common::CT::DATETIME_N ||
attr_type == common::CT::TIMESTAMP_N;
}
};

class AttributeTypeInfo {
public:
enum class enumATI {
NOT_NULL = 0,
AUTO_INC = 1,
BLOOM_FILTER = 2,
};

AttributeTypeInfo(common::CT attrt, bool notnull, uint precision = 0, ushort scale = 0, bool auto_inc = false,
DTCollation collation = DTCollation(), common::PackFmt fmt = common::PackFmt::DEFAULT,
bool filter = false)
: attrt(attrt), fmt(fmt), precision(precision), scale(scale), collation(collation) {
flag[static_cast<int>(enumATI::NOT_NULL)] = notnull;
flag[static_cast<int>(enumATI::BLOOM_FILTER)] = filter;
flag[static_cast<int>(enumATI::AUTO_INC)] = auto_inc;

// lookup only applies to string type
if (attrt != common::CT::STRING && attrt != common::CT::VARCHAR && Lookup())
fmt = common::PackFmt::DEFAULT;
}
common::CT Type() const { return attrt; }
common::PackType GetPackType() const {
return ATI::IsDateTimeType(attrt) || ATI::IsNumericType(attrt) || Lookup() ? common::PackType::INT
: common::PackType::STR;
}
uint Precision() const { return precision; }
ushort Scale() const { return scale; }
uint CharLen() const { return precision / collation.collation->mbmaxlen; }
bool NotNull() const { return flag[static_cast<int>(enumATI::NOT_NULL)]; }
bool AutoInc() const { return flag[static_cast<int>(enumATI::AUTO_INC)]; }
void SetCollation(const DTCollation &collation) { this->collation = collation; }
void SetCollation(CHARSET_INFO *charset_info) { this->collation.set(charset_info); }
DTCollation GetCollation() const { return collation; }
CHARSET_INFO *CharsetInfo() const { return const_cast<CHARSET_INFO *>(this->collation.collation); }
const types::RCDataType &ValuePrototype() const;
common::PackFmt Fmt() const { return fmt; }
bool Lookup() const { return fmt == common::PackFmt::LOOKUP; }
unsigned char Flag() const { return flag.to_ulong(); }
void SetFlag(unsigned char v) { flag = std::bitset<std::numeric_limits<unsigned char>::digits>(v); }

private:
common::CT attrt;
common::PackFmt fmt;
uint precision;
int scale;
DTCollation collation;

std::bitset<std::numeric_limits<unsigned char>::digits> flag;
};
} // namespace core
} // namespace Tianmu

#endif // TIANMU_CORE_RC_ATTR_TYPEINFO_H_
2 changes: 1 addition & 1 deletion storage/tianmu/core/sorter3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,4 @@ bool SorterLimit::PutValue(Sorter3 *s) {
return true;
}
} // namespace core
} // namespace Tianmu
} // namespace Tianmu
Loading

0 comments on commit 7d8a032

Please sign in to comment.