version_edit.cc 18.3 KB
Newer Older
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
S
Siying Dong 已提交
2 3 4
//  This source code is licensed under both the GPLv2 (found in the
//  COPYING file in the root directory) and Apache 2.0 License
//  (found in the LICENSE.Apache file in the root directory).
5
//
J
jorlow@chromium.org 已提交
6 7 8 9 10 11 12
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.

#include "db/version_edit.h"

#include "db/version_set.h"
13
#include "rocksdb/slice.h"
J
jorlow@chromium.org 已提交
14
#include "util/coding.h"
15
#include "util/event_logger.h"
16
#include "util/string_util.h"
17
#include "util/sync_point.h"
J
jorlow@chromium.org 已提交
18

19
namespace rocksdb {
J
jorlow@chromium.org 已提交
20 21 22 23

// Tag numbers for serialized VersionEdit.  These numbers are written to
// disk and should not be changed.
enum Tag {
24 25 26 27 28 29 30
  kComparator = 1,
  kLogNumber = 2,
  kNextFileNumber = 3,
  kLastSequence = 4,
  kCompactPointer = 5,
  kDeletedFile = 6,
  kNewFile = 7,
D
dgrogan@chromium.org 已提交
31
  // 8 was used for large value refs
32
  kPrevLogNumber = 9,
S
Siying Dong 已提交
33
  kMinLogNumberToKeep = 10,
34 35

  // these are new formats divergent from open source leveldb
36 37
  kNewFile2 = 100,
  kNewFile3 = 102,
38
  kNewFile4 = 103,      // 4th (the latest) format version of adding files
39 40 41 42
  kColumnFamily = 200,  // specify column family for version edit
  kColumnFamilyAdd = 201,
  kColumnFamilyDrop = 202,
  kMaxColumnFamily = 203,
J
jorlow@chromium.org 已提交
43 44
};

45 46 47
enum CustomTag {
  kTerminate = 1,  // The end of customized fields
  kNeedCompaction = 2,
S
Siying Dong 已提交
48 49 50 51 52
  // Since Manifest is not entirely currently forward-compatible, and the only
  // forward-compatbile part is the CutsomtTag of kNewFile, we currently encode
  // kMinLogNumberToKeep as part of a CustomTag as a hack. This should be
  // removed when manifest becomes forward-comptabile.
  kMinLogNumberToKeepHack = 3,
53 54 55 56 57 58
  kPathId = 65,
};
// If this bit for the custom tag is set, opening DB should fail if
// we don't know this field.
uint32_t kCustomTagNonSafeIgnoreMask = 1 << 6;

59 60 61 62 63
uint64_t PackFileNumberAndPathId(uint64_t number, uint64_t path_id) {
  assert(number <= kFileNumberMask);
  return number | (path_id * (kFileNumberMask + 1));
}

J
jorlow@chromium.org 已提交
64 65
void VersionEdit::Clear() {
  comparator_.clear();
66
  max_level_ = 0;
J
jorlow@chromium.org 已提交
67
  log_number_ = 0;
68
  prev_log_number_ = 0;
J
jorlow@chromium.org 已提交
69 70
  last_sequence_ = 0;
  next_file_number_ = 0;
71
  max_column_family_ = 0;
S
Siying Dong 已提交
72
  min_log_number_to_keep_ = 0;
J
jorlow@chromium.org 已提交
73 74
  has_comparator_ = false;
  has_log_number_ = false;
75
  has_prev_log_number_ = false;
J
jorlow@chromium.org 已提交
76 77
  has_next_file_number_ = false;
  has_last_sequence_ = false;
78
  has_max_column_family_ = false;
S
Siying Dong 已提交
79
  has_min_log_number_to_keep_ = false;
J
jorlow@chromium.org 已提交
80 81
  deleted_files_.clear();
  new_files_.clear();
82 83 84 85
  column_family_ = 0;
  is_column_family_add_ = 0;
  is_column_family_drop_ = 0;
  column_family_name_.clear();
J
jorlow@chromium.org 已提交
86 87
}

88
bool VersionEdit::EncodeTo(std::string* dst) const {
J
jorlow@chromium.org 已提交
89 90 91 92 93
  if (has_comparator_) {
    PutVarint32(dst, kComparator);
    PutLengthPrefixedSlice(dst, comparator_);
  }
  if (has_log_number_) {
94
    PutVarint32Varint64(dst, kLogNumber, log_number_);
J
jorlow@chromium.org 已提交
95
  }
96
  if (has_prev_log_number_) {
97
    PutVarint32Varint64(dst, kPrevLogNumber, prev_log_number_);
98
  }
J
jorlow@chromium.org 已提交
99
  if (has_next_file_number_) {
100
    PutVarint32Varint64(dst, kNextFileNumber, next_file_number_);
J
jorlow@chromium.org 已提交
101 102
  }
  if (has_last_sequence_) {
103
    PutVarint32Varint64(dst, kLastSequence, last_sequence_);
J
jorlow@chromium.org 已提交
104
  }
105
  if (has_max_column_family_) {
106
    PutVarint32Varint32(dst, kMaxColumnFamily, max_column_family_);
107
  }
K
kailiu 已提交
108
  for (const auto& deleted : deleted_files_) {
109 110
    PutVarint32Varint32Varint64(dst, kDeletedFile, deleted.first /* level */,
                                deleted.second /* file number */);
J
jorlow@chromium.org 已提交
111 112
  }

S
Siying Dong 已提交
113
  bool min_log_num_written = false;
D
dgrogan@chromium.org 已提交
114
  for (size_t i = 0; i < new_files_.size(); i++) {
J
jorlow@chromium.org 已提交
115
    const FileMetaData& f = new_files_[i].second;
116 117 118
    if (!f.smallest.Valid() || !f.largest.Valid()) {
      return false;
    }
119
    bool has_customized_fields = false;
S
Siying Dong 已提交
120
    if (f.marked_for_compaction || has_min_log_number_to_keep_) {
121 122 123
      PutVarint32(dst, kNewFile4);
      has_customized_fields = true;
    } else if (f.fd.GetPathId() == 0) {
124 125 126 127 128 129
      // Use older format to make sure user can roll back the build if they
      // don't config multiple DB paths.
      PutVarint32(dst, kNewFile2);
    } else {
      PutVarint32(dst, kNewFile3);
    }
130
    PutVarint32Varint64(dst, new_files_[i].first /* level */, f.fd.GetNumber());
131 132
    if (f.fd.GetPathId() != 0 && !has_customized_fields) {
      // kNewFile3
133 134
      PutVarint32(dst, f.fd.GetPathId());
    }
135
    PutVarint64(dst, f.fd.GetFileSize());
J
jorlow@chromium.org 已提交
136 137
    PutLengthPrefixedSlice(dst, f.smallest.Encode());
    PutLengthPrefixedSlice(dst, f.largest.Encode());
138
    PutVarint64Varint64(dst, f.smallest_seqno, f.largest_seqno);
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
    if (has_customized_fields) {
      // Customized fields' format:
      // +-----------------------------+
      // | 1st field's tag (varint32)  |
      // +-----------------------------+
      // | 1st field's size (varint32) |
      // +-----------------------------+
      // |    bytes for 1st field      |
      // |  (based on size decoded)    |
      // +-----------------------------+
      // |                             |
      // |          ......             |
      // |                             |
      // +-----------------------------+
      // | last field's size (varint32)|
      // +-----------------------------+
      // |    bytes for last field     |
      // |  (based on size decoded)    |
      // +-----------------------------+
      // | terminating tag (varint32)  |
      // +-----------------------------+
      //
      // Customized encoding for fields:
      //   tag kPathId: 1 byte as path_id
      //   tag kNeedCompaction:
      //        now only can take one char value 1 indicating need-compaction
      //
      if (f.fd.GetPathId() != 0) {
        PutVarint32(dst, CustomTag::kPathId);
        char p = static_cast<char>(f.fd.GetPathId());
        PutLengthPrefixedSlice(dst, Slice(&p, 1));
      }
      if (f.marked_for_compaction) {
        PutVarint32(dst, CustomTag::kNeedCompaction);
        char p = static_cast<char>(1);
        PutLengthPrefixedSlice(dst, Slice(&p, 1));
      }
S
Siying Dong 已提交
176 177 178 179 180 181 182
      if (has_min_log_number_to_keep_ && !min_log_num_written) {
        PutVarint32(dst, CustomTag::kMinLogNumberToKeepHack);
        std::string varint_log_number;
        PutFixed64(&varint_log_number, min_log_number_to_keep_);
        PutLengthPrefixedSlice(dst, Slice(varint_log_number));
        min_log_num_written = true;
      }
183 184 185 186 187
      TEST_SYNC_POINT_CALLBACK("VersionEdit::EncodeTo:NewFile4:CustomizeFields",
                               dst);

      PutVarint32(dst, CustomTag::kTerminate);
    }
J
jorlow@chromium.org 已提交
188
  }
189 190 191

  // 0 is default and does not need to be explicitly written
  if (column_family_ != 0) {
192
    PutVarint32Varint32(dst, kColumnFamily, column_family_);
193 194 195 196 197 198 199 200 201 202
  }

  if (is_column_family_add_) {
    PutVarint32(dst, kColumnFamilyAdd);
    PutLengthPrefixedSlice(dst, Slice(column_family_name_));
  }

  if (is_column_family_drop_) {
    PutVarint32(dst, kColumnFamilyDrop);
  }
203
  return true;
J
jorlow@chromium.org 已提交
204 205 206 207 208 209
}

static bool GetInternalKey(Slice* input, InternalKey* dst) {
  Slice str;
  if (GetLengthPrefixedSlice(input, &str)) {
    dst->DecodeFrom(str);
210
    return dst->Valid();
J
jorlow@chromium.org 已提交
211 212 213 214 215
  } else {
    return false;
  }
}

A
Andrew Kryczka 已提交
216
bool VersionEdit::GetLevel(Slice* input, int* level, const char** /*msg*/) {
J
jorlow@chromium.org 已提交
217
  uint32_t v;
218
  if (GetVarint32(input, &v)) {
J
jorlow@chromium.org 已提交
219
    *level = v;
220 221 222
    if (max_level_ < *level) {
      max_level_ = *level;
    }
J
jorlow@chromium.org 已提交
223 224 225 226 227 228
    return true;
  } else {
    return false;
  }
}

229 230 231 232 233 234 235
const char* VersionEdit::DecodeNewFile4From(Slice* input) {
  const char* msg = nullptr;
  int level;
  FileMetaData f;
  uint64_t number;
  uint32_t path_id = 0;
  uint64_t file_size;
S
Siying Dong 已提交
236 237 238
  // Since this is the only forward-compatible part of the code, we hack new
  // extension into this record. When we do, we set this boolean to distinguish
  // the record from the normal NewFile records.
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
  if (GetLevel(input, &level, &msg) && GetVarint64(input, &number) &&
      GetVarint64(input, &file_size) && GetInternalKey(input, &f.smallest) &&
      GetInternalKey(input, &f.largest) &&
      GetVarint64(input, &f.smallest_seqno) &&
      GetVarint64(input, &f.largest_seqno)) {
    // See comments in VersionEdit::EncodeTo() for format of customized fields
    while (true) {
      uint32_t custom_tag;
      Slice field;
      if (!GetVarint32(input, &custom_tag)) {
        return "new-file4 custom field";
      }
      if (custom_tag == kTerminate) {
        break;
      }
      if (!GetLengthPrefixedSlice(input, &field)) {
        return "new-file4 custom field lenth prefixed slice error";
      }
      switch (custom_tag) {
        case kPathId:
          if (field.size() != 1) {
            return "path_id field wrong size";
          }
          path_id = field[0];
          if (path_id > 3) {
            return "path_id wrong vaue";
          }
          break;
        case kNeedCompaction:
          if (field.size() != 1) {
            return "need_compaction field wrong size";
          }
          f.marked_for_compaction = (field[0] == 1);
          break;
S
Siying Dong 已提交
273 274 275 276 277 278 279 280
        case kMinLogNumberToKeepHack:
          // This is a hack to encode kMinLogNumberToKeep in a
          // forward-compatbile fashion.
          if (!GetFixed64(&field, &min_log_number_to_keep_)) {
            return "deleted log number malformatted";
          }
          has_min_log_number_to_keep_ = true;
          break;
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
        default:
          if ((custom_tag & kCustomTagNonSafeIgnoreMask) != 0) {
            // Should not proceed if cannot understand it
            return "new-file4 custom field not supported";
          }
          break;
      }
    }
  } else {
    return "new-file4 entry";
  }
  f.fd = FileDescriptor(number, path_id, file_size);
  new_files_.push_back(std::make_pair(level, f));
  return nullptr;
}

J
jorlow@chromium.org 已提交
297 298 299
Status VersionEdit::DecodeFrom(const Slice& src) {
  Clear();
  Slice input = src;
A
Abhishek Kona 已提交
300
  const char* msg = nullptr;
J
jorlow@chromium.org 已提交
301 302 303 304 305 306 307 308
  uint32_t tag;

  // Temporary storage for parsing
  int level;
  FileMetaData f;
  Slice str;
  InternalKey key;

A
Abhishek Kona 已提交
309
  while (msg == nullptr && GetVarint32(&input, &tag)) {
J
jorlow@chromium.org 已提交
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
    switch (tag) {
      case kComparator:
        if (GetLengthPrefixedSlice(&input, &str)) {
          comparator_ = str.ToString();
          has_comparator_ = true;
        } else {
          msg = "comparator name";
        }
        break;

      case kLogNumber:
        if (GetVarint64(&input, &log_number_)) {
          has_log_number_ = true;
        } else {
          msg = "log number";
        }
        break;

328 329 330 331 332 333 334 335
      case kPrevLogNumber:
        if (GetVarint64(&input, &prev_log_number_)) {
          has_prev_log_number_ = true;
        } else {
          msg = "previous log number";
        }
        break;

J
jorlow@chromium.org 已提交
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
      case kNextFileNumber:
        if (GetVarint64(&input, &next_file_number_)) {
          has_next_file_number_ = true;
        } else {
          msg = "next file number";
        }
        break;

      case kLastSequence:
        if (GetVarint64(&input, &last_sequence_)) {
          has_last_sequence_ = true;
        } else {
          msg = "last sequence number";
        }
        break;

352 353 354 355 356 357 358 359
      case kMaxColumnFamily:
        if (GetVarint32(&input, &max_column_family_)) {
          has_max_column_family_ = true;
        } else {
          msg = "max column family";
        }
        break;

S
Siying Dong 已提交
360 361 362 363 364 365 366 367
      case kMinLogNumberToKeep:
        if (GetVarint64(&input, &min_log_number_to_keep_)) {
          has_min_log_number_to_keep_ = true;
        } else {
          msg = "min log number to kee";
        }
        break;

J
jorlow@chromium.org 已提交
368
      case kCompactPointer:
369
        if (GetLevel(&input, &level, &msg) &&
J
jorlow@chromium.org 已提交
370
            GetInternalKey(&input, &key)) {
I
Igor Canadi 已提交
371 372 373
          // we don't use compact pointers anymore,
          // but we should not fail if they are still
          // in manifest
J
jorlow@chromium.org 已提交
374
        } else {
375 376 377
          if (!msg) {
            msg = "compaction pointer";
          }
J
jorlow@chromium.org 已提交
378 379 380
        }
        break;

I
Igor Canadi 已提交
381 382 383
      case kDeletedFile: {
        uint64_t number;
        if (GetLevel(&input, &level, &msg) && GetVarint64(&input, &number)) {
J
jorlow@chromium.org 已提交
384 385
          deleted_files_.insert(std::make_pair(level, number));
        } else {
386 387 388
          if (!msg) {
            msg = "deleted file";
          }
J
jorlow@chromium.org 已提交
389 390
        }
        break;
I
Igor Canadi 已提交
391
      }
J
jorlow@chromium.org 已提交
392

393 394 395 396 397
      case kNewFile: {
        uint64_t number;
        uint64_t file_size;
        if (GetLevel(&input, &level, &msg) && GetVarint64(&input, &number) &&
            GetVarint64(&input, &file_size) &&
J
jorlow@chromium.org 已提交
398 399
            GetInternalKey(&input, &f.smallest) &&
            GetInternalKey(&input, &f.largest)) {
400
          f.fd = FileDescriptor(number, 0, file_size);
J
jorlow@chromium.org 已提交
401 402
          new_files_.push_back(std::make_pair(level, f));
        } else {
403 404 405
          if (!msg) {
            msg = "new-file entry";
          }
J
jorlow@chromium.org 已提交
406 407
        }
        break;
408 409 410 411 412 413
      }
      case kNewFile2: {
        uint64_t number;
        uint64_t file_size;
        if (GetLevel(&input, &level, &msg) && GetVarint64(&input, &number) &&
            GetVarint64(&input, &file_size) &&
414 415 416
            GetInternalKey(&input, &f.smallest) &&
            GetInternalKey(&input, &f.largest) &&
            GetVarint64(&input, &f.smallest_seqno) &&
417
            GetVarint64(&input, &f.largest_seqno)) {
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
          f.fd = FileDescriptor(number, 0, file_size);
          new_files_.push_back(std::make_pair(level, f));
        } else {
          if (!msg) {
            msg = "new-file2 entry";
          }
        }
        break;
      }

      case kNewFile3: {
        uint64_t number;
        uint32_t path_id;
        uint64_t file_size;
        if (GetLevel(&input, &level, &msg) && GetVarint64(&input, &number) &&
            GetVarint32(&input, &path_id) && GetVarint64(&input, &file_size) &&
            GetInternalKey(&input, &f.smallest) &&
            GetInternalKey(&input, &f.largest) &&
            GetVarint64(&input, &f.smallest_seqno) &&
            GetVarint64(&input, &f.largest_seqno)) {
          f.fd = FileDescriptor(number, path_id, file_size);
439 440 441
          new_files_.push_back(std::make_pair(level, f));
        } else {
          if (!msg) {
442
            msg = "new-file3 entry";
443 444 445
          }
        }
        break;
446
      }
447

448 449 450 451 452
      case kNewFile4: {
        msg = DecodeNewFile4From(&input);
        break;
      }

453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
      case kColumnFamily:
        if (!GetVarint32(&input, &column_family_)) {
          if (!msg) {
            msg = "set column family id";
          }
        }
        break;

      case kColumnFamilyAdd:
        if (GetLengthPrefixedSlice(&input, &str)) {
          is_column_family_add_ = true;
          column_family_name_ = str.ToString();
        } else {
          if (!msg) {
            msg = "column family add";
          }
        }
        break;

      case kColumnFamilyDrop:
        is_column_family_drop_ = true;
        break;

J
jorlow@chromium.org 已提交
476 477 478 479 480 481
      default:
        msg = "unknown tag";
        break;
    }
  }

A
Abhishek Kona 已提交
482
  if (msg == nullptr && !input.empty()) {
J
jorlow@chromium.org 已提交
483 484 485 486
    msg = "invalid tag";
  }

  Status result;
A
Abhishek Kona 已提交
487
  if (msg != nullptr) {
J
jorlow@chromium.org 已提交
488 489 490 491 492
    result = Status::Corruption("VersionEdit", msg);
  }
  return result;
}

493
std::string VersionEdit::DebugString(bool hex_key) const {
J
jorlow@chromium.org 已提交
494 495 496 497 498 499 500 501 502 503
  std::string r;
  r.append("VersionEdit {");
  if (has_comparator_) {
    r.append("\n  Comparator: ");
    r.append(comparator_);
  }
  if (has_log_number_) {
    r.append("\n  LogNumber: ");
    AppendNumberTo(&r, log_number_);
  }
504 505 506 507
  if (has_prev_log_number_) {
    r.append("\n  PrevLogNumber: ");
    AppendNumberTo(&r, prev_log_number_);
  }
J
jorlow@chromium.org 已提交
508
  if (has_next_file_number_) {
509
    r.append("\n  NextFileNumber: ");
J
jorlow@chromium.org 已提交
510 511
    AppendNumberTo(&r, next_file_number_);
  }
S
Siying Dong 已提交
512 513 514 515
  if (has_min_log_number_to_keep_) {
    r.append("\n  MinLogNumberToKeep: ");
    AppendNumberTo(&r, min_log_number_to_keep_);
  }
J
jorlow@chromium.org 已提交
516 517 518 519 520 521 522 523 524 525 526 527
  if (has_last_sequence_) {
    r.append("\n  LastSeq: ");
    AppendNumberTo(&r, last_sequence_);
  }
  for (DeletedFileSet::const_iterator iter = deleted_files_.begin();
       iter != deleted_files_.end();
       ++iter) {
    r.append("\n  DeleteFile: ");
    AppendNumberTo(&r, iter->first);
    r.append(" ");
    AppendNumberTo(&r, iter->second);
  }
D
dgrogan@chromium.org 已提交
528
  for (size_t i = 0; i < new_files_.size(); i++) {
J
jorlow@chromium.org 已提交
529 530 531 532
    const FileMetaData& f = new_files_[i].second;
    r.append("\n  AddFile: ");
    AppendNumberTo(&r, new_files_[i].first);
    r.append(" ");
533
    AppendNumberTo(&r, f.fd.GetNumber());
J
jorlow@chromium.org 已提交
534
    r.append(" ");
535
    AppendNumberTo(&r, f.fd.GetFileSize());
G
Gabor Cselle 已提交
536
    r.append(" ");
537
    r.append(f.smallest.DebugString(hex_key));
G
Gabor Cselle 已提交
538
    r.append(" .. ");
539
    r.append(f.largest.DebugString(hex_key));
J
jorlow@chromium.org 已提交
540
  }
541 542 543 544 545 546 547 548 549
  r.append("\n  ColumnFamily: ");
  AppendNumberTo(&r, column_family_);
  if (is_column_family_add_) {
    r.append("\n  ColumnFamilyAdd: ");
    r.append(column_family_name_);
  }
  if (is_column_family_drop_) {
    r.append("\n  ColumnFamilyDrop");
  }
550 551
  if (has_max_column_family_) {
    r.append("\n  MaxColumnFamily: ");
552
    AppendNumberTo(&r, max_column_family_);
553
  }
J
jorlow@chromium.org 已提交
554 555 556 557
  r.append("\n}\n");
  return r;
}

558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
std::string VersionEdit::DebugJSON(int edit_num, bool hex_key) const {
  JSONWriter jw;
  jw << "EditNumber" << edit_num;

  if (has_comparator_) {
    jw << "Comparator" << comparator_;
  }
  if (has_log_number_) {
    jw << "LogNumber" << log_number_;
  }
  if (has_prev_log_number_) {
    jw << "PrevLogNumber" << prev_log_number_;
  }
  if (has_next_file_number_) {
    jw << "NextFileNumber" << next_file_number_;
  }
  if (has_last_sequence_) {
    jw << "LastSeq" << last_sequence_;
  }

  if (!deleted_files_.empty()) {
    jw << "DeletedFiles";
    jw.StartArray();

    for (DeletedFileSet::const_iterator iter = deleted_files_.begin();
         iter != deleted_files_.end();
         ++iter) {
      jw.StartArrayedObject();
      jw << "Level" << iter->first;
      jw << "FileNumber" << iter->second;
      jw.EndArrayedObject();
    }

    jw.EndArray();
  }

  if (!new_files_.empty()) {
    jw << "AddedFiles";
    jw.StartArray();

    for (size_t i = 0; i < new_files_.size(); i++) {
      jw.StartArrayedObject();
      jw << "Level" << new_files_[i].first;
      const FileMetaData& f = new_files_[i].second;
      jw << "FileNumber" << f.fd.GetNumber();
      jw << "FileSize" << f.fd.GetFileSize();
      jw << "SmallestIKey" << f.smallest.DebugString(hex_key);
      jw << "LargestIKey" << f.largest.DebugString(hex_key);
      jw.EndArrayedObject();
    }

    jw.EndArray();
  }

  jw << "ColumnFamily" << column_family_;

  if (is_column_family_add_) {
    jw << "ColumnFamilyAdd" << column_family_name_;
  }
  if (is_column_family_drop_) {
    jw << "ColumnFamilyDrop" << column_family_name_;
  }
  if (has_max_column_family_) {
    jw << "MaxColumnFamily" << max_column_family_;
  }
S
Siying Dong 已提交
623 624 625
  if (has_min_log_number_to_keep_) {
    jw << "MinLogNumberToKeep" << min_log_number_to_keep_;
  }
626 627 628 629 630 631

  jw.EndObject();

  return jw.Get();
}

632
}  // namespace rocksdb