diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index ef17342bc1..523555a771 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -3525,12 +3525,8 @@ bool rangeQuery(const std::string& s) { // 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. -void preprocessMappedKey(Tuple& mappedKeyFormatTuple, - std::vector>& vt, - std::vector& strings, - bool& isRangeQuery) { +void preprocessMappedKey(Tuple& mappedKeyFormatTuple, std::vector>& vt, bool& isRangeQuery) { vt.reserve(mappedKeyFormatTuple.size()); - strings.reserve(mappedKeyFormatTuple.size()); for (int i = 0; i < mappedKeyFormatTuple.size(); i++) { Tuple::ElementType type = mappedKeyFormatTuple.getType(i); @@ -3539,7 +3535,6 @@ void preprocessMappedKey(Tuple& mappedKeyFormatTuple, auto sz = s.size(); bool escaped = unescapeLiterals(s, "{{", "{"); escaped = unescapeLiterals(s, "}}", "}") || escaped; - strings.push_back(s); if (escaped) { Tuple escapedTuple; escapedTuple.append(s); @@ -3567,7 +3562,7 @@ void preprocessMappedKey(Tuple& mappedKeyFormatTuple, Key constructMappedKey(KeyValueRef* keyValue, std::vector>& vec, Tuple& mappedKeyTuple, - std::vector& strings) { + Tuple& mappedKeyFormatTuple) { // Lazily parse key and/or value to tuple because they may not need to be a tuple if not used. Optional keyTuple; Optional valueTuple; @@ -3583,7 +3578,7 @@ Key constructMappedKey(KeyValueRef* keyValue, mappedKeyTuple.append(vec[i].get()); } else { // singleKeyOrValue is true - std::string s = strings[i]; + std::string s = mappedKeyFormatTuple.getString(i).toString(); auto sz = s.size(); int idx; Tuple* referenceTuple; @@ -3624,11 +3619,10 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") { Tuple mappedKeyTuple; std::vector> vt; - std::vector strings; bool isRangeQuery = false; - preprocessMappedKey(mappedKeyFormatTuple, vt, strings, isRangeQuery); + preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery); - Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, strings); + Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple); Key expectedMappedKey = Tuple() .append("normal"_sr) @@ -3646,10 +3640,9 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") { Tuple mappedKeyTuple; std::vector> vt; - std::vector strings; bool isRangeQuery = false; - preprocessMappedKey(mappedKeyFormatTuple, vt, strings, isRangeQuery); - Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, strings); + preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery); + Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple); Key expectedMappedKey = Tuple().append("{{}"_sr).append("}"_sr).getDataAsStandalone(); // std::cout << printable(mappedKey) << " == " << printable(expectedMappedKey) << std::endl; @@ -3661,10 +3654,9 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") { Tuple mappedKeyTuple; std::vector> vt; - std::vector strings; bool isRangeQuery = false; - preprocessMappedKey(mappedKeyFormatTuple, vt, strings, isRangeQuery); - Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, strings); + preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery); + Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple); Key expectedMappedKey = Tuple().append("{{}"_sr).append("}"_sr).getDataAsStandalone(); // std::cout << printable(mappedKey) << " == " << printable(expectedMappedKey) << std::endl; @@ -3677,11 +3669,10 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") { try { Tuple mappedKeyTuple; std::vector> vt; - std::vector strings; bool isRangeQuery = false; - preprocessMappedKey(mappedKeyFormatTuple, vt, strings, isRangeQuery); + preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery); - Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, strings); + Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple); } catch (Error& e) { ASSERT(e.code() == error_code_mapper_bad_index); throwException = true; @@ -3694,11 +3685,10 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") { try { Tuple mappedKeyTuple; std::vector> vt; - std::vector strings; bool isRangeQuery = false; - preprocessMappedKey(mappedKeyFormatTuple, vt, strings, isRangeQuery); + preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery); - Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, strings); + Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple); } catch (Error& e) { ASSERT(e.code() == error_code_mapper_bad_range_decriptor); throwException2 = true; @@ -3711,11 +3701,10 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") { try { Tuple mappedKeyTuple; std::vector> vt; - std::vector strings; bool isRangeQuery = false; - preprocessMappedKey(mappedKeyFormatTuple, vt, strings, isRangeQuery); + preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery); - Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, strings); + Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple); } catch (Error& e) { ASSERT(e.code() == error_code_mapper_bad_index); throwException3 = true; @@ -3750,16 +3739,15 @@ ACTOR Future mapKeyValues(StorageServer* data, } state KeyValueRef* it = input.data.begin(); state std::vector> vt; - state std::vector strings; state bool isRangeQuery = false; - preprocessMappedKey(mappedKeyFormatTuple, vt, strings, isRangeQuery); + preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery); for (; it != input.data.end(); it++) { state MappedKeyValueRef kvm; kvm.key = it->key; kvm.value = it->value; - state Key mappedKey = constructMappedKey(it, vt, mappedKeyTuple, strings); + state Key mappedKey = constructMappedKey(it, vt, mappedKeyTuple, mappedKeyFormatTuple); // Make sure the mappedKey is always available, so that it's good even we want to get key asynchronously. result.arena.dependsOn(mappedKey.arena()); diff --git a/packaging/docker/sidecar.py b/packaging/docker/sidecar.py index 6fb80b4880..342d9dc305 100755 --- a/packaging/docker/sidecar.py +++ b/packaging/docker/sidecar.py @@ -523,7 +523,7 @@ class Server(BaseHTTPRequestHandler): self.send_error(404, "Path not found") self.end_headers() if self.path.startswith("/is_present/"): - if is_present(os.path.basename(self.path))): + if is_present(os.path.basename(self.path)): self.send_text("OK") else: self.send_error(404, "Path not found")