KVDocument里什么情况下会有多个KVIndexDocument ?
- Dominant language
- C++
- Stars
- 1.8k
- Forks
- 352
- PR merge metrics
- No merged PRs in 30d
Description
看到KVDocument里有个成员变量: std::vector _docs;
看了一些test case和代码,没发现会有多个 _docs的情况
另外单测里,这个case的value.size()为什么是39?:
{
document::KVDocument doc;
RawDocumentParser::Message msg;
string rawData = "userid=100;itemid=1;price=99;title=hello;CMD=add";
msg.data = rawData;
msg.timestamp = 100;
ASSERT_TRUE(parser.parse(msg, doc));
auto kvIndexDoc = doc.begin();
ASSERT_EQ(1u, kvIndexDoc->GetPKeyHash());
ASSERT_FALSE(kvIndexDoc->HasSKey());
ASSERT_EQ(100, doc.GetTimestamp());
ASSERT_EQ(100, kvIndexDoc->GetTimestamp());
ASSERT_EQ(ADD_DOC, kvIndexDoc->GetDocOperateType());
auto value = kvIndexDoc->GetValue();
ASSERT_EQ(39u, value.size());
StringAttributeConvertor convertor;
auto attrMeta = convertor.Decode(value);
ASSERT_EQ(100, *(int64_t*)(attrMeta.data.data() + 1));
ASSERT_EQ(99, *(int64_t*)(attrMeta.data.data() + 1 + sizeof(int64_t)));
std::string expected = "hello";
std::string actual(attrMeta.data.data() + 1 + sizeof(int64_t) + sizeof(int64_t) + 8 + 1);
ASSERT_EQ(expected, actual);
}
想学习下这边的kv、kkv部分,如果能有一些相关的设计文档说明更好,谢谢
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the KVDocument and KVIndexDocument declarations, then run the parser test containing the userid/itemid/price/title example. Trace how _docs is populated and how GetValue() is encoded; the documentation is done when it explains when multiple KVIndexDocument objects occur, why value.size() is 39, and how KV and KKV relate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- databases, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100