diff --git a/include/libs/index/index.h b/include/libs/index/index.h index f4d45477c1..f93c46da0c 100644 --- a/include/libs/index/index.h +++ b/include/libs/index/index.h @@ -44,41 +44,46 @@ typedef enum { QUERY_TERM = 0, QUERY_PREFIX = 1, QUERY_SUFFIX = 2, QUERY_REGEX = * @param: oper * */ -SIndexMultiTermQuery *indexMultiTermQueryCreate(EIndexOperatorType oper); -void indexMultiTermQueryDestroy(SIndexMultiTermQuery *pQuery); -int indexMultiTermQueryAdd(SIndexMultiTermQuery *pQuery, SIndexTerm *term, EIndexQueryType type); +SIndexMultiTermQuery* indexMultiTermQueryCreate(EIndexOperatorType oper); +void indexMultiTermQueryDestroy(SIndexMultiTermQuery* pQuery); +int indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EIndexQueryType type); /* * @param: * @param: */ -int indexOpen(SIndexOpts *opt, const char *path, SIndex **index); -void indexClose(SIndex *index); -int indexPut(SIndex *index, SIndexMultiTerm *terms, uint64_t uid); -int indexDelete(SIndex *index, SIndexMultiTermQuery *query); -int indexSearch(SIndex *index, SIndexMultiTermQuery *query, SArray *result); -int indexRebuild(SIndex *index, SIndexOpts *opt); +int indexOpen(SIndexOpts* opt, const char* path, SIndex** index); +void indexClose(SIndex* index); +int indexPut(SIndex* index, SIndexMultiTerm* terms, uint64_t uid); +int indexDelete(SIndex* index, SIndexMultiTermQuery* query); +int indexSearch(SIndex* index, SIndexMultiTermQuery* query, SArray* result); +int indexRebuild(SIndex* index, SIndexOpts* opt); /* * @param * @param */ -SIndexMultiTerm *indexMultiTermCreate(); -int indexMultiTermAdd(SIndexMultiTerm *terms, SIndexTerm *term); -void indexMultiTermDestroy(SIndexMultiTerm *terms); +SIndexMultiTerm* indexMultiTermCreate(); +int indexMultiTermAdd(SIndexMultiTerm* terms, SIndexTerm* term); +void indexMultiTermDestroy(SIndexMultiTerm* terms); /* * @param: * @param: */ -SIndexOpts *indexOptsCreate(); -void indexOptsDestroy(SIndexOpts *opts); +SIndexOpts* indexOptsCreate(); +void indexOptsDestroy(SIndexOpts* opts); /* * @param: * @param: */ -SIndexTerm *indexTermCreate(int64_t suid, SIndexOperOnColumn operType, uint8_t colType, const char *colName, - int32_t nColName, const char *colVal, int32_t nColVal); -void indexTermDestroy(SIndexTerm *p); +SIndexTerm* indexTermCreate(int64_t suid, + SIndexOperOnColumn operType, + uint8_t colType, + const char* colName, + int32_t nColName, + const char* colVal, + int32_t nColVal); +void indexTermDestroy(SIndexTerm* p); #ifdef __cplusplus } diff --git a/source/libs/index/inc/index_tfile.h b/source/libs/index/inc/index_tfile.h index 613c6fbb7c..4da80a6dbe 100644 --- a/source/libs/index/inc/index_tfile.h +++ b/source/libs/index/inc/index_tfile.h @@ -60,6 +60,7 @@ typedef struct TFileWriter { FstBuilder* fb; WriterCtx* ctx; TFileHeader header; + uint32_t offset; } TFileWriter; typedef struct TFileReader { @@ -101,7 +102,7 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArr TFileWriter* tfileWriterCreate(WriterCtx* ctx, TFileHeader* header); void tfileWriterDestroy(TFileWriter* tw); -int tfileWriterPut(TFileWriter* tw, const char* key, int32_t nKey, const char* val, int32_t nVal); +int tfileWriterPut(TFileWriter* tw, void* data); int tfileWriterFinish(TFileWriter* tw); // diff --git a/source/libs/index/src/index_tfile.c b/source/libs/index/src/index_tfile.c index 86e60bc7dc..ad249868d5 100644 --- a/source/libs/index/src/index_tfile.c +++ b/source/libs/index/src/index_tfile.c @@ -36,6 +36,8 @@ static FORCE_INLINE int tfileWriteHeader(TFileWriter* writer) { int offset = p - buf; int nwrite = writer->ctx->write(writer->ctx, buf, offset); if (offset != nwrite) { return -1; } + writer->offset = offset; + return 0; } static FORCE_INLINE int tfileReadLoadHeader(TFileReader* reader) { // TODO simple tfile header later @@ -238,9 +240,16 @@ TFileWriter* tfileWriterCreate(WriterCtx* ctx, TFileHeader* header) { } tw->ctx = ctx; tw->header = *header; - + tfileWriteHeader(tw); return tw; } + +int TFileWriterPut(TFileWriter* tw, void* data) { + int32_t sz = taosArrayGetSize((SArray*)data); + + // sort by and write to + return 0; +} void tfileWriterDestroy(TFileWriter* tw) { if (tw == NULL) { return; }