Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
KVS: Support valref pointing to zero length blob objects #1237
This series of patches is to support valref treeobjects pointing to zero-length blobref data.
This seems like a lot of code for a pretty dumb corner case, but it came down to updating the KVS cache API to not assume non-NULL data pointer means valid and NULL data pointer is invalid. A flag was placed into the KVS cache entry to handle this, but it beget a number of API style changes.
Under the old API:
So for consistency,
In order to clear data from an entry,
As a consequence, it's worth noting that
Debate on implementation:
Tiny part of me dislikes the function name "empty". Can discuss alternates. I considered using a flag type variable to say "I have data", but that seemed even uglier and more confusing.
I also considered removing the "empty" functions and supporting a
Also, for one error case I choose errno EBADE. Right one??
@@ Coverage Diff @@ ## master #1237 +/- ## ========================================== + Coverage 78.13% 78.15% +0.02% ========================================== Files 154 154 Lines 28680 28702 +22 ========================================== + Hits 22408 22431 +23 + Misses 6272 6271 -1
Are you referring to the fact I have a "NONE" data type? I suppose this is mostly for internal reasons, to signify the user has not yet assigned "JSON" or "RAW" data, so the cache entry doesn't know. I suppose that could be masked/hidden internally.
Thought, is "type" perhaps the wrong word to use?
It occurred to me last night that instead of creating
probably better than adding two new functions.
Well, I'll let the review happen on what's there for now. I can change this later.
Also, "NONE" maybe should be changed to "UNKNOWN" ... TBD
I was just thinking that one creation function could set the type to none/unknown, and it could get its type assigned when it becomes valid. Maybe that doesn't fit - I didn't look too closely. Sorry, getting packed up today so I'll be offline most of today, but I'll try to check in later.
As for your question, "it could get its type assigned when it becomes valid". Basically assigning a type (or none) is an option for the caller. In some cases, assigning the type ahead of time is effectively a flag saying, "Hey, this is what I'm expecting". I use this "flag" so that content-loading is aware what to expect.