本文整理汇总了C++中data_entry类的典型用法代码示例。如果您正苦于以下问题:C++ data_entry类的具体用法?C++ data_entry怎么用?C++ data_entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了data_entry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: get
int tair_manager::get(int area, data_entry &key, data_entry &value)
{
if (status != STATUS_CAN_WORK) {
return TAIR_RETURN_SERVER_CAN_NOT_WORK;
}
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
data_entry mkey = key;
mkey.merge_area(area);
int bucket_number = get_bucket_number(key);
log_debug("get request will server in bucket: %d", bucket_number);
PROFILER_BEGIN("get from storage engine");
int rc = storage_mgr->get(bucket_number, mkey, value);
PROFILER_END();
key.data_meta = mkey.data_meta;
TAIR_STAT.stat_get(area, rc);
return rc;
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:26,代码来源:tair_manager.cpp
示例2: __get_items
int item_manager::__get_items(tair_manager *tair_mgr,int area,data_entry& key,data_entry& value,vector<any>& items,int type /*ELEMENT_TYPE_INVALID*/)
{
int ret = TAIR_RETURN_FAILED;
if( (ret = tair_mgr->get(area,key,value)) != TAIR_RETURN_SUCCESS ){
return ret;
}
if (!tair_mgr->get_storage_manager()->test_flag(value.data_meta.flag, TAIR_ITEM_FLAG_ITEM)) {
log_debug("is not items type,flag:%d",value.data_meta.flag);
return TAIR_RETURN_TYPE_NOT_MATCH;
}
if(type != ELEMENT_TYPE_INVALID){ //need check type
uint32_t attr = get_attribute(value);
log_debug("__get_items:type:%d,attr:%u",type,VAL_TYPE(attr));
if(static_cast<uint32_t>(type) != VAL_TYPE(attr)){
return TAIR_RETURN_TYPE_NOT_MATCH;
}
}
if( !parse_array(get_items_addr(value),value.get_data()+value.get_size(),items)){
log_debug("parse_array failed");
return TAIR_RETURN_SERIALIZE_ERROR;
}
if(items.size() == 0){ //empty
return TAIR_RETURN_ITEM_EMPTY;
}
return 0;
}
开发者ID:xiangyong,项目名称:platform,代码行数:27,代码来源:item_manager.cpp
示例3: log
void update_log::log(sn_operation_type operation_type, data_entry &key, data_entry &value, uint16_t db_id)
{
uint key_size = key.get_size();
if (key.data_meta.keysize == 0){
key.data_meta.keysize = key_size;
}
log_debug("key length: %d, value length:%d", key_size, value.get_size());
uint value_size = 0;
uint header_size = sizeof(item_meta_info);
int total_size = header_size + key_size + 3 ;
if (operation_type == SN_PUT) {
value_size = value.get_size();
if (key.data_meta.valsize == 0){
key.data_meta.valsize = value_size;
}
total_size += value_size;
}
char *log_str = (char *)malloc(total_size);
memcpy(log_str, &(key.data_meta), header_size);
char *ptr = log_str + header_size;
*((int8_t *)ptr) = (int8_t)operation_type;
*((uint16_t *)(ptr + 1)) = (uint16_t)db_id;
memcpy(ptr + 3, key.get_data(), key_size);
if (operation_type == SN_PUT) {
memcpy(ptr + 3 + key_size, value.get_data(), value_size);
}
PROFILER_BEGIN("write migrate log");
writer->write(log_str, total_size);
PROFILER_END();
free(log_str);
}
开发者ID:IsCaster,项目名称:tair-rdb,代码行数:32,代码来源:update_log.cpp
示例4: put
int tair_manager::put(int area, data_entry &key, data_entry &value, int expire_time)
{
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (value.get_size() >= TAIR_MAX_DATA_SIZE || value.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
data_entry mkey = key; // key merged with area
mkey.merge_area(area);
int bucket_number = get_bucket_number(key);
log_debug("put request will server in bucket: %d key =%s ", bucket_number, key.get_data());
key.data_meta.log_self();
int op_flag = get_op_flag(bucket_number, key.server_flag);
int rc = TAIR_RETURN_SERVER_CAN_NOT_WORK;
PROFILER_BEGIN("should write local?");
if (should_write_local(bucket_number, key.server_flag, op_flag, rc) == false) {
PROFILER_END();
return rc;
}
PROFILER_END();
// save into the storage engine
bool version_care = op_flag & TAIR_OPERATION_VERSION;
PROFILER_BEGIN("put into storage");
rc = storage_mgr->put(bucket_number, mkey, value, version_care, expire_time);
PROFILER_END();
if (rc == TAIR_RETURN_SUCCESS ) {
key.data_meta = mkey.data_meta;
if (op_flag & TAIR_OPERATION_DUPLICATE) {
vector<uint64_t> slaves;
get_slaves(key.server_flag, bucket_number, slaves);
if (slaves.empty() == false) {
PROFILER_BEGIN("do duplicate");
duplicator->duplicate_data(area, &key, &value, bucket_number, slaves);
PROFILER_END();
}
}
if (migrate_log != NULL && need_do_migrate_log(bucket_number)) {
PROFILER_BEGIN("do migrate log");
migrate_log->log(SN_PUT, mkey, value, bucket_number);
PROFILER_END();
}
}
TAIR_STAT.stat_put(area);
return rc;
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:59,代码来源:tair_manager.cpp
示例5: dump_key
void RequestProcessor::dump_key(const data_entry &key, const char *msg) {
if (msg == NULL) {
msg = "error";
}
char *d_str = util::string_util::bin2ascii(key.get_data(), key.get_size(), NULL, 0);
log_error("%s, key: %s", msg, d_str);
free(d_str);
}
开发者ID:xiangyong,项目名称:platform,代码行数:8,代码来源:inval_processor.cpp
示例6: remove
int tair_manager::remove(int area, data_entry &key)
{
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
data_entry mkey = key;
mkey.merge_area(area);
int bucket_number = get_bucket_number(key);
int op_flag = get_op_flag(bucket_number, key.server_flag);
int rc = TAIR_RETURN_SERVER_CAN_NOT_WORK;
PROFILER_BEGIN("should write local?");
if (should_write_local(bucket_number, key.server_flag, op_flag, rc) == false) {
PROFILER_END();
return rc;
}
PROFILER_END();
bool version_care = op_flag & TAIR_OPERATION_VERSION;
PROFILER_BEGIN("remove from storage engine");
rc = storage_mgr->remove(bucket_number, mkey, version_care);
PROFILER_END();
if (rc == TAIR_RETURN_SUCCESS || rc == TAIR_RETURN_DATA_NOT_EXIST) {
if (op_flag & TAIR_OPERATION_DUPLICATE) {
vector<uint64_t> slaves;
get_slaves(key.server_flag, bucket_number, slaves);
if (slaves.empty() == false) {
PROFILER_BEGIN("do duplicate");
duplicator->duplicate_data(area, &key, NULL, bucket_number, slaves);
PROFILER_END();
}
}
if (migrate_log != NULL && need_do_migrate_log(bucket_number)) {
PROFILER_BEGIN("do migrate log");
migrate_log->log(SN_REMOVE, mkey, mkey, bucket_number);
PROFILER_END();
}
}
TAIR_STAT.stat_remove(area);
return rc;
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:51,代码来源:tair_manager.cpp
示例7: get_item_count
int tair_manager::get_item_count(int area, data_entry& key)
{
if (status != STATUS_CAN_WORK) {
return TAIR_RETURN_SERVER_CAN_NOT_WORK;
}
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
return json::item_manager::get_item_count(this,area,key);
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:14,代码来源:tair_manager.cpp
示例8: guard
int tair_manager::add_count(int area, data_entry &key, int count, int init_value, int *result_value, int expire_time)
{
if (status != STATUS_CAN_WORK) {
return TAIR_RETURN_SERVER_CAN_NOT_WORK;
}
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
tbsys::CThreadGuard guard(&counter_mutex[get_mutex_index(key)]);
// get from storage engine
data_entry old_value;
PROFILER_BEGIN("get from storage");
int rc = get(area, key, old_value);
PROFILER_END();
log_debug("get result: %d, flag: %d", rc, key.data_meta.flag);
key.data_meta.log_self();
if (rc == TAIR_RETURN_SUCCESS && IS_ADDCOUNT_TYPE(key.data_meta.flag)) {
// old value exist
int32_t *v = (int32_t *)(old_value.get_data() + ITEM_HEAD_LENGTH);
log_debug("old count: %d, new count: %d, init value: %d", (*v), count, init_value);
*v += count;
*result_value = *v;
} else if(rc == TAIR_RETURN_SUCCESS){
//exist,but is not add_count,return error;
log_debug("cann't override old value");
return TAIR_RETURN_CANNOT_OVERRIDE;
}else {
// old value not exist
char fv[6]; // 2 + sizeof(int)
*((short *)fv) = 0x1600; // for java header
*result_value = init_value + count;
*((int32_t *)(fv + 2)) = *result_value;
old_value.set_data(fv, 6);
}
old_value.data_meta.flag |= TAIR_ITEM_FLAG_ADDCOUNT;
log_debug("before put flag: %d", old_value.data_meta.flag);
PROFILER_BEGIN("save count into storage");
int result = put(area, key, old_value, expire_time);
PROFILER_END();
return result;
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:48,代码来源:tair_manager.cpp
示例9: get_from_local_cluster
int get_from_local_cluster(ClusterHandler& handler, data_entry& key, data_entry*& value, bool& skip)
{
int ret = handler.client()->get_hidden(key.get_area(), key, value);
if (ret == TAIR_RETURN_DATA_NOT_EXIST || ret == TAIR_RETURN_DATA_EXPIRED)
{
log_warn("key not exist local");
skip = true;
ret = TAIR_RETURN_SUCCESS;
}
else if (ret != TAIR_RETURN_SUCCESS && ret != TAIR_RETURN_HIDDEN)
{
log_error("get local fail, ret: %d", ret);
}
else
{
key.data_meta.cdate = value->data_meta.cdate;
key.data_meta.edate = value->data_meta.edate;
key.data_meta.mdate = value->data_meta.mdate;
key.data_meta.version = value->data_meta.version;
key.data_meta.keysize = value->data_meta.keysize;
key.data_meta.valsize = value->data_meta.valsize;
ret = TAIR_RETURN_SUCCESS;
}
return ret;
}
开发者ID:0x3FFFFFFF,项目名称:tair,代码行数:26,代码来源:ldb_rsync.cpp
示例10: get_items
int tair_manager::get_items(int area,
data_entry& key,
int offset, int count, data_entry& value /*out*/,
int type /*=ELEMENT_TYPE_INVALID*/)
{
if (status != STATUS_CAN_WORK) {
return TAIR_RETURN_SERVER_CAN_NOT_WORK;
}
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
return json::item_manager::get_items(this,area,key,offset,count,value,type);
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:17,代码来源:tair_manager.cpp
示例11: remove_items
int tair_manager::remove_items(int area,
data_entry& key, int offset, int count)
{
if (status != STATUS_CAN_WORK) {
return TAIR_RETURN_SERVER_CAN_NOT_WORK;
}
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
//tbsys::CThreadGuard guard(&removeItemsMutex[getMutexIndex(key)]);
tbsys::CThreadGuard guard(&item_mutex[get_mutex_index(key)]);
return json::item_manager::remove_items(this,area,key,offset,count);
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:18,代码来源:tair_manager.cpp
示例12: get_and_remove
int tair_manager::get_and_remove(int area,
data_entry& key,
int offset, int count, data_entry& value /*out*/,
int type /*=ELEMENT_TYPE_INVALID*/)
{
if (status != STATUS_CAN_WORK) {
return TAIR_RETURN_SERVER_CAN_NOT_WORK;
}
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
//tbsys::CThreadGuard guard(&getAndRemoveItemsMutex[getMutexIndex(key)]);
tbsys::CThreadGuard guard(&item_mutex[get_mutex_index(key)]);
return json::item_manager::get_and_remove(this,area,key,offset,count,value,type);
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:19,代码来源:tair_manager.cpp
示例13: add_del_key
//add del key
bool add_del_key(const data_entry& key)
{
uint temp = len + key.get_size() + 1;
if (temp > MAX_MUPDATE_PACKET_SIZE){
return false;
}
if (key_and_values == NULL) {
key_and_values = new tair_operc_vector();
}
operation_record *oprec = new operation_record();
oprec->key = new data_entry();
oprec->key->clone(key);
//log_debug("addkeyis %d", oprec->key->m_isMerged);
oprec->operation_type = 2;
oprec->value = NULL;
key_and_values->push_back(oprec);
count++;
len += key.get_size() + 1;
return true;
}
开发者ID:xiangyong,项目名称:platform,代码行数:21,代码来源:mupdate_packet.hpp
示例14: direct_remove
int tair_manager::direct_remove(data_entry &key)
{
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
data_entry akey = key;
akey.decode_area();
int bucket_number = get_bucket_number(akey);
int rc = storage_mgr->remove(bucket_number, key, false);
if (rc == TAIR_RETURN_DATA_NOT_EXIST) {
// for migrate, return SUCCESS
rc = TAIR_RETURN_SUCCESS;
}
TAIR_STAT.stat_remove(akey.area);
return rc;
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:20,代码来源:tair_manager.cpp
示例15: direct_put
int tair_manager::direct_put(data_entry &key, data_entry &value)
{
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (value.get_size() >= TAIR_MAX_DATA_SIZE || value.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
data_entry akey = key;
int area = akey.decode_area();
key.area = area;
int bucket_number = get_bucket_number(akey);
int rc = storage_mgr->put(bucket_number, key, value, false, 0);
TAIR_STAT.stat_put(area);
return rc;
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:21,代码来源:tair_manager.cpp
示例16: get_bucket
int fdb_manager::get(int bucket_number, data_entry & key,
data_entry & value, bool with_stat)
{
fdb_bucket *bucket = get_bucket(bucket_number);
if(bucket == NULL) {
return TAIR_RETURN_FAILED;
}
int rc = TAIR_RETURN_SUCCESS;
PROFILER_BEGIN("get from cache");
if(memory_cache->get(bucket_number, key, value) == EXIT_SUCCESS) {
log_debug("value get from mdb, size: %d", value.get_size());
value.decode_meta(true);
key.data_meta = value.data_meta;
log_debug("memcache ing");
key.data_meta.log_self();
log_debug("cache hit...");
PROFILER_END();
return rc;
}
PROFILER_END();
rc = bucket->get(key, value);
log_debug("fdb getting");
key.data_meta.log_self();
PROFILER_BEGIN("put into cache");
if(rc == TAIR_RETURN_SUCCESS) {
data_entry temp_value = value;
temp_value.merge_meta();
log_debug("value put into mdb, size: %d", temp_value.get_size());
memory_cache->put(bucket_number, key, temp_value, false,
key.data_meta.edate);
}
PROFILER_END();
return rc;
}
开发者ID:xiangyong,项目名称:platform,代码行数:39,代码来源:fdb_manager.cpp
示例17: add_put_key_data
bool add_put_key_data(const data_entry &key, const value_entry &data)
{
uint32_t temp = len + key.get_size() + 1 + data.get_size();
if (temp > MAX_MPUT_PACKET_SIZE && count > 0) {
log_info("mput packet size overflow: %u", temp);
return false;
}
if (record_vec == NULL) {
record_vec = new mput_record_vec();
alloc = true;
}
mput_record* rec = new mput_record();
rec->key = new data_entry();
rec->key->clone(key);
rec->value = new value_entry();
rec->value->clone(data);
record_vec->push_back(rec);
len += key.get_size() + 1;
len += data.get_size();
count++;
return true;
}
开发者ID:yinchunxiang,项目名称:tair_trunk_r1797_annotation,代码行数:23,代码来源:put_packet.hpp
示例18: get_from_local_cluster
int get_from_local_cluster(ClusterHandler& handler, data_entry& key, data_entry*& value)
{
int ret = handler.client()->get_hidden(key.get_area(), key, value);
if (ret == TAIR_RETURN_HIDDEN)
{
ret = TAIR_RETURN_SUCCESS;
}
else if (ret == TAIR_RETURN_DATA_EXPIRED)
{
ret = TAIR_RETURN_DATA_NOT_EXIST;
}
return ret;
}
开发者ID:0x3FFFFFFF,项目名称:tair,代码行数:14,代码来源:repair_rsync.cpp
示例19: get_items
int item_manager::get_items(tair_manager *tair_mgr,int area,data_entry& key,int offset,int count,data_entry& value /*out*/,int type)
{
if(area < 0 || key.get_size() <= 0 || count < 1){
return TAIR_RETURN_INVALID_ARGUMENT;
}
data_entry tmp_value;
vector<any> items;
int ret = -1;
log_debug("start get_items:type:%d",type);
if ( (ret = __get_items(tair_mgr,area,key,tmp_value,items,type)) < 0){
log_debug("__get_items failed:%d",ret);
return ret;
}
vector<any>::iterator start;
vector<any>::iterator end;
if ( (ret = __set_region(items,offset,count,start,end)) < 0){
log_debug("__set_region failed");
return ret;
}
int result_count = end - start;
uint32_t attr = get_attribute(tmp_value);
uint32_t result_attr = 0;
SET_VAL_COUNT(result_attr,result_count);
SET_VAL_TYPE(result_attr,VAL_TYPE(attr));
string result( reinterpret_cast<char *>(&result_attr),sizeof(uint32_t));//just reserve space
if( !prepare_serialize(VAL_TYPE(attr),start,end,result) ){
log_debug("prepare_serialize failed");
return TAIR_RETURN_SERIALIZE_ERROR;
}
log_debug("end get_items: success");
value.set_data(result.data(),result.size(),true);
set_attribute(value,result_attr);
return TAIR_RETURN_SUCCESS;
}
开发者ID:xiangyong,项目名称:platform,代码行数:37,代码来源:item_manager.cpp
示例20: add_items
int tair_manager::add_items(int area,
data_entry& key,
data_entry& value,
int max_count, int expire_time/* = 0*/)
{
if (status != STATUS_CAN_WORK) {
return TAIR_RETURN_SERVER_CAN_NOT_WORK;
}
if (key.get_size() >= TAIR_MAX_KEY_SIZE || key.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (value.get_size() >= TAIR_MAX_DATA_SIZE || value.get_size() < 1) {
return TAIR_RETURN_ITEMSIZE_ERROR;
}
if (area < 0 || area >= TAIR_MAX_AREA_COUNT) {
return TAIR_RETURN_INVALID_ARGUMENT;
}
key.data_meta.flag |= TAIR_ITEM_FLAG_ITEM;
tbsys::CThreadGuard guard(&item_mutex[get_mutex_index(key)]);
return json::item_manager::add_items(this,area,key,value,max_count,expire_time);
}
开发者ID:brianzf,项目名称:TAIR-old-version,代码行数:24,代码来源:tair_manager.cpp
注:本文中的data_entry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论