Skip to content

Commit

Permalink
Solve the problem of ES writing error caused by truncation of UTF8 ch… (
Browse files Browse the repository at this point in the history
vesoft-inc#4799)

* Solve the problem of ES writing error caused by truncation of UTF8 characters

* fix license typo
  • Loading branch information
cangfengzhs authored Oct 28, 2022
1 parent f2b8264 commit 39ca73b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/common/plugin/fulltext/FTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,15 @@ struct DocIDTraits {
}

static std::string val(const std::string& v) {
return ((v.size() > MAX_INDEX_TYPE_LENGTH) ? v.substr(0, MAX_INDEX_TYPE_LENGTH) : v);
if (v.size() <= MAX_INDEX_TYPE_LENGTH) {
return v;
}
size_t len = MAX_INDEX_TYPE_LENGTH;
const int utf8Mask = 1 << 7; // 10000000
while (len < v.size() && (v[len - 1] & utf8Mask)) {
len++;
}
return v.substr(0, len);
}

static std::string normalizedJson(const std::string& v) {
Expand Down
2 changes: 1 addition & 1 deletion src/storage/query/ScanEdgeProcessor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2020 vesoft inc. All rights reserved.:
/* Copyright (c) 2020 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/storage/query/ScanVertexProcessor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2020 vesoft inc. All rights reserved.:
/* Copyright (c) 2020 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/
Expand Down

0 comments on commit 39ca73b

Please sign in to comment.