diff options
Diffstat (limited to 'db/dbformat.cc')
-rw-r--r-- | db/dbformat.cc | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/db/dbformat.cc b/db/dbformat.cc index 2664eb4..c12c138 100644 --- a/db/dbformat.cc +++ b/db/dbformat.cc @@ -84,69 +84,4 @@ void InternalKeyComparator::FindShortSuccessor(std::string* key) const { } } -LargeValueRef LargeValueRef::Make(const Slice& value, CompressionType ctype) { - LargeValueRef result; - port::SHA1_Hash(value.data(), value.size(), &result.data[0]); - EncodeFixed64(&result.data[20], value.size()); - result.data[28] = static_cast<unsigned char>(ctype); - return result; -} - -std::string LargeValueRefToFilenameString(const LargeValueRef& h) { - assert(sizeof(h.data) == LargeValueRef::ByteSize()); - assert(sizeof(h.data) == 29); // So we can hardcode the array size of buf - static const char tohex[] = "0123456789abcdef"; - char buf[20*2]; - for (int i = 0; i < 20; i++) { - buf[2*i] = tohex[(h.data[i] >> 4) & 0xf]; - buf[2*i+1] = tohex[h.data[i] & 0xf]; - } - std::string result = std::string(buf, sizeof(buf)); - result += "-"; - result += NumberToString(h.ValueSize()); - result += "-"; - result += NumberToString(static_cast<uint64_t>(h.compression_type())); - return result; -} - -static uint32_t hexvalue(char c) { - if (c >= '0' && c <= '9') { - return c - '0'; - } else if (c >= 'A' && c <= 'F') { - return 10 + c - 'A'; - } else { - assert(c >= 'a' && c <= 'f'); - return 10 + c - 'a'; - } -} - -bool FilenameStringToLargeValueRef(const Slice& s, LargeValueRef* h) { - Slice in = s; - if (in.size() < 40) { - return false; - } - for (int i = 0; i < 20; i++) { - if (!isxdigit(in[i*2]) || !isxdigit(in[i*2+1])) { - return false; - } - unsigned char c = (hexvalue(in[i*2])<<4) | hexvalue(in[i*2+1]); - h->data[i] = c; - } - in.remove_prefix(40); - uint64_t value_size, ctype; - - if (ConsumeChar(&in, '-') && - ConsumeDecimalNumber(&in, &value_size) && - ConsumeChar(&in, '-') && - ConsumeDecimalNumber(&in, &ctype) && - in.empty() && - (ctype <= kSnappyCompression)) { - EncodeFixed64(&h->data[20], value_size); - h->data[28] = static_cast<unsigned char>(ctype); - return true; - } else { - return false; - } -} - } |