コード例 #1
0
ファイル: data_index.cpp プロジェクト: 343829084/toft
void DataIndex::AddDataBlockInfo(int compress_data_size, int uncompress_data_size,
                                 const std::string &first_key) {
    if (buffer_.empty())
        buffer_ = kIndexBlockMagic;
    PutFixed64(&buffer_, last_offset_);
    PutFixed32(&buffer_, uncompress_data_size);
    Varint::Put32(&buffer_, first_key.size());
    buffer_ += first_key;
    last_offset_ += compress_data_size;
}
コード例 #2
0
ファイル: dbformat.cpp プロジェクト: yanxi10/leveldblib
void InternalKeyComparator::FindShortSuccessor(std::string* key) const {
  Slice user_key = ExtractUserKey(*key);
  std::string tmp(user_key.data(), user_key.size());
  user_comparator_->FindShortSuccessor(&tmp);
  if (tmp.size() < user_key.size() &&
      user_comparator_->Compare(user_key, tmp) < 0) {
    // User key has become shorter physically, but larger logically.
    // Tack on the earliest possible number to the shortened user key.
    PutFixed64(&tmp, PackSequenceAndType(kMaxSequenceNumber,kValueTypeForSeek));
    assert(this->Compare(*key, tmp) < 0);
    key->swap(tmp);
  }
}
コード例 #3
0
ファイル: dbformat.cpp プロジェクト: yanxi10/leveldblib
void InternalKeyComparator::FindShortestSeparator(
      std::string* start,
      const Slice& limit) const {
  // Attempt to shorten the user portion of the key
  Slice user_start = ExtractUserKey(*start);
  Slice user_limit = ExtractUserKey(limit);
  std::string tmp(user_start.data(), user_start.size());
  user_comparator_->FindShortestSeparator(&tmp, user_limit);
  if (tmp.size() < user_start.size() &&
      user_comparator_->Compare(user_start, tmp) < 0) {
    // User key has become shorter physically, but larger logically.
    // Tack on the earliest possible number to the shortened user key.
    PutFixed64(&tmp, PackSequenceAndType(kMaxSequenceNumber,kValueTypeForSeek));
    assert(this->Compare(*start, tmp) < 0);
    assert(this->Compare(tmp, limit) < 0);
    start->swap(tmp);
  }
}
コード例 #4
0
ファイル: dbformat.cpp プロジェクト: yanxi10/leveldblib
void AppendInternalKey(std::string* result, const ParsedInternalKey& key) {
  result->append(key.user_key.data(), key.user_key.size());
  PutFixed64(result, PackSequenceAndType(key.sequence, key.type));
}