create a vector of Optional in case of a singleKeyOrValue, insert an empty Tuple to vector as placeholder in case of a rangeQuery, insert Optional.empty as placeholder in other cases, insert the correct Tuple to be used.
| 4068 | // in case of a rangeQuery, insert Optional.empty as placeholder |
| 4069 | // in other cases, insert the correct Tuple to be used. |
| 4070 | void preprocessMappedKey(Tuple& mappedKeyFormatTuple, std::vector<Optional<Tuple>>& vt, bool& isRangeQuery) { |
| 4071 | vt.reserve(mappedKeyFormatTuple.size()); |
| 4072 | |
| 4073 | for (int i = 0; i < mappedKeyFormatTuple.size(); i++) { |
| 4074 | Tuple::ElementType type = mappedKeyFormatTuple.getType(i); |
| 4075 | if (type == Tuple::BYTES || type == Tuple::UTF8) { |
| 4076 | std::string s = mappedKeyFormatTuple.getString(i).toString(); |
| 4077 | auto sz = s.size(); |
| 4078 | bool escaped = unescapeLiterals(s, "{{", "{"); |
| 4079 | escaped = unescapeLiterals(s, "}}", "}") || escaped; |
| 4080 | if (escaped) { |
| 4081 | vt.emplace_back(Tuple::makeTuple(s)); |
| 4082 | } else if (singleKeyOrValue(s, sz)) { |
| 4083 | // when it is SingleKeyOrValue, insert an empty Tuple to vector as placeholder |
| 4084 | vt.emplace_back(Tuple()); |
| 4085 | } else if (rangeQuery(s)) { |
| 4086 | if (i != mappedKeyFormatTuple.size() - 1) { |
| 4087 | // It must be the last element of the mapper tuple |
| 4088 | throw mapper_bad_range_decriptor(); |
| 4089 | } |
| 4090 | // when it is rangeQuery, insert Optional.empty as placeholder |
| 4091 | vt.emplace_back(Optional<Tuple>()); |
| 4092 | isRangeQuery = true; |
| 4093 | } else { |
| 4094 | Tuple t; |
| 4095 | t.appendRaw(mappedKeyFormatTuple.subTupleRawString(i)); |
| 4096 | vt.emplace_back(t); |
| 4097 | } |
| 4098 | } else { |
| 4099 | Tuple t; |
| 4100 | t.appendRaw(mappedKeyFormatTuple.subTupleRawString(i)); |
| 4101 | vt.emplace_back(t); |
| 4102 | } |
| 4103 | } |
| 4104 | } |
| 4105 | |
| 4106 | Key constructMappedKey(KeyValueRef* keyValue, |
| 4107 | std::vector<Optional<Tuple>>& vec, |
no test coverage detected