commit
fb6fa6adc5
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TDENGINE_OS_H
|
#ifndef _TD_OS_H_
|
||||||
#define TDENGINE_OS_H
|
#define _TD_OS_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -82,4 +82,4 @@ void osInit();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /*_TD_OS_H_*/
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
#ifndef _TD_OS_FILE_H_
|
#ifndef _TD_OS_FILE_H_
|
||||||
#define _TD_OS_FILE_H_
|
#define _TD_OS_FILE_H_
|
||||||
|
|
||||||
|
#include "osSocket.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "osSocket.h"
|
|
||||||
|
|
||||||
#ifndef ALLOW_FORBID_FUNC
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
#define open OPEN_FUNC_TAOS_FORBID
|
#define open OPEN_FUNC_TAOS_FORBID
|
||||||
#define fopen FOPEN_FUNC_TAOS_FORBID
|
#define fopen FOPEN_FUNC_TAOS_FORBID
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
#ifndef _TD_OS_SEMPHONE_H_
|
#ifndef _TD_OS_SEMPHONE_H_
|
||||||
#define _TD_OS_SEMPHONE_H_
|
#define _TD_OS_SEMPHONE_H_
|
||||||
|
|
||||||
|
#include <semaphore.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <semaphore.h>
|
|
||||||
|
|
||||||
#if defined (_TD_DARWIN_64)
|
#if defined (_TD_DARWIN_64)
|
||||||
typedef struct tsem_s *tsem_t;
|
typedef struct tsem_s *tsem_t;
|
||||||
int tsem_init(tsem_t *sem, int pshared, unsigned int value);
|
int tsem_init(tsem_t *sem, int pshared, unsigned int value);
|
||||||
|
|
|
@ -16,10 +16,6 @@
|
||||||
#ifndef _TD_OS_SOCKET_H_
|
#ifndef _TD_OS_SOCKET_H_
|
||||||
#define _TD_OS_SOCKET_H_
|
#define _TD_OS_SOCKET_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
#include "winsock2.h"
|
#include "winsock2.h"
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
|
@ -30,6 +26,10 @@ extern "C" {
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TAOS_EPOLL_WAIT_TIME 500
|
#define TAOS_EPOLL_WAIT_TIME 500
|
||||||
typedef int32_t SOCKET;
|
typedef int32_t SOCKET;
|
||||||
typedef SOCKET EpollFd;
|
typedef SOCKET EpollFd;
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
#ifndef _TD_OS_SYSINFO_H_
|
#ifndef _TD_OS_SYSINFO_H_
|
||||||
#define _TD_OS_SYSINFO_H_
|
#define _TD_OS_SYSINFO_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t total;
|
int64_t total;
|
||||||
int64_t used;
|
int64_t used;
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
#ifndef _TD_OS_THREAD_H_
|
#ifndef _TD_OS_THREAD_H_
|
||||||
#define _TD_OS_THREAD_H_
|
#define _TD_OS_THREAD_H_
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,8 +39,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
||||||
if (pCol->spaceSize < spaceNeeded) {
|
if (pCol->spaceSize < spaceNeeded) {
|
||||||
void *ptr = realloc(pCol->pData, spaceNeeded);
|
void *ptr = realloc(pCol->pData, spaceNeeded);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)spaceNeeded,
|
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)spaceNeeded, strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
pCol->pData = ptr;
|
pCol->pData = ptr;
|
||||||
|
@ -66,7 +65,6 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
||||||
* Duplicate the schema and return a new object
|
* Duplicate the schema and return a new object
|
||||||
*/
|
*/
|
||||||
STSchema *tdDupSchema(const STSchema *pSchema) {
|
STSchema *tdDupSchema(const STSchema *pSchema) {
|
||||||
|
|
||||||
int tlen = sizeof(STSchema) + sizeof(STColumn) * schemaNCols(pSchema);
|
int tlen = sizeof(STSchema) + sizeof(STColumn) * schemaNCols(pSchema);
|
||||||
STSchema *tSchema = (STSchema *)malloc(tlen);
|
STSchema *tSchema = (STSchema *)malloc(tlen);
|
||||||
if (tSchema == NULL) return NULL;
|
if (tSchema == NULL) return NULL;
|
||||||
|
@ -659,9 +657,7 @@ static int compareColIdx(const void* a, const void* b) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdSortKVRowByColIdx(SKVRow row) {
|
void tdSortKVRowByColIdx(SKVRow row) { qsort(kvRowColIdx(row), kvRowNCols(row), sizeof(SColIdx), compareColIdx); }
|
||||||
qsort(kvRowColIdx(row), kvRowNCols(row), sizeof(SColIdx), compareColIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
|
int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
|
||||||
SColIdx *pColIdx = NULL;
|
SColIdx *pColIdx = NULL;
|
||||||
|
|
|
@ -43,14 +43,12 @@
|
||||||
* An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
|
* An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
|
||||||
* tomorrow - (allowable under ISO 8601) is supported.
|
* tomorrow - (allowable under ISO 8601) is supported.
|
||||||
*/
|
*/
|
||||||
static int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
|
static int64_t user_mktime64(const uint32_t year0, const uint32_t mon0, const uint32_t day, const uint32_t hour,
|
||||||
const unsigned int day, const unsigned int hour,
|
const uint32_t min, const uint32_t sec, int64_t time_zone) {
|
||||||
const unsigned int min, const unsigned int sec, int64_t time_zone)
|
uint32_t mon = mon0, year = year0;
|
||||||
{
|
|
||||||
unsigned int mon = mon0, year = year0;
|
|
||||||
|
|
||||||
/* 1..12 -> 11,12,1..10 */
|
/* 1..12 -> 11,12,1..10 */
|
||||||
if (0 >= (int) (mon -= 2)) {
|
if (0 >= (int32_t)(mon -= 2)) {
|
||||||
mon += 12; /* Puts Feb last since it has leap day */
|
mon += 12; /* Puts Feb last since it has leap day */
|
||||||
year -= 1;
|
year -= 1;
|
||||||
}
|
}
|
||||||
|
@ -83,10 +81,8 @@ static int32_t parseLocaltimeDst(char* timestr, int64_t* time, int32_t timePrec)
|
||||||
static char* forwardToTimeStringEnd(char* str);
|
static char* forwardToTimeStringEnd(char* str);
|
||||||
static bool checkTzPresent(const char* str, int32_t len);
|
static bool checkTzPresent(const char* str, int32_t len);
|
||||||
|
|
||||||
static int32_t (*parseLocaltimeFp[]) (char* timestr, int64_t* time, int32_t timePrec) = {
|
static int32_t (*parseLocaltimeFp[])(char* timestr, int64_t* time, int32_t timePrec) = {parseLocaltime,
|
||||||
parseLocaltime,
|
parseLocaltimeDst};
|
||||||
parseLocaltimeDst
|
|
||||||
};
|
|
||||||
|
|
||||||
int32_t taosParseTime(const char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t day_light) {
|
int32_t taosParseTime(const char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t day_light) {
|
||||||
/* parse datatime string in with tz */
|
/* parse datatime string in with tz */
|
||||||
|
@ -104,7 +100,7 @@ bool checkTzPresent(const char* str, int32_t len) {
|
||||||
int32_t seg_len = len - (int32_t)(seg - str);
|
int32_t seg_len = len - (int32_t)(seg - str);
|
||||||
|
|
||||||
char* c = &seg[seg_len - 1];
|
char* c = &seg[seg_len - 1];
|
||||||
for (int i = 0; i < seg_len; ++i) {
|
for (int32_t i = 0; i < seg_len; ++i) {
|
||||||
if (*c == 'Z' || *c == 'z' || *c == '+' || *c == '-') {
|
if (*c == 'Z' || *c == 'z' || *c == '+' || *c == '-') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +201,6 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int64_t minute = strnatoi(&str[i], 2);
|
int64_t minute = strnatoi(&str[i], 2);
|
||||||
if (minute > 59) {
|
if (minute > 59) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -233,9 +228,8 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
||||||
* 2013-04-12T15:52:01.123+0800
|
* 2013-04-12T15:52:01.123+0800
|
||||||
*/
|
*/
|
||||||
int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim) {
|
int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim) {
|
||||||
|
int64_t factor =
|
||||||
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
|
(timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
||||||
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
|
||||||
int64_t tzOffset = 0;
|
int64_t tzOffset = 0;
|
||||||
|
|
||||||
struct tm tm = {0};
|
struct tm tm = {0};
|
||||||
|
@ -320,7 +314,8 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int64_t seconds = user_mktime64(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, timezone);
|
int64_t seconds =
|
||||||
|
user_mktime64(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, timezone);
|
||||||
|
|
||||||
int64_t fraction = 0;
|
int64_t fraction = 0;
|
||||||
|
|
||||||
|
@ -331,8 +326,8 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
|
int64_t factor =
|
||||||
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
(timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
||||||
*time = factor * seconds + fraction;
|
*time = factor * seconds + fraction;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -360,27 +355,22 @@ int32_t parseLocaltimeDst(char* timestr, int64_t* time, int32_t timePrec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
|
int64_t factor =
|
||||||
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
(timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
||||||
*time = factor * seconds + fraction;
|
*time = factor * seconds + fraction;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) {
|
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) {
|
||||||
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI ||
|
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||||
fromPrecision == TSDB_TIME_PRECISION_MICRO ||
|
|
||||||
fromPrecision == TSDB_TIME_PRECISION_NANO);
|
fromPrecision == TSDB_TIME_PRECISION_NANO);
|
||||||
assert(toPrecision == TSDB_TIME_PRECISION_MILLI ||
|
assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||||
toPrecision == TSDB_TIME_PRECISION_MICRO ||
|
|
||||||
toPrecision == TSDB_TIME_PRECISION_NANO);
|
toPrecision == TSDB_TIME_PRECISION_NANO);
|
||||||
static double factors[3][3] = { {1., 1000., 1000000.},
|
static double factors[3][3] = {{1., 1000., 1000000.}, {1.0 / 1000, 1., 1000.}, {1.0 / 1000000, 1.0 / 1000, 1.}};
|
||||||
{1.0 / 1000, 1., 1000.},
|
|
||||||
{1.0 / 1000000, 1.0 / 1000, 1.} };
|
|
||||||
return (int64_t)((double)time * factors[fromPrecision][toPrecision]);
|
return (int64_t)((double)time * factors[fromPrecision][toPrecision]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
||||||
|
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case 's':
|
case 's':
|
||||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_SECOND, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
(*result) = convertTimePrecision(val * MILLISECOND_PER_SECOND, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||||
|
@ -427,7 +417,8 @@ static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t time
|
||||||
* d - Days (24 hours)
|
* d - Days (24 hours)
|
||||||
* w - Weeks (7 days)
|
* w - Weeks (7 days)
|
||||||
*/
|
*/
|
||||||
int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* duration, char* unit, int32_t timePrecision) {
|
int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* duration, char* unit,
|
||||||
|
int32_t timePrecision) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
|
|
||||||
|
@ -476,7 +467,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||||
localtime_r(&tt, &tm);
|
localtime_r(&tt, &tm);
|
||||||
int mon = tm.tm_year * 12 + tm.tm_mon + (int)duration;
|
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)duration;
|
||||||
tm.tm_year = mon / 12;
|
tm.tm_year = mon / 12;
|
||||||
tm.tm_mon = mon % 12;
|
tm.tm_mon = mon % 12;
|
||||||
|
|
||||||
|
@ -499,11 +490,11 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t t = (time_t)skey;
|
time_t t = (time_t)skey;
|
||||||
localtime_r(&t, &tm);
|
localtime_r(&t, &tm);
|
||||||
int smon = tm.tm_year * 12 + tm.tm_mon;
|
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
|
||||||
|
|
||||||
t = (time_t)ekey;
|
t = (time_t)ekey;
|
||||||
localtime_r(&t, &tm);
|
localtime_r(&t, &tm);
|
||||||
int emon = tm.tm_year * 12 + tm.tm_mon;
|
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
|
||||||
|
|
||||||
if (unit == 'y') {
|
if (unit == 'y') {
|
||||||
interval *= 12;
|
interval *= 12;
|
||||||
|
@ -531,10 +522,10 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
|
||||||
|
|
||||||
if (pInterval->slidingUnit == 'y') {
|
if (pInterval->slidingUnit == 'y') {
|
||||||
tm.tm_mon = 0;
|
tm.tm_mon = 0;
|
||||||
tm.tm_year = (int)(tm.tm_year / pInterval->sliding * pInterval->sliding);
|
tm.tm_year = (int32_t)(tm.tm_year / pInterval->sliding * pInterval->sliding);
|
||||||
} else {
|
} else {
|
||||||
int mon = tm.tm_year * 12 + tm.tm_mon;
|
int32_t mon = tm.tm_year * 12 + tm.tm_mon;
|
||||||
mon = (int)(mon / pInterval->sliding * pInterval->sliding);
|
mon = (int32_t)(mon / pInterval->sliding * pInterval->sliding);
|
||||||
tm.tm_year = mon / 12;
|
tm.tm_year = mon / 12;
|
||||||
tm.tm_mon = mon % 12;
|
tm.tm_mon = mon % 12;
|
||||||
}
|
}
|
||||||
|
@ -619,7 +610,7 @@ const char* fmtts(int64_t ts) {
|
||||||
buf[pos++] = ' ';
|
buf[pos++] = ' ';
|
||||||
}
|
}
|
||||||
pos += strftime(buf + pos, sizeof(buf), "ms=%Y-%m-%d %H:%M:%S", &tm);
|
pos += strftime(buf + pos, sizeof(buf), "ms=%Y-%m-%d %H:%M:%S", &tm);
|
||||||
pos += sprintf(buf + pos, ".%03d", (int)(ts % 1000));
|
pos += sprintf(buf + pos, ".%03d", (int32_t)(ts % 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -631,7 +622,7 @@ const char* fmtts(int64_t ts) {
|
||||||
buf[pos++] = ' ';
|
buf[pos++] = ' ';
|
||||||
}
|
}
|
||||||
pos += strftime(buf + pos, sizeof(buf), "us=%Y-%m-%d %H:%M:%S", &tm);
|
pos += strftime(buf + pos, sizeof(buf), "us=%Y-%m-%d %H:%M:%S", &tm);
|
||||||
pos += sprintf(buf + pos, ".%06d", (int)(ts % 1000000));
|
pos += sprintf(buf + pos, ".%06d", (int32_t)(ts % 1000000));
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
|
@ -154,7 +154,8 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
||||||
// ascending by default
|
// ascending by default
|
||||||
pTSBuf->cur.order = TSDB_ORDER_ASC;
|
pTSBuf->cur.order = TSDB_ORDER_ASC;
|
||||||
|
|
||||||
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOfGroups:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->pFile),
|
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOfGroups:%d, autoDelete:%d", pTSBuf->path,
|
||||||
|
// fileno(pTSBuf->pFile),
|
||||||
// pTSBuf->fileSize, pTSBuf->numOfGroups, pTSBuf->autoDelete);
|
// pTSBuf->fileSize, pTSBuf->numOfGroups, pTSBuf->autoDelete);
|
||||||
|
|
||||||
return pTSBuf;
|
return pTSBuf;
|
||||||
|
@ -265,9 +266,8 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
|
||||||
STSList* pTsData = &pTSBuf->tsData;
|
STSList* pTsData = &pTSBuf->tsData;
|
||||||
|
|
||||||
pBlock->numOfElem = pTsData->len / TSDB_KEYSIZE;
|
pBlock->numOfElem = pTsData->len / TSDB_KEYSIZE;
|
||||||
pBlock->compLen =
|
pBlock->compLen = tsCompressTimestamp(pTsData->rawBuf, pTsData->len, pTsData->len / TSDB_KEYSIZE, pBlock->payload,
|
||||||
tsCompressTimestamp(pTsData->rawBuf, pTsData->len, pTsData->len/TSDB_KEYSIZE, pBlock->payload, pTsData->allocSize,
|
pTsData->allocSize, TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize);
|
||||||
TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize);
|
|
||||||
|
|
||||||
int64_t r = taosLSeekFile(pTSBuf->pFile, pTSBuf->fileSize, SEEK_SET);
|
int64_t r = taosLSeekFile(pTSBuf->pFile, pTSBuf->fileSize, SEEK_SET);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
@ -666,7 +666,8 @@ int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader) {
|
||||||
|
|
||||||
size_t ws = taosWriteFile(pTSBuf->pFile, pHeader, sizeof(STSBufFileHeader));
|
size_t ws = taosWriteFile(pTSBuf->pFile, pHeader, sizeof(STSBufFileHeader));
|
||||||
if (ws != 1) {
|
if (ws != 1) {
|
||||||
// qError("ts update header fwrite failed, size:%d, expected size:%d", (int32_t)ws, (int32_t)sizeof(STSBufFileHeader));
|
// qError("ts update header fwrite failed, size:%d, expected size:%d", (int32_t)ws,
|
||||||
|
// (int32_t)sizeof(STSBufFileHeader));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1089,14 +1090,14 @@ int32_t dumpFileBlockByGroupId(STSBuf* pTSBuf, int32_t groupIndex, void* buf, in
|
||||||
*numOfBlocks = 0;
|
*numOfBlocks = 0;
|
||||||
|
|
||||||
if (taosLSeekFile(pTSBuf->pFile, pBlockInfo->offset, SEEK_SET) != 0) {
|
if (taosLSeekFile(pTSBuf->pFile, pBlockInfo->offset, SEEK_SET) != 0) {
|
||||||
int code = TAOS_SYSTEM_ERROR(taosEOFFile(pTSBuf->pFile));
|
int32_t code = TAOS_SYSTEM_ERROR(taosEOFFile(pTSBuf->pFile));
|
||||||
// qError("%p: fseek failed: %s", pSql, tstrerror(code));
|
// qError("%p: fseek failed: %s", pSql, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t s = taosReadFile(pTSBuf->pFile, buf, pBlockInfo->compLen);
|
size_t s = taosReadFile(pTSBuf->pFile, buf, pBlockInfo->compLen);
|
||||||
if (s != pBlockInfo->compLen) {
|
if (s != pBlockInfo->compLen) {
|
||||||
int code = TAOS_SYSTEM_ERROR(taosEOFFile(pTSBuf->pFile));
|
int32_t code = TAOS_SYSTEM_ERROR(taosEOFFile(pTSBuf->pFile));
|
||||||
// tscError("%p: fread didn't return expected data: %s", pSql, tstrerror(code));
|
// tscError("%p: fread didn't return expected data: %s", pSql, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1120,6 +1121,4 @@ STSElem tsBufFindElemStartPosByTag(STSBuf* pTSBuf, SVariant* pTag) {
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tsBufIsValidElem(STSElem* pElem) {
|
bool tsBufIsValidElem(STSElem* pElem) { return pElem->id >= 0; }
|
||||||
return pElem->id >= 0;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue