MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / addHashFieldToReply

Function addHashFieldToReply

src/t_hash.cpp:775–808  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

773}
774
775static void addHashFieldToReply(client *c, robj_roptr o, sds field) {
776 int ret;
777
778 if (o == nullptr) {
779 addReplyNull(c);
780 return;
781 }
782
783 if (o->encoding == OBJ_ENCODING_ZIPLIST) {
784 const unsigned char *vstr = NULL;
785 unsigned int vlen = UINT_MAX;
786 long long vll = LLONG_MAX;
787
788 ret = hashTypeGetFromZiplist(o, field, &vstr, &vlen, &vll);
789 if (ret < 0) {
790 addReplyNull(c);
791 } else {
792 if (vstr) {
793 addReplyBulkCBuffer(c, vstr, vlen);
794 } else {
795 addReplyBulkLongLong(c, vll);
796 }
797 }
798
799 } else if (o->encoding == OBJ_ENCODING_HT) {
800 const char* value = hashTypeGetFromHashTable(o, field);
801 if (value == NULL)
802 addReplyNull(c);
803 else
804 addReplyBulkCBuffer(c, value, sdslen(value));
805 } else {
806 serverPanic("Unknown hash encoding");
807 }
808}
809
810void hgetCommand(client *c) {
811 robj_roptr o;

Callers 2

hgetCommandFunction · 0.85
hmgetCommandFunction · 0.85

Calls 6

addReplyNullFunction · 0.85
hashTypeGetFromZiplistFunction · 0.85
addReplyBulkCBufferFunction · 0.85
addReplyBulkLongLongFunction · 0.85
hashTypeGetFromHashTableFunction · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected