What follows is evidence that we do not live in the best of all possible worlds
| 1631 | |
| 1632 | // What follows is evidence that we do not live in the best of all possible worlds |
| 1633 | std::string unstrincObjectId(StringRef encodedKeyPart) { |
| 1634 | bool reduceLength = false; |
| 1635 | bool shouldBeNullTerminated = true; |
| 1636 | switch (DVTypeCode(encodedKeyPart[0])) { |
| 1637 | case DVTypeCode::NUMBER: |
| 1638 | shouldBeNullTerminated = false; |
| 1639 | if (encodedKeyPart.size() == 12) |
| 1640 | reduceLength = true; |
| 1641 | break; |
| 1642 | case DVTypeCode::OID: |
| 1643 | shouldBeNullTerminated = false; |
| 1644 | if (encodedKeyPart.size() == 14) |
| 1645 | reduceLength = true; |
| 1646 | break; |
| 1647 | case DVTypeCode::DATE: |
| 1648 | shouldBeNullTerminated = false; |
| 1649 | if (encodedKeyPart.size() == 10) |
| 1650 | reduceLength = true; |
| 1651 | break; |
| 1652 | default: |
| 1653 | throw unsupported_operation(); |
| 1654 | } |
| 1655 | |
| 1656 | if (reduceLength) { |
| 1657 | return std::string((const char*)encodedKeyPart.begin(), encodedKeyPart.size() - 1); |
| 1658 | } else { |
| 1659 | std::string ret((const char*)encodedKeyPart.begin(), encodedKeyPart.size()); |
| 1660 | if (!shouldBeNullTerminated || (uint8_t)ret[encodedKeyPart.size() - 1] == 1) |
| 1661 | ret[encodedKeyPart.size() - 1]--; |
| 1662 | return ret; |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | ACTOR static Future<Void> scanAndBuildIndex(PlanCheckpoint* checkpoint, |
| 1667 | Reference<DocTransaction> tr, |
no test coverage detected