Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
519c4cdf
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
519c4cdf
编写于
5月 20, 2022
作者:
H
Hongze Cheng
提交者:
GitHub
5月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12741 from taosdata/fix/hzcheng_3.0
fix: alter table
上级
101d6a48
90dff224
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
139 addition
and
10 deletion
+139
-10
source/dnode/vnode/src/meta/metaEntry.c
source/dnode/vnode/src/meta/metaEntry.c
+4
-4
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+135
-6
未找到文件。
source/dnode/vnode/src/meta/metaEntry.c
浏览文件 @
519c4cdf
...
...
@@ -56,8 +56,8 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
name
)
<
0
)
return
-
1
;
if
(
pME
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
tDecodeSSchemaWrapper
Ex
(
pCoder
,
&
pME
->
stbEntry
.
schema
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
Ex
(
pCoder
,
&
pME
->
stbEntry
.
schemaTag
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
(
pCoder
,
&
pME
->
stbEntry
.
schema
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
(
pCoder
,
&
pME
->
stbEntry
.
schemaTag
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
...
...
@@ -67,10 +67,10 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pCoder
,
&
pME
->
ntbEntry
.
ncid
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
Ex
(
pCoder
,
&
pME
->
ntbEntry
.
schema
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
(
pCoder
,
&
pME
->
ntbEntry
.
schema
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
pME
->
smaEntry
.
tsma
=
tDecoderMalloc
(
pCoder
,
sizeof
(
STSma
));
if
(
!
pME
->
smaEntry
.
tsma
)
{
if
(
!
pME
->
smaEntry
.
tsma
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
519c4cdf
...
...
@@ -4,6 +4,7 @@
#include "os.h"
#include "tdb.h"
#include <shared_mutex>
#include <string>
#include <thread>
#include <vector>
...
...
@@ -118,7 +119,7 @@ static int tDefaultKeyCmpr(const void *pKey1, int keyLen1, const void *pKey2, in
return
cret
;
}
TEST
(
tdb_test
,
simple_insert1
)
{
TEST
(
tdb_test
,
DISABLED_
simple_insert1
)
{
int
ret
;
TDB
*
pEnv
;
TTB
*
pDb
;
...
...
@@ -238,7 +239,7 @@ TEST(tdb_test, simple_insert1) {
GTEST_ASSERT_EQ
(
ret
,
0
);
}
TEST
(
tdb_test
,
simple_insert2
)
{
TEST
(
tdb_test
,
DISABLED_
simple_insert2
)
{
int
ret
;
TDB
*
pEnv
;
TTB
*
pDb
;
...
...
@@ -325,7 +326,7 @@ TEST(tdb_test, simple_insert2) {
GTEST_ASSERT_EQ
(
ret
,
0
);
}
TEST
(
tdb_test
,
simple_delete1
)
{
TEST
(
tdb_test
,
DISABLED_
simple_delete1
)
{
int
ret
;
TTB
*
pDb
;
char
key
[
128
];
...
...
@@ -420,7 +421,7 @@ TEST(tdb_test, simple_delete1) {
tdbClose
(
pEnv
);
}
TEST
(
tdb_test
,
simple_upsert1
)
{
TEST
(
tdb_test
,
DISABLED_
simple_upsert1
)
{
int
ret
;
TDB
*
pEnv
;
TTB
*
pDb
;
...
...
@@ -485,12 +486,12 @@ TEST(tdb_test, simple_upsert1) {
tdbClose
(
pEnv
);
}
TEST
(
tdb_test
,
multi_thread_query
)
{
TEST
(
tdb_test
,
DISABLED_
multi_thread_query
)
{
int
ret
;
TDB
*
pEnv
;
TTB
*
pDb
;
tdb_cmpr_fn_t
compFunc
;
int
nData
=
2
0000
;
int
nData
=
10
0000
;
TXN
txn
;
taosRemoveDir
(
"tdb"
);
...
...
@@ -598,3 +599,131 @@ TEST(tdb_test, multi_thread_query) {
ret
=
tdbClose
(
pEnv
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
TEST
(
tdb_test
,
multi_thread1
)
{
#if 0
int ret;
TDB *pDb;
TTB *pTb;
tdb_cmpr_fn_t compFunc;
int nData = 10000000;
TXN txn;
std::shared_timed_mutex mutex;
taosRemoveDir("tdb");
// Open Env
ret = tdbOpen("tdb", 512, 1, &pDb);
GTEST_ASSERT_EQ(ret, 0);
ret = tdbTbOpen("db.db", -1, -1, NULL, pDb, &pTb);
GTEST_ASSERT_EQ(ret, 0);
auto insert = [](TDB *pDb, TTB *pTb, int nData, int *stop, std::shared_timed_mutex *mu) {
TXN txn = {0};
char key[128];
char val[128];
SPoolMem *pPool = openPool();
txn.flags = TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED;
txn.txnId = -1;
txn.xMalloc = poolMalloc;
txn.xFree = poolFree;
txn.xArg = pPool;
tdbBegin(pDb, &txn);
for (int iData = 1; iData <= nData; iData++) {
sprintf(key, "key%d", iData);
sprintf(val, "value%d", iData);
{
std::lock_guard<std::shared_timed_mutex> wmutex(*mu);
int ret = tdbTbInsert(pTb, key, strlen(key), val, strlen(val), &txn);
GTEST_ASSERT_EQ(ret, 0);
}
if (pPool->size > 1024 * 1024) {
tdbCommit(pDb, &txn);
clearPool(pPool);
tdbBegin(pDb, &txn);
}
}
tdbCommit(pDb, &txn);
closePool(pPool);
*stop = 1;
};
auto query = [](TTB *pTb, int *stop, std::shared_timed_mutex *mu) {
TBC *pDBC;
void *pKey = NULL;
void *pVal = NULL;
int vLen, kLen;
int ret;
TXN txn;
SPoolMem *pPool = openPool();
txn.flags = 0;
txn.txnId = 0;
txn.xMalloc = poolMalloc;
txn.xFree = poolFree;
txn.xArg = pPool;
for (;;) {
if (*stop) break;
clearPool(pPool);
int count = 0;
{
std::shared_lock<std::shared_timed_mutex> rMutex(*mu);
ret = tdbTbcOpen(pTb, &pDBC, &txn);
GTEST_ASSERT_EQ(ret, 0);
tdbTbcMoveToFirst(pDBC);
for (;;) {
ret = tdbTbcNext(pDBC, &pKey, &kLen, &pVal, &vLen);
if (ret < 0) break;
count++;
}
std::cout << count << std::endl;
tdbTbcClose(pDBC);
}
usleep(500000);
}
closePool(pPool);
tdbFree(pKey);
tdbFree(pVal);
};
std::vector<std::thread> threads;
int nThreads = 10;
int stop = 0;
for (int i = 0; i < nThreads; i++) {
if (i == 0) {
threads.push_back(std::thread(insert, pDb, pTb, nData, &stop, &mutex));
} else {
threads.push_back(std::thread(query, pTb, &stop, &mutex));
}
}
for (auto &th : threads) {
th.join();
}
// Close a database
tdbTbClose(pTb);
// Close Env
ret = tdbClose(pDb);
GTEST_ASSERT_EQ(ret, 0);
#endif
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录