update fst write
This commit is contained in:
parent
716c0045f8
commit
e3ccb28c09
|
@ -268,9 +268,6 @@ FstNode* fstGetNode(Fst *fst, CompiledAddr);
|
||||||
FstNode* fstGetRoot(Fst *fst);
|
FstNode* fstGetRoot(Fst *fst);
|
||||||
FstType fstGetType(Fst *fst);
|
FstType fstGetType(Fst *fst);
|
||||||
CompiledAddr fstGetRootAddr(Fst *fst);
|
CompiledAddr fstGetRootAddr(Fst *fst);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Output fstEmptyFinalOutput(Fst *fst, bool *null);
|
Output fstEmptyFinalOutput(Fst *fst, bool *null);
|
||||||
bool fstVerify(Fst *fst);
|
bool fstVerify(Fst *fst);
|
||||||
|
|
||||||
|
@ -304,6 +301,7 @@ typedef struct StreamWithStateResult {
|
||||||
} StreamWithStateResult;
|
} StreamWithStateResult;
|
||||||
|
|
||||||
StreamWithStateResult *swsResultCreate(FstSlice *data, FstOutput fOut, void *state);
|
StreamWithStateResult *swsResultCreate(FstSlice *data, FstOutput fOut, void *state);
|
||||||
|
void swsResultDestroy(StreamWithStateResult *result);
|
||||||
|
|
||||||
typedef void* (*StreamCallback)(void *);
|
typedef void* (*StreamCallback)(void *);
|
||||||
StreamWithState *streamWithStateCreate(Fst *fst, Automation *automation, FstBoundWithData *min, FstBoundWithData *max) ;
|
StreamWithState *streamWithStateCreate(Fst *fst, Automation *automation, FstBoundWithData *min, FstBoundWithData *max) ;
|
||||||
|
|
|
@ -1301,12 +1301,16 @@ StreamWithStateResult *streamWithStateNextWith(StreamWithState *sws, StreamCallb
|
||||||
if (fstBoundWithDataExceededBy(sws->endAt, &slice)) {
|
if (fstBoundWithDataExceededBy(sws->endAt, &slice)) {
|
||||||
taosArrayDestroyEx(sws->stack, streamStateDestroy);
|
taosArrayDestroyEx(sws->stack, streamStateDestroy);
|
||||||
sws->stack = (SArray *)taosArrayInit(256, sizeof(StreamState));
|
sws->stack = (SArray *)taosArrayInit(256, sizeof(StreamState));
|
||||||
|
fstSliceDestroy(&slice);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (FST_NODE_IS_FINAL(nextNode) && isMatch) {
|
if (FST_NODE_IS_FINAL(nextNode) && isMatch) {
|
||||||
FstOutput fOutput = {.null = false, .out = out + FST_NODE_FINAL_OUTPUT(nextNode)};
|
FstOutput fOutput = {.null = false, .out = out + FST_NODE_FINAL_OUTPUT(nextNode)};
|
||||||
return swsResultCreate(&slice, fOutput , tState);
|
StreamWithStateResult *result = swsResultCreate(&slice, fOutput , tState);
|
||||||
|
fstSliceDestroy(&slice);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
fstSliceDestroy(&slice);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1321,8 +1325,14 @@ StreamWithStateResult *swsResultCreate(FstSlice *data, FstOutput fOut, void *sta
|
||||||
result->state = state;
|
result->state = state;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void swsResultDestroy(StreamWithStateResult *result) {
|
||||||
|
if (NULL == result) { return; }
|
||||||
|
|
||||||
|
fstSliceDestroy(&result->data);
|
||||||
|
free(result);
|
||||||
|
}
|
||||||
|
|
||||||
void streamStateDestroy(void *s) {
|
void streamStateDestroy(void *s) {
|
||||||
if (NULL == s) { return; }
|
if (NULL == s) { return; }
|
||||||
StreamState *ss = (StreamState *)s;
|
StreamState *ss = (StreamState *)s;
|
||||||
|
|
|
@ -107,7 +107,6 @@ FstSlice fstSliceCreate(uint8_t *data, uint64_t len) {
|
||||||
FstSlice fstSliceCopy(FstSlice *s, int32_t start, int32_t end) {
|
FstSlice fstSliceCopy(FstSlice *s, int32_t start, int32_t end) {
|
||||||
FstString *str = s->str;
|
FstString *str = s->str;
|
||||||
str->ref++;
|
str->ref++;
|
||||||
int32_t alen;
|
|
||||||
//uint8_t *buf = fstSliceData(s, &alen);
|
//uint8_t *buf = fstSliceData(s, &alen);
|
||||||
//start = buf + start - (buf - s->start);
|
//start = buf + start - (buf - s->start);
|
||||||
//end = buf + end - (buf - s->start);
|
//end = buf + end - (buf - s->start);
|
||||||
|
@ -117,9 +116,10 @@ FstSlice fstSliceCopy(FstSlice *s, int32_t start, int32_t end) {
|
||||||
}
|
}
|
||||||
FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end) {
|
FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end) {
|
||||||
|
|
||||||
int32_t alen, tlen = end - start + 1;
|
int32_t tlen = end - start + 1;
|
||||||
uint8_t *data = fstSliceData(s, &alen);
|
int32_t slen;
|
||||||
assert(tlen <= alen);
|
uint8_t *data = fstSliceData(s, &slen);
|
||||||
|
assert(tlen <= slen);
|
||||||
|
|
||||||
uint8_t *buf = malloc(sizeof(uint8_t) * tlen);
|
uint8_t *buf = malloc(sizeof(uint8_t) * tlen);
|
||||||
memcpy(buf, data + start, tlen);
|
memcpy(buf, data + start, tlen);
|
||||||
|
@ -136,7 +136,7 @@ FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end) {
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
bool fstSliceIsEmpty(FstSlice *s) {
|
bool fstSliceIsEmpty(FstSlice *s) {
|
||||||
return s->str == NULL || s->start < 0 || s->end < 0;
|
return s->str == NULL || s->str->len == 0 || s->start < 0 || s->end < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *fstSliceData(FstSlice *s, int32_t *size) {
|
uint8_t *fstSliceData(FstSlice *s, int32_t *size) {
|
||||||
|
@ -161,7 +161,6 @@ int fstSliceCompare(FstSlice *a, FstSlice *b) {
|
||||||
uint8_t *aBuf = fstSliceData(a, &alen);
|
uint8_t *aBuf = fstSliceData(a, &alen);
|
||||||
uint8_t *bBuf = fstSliceData(b, &blen);
|
uint8_t *bBuf = fstSliceData(b, &blen);
|
||||||
|
|
||||||
|
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
for (i = 0, j = 0; i < alen && j < blen; i++, j++) {
|
for (i = 0, j = 0; i < alen && j < blen; i++, j++) {
|
||||||
uint8_t x = aBuf[i];
|
uint8_t x = aBuf[i];
|
||||||
|
|
Loading…
Reference in New Issue