Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Add metadata method to public API #34

Closed
RobDickinson opened this issue Feb 17, 2017 · 3 comments
Closed

Add metadata method to public API #34

RobDickinson opened this issue Feb 17, 2017 · 3 comments

Comments

@RobDickinson
Copy link
Member

Currently KVTree has GetPath and GetSize methods to return metadata about the datastore, but this pattern will pollute the API if we add a bunch of these down the road. Instead let's replace those current methods with a single Metadata method that populates a struct with all those details.

struct KVTreeMetadata {                              // add
    string path;
    size_t size;
    size_t leaves;
    size_t nodes;
}
class KVTree {
  public:
    const string& GetPath();                         // remove
    const size_t GetSize();                          // remove
    void Metadata(const KVTreeMetadata& metadata);   // add

This will be very helpful for changes like #10 that affect internal structure and are easier to validate if more internal state can be exposed easily.

@RobDickinson
Copy link
Member Author

RobDickinson commented Feb 17, 2017

Existing tests that check path/size were changed to this pattern:

    KVTreeMetadata kvmeta = {};
    kv->Metadata(kvmeta);
    ASSERT_TRUE(kvmeta.path == PATH);
    ASSERT_TRUE(kvmeta.size == PMEMOBJ_MIN_POOL);

RobDickinson added a commit that referenced this issue Feb 17, 2017
@RobDickinson
Copy link
Member Author

Just a little refactoring here at the end -- shouldn't be using name and path interchangeably anywhere now. (should just be path)

RobDickinson added a commit that referenced this issue Feb 17, 2017
@RobDickinson
Copy link
Member Author

No additional unit tests were added for this change -- just being able to execute all current tests is good enough.

szadam pushed a commit to szadam/pmemkv that referenced this issue Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant