Closed broneill closed 7 years ago
Hi, thanks for checking out the project. I hope you did not encounter any "oh my god what on earth are they doing here" moments. I am not entirely sure what you mean by
The key remains in the same place until you move it.
As far as I can remember, the entire point of the operation you commented on was to remove the entire key/value pair. Setting only the value to null
and keeping the key intact is not what I was looking for. At least, that is how I would interpret store(null)
.
In general, I always get a bad feeling when an explicit null
literal is passed to the public API of a library. Instead of trying to solve this API issue via JavaDoc, my suggestion would be to introduce another method:
/**
* Deletes the key/value pair at the current cursor position. [Needs to specify the cursor
* position after completing the operation].
*/
public void delete() {
this.store(null);
}
That way, the old API is still valid (in fact the new method merely forwards the call), but users of the new API don't need to pass a null
literal anymore. In my opinion, delete()
is much more intention-revealing to the reader of the code than store(null)
.
Thanks, I'll add the delete method. I'll have it return a boolean for more utility, and to be consistent with the pattern of methods in the View interface. Perhaps insert/update/etc can be added later.
Alright! I'll keep track of your repo; we will update to the latest TUPL version soon anyways, then I can rewrite this code in ChronoDB to use the new delete
API.
Other than bug fixes, all changes are now being made to version 1.4, which breaks compatibility only due to a license change.
Out of curiosity, I wanted to see how Tupl was being used by Chronos. I noticed in a few places that delete actions over a range of records first store the keys into a collection, and then perform a second pass over them. This comment caught my attention too:
Tupl Cursors do support this -- you just call store(null) on the current entry. The key remains in the same place until you move it. This more of a Tupl question than anything else. I'm wondering how can the documentation be improved so that this feature isn't overlooked?