MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / unstrincObjectId

Function unstrincObjectId

src/QLPlan.actor.cpp:1633–1664  ·  view source on GitHub ↗

What follows is evidence that we do not live in the best of all possible worlds

Source from the content-addressed store, hash-verified

1631
1632// What follows is evidence that we do not live in the best of all possible worlds
1633std::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
1666ACTOR static Future<Void> scanAndBuildIndex(PlanCheckpoint* checkpoint,
1667 Reference<DocTransaction> tr,

Callers 1

Calls 3

DVTypeCodeEnum · 0.85
beginMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected