diff --git a/lib/redis/rediswriter-utility.cpp b/lib/redis/rediswriter-utility.cpp index 643dab0fe..2ca9cd739 100644 --- a/lib/redis/rediswriter-utility.cpp +++ b/lib/redis/rediswriter-utility.cpp @@ -130,87 +130,6 @@ String RedisWriter::CalculateCheckSumVars(const CustomVarObject::Ptr& object) return HashValue(vars); } -/** - * Collect the leaves of haystack in needles - * - * haystack = { - * "disks": { - * "disk": {}, - * "disk /": { - * "disk_partitions": "/" - * } - * } - * } - * - * path = [] - * - * needles = { - * "disks": [ - * [ - * ["disks", "disk /", "disk_partitions"], - * "/" - * ] - * ] - * } - * - * @param haystack A config object's custom vars as returned by {@link CustomVarObject#GetVars()} - * @param path Used for buffering only, shall be empty - * @param needles The result, a mapping from the top-level custom var key to a list of leaves with full path and value - */ -static void CollectScalarVars(Value haystack, std::vector& path, std::map>>& needles) -{ - switch (haystack.GetType()) { - case ValueObject: - { - const Object::Ptr& obj = haystack.Get(); - - Dictionary::Ptr dict = dynamic_pointer_cast(obj); - - if (dict) { - ObjectLock olock(dict); - - for (auto& kv : dict) { - path.emplace_back(kv.first); - CollectScalarVars(kv.second, path, needles); - path.pop_back(); - } - - break; - } - - Array::Ptr arr = dynamic_pointer_cast(obj); - - if (arr) { - double index = 0.0; - - ObjectLock xlock(arr); - - for (auto& v : arr) { - path.emplace_back(index); - CollectScalarVars(v, path, needles); - path.pop_back(); - - index += 1.0; - } - - break; - } - } - - haystack = Empty; - - case ValueString: - case ValueNumber: - case ValueBoolean: - case ValueEmpty: - needles[path[0].Get()].emplace_back(Array::FromVector(path), haystack); - break; - - default: - VERIFY(!"Invalid variant type."); - } -} - /** * Prepare object's custom vars for being written to Redis * @@ -234,7 +153,7 @@ static void CollectScalarVars(Value haystack, std::vector& path, std::map * } * } * ])): { - * "env_checksum": SHA1(Environment), + * "envId": SHA1(Environment), * "name_checksum": SHA1("disks"), * "name": "disks", * "value": { @@ -242,12 +161,6 @@ static void CollectScalarVars(Value haystack, std::vector& path, std::map * "disk /": { * "disk_partitions": "/" * } - * }, - * "flat": { - * SHA1(PackObject(["disks", "disk /", "disk_partitions"])): { - * "name": ["disks", "disk /", "disk_partitions"], - * "value": "/" - * } * } * } * } @@ -263,13 +176,6 @@ Dictionary::Ptr RedisWriter::SerializeVars(const CustomVarObject::Ptr& object) if (!vars) return nullptr; - std::map>> scalarVars; - - { - std::vector pathBuf; - CollectScalarVars(vars, pathBuf, scalarVars); - } - Dictionary::Ptr res = new Dictionary(); auto env (GetEnvironment()); auto envChecksum (SHA1(env));