作者: 韩晨旭 10225101440 李畅 10225102463
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
984 B

#include <iostream>
#include <gtest/gtest.h>
#include "leveldb/db.h"
#include "leveldb/env.h"
#include "table/vtable_builder.h"
#include "table/vtable_reader.h"
#include "table/vtable_format.h"
using namespace std;
using namespace leveldb;
int main() {
VTableHandle handle1;
VTableHandle handle2;
VTableRecord record1;
VTableRecord record2;
record1.key = "001";
record1.value = "value1";
record2.key = "002";
record2.value = "value2";
Options opt;
WritableFile *file;
opt.env->NewWritableFile("1.vtb", &file);
VTableBuilder builder(opt, file);
builder.Add(record1, &handle1);
builder.Add(record2, &handle2);
builder.Finish();
VTableReader reader;
reader.Open(opt, "1.vtb");
VTableRecord res_record;
reader.Get(handle2, &res_record);
cout << res_record.key.ToString() << " " << res_record.value.ToString() << endl;
reader.Get(handle1, &res_record);
cout << res_record.key.ToString() << " " << res_record.value.ToString() << endl;
}