| 640 | } |
| 641 | |
| 642 | rocksdb::Status Json::DebugMemory(engine::Context &ctx, const std::string &user_key, const std::string &path, |
| 643 | std::vector<size_t> *results) { |
| 644 | auto ns_key = AppendNamespacePrefix(user_key); |
| 645 | JsonMetadata metadata; |
| 646 | if (path == "$") { |
| 647 | std::string bytes; |
| 648 | Slice rest; |
| 649 | auto s = GetMetadata(ctx, {kRedisJson}, ns_key, &bytes, &metadata, &rest); |
| 650 | if (!s.ok()) return s; |
| 651 | results->emplace_back(rest.size()); |
| 652 | } else { |
| 653 | JsonValue json_val; |
| 654 | auto s = read(ctx, ns_key, &metadata, &json_val); |
| 655 | if (!s.ok()) return s; |
| 656 | auto str_bytes = json_val.GetBytes(path, metadata.format, storage_->GetConfig()->json_max_nesting_depth); |
| 657 | if (!str_bytes) return rocksdb::Status::InvalidArgument(str_bytes.Msg()); |
| 658 | *results = std::move(*str_bytes); |
| 659 | } |
| 660 | return rocksdb::Status::OK(); |
| 661 | } |
| 662 | |
| 663 | rocksdb::Status Json::Resp(engine::Context &ctx, const std::string &user_key, const std::string &path, |
| 664 | std::vector<std::string> *results, RESP resp) { |