Giter Club home page Giter Club logo

Comments (3)

Lambert-zw avatar Lambert-zw commented on July 17, 2024

`int32_t BatchPutOp(Client* client, int32_t argc, std::string* argv, ErrorCode* err) {
if (argc != 4) {
LOG(ERROR) << "args number error: " << argc << ", need 4.";
PrintCmdHelpInfo(argv[1]);
return -1;
}

std::string tablename = argv[2];
std::string record_file = argv[3];
TablePtr table(client->OpenTable(tablename, err));
if (table == NULL) {
    LOG(ERROR) << "fail to open table";
    return -1;
}
const int32_t buf_size = 1024 * 1024;
char buf[buf_size];
std::ifstream stream(record_file.c_str());

// input record format: rowkey columnfamily:qualifier value
// or: key:value
std::vector<std::string> input_v;
g_start_time = time(NULL);
while (stream.getline(buf, buf_size)) {
    SplitString(buf, " ", &input_v);
    if (input_v.size() != 3 && input_v.size() != 2) {
        LOG(ERROR) << "input file format error, skip it: " << buf;
        continue;
    }
    std::string rowkey = input_v[0];
    if (FLAGS_readable && !ParseDebugString(input_v[0], &rowkey)) {
        LOG(ERROR) << "input file format error, skip it: " << buf;
        continue;
    }
    std::string family;
    std::string qualifier;
    std::string value = input_v[input_v.size() - 1];
    if (FLAGS_readable && !ParseDebugString(input_v[input_v.size() - 1], &value)) {
        LOG(ERROR) << "input file format error, skip it: " << buf;
        continue;
    }
    RowMutation* mutation = table->NewRowMutation(rowkey);
    if (input_v.size() == 2) {
        // for kv mode
        mutation->Put(value);
    } else {
        // for table mode, put(family, qulifier, value)
        ParseCfQualifier(input_v[1], &family, &qualifier);
        mutation->Put(family, qualifier, value);
    }
    mutation->SetCallBack(BatchPutCallBack);
    table->ApplyMutation(mutation);
}
// 这里如果产生极限情况的话
while (!table->IsPutFinished()) {
    usleep(100000);
}

g_end_time = time(NULL);
g_used_time = g_end_time-g_start_time;
LOG(INFO) << "Write done,write_key_num=" << g_key_num << " used_time=" << g_used_time <<std::endl;
return 0;

}
`

from tera.

datonli avatar datonli commented on July 17, 2024

@NightStarSoul 感谢你的反馈,这个问题确实存在。在tera内部版本的代码中已经把sdk端OpenTable返回的Table* 指针——其实是TableWrapper* 指针,所包含的TableImpl* 改为shared_ptr的了,table的生命周期有shared_ptr保证,这个问题会得到解决。

from tera.

datonli avatar datonli commented on July 17, 2024

新版本已更新,问题已修复

from tera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.