Merge branch 'develop' into feature/liaohj
This commit is contained in:
commit
4156af7c0d
|
@ -63,7 +63,7 @@ Query OK, 2 row(s) in set (0.001700s)</code></pre>
|
||||||
<a class='anchor' id='主要功能'></a><h2>主要功能</h2>
|
<a class='anchor' id='主要功能'></a><h2>主要功能</h2>
|
||||||
<p>TDengine的核心功能是时序数据库。除此之外,为减少研发的复杂度、系统维护的难度,TDengine还提供缓存、消息队列、订阅、流式计算等功能。更详细的功能如下:</p>
|
<p>TDengine的核心功能是时序数据库。除此之外,为减少研发的复杂度、系统维护的难度,TDengine还提供缓存、消息队列、订阅、流式计算等功能。更详细的功能如下:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>使用类SQL语言用插入或查询数据</li>
|
<li>使用类SQL语言插入或查询数据</li>
|
||||||
<li>支持C/C++, Java(JDBC), Python, Go, RESTful, and Node.JS 开发接口</li>
|
<li>支持C/C++, Java(JDBC), Python, Go, RESTful, and Node.JS 开发接口</li>
|
||||||
<li>可通过Python/R/Matlab or TDengine shell做Ad Hoc查询分析</li>
|
<li>可通过Python/R/Matlab or TDengine shell做Ad Hoc查询分析</li>
|
||||||
<li>通过定时连续查询支持基于滑动窗口的流式计算</li>
|
<li>通过定时连续查询支持基于滑动窗口的流式计算</li>
|
||||||
|
|
|
@ -24,7 +24,7 @@ tags (location binary(20), type int)</code></pre>
|
||||||
<p>说明:</p>
|
<p>说明:</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>TAGS列总长度不能超过512 bytes;</li>
|
<li>TAGS列总长度不能超过512 bytes;</li>
|
||||||
<li>TAGS列的数据类型不能是timestamp和nchar类型;</li>
|
<li>TAGS列的数据类型不能是timestamp类型;</li>
|
||||||
<li>TAGS列名不能与其他列名相同;</li>
|
<li>TAGS列名不能与其他列名相同;</li>
|
||||||
<li>TAGS列名不能为预留关键字. </li></ol></li>
|
<li>TAGS列名不能为预留关键字. </li></ol></li>
|
||||||
<li><p>显示已创建的超级表</p>
|
<li><p>显示已创建的超级表</p>
|
||||||
|
@ -40,7 +40,7 @@ tags (location binary(20), type int)</code></pre>
|
||||||
<p>统计属于某个STable并满足查询条件的子表的数量</p></li>
|
<p>统计属于某个STable并满足查询条件的子表的数量</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<a class='anchor' id='写数据时自动建子表'></a><h2>写数据时自动建子表</h2>
|
<a class='anchor' id='写数据时自动建子表'></a><h2>写数据时自动建子表</h2>
|
||||||
<p>在某些特殊场景中,用户在写数据时并不确定某个设备的表是否存在,此时可使用自动建表语法来实现写入数据时里用超级表定义的表结构自动创建不存在的子表,若该表已存在则不会建立新表。注意:自动建表语句只能自动建立子表而不能建立超级表,这就要求超级表已经被事先定义好。自动建表语法跟insert/import语法非常相似,唯一区别是语句中增加了超级表和标签信息。具体语法如下:</p>
|
<p>在某些特殊场景中,用户在写数据时并不确定某个设备的表是否存在,此时可使用自动建表语法来实现写入数据时用超级表定义的表结构自动创建不存在的子表,若该表已存在则不会建立新表。注意:自动建表语句只能自动建立子表而不能建立超级表,这就要求超级表已经被事先定义好。自动建表语法跟insert/import语法非常相似,唯一区别是语句中增加了超级表和标签信息。具体语法如下:</p>
|
||||||
<pre><code class="mysql language-mysql">INSERT INTO <tb_name> USING <stb_name> TAGS (<tag1_value>, ...) VALUES (field_value, ...) (field_value, ...) ...;</code></pre>
|
<pre><code class="mysql language-mysql">INSERT INTO <tb_name> USING <stb_name> TAGS (<tag1_value>, ...) VALUES (field_value, ...) (field_value, ...) ...;</code></pre>
|
||||||
<p>向表tb_name中插入一条或多条记录,如果tb_name这张表不存在,则会用超级表stb_name定义的表结构以及用户指定的标签值(即tag1_value…)来创建名为tb_name新表,并将用户指定的值写入表中。如果tb_name已经存在,则建表过程会被忽略,系统也不会检查tb_name的标签是否与用户指定的标签值一致,也即不会更新已存在表的标签。</p>
|
<p>向表tb_name中插入一条或多条记录,如果tb_name这张表不存在,则会用超级表stb_name定义的表结构以及用户指定的标签值(即tag1_value…)来创建名为tb_name新表,并将用户指定的值写入表中。如果tb_name已经存在,则建表过程会被忽略,系统也不会检查tb_name的标签是否与用户指定的标签值一致,也即不会更新已存在表的标签。</p>
|
||||||
<pre><code class="mysql language-mysql">INSERT INTO <tb1_name> USING <stb1_name> TAGS (<tag1_value1>, ...) VALUES (<field1_value1>, ...) (<field1_value2>, ...) ... <tb_name2> USING <stb_name2> TAGS(<tag1_value2>, ...) VALUES (<field1_value1>, ...) ...;</code></pre>
|
<pre><code class="mysql language-mysql">INSERT INTO <tb1_name> USING <stb1_name> TAGS (<tag1_value1>, ...) VALUES (<field1_value1>, ...) (<field1_value2>, ...) ... <tb_name2> USING <stb_name2> TAGS(<tag1_value2>, ...) VALUES (<field1_value1>, ...) ...;</code></pre>
|
||||||
|
@ -105,6 +105,6 @@ GROUP BY location, type </code></pre>
|
||||||
<p>查询仅位于北京以外地区的温度传感器最近24小时(24h)采样值的数量count(*)、平均温度avg(degree)、最高温度max(degree)和最低温度min(degree),将采集结果按照10分钟为周期进行聚合,并将结果按所处地域(location)和传感器类型(type)再次进行聚合。</p>
|
<p>查询仅位于北京以外地区的温度传感器最近24小时(24h)采样值的数量count(*)、平均温度avg(degree)、最高温度max(degree)和最低温度min(degree),将采集结果按照10分钟为周期进行聚合,并将结果按所处地域(location)和传感器类型(type)再次进行聚合。</p>
|
||||||
<pre><code class="mysql language-mysql">SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
|
<pre><code class="mysql language-mysql">SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
|
||||||
FROM thermometer
|
FROM thermometer
|
||||||
WHERE name<>'beijing' and ts>=now-1d
|
WHERE location<>'beijing' and ts>=now-1d
|
||||||
INTERVAL(10M)
|
INTERVAL(10M)
|
||||||
GROUP BY location, type</code></pre><a href='../index.html'>回去</a></section></main></div><?php include($s.'/footer.php'); ?><script>$('pre').addClass('prettyprint linenums');PR.prettyPrint()</script><script src='lib/docs/liner.js'></script></body></html>
|
GROUP BY location, type</code></pre><a href='../index.html'>回去</a></section></main></div><?php include($s.'/footer.php'); ?><script>$('pre').addClass('prettyprint linenums');PR.prettyPrint()</script><script src='lib/docs/liner.js'></script></body></html>
|
||||||
|
|
|
@ -434,8 +434,9 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef CLUSTER
|
|
||||||
uint16_t rspCode = pMsg->content[0];
|
uint16_t rspCode = pMsg->content[0];
|
||||||
|
#ifdef CLUSTER
|
||||||
|
|
||||||
|
|
||||||
if (rspCode == TSDB_CODE_REDIRECT) {
|
if (rspCode == TSDB_CODE_REDIRECT) {
|
||||||
tscTrace("%p it shall be redirected!", pSql);
|
tscTrace("%p it shall be redirected!", pSql);
|
||||||
|
|
|
@ -647,11 +647,8 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
||||||
pCmd->limit.limit = pSql->cmd.globalLimit - pRes->numOfTotal;
|
pCmd->limit.limit = pSql->cmd.globalLimit - pRes->numOfTotal;
|
||||||
pCmd->limit.offset = pRes->offset;
|
pCmd->limit.offset = pRes->offset;
|
||||||
|
|
||||||
#ifdef CLUSTER
|
|
||||||
if ((++pSql->cmd.vnodeIdx) <= pMeterMetaInfo->pMetricMeta->numOfVnodes) {
|
|
||||||
#else
|
|
||||||
if ((++pSql->cmd.vnodeIdx) < pMeterMetaInfo->pMetricMeta->numOfVnodes) {
|
if ((++pSql->cmd.vnodeIdx) < pMeterMetaInfo->pMetricMeta->numOfVnodes) {
|
||||||
#endif
|
|
||||||
pSql->cmd.command = TSDB_SQL_SELECT;
|
pSql->cmd.command = TSDB_SQL_SELECT;
|
||||||
assert(pSql->fp == NULL);
|
assert(pSql->fp == NULL);
|
||||||
tscProcessSql(pSql);
|
tscProcessSql(pSql);
|
||||||
|
|
|
@ -243,10 +243,6 @@ int taosInitTimer(void (*callback)(int), int ms) {
|
||||||
return setitimer(ITIMER_REAL, &tv, NULL);
|
return setitimer(ITIMER_REAL, &tv, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *taosCharsetReplace(char *charsetstr) {
|
|
||||||
return charsetstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosGetSystemTimezone() {
|
void taosGetSystemTimezone() {
|
||||||
// get and set default timezone
|
// get and set default timezone
|
||||||
SGlobalConfig *cfg_timezone = tsGetConfigOption("timezone");
|
SGlobalConfig *cfg_timezone = tsGetConfigOption("timezone");
|
||||||
|
@ -416,3 +412,11 @@ int tsem_post(dispatch_semaphore_t *sem) {
|
||||||
int tsem_destroy(dispatch_semaphore_t *sem) {
|
int tsem_destroy(dispatch_semaphore_t *sem) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t __sync_val_load_32(int32_t *ptr) {
|
||||||
|
return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __sync_val_restore_32(int32_t *ptr, int32_t newval) {
|
||||||
|
__atomic_store_n(ptr, newval, __ATOMIC_RELEASE);
|
||||||
|
}
|
|
@ -210,25 +210,6 @@ void taosGetSystemTimezone() {
|
||||||
pPrint("timezone not configured, set to system default:%s", tsTimezone);
|
pPrint("timezone not configured, set to system default:%s", tsTimezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct CharsetPair {
|
|
||||||
char *oldCharset;
|
|
||||||
char *newCharset;
|
|
||||||
} CharsetPair;
|
|
||||||
|
|
||||||
char *taosCharsetReplace(char *charsetstr) {
|
|
||||||
CharsetPair charsetRep[] = {
|
|
||||||
{"utf8", "UTF-8"}, {"936", "CP936"},
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < tListLen(charsetRep); ++i) {
|
|
||||||
if (strcasecmp(charsetRep[i].oldCharset, charsetstr) == 0) {
|
|
||||||
return strdup(charsetRep[i].newCharset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return strdup(charsetstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* POSIX format locale string:
|
* POSIX format locale string:
|
||||||
* (Language Strings)_(Country/Region Strings).(code_page)
|
* (Language Strings)_(Country/Region Strings).(code_page)
|
||||||
|
|
|
@ -205,10 +205,6 @@ __int64 interlocked_fetch_xor_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
|
||||||
void tsPrintOsInfo() {}
|
void tsPrintOsInfo() {}
|
||||||
|
|
||||||
char *taosCharsetReplace(char *charsetstr) {
|
|
||||||
return charsetstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosGetSystemTimezone() {
|
void taosGetSystemTimezone() {
|
||||||
// get and set default timezone
|
// get and set default timezone
|
||||||
SGlobalConfig *cfg_timezone = tsGetConfigOption("timezone");
|
SGlobalConfig *cfg_timezone = tsGetConfigOption("timezone");
|
||||||
|
|
|
@ -546,6 +546,7 @@ int vnodeImportToCache(SImportInfo *pImport, char *payload, int rows) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(rows);
|
||||||
dTrace("vid:%d sid:%d id:%s, %d rows data will be imported to cache, firstKey:%ld lastKey:%ld",
|
dTrace("vid:%d sid:%d id:%s, %d rows data will be imported to cache, firstKey:%ld lastKey:%ld",
|
||||||
pObj->vnode, pObj->sid, pObj->meterId, rows, firstKey, lastKey);
|
pObj->vnode, pObj->sid, pObj->meterId, rows, firstKey, lastKey);
|
||||||
|
|
||||||
|
@ -781,7 +782,7 @@ int vnodeImportStartToCache(SImportInfo *pImport, char *payload, int rows) {
|
||||||
pImport->importedRows = rows;
|
pImport->importedRows = rows;
|
||||||
code = vnodeImportToCache(pImport, payload, rows);
|
code = vnodeImportToCache(pImport, payload, rows);
|
||||||
} else {
|
} else {
|
||||||
dTrace("vid:%d sid:%d id:%s, data is already imported to cache", pObj->vnode, pObj->sid, pObj->meterId);
|
dTrace("vid:%d sid:%d id:%s, data is already imported to cache, firstKey:%lld", pObj->vnode, pObj->sid, pObj->meterId, pImport->firstKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -517,3 +517,22 @@ FORCE_INLINE double taos_align_get_double(char* pBuf) {
|
||||||
*(int64_t*)(&dv) = *(int64_t*)pBuf;
|
*(int64_t*)(&dv) = *(int64_t*)pBuf;
|
||||||
return dv;
|
return dv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct CharsetPair {
|
||||||
|
char *oldCharset;
|
||||||
|
char *newCharset;
|
||||||
|
} CharsetPair;
|
||||||
|
|
||||||
|
char *taosCharsetReplace(char *charsetstr) {
|
||||||
|
CharsetPair charsetRep[] = {
|
||||||
|
{ "utf8", "UTF-8" }, { "936", "CP936" },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < tListLen(charsetRep); ++i) {
|
||||||
|
if (strcasecmp(charsetRep[i].oldCharset, charsetstr) == 0) {
|
||||||
|
return strdup(charsetRep[i].newCharset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strdup(charsetstr);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue