bool Builder::pack() { if (_isGateWay) { std::string *s = new (std::nothrow) std::string(6, 0); if (s == NULL) { return false; } stream.reset(s); *(UInt16*)&((*s)[4]) = op; packContent(); size_t sz = s->size() - 6; memcpy(&(*s)[0], &sz, 3); return true; } else { std::string *s = new(std::nothrow) std::string(10, 0); if (s == NULL) { return false; } stream.reset(s); //*((UInt16*)&((*s)[4])) = op; packContent(); size_t sz = s->size() - 10; packhead.Setop(op); packhead.Setlen(sz); packhead.PackBuffer(reinterpret_cast<uint8_t*>(&((*s)[0])) ); return true; } }
/** Put Key in Bucket Request ** * Request * Send the name of the bucket (1), the key (2), the key's content (3), the quorum (4), and the commits-before-ack (5) * * Response * riak sends either the message code or (optionally) two values: the bucket+key's vclock (1) and content(s) on the key (2) */ char *putKey(char *key, char *bucket, char *v_clock, _content *content, uint32_t quorum, uint32_t commit, bool return_body) { RpbPutReq pb_msg; pb_msg.set_bucket(bucket); pb_msg.set_key(key); if(commit) pb_msg.set_dw(commit); if(quorum) pb_msg.set_w(quorum); if(v_clock) pb_msg.set_vclock(v_clock); packContent(pb_msg.mutable_content(), content); return buildRequest(&pb_msg, MC_PUT_REQUEST); }