...
 
Commits (2)
    https://gitcode.net/oceanbase/oblogmsg/-/commit/ea10d4b4cb0059aed02572836965d91700f0ec02 add flag used to mark partitioned dependent column 2022-11-30T01:54:10+08:00 自凡 wangxiantong.wxt@alibaba-inc.com https://gitcode.net/oceanbase/oblogmsg/-/commit/20588139cc7774c533450729bb60a2ad33b4e0d4 add param default value 2022-11-30T19:00:00+08:00 自凡 wangxiantong.wxt@alibaba-inc.com
......@@ -107,9 +107,13 @@ public:
virtual void setValuesOfEnumSet(std::vector<const char*>& v);
virtual void setValuesOfEnumSet(const char** v, size_t size);
virtual void setGenerated(bool Generated);
virtual void setHiddenRowKey();
virtual void setGenerated(bool generated = true);
virtual void setHiddenRowKey(bool hiddenRowKey = true);
virtual bool isHiddenRowKey();
virtual void setPartitioned(bool partitioned = true);
virtual bool isPartitioned();
virtual void setDependent(bool dependent = true);
virtual bool isDependent();
public:
int appendTo(std::string& s);
......
......@@ -142,6 +142,8 @@ public:
};
#define COL_FLAG_GENERATED 0x01 // col is generated
#define COL_FLAG_HIDDEN_ROWKEY (0x01 << 1) // 0x02
#define COL_FLAG_PARTITIONED (0x01 << 2) // 0x04
#define COL_FLAG_DEPENDENT (0x01 << 3) // 0x08
// ---------------------ColMeta-----------------------
struct ColMetaHeader {
uint32_t m_nameOffset;
......@@ -404,18 +406,50 @@ void IColMeta::setFlag(unsigned char flag)
{
m_col->m_colMetaHeader->m_flag = flag;
}
void IColMeta::setGenerated(bool Generated)
void IColMeta::setGenerated(bool generated)
{
m_col->m_colMetaHeader->m_flag |= COL_FLAG_GENERATED;
if (generated) {
m_col->m_colMetaHeader->m_flag |= COL_FLAG_GENERATED;
} else {
m_col->m_colMetaHeader->m_flag &= ~COL_FLAG_GENERATED;
}
}
void IColMeta::setHiddenRowKey()
void IColMeta::setHiddenRowKey(bool hiddenRowKey)
{
m_col->m_colMetaHeader->m_flag |= COL_FLAG_HIDDEN_ROWKEY;
if (hiddenRowKey) {
m_col->m_colMetaHeader->m_flag |= COL_FLAG_HIDDEN_ROWKEY;
} else {
m_col->m_colMetaHeader->m_flag &= ~COL_FLAG_HIDDEN_ROWKEY;
}
}
bool IColMeta::isHiddenRowKey()
{
return m_col->m_colMetaHeader->m_flag & COL_FLAG_HIDDEN_ROWKEY;
}
void IColMeta::setPartitioned(bool partitioned)
{
if (partitioned) {
m_col->m_colMetaHeader->m_flag |= COL_FLAG_PARTITIONED;
} else{
m_col->m_colMetaHeader->m_flag &= ~COL_FLAG_PARTITIONED;
}
}
bool IColMeta::isPartitioned()
{
return m_col->m_colMetaHeader->m_flag & COL_FLAG_PARTITIONED;
}
void IColMeta::setDependent(bool dependent)
{
if (dependent) {
m_col->m_colMetaHeader->m_flag |= COL_FLAG_DEPENDENT;
} else {
m_col->m_colMetaHeader->m_flag &= ~COL_FLAG_DEPENDENT;
}
}
bool IColMeta::isDependent()
{
return m_col->m_colMetaHeader->m_flag & COL_FLAG_DEPENDENT;
}
int IColMeta::appendTo(std::string& s)
{
return m_col->appendTo(s);
......@@ -440,7 +474,6 @@ void IColMeta::setUserData(void* data)
{
m_userData = data;
}
void* IColMeta::getUserData()
{
return m_userData;
......@@ -528,8 +561,7 @@ struct TableMetaInfo : public MetaInfo {
size_t colCount = m_tblMetaHeader->m_colCount;
size_t dataSize = m_tblMetaHeader->m_colsSize;
const size_t maxColCount = 5120;
if (m_data.getRealSize() + dataSize > size ||
colCount > maxColCount)
if (m_data.getRealSize() + dataSize > size || colCount > maxColCount)
return -11;
// parse col meta
......@@ -1678,7 +1710,7 @@ struct MetaDataCollectionInfo : public MetaInfo {
~MetaDataCollectionInfo()
{
if (m_removePtr)
delete[](char*) m_ptr;
delete[] (char*)m_ptr;
clear();
}
......
......@@ -39,7 +39,14 @@ IColMeta* createColMeta(const char* name, int type, int length)
colMeta->setNotNull(NN);
colMeta->setDefault(DEF);
colMeta->setEncoding(ENC);
colMeta->setGenerated(false);
colMeta->setGenerated(true);
colMeta->setHiddenRowKey(false);
colMeta->setHiddenRowKey(true);
colMeta->setPartitioned(false);
colMeta->setPartitioned(true);
colMeta->setDependent(false);
colMeta->setDependent(true);
colMeta->setOriginType("varchar");
colMeta->setPrecision(5);
colMeta->setScale(3);
......@@ -351,6 +358,12 @@ TEST(LogRecordImpl, LogRecordImplAPI)
ASSERT_EQ(12345, col_meta->getDecimals());
bool is_generated_column = col_meta->isGenerated();
ASSERT_TRUE(is_generated_column);
bool is_hidden_row_key = col_meta->isHiddenRowKey();
ASSERT_TRUE(is_hidden_row_key);
bool is_partitioned_column = col_meta->isPartitioned();
ASSERT_TRUE(is_partitioned_column);
bool is_dependent_column = col_meta->isDependent();
ASSERT_TRUE(is_dependent_column);
LogMsgFactory::destroy(table_meta);
// 224
......@@ -537,6 +550,12 @@ TEST(LogRecordImpl, LogRecordImplTestPKS1)
ASSERT_EQ(12345, col_meta->getDecimals());
bool is_generated_column = col_meta->isGenerated();
ASSERT_TRUE(is_generated_column);
bool is_hidden_row_key = col_meta->isHiddenRowKey();
ASSERT_TRUE(is_hidden_row_key);
bool is_partitioned_column = col_meta->isPartitioned();
ASSERT_TRUE(is_partitioned_column);
bool is_dependent_column = col_meta->isDependent();
ASSERT_TRUE(is_dependent_column);
// LogMsgFactory::destroy(table_meta);
}
......
......@@ -36,7 +36,14 @@ IColMeta* createColMeta(const char* name, int type, int length)
colMeta->setNotNull(NN);
colMeta->setDefault(DEF);
colMeta->setEncoding(ENC);
colMeta->setGenerated(false);
colMeta->setGenerated(true);
colMeta->setHiddenRowKey(false);
colMeta->setHiddenRowKey(true);
colMeta->setPartitioned(false);
colMeta->setPartitioned(true);
colMeta->setDependent(false);
colMeta->setDependent(true);
colMeta->setOriginType("varchar");
colMeta->setPrecision(5);
colMeta->setScale(4);
......@@ -146,7 +153,12 @@ void parseAndcheckRecord(LogRecordImpl& parser, const char* m, size_t msgSize)
ASSERT_EQ(12345, col_meta->getDecimals());
bool is_generated_column = col_meta->isGenerated();
ASSERT_TRUE(is_generated_column);
bool is_hidden_row_key = col_meta->isHiddenRowKey();
ASSERT_TRUE(is_hidden_row_key);
bool is_partitioned_column = col_meta->isPartitioned();
ASSERT_TRUE(is_partitioned_column);
bool is_dependent_column = col_meta->isDependent();
ASSERT_TRUE(is_dependent_column);
LogMsgFactory::destroy(table_meta);
}
......