Skip to content

C++ client unable to access the blob data #858

Answered by sighingnow
liusitan asked this question in Q&A
Discussion options

You must be logged in to vote

The error is because you are dereferencing a null std::unique_ptr. To make your code work, you need

    //get the object from vienayrd instance
-   std::unique_ptr<ObjectMeta> rom;//received object meta
+   std::unique_ptr<ObjectMeta> rom(new ObjectMeta{});//received object meta
    c->GetMetaData(id,*rom);
    auto buffer = rom->GetMember("_buffer");
    // auto receivedBlob =  std::reinterpret_pointer_cast<Blob>(buffer);
    auto receivedBlob = std::dynamic_pointer_cast<vineyard::Blob>(buffer);
    receivedBlob->data();
    std::cout<<receivedBlob->data()<<std::endl;

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by sighingnow
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested component:client Issues about vineyard's IPC or RPC client.
2 participants
Converted from issue

This discussion was converted from issue #828 on July 18, 2022 02:24.