Skip to content

Commit

Permalink
fix: Revert new jsoncons version
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Bagritsevich <[email protected]>
  • Loading branch information
BagritsevichStepan committed Jan 8, 2025
1 parent f3426bd commit 0ad5f68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ set(REFLEX "${THIRD_PARTY_LIB_DIR}/reflex/bin/reflex")
add_third_party(
jsoncons
GIT_REPOSITORY https://github.com/dragonflydb/jsoncons
GIT_TAG Dragonfly.178
# URL https://github.com/danielaparker/jsoncons/archive/refs/tags/v0.171.1.tar.gz
GIT_TAG Dragonfly
GIT_SHALLOW 1
# PATCH_COMMAND patch -p1 -i "${CMAKE_SOURCE_DIR}/patches/jsoncons-v0.171.0.patch"
CMAKE_PASS_FLAGS "-DJSONCONS_BUILD_TESTS=OFF -DJSONCONS_HAS_POLYMORPHIC_ALLOCATOR=ON"
LIB "none"
)
Expand Down
7 changes: 0 additions & 7 deletions src/core/compact_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,6 @@ void CompactObj::SetJson(JsonType&& j) {
if (taglen_ == JSON_TAG && JsonEnconding() == kEncodingJsonCons) {
DCHECK(u_.json_obj.cons.json_ptr != nullptr); // must be allocated
u_.json_obj.cons.json_ptr->swap(j);
DCHECK(jsoncons::is_trivial_storage(u_.json_obj.cons.json_ptr->storage_kind()) ||
u_.json_obj.cons.json_ptr->get_allocator().resource() == tl.local_mr);

// We do not set bytes_used as this is needed. Consider the two following cases:
// 1. old json contains 50 bytes. The delta for new one is 50, so the total bytes
// the new json occupies is 100.
Expand All @@ -892,10 +889,6 @@ void CompactObj::SetJson(JsonType&& j) {

SetMeta(JSON_TAG);
u_.json_obj.cons.json_ptr = AllocateMR<JsonType>(std::move(j));

// With trivial storage json_ptr->get_allocator() throws an exception.
DCHECK(jsoncons::is_trivial_storage(u_.json_obj.cons.json_ptr->storage_kind()) ||
u_.json_obj.cons.json_ptr->get_allocator().resource() == tl.local_mr);
u_.json_obj.cons.bytes_used = 0;
}

Expand Down
10 changes: 6 additions & 4 deletions src/server/json_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ OpResult<long> OpDel(const OpArgs& op_args, string_view key, string_view path,

if (json_path.HoldsJsonPath()) {
const json::Path& path = json_path.AsJsonPath();
long deletions =
json::MutatePath(path, [](optional<string_view>, JsonType* val) { return true; }, json_val);
long deletions = json::MutatePath(
path, [](optional<string_view>, JsonType* val) { return true; }, json_val);
return deletions;
}

Expand Down Expand Up @@ -1353,8 +1353,10 @@ OpResult<bool> OpSet(const OpArgs& op_args, string_view key, string_view path,
path_exists = true;
if (!is_nx_condition) {
operation_result = true;
*val =
JsonType(new_json, std::pmr::polymorphic_allocator<char>{CompactObj::memory_resource()});
static_assert(
std::is_same_v<std::allocator_traits<JsonType>::propagate_on_container_copy_assignment,
std::false_type>);
*val = new_json;
}
return {};
};
Expand Down

0 comments on commit 0ad5f68

Please sign in to comment.