havenask icon indicating copy to clipboard operation
havenask copied to clipboard

KVDocument里什么情况下会有多个KVIndexDocument ?

Open xiaohei520321 opened this issue 2 years ago • 1 comments

看到KVDocument里有个成员变量: std::vector<KVIndexDocument> _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部分,如果能有一些相关的设计文档说明更好,谢谢

xiaohei520321 avatar Nov 07 '23 06:11 xiaohei520321

现在kv和kkv虽然索引结构上支持,但是在功能上还没有放开。上面的DocVector是一个比较高级的功能,相当与一个文档有多个同级的子文档,这个功能使用起来比较复杂,后续应该也不会开放出去。

xuxijie avatar Nov 07 '23 07:11 xuxijie