Skip to content

Commit

Permalink
fix jsonindex parse string to int
Browse files Browse the repository at this point in the history
Signed-off-by: Xianhui.Lin <[email protected]>

fix unitest

Signed-off-by: Xianhui.Lin <[email protected]>
  • Loading branch information
JsDove committed Jan 8, 2025
1 parent 24c1e95 commit 46d0809
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions internal/core/src/common/Json.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ class Json {

// it's always safe to add the padding,
// as we have allocated the memory with this padding
auto doc = parser.parse(data_.data() + offset, length);
auto doc = parser.parse(
data_.data() + offset, length, length + simdjson::SIMDJSON_PADDING);
AssertInfo(doc.error() == simdjson::SUCCESS,
"failed to parse the json {}: {}",
std::string(data_.data() + offset, length),
Expand Down Expand Up @@ -241,10 +242,6 @@ class Json {
template <typename T>
value_result<T>
at(uint16_t offset, uint16_t length) const {
if constexpr (std::is_same_v<T, std::string_view> ||
std::is_same_v<T, std::string>) {
return value_result<T>(T(data_.data() + offset, length));
}
return doc(offset, length).get<T>();
}

Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/index/JsonKeyInvertedIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ JsonKeyInvertedIndex::TravelJson(const char* json,
} else if (current.type == JSMN_STRING) {
Assert(current.size == 0);
AddInvertedRecord(
path, offset, current.start, current.end - current.start);
path, offset, current.start - 1, current.end - current.start + 1);
index++;
}
}
Expand Down
3 changes: 2 additions & 1 deletion internal/indexnode/task_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ func (st *statsTask) Execute(ctx context.Context) error {
log.Ctx(ctx).Warn("stats wrong, failed to create text index", zap.Error(err))
return err
}
} else if st.req.GetSubJobType() == indexpb.StatsSubJob_JsonKeyIndexJob {
}
if st.req.GetSubJobType() == indexpb.StatsSubJob_Sort || st.req.GetSubJobType() == indexpb.StatsSubJob_JsonKeyIndexJob {
err = st.createJSONKeyIndex(ctx,
st.req.GetStorageConfig(),
st.req.GetCollectionID(),
Expand Down

0 comments on commit 46d0809

Please sign in to comment.