王听正
王听正

Reputation: 21

Why flag "begin" in leveldb WAL is defined as ptr == slice.data()?

This code is in leveldb to get the type of fragment type in WAL

Status Writer::AddRecord(const Slice& slice) {
   RecordType type; 
    // Why not defined as left == slice.size();
    const bool begin = (ptr == slice.data());
    const bool end = (left == fragment_length);
    if (begin && end) {
      type = kFullType;
    } else if (begin) {
      type = kFirstType;
    } else if (end) {
      type = kLastType;
    } else {
      type = kMiddleType;
    }

}

Why not defined as left == slice.size()? It looks more simpler?

Upvotes: 1

Views: 42

Answers (0)

Related Questions