Ver a proveniência

Merge branch 'cyq' into ld

pull/2/head
augurier há 8 meses
ascendente
cometimento
76b52eb235
3 ficheiros alterados com 20 adições e 16 eliminações
  1. +2
    -0
      benchmarks/db_bench.cc
  2. +2
    -2
      fielddb/field_db.h
  3. +16
    -14
      fielddb/request.cpp

+ 2
- 0
benchmarks/db_bench.cc Ver ficheiro

@ -1127,6 +1127,8 @@ int main(int argc, char** argv) {
}
}
FLAGS_num /= FLAGS_threads;
leveldb::g_env = leveldb::Env::Default();
// Choose a location for the test database if none given with --db=<path>

+ 2
- 2
fielddb/field_db.h Ver ficheiro

@ -109,7 +109,7 @@ private:
uint64_t write_clean_elapsed = 0;
uint64_t write_bytes = 0;
uint64_t write_bytes_lim = 20 * 1024 * 1024;
uint64_t write_bytes_lim = 50 * 1024 * 1024;
uint64_t temp_elapsed = 0;
@ -135,7 +135,7 @@ private:
std::cout << "temp_elased : " << temp_elapsed * 1.0 / count<< std::endl;
// std::cout << MetaBatch.ApproximateSize() << " " << IndexBatch.ApproximateSize() << " " << KVBatch.ApproximateSize() << std::endl;
std::cout << "=====================================================\n";
write_bytes_lim = write_bytes + 20 * 1024 * 1024;
write_bytes_lim = write_bytes + 50 * 1024 * 1024;
std::fflush(stdout);
}
}

+ 16
- 14
fielddb/request.cpp Ver ficheiro

@ -17,6 +17,8 @@
namespace fielddb {
using namespace leveldb;
const char EMPTY[1] = {0};
//为虚函数提供最基本的实现
void Request::PendReq(Request *req) {
assert(0);
@ -77,7 +79,7 @@ void FieldsReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch,
DB->index_mu.AssertHeld();
//1.将存在冲突的put pend到对应的请求
for(auto [field_name,field_value] : *Fields) {
if(field_name == "") break;
if(field_name == EMPTY) break;
if(DB->index_.count(field_name)) {
auto [index_status,parent_req] = DB->index_[field_name];
if(index_status == IndexStatus::Creating || index_status == IndexStatus::Deleting) {
@ -92,7 +94,7 @@ void FieldsReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch,
//冲突也可能存在于,需要删除旧数据的索引,但该索引正在创删中
if (oldFields != nullptr){
for(auto [field_name,field_value] : *oldFields) {
if(field_name == "") break;
if(field_name == EMPTY) break;
if(DB->index_.count(field_name)) {
auto [index_status,parent_req] = DB->index_[field_name];
if(index_status == IndexStatus::Creating || index_status == IndexStatus::Deleting) {
@ -119,7 +121,7 @@ void FieldsReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch,
//3.1对于含有索引的oldfield删除索引
if (HasOldIndex) {
for(auto [field_name,field_value] : *oldFields) {
if(field_name == "") continue;
if(field_name == EMPTY) continue;
if(DB->index_.count(field_name)) {
std::string indexKey;
AppendIndexKey(&indexKey, ParsedInternalIndexKey(
@ -132,7 +134,7 @@ void FieldsReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch,
//3.2对于含有索引的field建立索引
if (HasIndex) {
for(auto [field_name,field_value] : *Fields) {
if(field_name == "") continue;
if(field_name == EMPTY) continue;
if(DB->index_.count(field_name)) {
std::string indexKey;
AppendIndexKey(&indexKey, ParsedInternalIndexKey(
@ -177,7 +179,7 @@ void DeleteReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch,
DB->index_mu.AssertHeld();
//1.将存在冲突的delete pend到对应的请求
for(auto [field_name,field_value] : *Fields) {
if(field_name == "") break;
if(field_name == EMPTY) break;
if(DB->index_.count(field_name)) {
auto [index_status,parent_req] = DB->index_[field_name];
if(index_status == IndexStatus::Creating || index_status == IndexStatus::Deleting) {
@ -198,7 +200,7 @@ void DeleteReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch,
MetaBatch.Put(MetaKey, Slice());
//3.对于含有索引的field删除索引
for(auto [field_name,field_value] : *Fields) {
if(field_name == "") continue;
if(field_name == EMPTY) continue;
if(DB->index_.count(field_name)) {
std::string indexKey;
AppendIndexKey(&indexKey, ParsedInternalIndexKey(
@ -338,17 +340,17 @@ BatchReq::BatchReq(WriteBatch *Batch,port::Mutex *mu):
void Put(const Slice &key, const Slice &value) override {
//为key和value构造存储的地方,防止由于string的析构造成可能得内存访问错误
str_buf->push_back(key.ToString());
FieldArray *field = new FieldArray;
field = ParseValue(value.ToString(), field);
if (field->empty()){ //batch中的value没有field
fa_buf->push_back({{"",value.ToString()}});
} else {
fa_buf->push_back(*field);
}
fa_buf->push_back({{EMPTY,value.ToString()}});
// FieldArray *field = new FieldArray;
// field = ParseValue(value.ToString(), field);
// if (field->empty()){ //batch中的value没有field
// } else {
// fa_buf->push_back(*field);
// }
sub_requests->emplace_back(new FieldsReq(&str_buf->back(),&fa_buf->back(),mu));
sub_requests->back()->parent = req;
delete field;
// delete field;
}
void Delete(const Slice &key) override {
str_buf->push_back(key.ToString());

Carregando…
Cancelar
Guardar