提交 aec7bef2 编写于 作者: dengyihao's avatar dengyihao

add UT

上级 7ae87c10
...@@ -275,6 +275,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) { ...@@ -275,6 +275,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
__compar_fn_t fn; __compar_fn_t fn;
int8_t colType = tw->header.colType; int8_t colType = tw->header.colType;
colType = INDEX_TYPE_GET_TYPE(colType);
if (colType == TSDB_DATA_TYPE_BINARY || colType == TSDB_DATA_TYPE_NCHAR) { if (colType == TSDB_DATA_TYPE_BINARY || colType == TSDB_DATA_TYPE_NCHAR) {
fn = tfileStrCompare; fn = tfileStrCompare;
} else { } else {
...@@ -572,6 +573,8 @@ static int tfileWriteHeader(TFileWriter* writer) { ...@@ -572,6 +573,8 @@ static int tfileWriteHeader(TFileWriter* writer) {
static int tfileWriteData(TFileWriter* write, TFileValue* tval) { static int tfileWriteData(TFileWriter* write, TFileValue* tval) {
TFileHeader* header = &write->header; TFileHeader* header = &write->header;
uint8_t colType = header->colType; uint8_t colType = header->colType;
colType = INDEX_TYPE_GET_TYPE(colType);
if (colType == TSDB_DATA_TYPE_BINARY || colType == TSDB_DATA_TYPE_NCHAR) { if (colType == TSDB_DATA_TYPE_BINARY || colType == TSDB_DATA_TYPE_NCHAR) {
FstSlice key = fstSliceCreate((uint8_t*)(tval->colVal), (size_t)strlen(tval->colVal)); FstSlice key = fstSliceCreate((uint8_t*)(tval->colVal), (size_t)strlen(tval->colVal));
if (fstBuilderInsert(write->fb, key, tval->offset)) { if (fstBuilderInsert(write->fb, key, tval->offset)) {
......
...@@ -312,11 +312,14 @@ void validateTFile(char* arg) { ...@@ -312,11 +312,14 @@ void validateTFile(char* arg) {
tfCleanup(); tfCleanup();
} }
void iterTFileReader(char* path, char* ver) { void iterTFileReader(char* path, char* uid, char* colName, char* ver) {
tfInit(); tfInit();
uint64_t suid = atoi(uid);
int version = atoi(ver); int version = atoi(ver);
TFileReader* reader = tfileReaderOpen(path, 0, version, "tag1");
TFileReader* reader = tfileReaderOpen(path, suid, version, colName);
Iterate* iter = tfileIteratorCreate(reader); Iterate* iter = tfileIteratorCreate(reader);
bool tn = iter ? iter->next(iter) : false; bool tn = iter ? iter->next(iter) : false;
int count = 0; int count = 0;
...@@ -337,9 +340,9 @@ void iterTFileReader(char* path, char* ver) { ...@@ -337,9 +340,9 @@ void iterTFileReader(char* path, char* ver) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
// tool to check all kind of fst test // tool to check all kind of fst test
// if (argc > 1) { validateTFile(argv[1]); } // if (argc > 1) { validateTFile(argv[1]); }
if (argc > 2) { if (argc > 4) {
// opt // path suid colName ver
iterTFileReader(argv[1], argv[2]); iterTFileReader(argv[1], argv[2], argv[3], argv[4]);
} }
// checkFstCheckIterator(); // checkFstCheckIterator();
// checkFstLongTerm(); // checkFstLongTerm();
......
...@@ -22,7 +22,7 @@ class JsonEnv : public ::testing::Test { ...@@ -22,7 +22,7 @@ class JsonEnv : public ::testing::Test {
virtual void SetUp() { virtual void SetUp() {
taosRemoveDir(dir.c_str()); taosRemoveDir(dir.c_str());
taosMkDir(dir.c_str()); taosMkDir(dir.c_str());
printf("set up\n");
opts = indexOptsCreate(); opts = indexOptsCreate();
int ret = tIndexJsonOpen(opts, dir.c_str(), &index); int ret = tIndexJsonOpen(opts, dir.c_str(), &index);
assert(ret == 0); assert(ret == 0);
...@@ -30,6 +30,7 @@ class JsonEnv : public ::testing::Test { ...@@ -30,6 +30,7 @@ class JsonEnv : public ::testing::Test {
virtual void TearDown() { virtual void TearDown() {
tIndexJsonClose(index); tIndexJsonClose(index);
indexOptsDestroy(opts); indexOptsDestroy(opts);
printf("destory\n");
} }
SIndexJsonOpts* opts; SIndexJsonOpts* opts;
SIndexJson* index; SIndexJson* index;
...@@ -37,7 +38,7 @@ class JsonEnv : public ::testing::Test { ...@@ -37,7 +38,7 @@ class JsonEnv : public ::testing::Test {
TEST_F(JsonEnv, testWrite) { TEST_F(JsonEnv, testWrite) {
{ {
std::string colName("voltage"); std::string colName("test");
std::string colVal("ab"); std::string colVal("ab");
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
colVal.c_str(), colVal.size()); colVal.c_str(), colVal.size());
...@@ -76,7 +77,7 @@ TEST_F(JsonEnv, testWrite) { ...@@ -76,7 +77,7 @@ TEST_F(JsonEnv, testWrite) {
indexMultiTermDestroy(terms); indexMultiTermDestroy(terms);
} }
{ {
std::string colName("voltage"); std::string colName("test");
std::string colVal("ab"); std::string colVal("ab");
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST); SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
...@@ -91,6 +92,19 @@ TEST_F(JsonEnv, testWrite) { ...@@ -91,6 +92,19 @@ TEST_F(JsonEnv, testWrite) {
} }
} }
TEST_F(JsonEnv, testWriteMillonData) { TEST_F(JsonEnv, testWriteMillonData) {
{
std::string colName("test");
std::string colVal("ab");
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
colVal.c_str(), colVal.size());
SIndexMultiTerm* terms = indexMultiTermCreate();
indexMultiTermAdd(terms, term);
for (size_t i = 0; i < 100; i++) {
tIndexJsonPut(index, terms, i);
}
indexMultiTermDestroy(terms);
}
{ {
std::string colName("voltagefdadfa"); std::string colName("voltagefdadfa");
std::string colVal("abxxxxxxxxxxxx"); std::string colVal("abxxxxxxxxxxxx");
...@@ -105,7 +119,7 @@ TEST_F(JsonEnv, testWriteMillonData) { ...@@ -105,7 +119,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
indexMultiTermDestroy(terms); indexMultiTermDestroy(terms);
} }
{ {
std::string colName("voltage"); std::string colName("test");
std::string colVal("ab"); std::string colVal("ab");
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST); SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册