//
// Created by 马也驰 on 2025/1/3.
//

#ifndef LEVELDB_GC_EXECUTOR_H
#define LEVELDB_GC_EXECUTOR_H

#include <cstdint>
#include <cstdlib>
#include <string>

class VlogGC;

class gc_executor {
 public:
  explicit gc_executor() {}

  ~gc_executor() = default;

 public:
  static void exec_gc(VlogGC *vlog_gc_, size_t old_vlog_num, size_t new_vlog_num);

 private:
  static inline bool value_deleted(uint16_t value_len) {
    return !(value_len >> 15);
  }
  static inline uint16_t get_value_len(char *value) {
    uint16_t value_len;
    memcpy(&value_len, value, sizeof(uint16_t));
    return value_len;
  }
  static inline size_t get_value_slotnum(char *value) {
    size_t slot_num;
    memcpy(&slot_num, &value[sizeof(uint16_t)], sizeof(size_t));
    return slot_num;
  }

};

#endif  // LEVELDB_GC_EXECUTOR_H
