@@ -320,10 +320,11 @@ Status
320
320
DbImpl::Put (const WriteOptions& options, const Slice& key, const Slice& value) {
321
321
terark::db::DbContext* ctx = GetDbContext ();
322
322
assert (NULL != ctx);
323
+ auto userBuf = ctx->bufs .get ();
323
324
try {
324
325
TRACE_KEY_VAL (key, value);
325
- encodeKeyVal (ctx-> userBuf , key, value);
326
- long long recId = ctx->upsertRow (ctx-> userBuf );
326
+ encodeKeyVal (* userBuf, key, value);
327
+ long long recId = ctx->upsertRow (* userBuf);
327
328
TERARK_RT_assert (recId >= 0 , std::logic_error);
328
329
return Status::OK ();
329
330
}
358
359
WriteBatchHandler::Put (const Slice& key, const Slice& value) {
359
360
auto opctx = context_;
360
361
terark::db::DbContext* ctx = opctx->m_batchWriter .getCtx ();
361
- encodeKeyVal (ctx->userBuf , key, value);
362
- opctx->m_batchWriter .upsertRow (ctx->userBuf );
362
+ auto userBuf = ctx->bufs .get ();
363
+ encodeKeyVal (*userBuf, key, value);
364
+ opctx->m_batchWriter .upsertRow (*userBuf);
363
365
}
364
366
365
367
static const long g_logBatchRemoveNotFound =
@@ -423,16 +425,17 @@ Status
423
425
DbImpl::Get (const ReadOptions& options, const Slice& key, std::string* value) {
424
426
terark::db::DbContext* ctx = GetDbContext ();
425
427
assert (NULL != ctx);
428
+ auto userBuf = ctx->bufs .get ();
426
429
ctx->indexSearchExact (0 , key, &ctx->exactMatchRecIdvec );
427
430
if (!ctx->exactMatchRecIdvec .empty ()) {
428
431
auto recId = ctx->exactMatchRecIdvec [0 ];
429
432
try {
430
- ctx->selectOneColgroup (recId, 1 , &ctx-> userBuf );
433
+ ctx->selectOneColgroup (recId, 1 , userBuf. get () );
431
434
// fprintf(stderr
432
435
// , "DEBUG: recId=%lld, colgroup[1]={size=%zd, content=%.*s}\n"
433
436
// , recId, ctx->userBuf.size(), (int)ctx->userBuf.size(), ctx->userBuf.data());
434
437
value->resize (0 );
435
- value->append ((char *)ctx-> userBuf . data (), ctx-> userBuf . size ());
438
+ value->append ((char *)userBuf-> data (), userBuf-> size ());
436
439
return Status::OK ();
437
440
}
438
441
catch (const std::exception &) {
0 commit comments