add UT
This commit is contained in:
parent
7ae87c1010
commit
aec7bef25b
|
@ -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) {
|
||||||
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,15 +312,18 @@ void validateTFile(char* arg) {
|
||||||
tfCleanup();
|
tfCleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void iterTFileReader(char* path, char* ver) {
|
void iterTFileReader(char* path, char* uid, char* colName, char* ver) {
|
||||||
tfInit();
|
tfInit();
|
||||||
|
|
||||||
int version = atoi(ver);
|
uint64_t suid = atoi(uid);
|
||||||
TFileReader* reader = tfileReaderOpen(path, 0, version, "tag1");
|
int version = atoi(ver);
|
||||||
Iterate* iter = tfileIteratorCreate(reader);
|
|
||||||
bool tn = iter ? iter->next(iter) : false;
|
TFileReader* reader = tfileReaderOpen(path, suid, version, colName);
|
||||||
int count = 0;
|
|
||||||
int termCount = 0;
|
Iterate* iter = tfileIteratorCreate(reader);
|
||||||
|
bool tn = iter ? iter->next(iter) : false;
|
||||||
|
int count = 0;
|
||||||
|
int termCount = 0;
|
||||||
while (tn == true) {
|
while (tn == true) {
|
||||||
count++;
|
count++;
|
||||||
IterateValue* cv = iter->getValue(iter);
|
IterateValue* cv = iter->getValue(iter);
|
||||||
|
@ -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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
|
|
||||||
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) {
|
||||||
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) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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) {
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue