fix tag query error
This commit is contained in:
parent
9453f80d65
commit
ac32738964
|
@ -306,6 +306,7 @@ int32_t indexConvertDataToStr(void* src, int8_t type, void** dst) {
|
||||||
tlen = taosEncodeBinary(NULL, src, sizeof(float));
|
tlen = taosEncodeBinary(NULL, src, sizeof(float));
|
||||||
*dst = taosMemoryCalloc(1, tlen + 1);
|
*dst = taosMemoryCalloc(1, tlen + 1);
|
||||||
tlen = taosEncodeBinary(dst, src, sizeof(float));
|
tlen = taosEncodeBinary(dst, src, sizeof(float));
|
||||||
|
*dst = *dst - tlen;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_UINT:
|
case TSDB_DATA_TYPE_UINT:
|
||||||
*dst = taosMemoryCalloc(1, sizeof(int64_t) + 1);
|
*dst = taosMemoryCalloc(1, sizeof(int64_t) + 1);
|
||||||
|
@ -319,6 +320,7 @@ int32_t indexConvertDataToStr(void* src, int8_t type, void** dst) {
|
||||||
tlen = taosEncodeBinary(NULL, src, sizeof(double));
|
tlen = taosEncodeBinary(NULL, src, sizeof(double));
|
||||||
*dst = taosMemoryCalloc(1, tlen + 1);
|
*dst = taosMemoryCalloc(1, tlen + 1);
|
||||||
tlen = taosEncodeBinary(dst, src, sizeof(double));
|
tlen = taosEncodeBinary(dst, src, sizeof(double));
|
||||||
|
*dst = *dst - tlen;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
|
@ -1324,7 +1324,7 @@ StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallb
|
||||||
if (FST_NODE_ADDR(p->node) != fstGetRootAddr(sws->fst)) {
|
if (FST_NODE_ADDR(p->node) != fstGetRootAddr(sws->fst)) {
|
||||||
taosArrayPop(sws->inp);
|
taosArrayPop(sws->inp);
|
||||||
}
|
}
|
||||||
streamStateDestroy(p);
|
// streamStateDestroy(p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FstTransition trn;
|
FstTransition trn;
|
||||||
|
|
|
@ -410,8 +410,9 @@ static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTempResult*
|
||||||
|
|
||||||
ret = tfileReaderLoadTableIds((TFileReader*)reader, offset, tr->total);
|
ret = tfileReaderLoadTableIds((TFileReader*)reader, offset, tr->total);
|
||||||
cost = taosGetTimestampUs() - et;
|
cost = taosGetTimestampUs() - et;
|
||||||
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, load all table info, time cost: %" PRIu64 "us", tem->suid,
|
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, load all table info, offset: %" PRIu64
|
||||||
tem->colName, tem->colVal, cost);
|
", size: %d, time cost: %" PRIu64 "us",
|
||||||
|
tem->suid, tem->colName, tem->colVal, offset, (int)taosArrayGetSize(tr->total), cost);
|
||||||
}
|
}
|
||||||
fstSliceDestroy(&key);
|
fstSliceDestroy(&key);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -941,7 +942,7 @@ static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray*
|
||||||
// TODO(yihao): opt later
|
// TODO(yihao): opt later
|
||||||
WriterCtx* ctx = reader->ctx;
|
WriterCtx* ctx = reader->ctx;
|
||||||
// add block cache
|
// add block cache
|
||||||
char block[1024] = {0};
|
char block[4096] = {0};
|
||||||
int32_t nread = ctx->readFrom(ctx, block, sizeof(block), offset);
|
int32_t nread = ctx->readFrom(ctx, block, sizeof(block), offset);
|
||||||
assert(nread >= sizeof(uint32_t));
|
assert(nread >= sizeof(uint32_t));
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,29 @@ class JsonEnv : public ::testing::Test {
|
||||||
SIndexJson* index;
|
SIndexJson* index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void WriteData(SIndexJson* index, const std::string& colName, int8_t dtype, void* data, int dlen, int tableId,
|
||||||
|
int8_t operType = ADD_VALUE) {
|
||||||
|
SIndexTerm* term =
|
||||||
|
indexTermCreate(1, (SIndexOperOnColumn)operType, dtype, colName.c_str(), colName.size(), (const char*)data, dlen);
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
|
tIndexJsonPut(index, terms, (int64_t)tableId);
|
||||||
|
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
|
}
|
||||||
|
static void Search(SIndexJson* index, const std::string& colNam, int8_t dtype, void* data, int dlen, int8_t filterType,
|
||||||
|
SArray** result) {
|
||||||
|
std::string colName(colNam);
|
||||||
|
|
||||||
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
|
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, dtype, colName.c_str(), colName.size(), (const char*)data, dlen);
|
||||||
|
|
||||||
|
SArray* res = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
indexMultiTermQueryAdd(mq, q, (EIndexQueryType)filterType);
|
||||||
|
tIndexJsonSearch(index, mq, res);
|
||||||
|
indexMultiTermQueryDestroy(mq);
|
||||||
|
*result = res;
|
||||||
|
}
|
||||||
TEST_F(JsonEnv, testWrite) {
|
TEST_F(JsonEnv, testWrite) {
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
|
@ -329,7 +352,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(JsonEnv, testWriteJsonTfileAndCache) {
|
TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
{
|
{
|
||||||
std::string colName("test1");
|
std::string colName("test1");
|
||||||
int val = 10;
|
int val = 10;
|
||||||
|
@ -485,3 +508,73 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache) {
|
||||||
indexMultiTermQueryDestroy(mq);
|
indexMultiTermQueryDestroy(mq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT2) {
|
||||||
|
{
|
||||||
|
int val = 10;
|
||||||
|
std::string colName("test1");
|
||||||
|
for (int i = 0; i < 10000; i++) {
|
||||||
|
val += 1;
|
||||||
|
WriteData(index, colName, TSDB_DATA_TYPE_INT, &val, sizeof(val), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int val = 10;
|
||||||
|
std::string colName("test2xxx");
|
||||||
|
std::string colVal("xxxxxxxxxxxxxxx");
|
||||||
|
for (int i = 0; i < 100000; i++) {
|
||||||
|
val += 1;
|
||||||
|
WriteData(index, colName, TSDB_DATA_TYPE_BINARY, (void*)(colVal.c_str()), colVal.size(), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SArray* res = NULL;
|
||||||
|
std::string colName("test1");
|
||||||
|
int val = 9;
|
||||||
|
Search(index, colName, TSDB_DATA_TYPE_INT, &val, sizeof(val), QUERY_GREATER_EQUAL, &res);
|
||||||
|
EXPECT_EQ(10000, taosArrayGetSize(res));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SArray* res = NULL;
|
||||||
|
std::string colName("test2xxx");
|
||||||
|
std::string colVal("xxxxxxxxxxxxxxx");
|
||||||
|
Search(index, colName, TSDB_DATA_TYPE_BINARY, (void*)(colVal.c_str()), colVal.size(), QUERY_TERM, &res);
|
||||||
|
EXPECT_EQ(100000, taosArrayGetSize(res));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_F(JsonEnv, testWriteJsonTfileAndCache_FLOAT) {
|
||||||
|
{
|
||||||
|
float val = 10.0;
|
||||||
|
std::string colName("test1");
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
WriteData(index, colName, TSDB_DATA_TYPE_FLOAT, &val, sizeof(val), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
float val = 2.0;
|
||||||
|
std::string colName("test1");
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
WriteData(index, colName, TSDB_DATA_TYPE_FLOAT, &val, sizeof(val), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SArray* res = NULL;
|
||||||
|
std::string colName("test1");
|
||||||
|
float val = 1.9;
|
||||||
|
Search(index, colName, TSDB_DATA_TYPE_FLOAT, &val, sizeof(val), QUERY_GREATER_EQUAL, &res);
|
||||||
|
EXPECT_EQ(2000, taosArrayGetSize(res));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SArray* res = NULL;
|
||||||
|
std::string colName("test1");
|
||||||
|
float val = 2.1;
|
||||||
|
Search(index, colName, TSDB_DATA_TYPE_FLOAT, &val, sizeof(val), QUERY_GREATER_EQUAL, &res);
|
||||||
|
EXPECT_EQ(1000, taosArrayGetSize(res));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::string colName("test1");
|
||||||
|
SArray* res = NULL;
|
||||||
|
float val = 2.1;
|
||||||
|
Search(index, colName, TSDB_DATA_TYPE_FLOAT, &val, sizeof(val), QUERY_GREATER_EQUAL, &res);
|
||||||
|
EXPECT_EQ(1000, taosArrayGetSize(res));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue