peter-lawrey / HugeCollections-OLD

Huge Collections for Java using efficient off heap storage
273 stars 51 forks source link

SharedHashMap interface signatures #14

Closed Cotton-Ben closed 10 years ago

Cotton-Ben commented 10 years ago

Do you think it might be a little clearer if the

 V acquireUsing(Object key, V value);

signature was changed to

 V getOrCreate(Object key, V value);  //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value);     //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Cotton-Ben commented 10 years ago
 V getNonNullUsing(Object key, V value);     //even better?
Cotton-Ben commented 10 years ago

I change me mind! I'm now familar with ...

V acquireUsing(Object key, V value);

let's keep it.

peter-lawrey commented 10 years ago

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14 .

RobAustin commented 10 years ago

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14 .

— Reply to this email directly or view it on GitHub.

peter-lawrey commented 10 years ago

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

Cotton-Ben commented 10 years ago

I thought so too at first, but on second thought ... 'acquire' feels more regal.

On 03/04/2014 02:59 PM, Rob Austin wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14 .

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028.

RobAustin commented 10 years ago

Some good java doc will help, Peter if you email me an explanation, I’ll add it to the code.

Rob

On 4 Mar 2014, at 20:08, Ben Cotton notifications@github.com wrote:

I thought so too at first, but on second thought ... 'acquire' feels more regal.

On 03/04/2014 02:59 PM, Rob Austin wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14 .

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028.

— Reply to this email directly or view it on GitHub.

peter-lawrey commented 10 years ago

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

peter-lawrey commented 10 years ago

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

RobAustin commented 10 years ago

Ok

Sent from my iPad

On 4 Mar 2014, at 23:00, Peter Lawrey notifications@github.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

— Reply to this email directly or view it on GitHub.

peter-lawrey commented 10 years ago

Could you do a review of the methods implemented by AbstractMap to see which ones we might want to override?

On 5 March 2014 10:01, Peter Lawrey peter.lawrey@gmail.com wrote:

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

RobAustin commented 10 years ago

No - as before you do the replace you have to read() to see if a value exists so you do the read anyway.

Sent from my iPad

On 4 Mar 2014, at 23:01, Peter Lawrey notifications@github.com wrote:

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

— Reply to this email directly or view it on GitHub.

RobAustin commented 10 years ago

Sure - I'll raise some Jira's.

Sent from my iPad

On 4 Mar 2014, at 23:02, Peter Lawrey notifications@github.com wrote:

Could you do a review of the methods implemented by AbstractMap to see which ones we might want to override?

On 5 March 2014 10:01, Peter Lawrey peter.lawrey@gmail.com wrote:

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

— Reply to this email directly or view it on GitHub.

peter-lawrey commented 10 years ago

Just for the record, acquireUsing, doesn't create any objects or use any extra memory unless you pass null.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

Cotton-Ben commented 10 years ago

Absolutely. I can see it being empowering ....

Sent from my iPhone

On Mar 4, 2014, at 6:01 PM, Peter Lawrey notifications@github.com wrote:

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

— Reply to this email directly or view it on GitHub.

RobAustin commented 10 years ago

These methods although similar, are not identical, I will refactor out the commonalities though

Sent from my iPad

On 4 Mar 2014, at 23:00, Peter Lawrey notifications@github.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028 .

— Reply to this email directly or view it on GitHub.

peter-lawrey commented 10 years ago

Refactoring is a nice to have for the alpha release, we should go back and refactor for the beta release.

On 5 March 2014 10:10, Rob Austin notifications@github.com wrote:

These methods although similar, are not identical, I will refactor out the commonalities though

Sent from my iPad

On 4 Mar 2014, at 23:00, Peter Lawrey notifications@github.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028>

.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36690859 .

RobAustin commented 10 years ago

Ok - I'll focus on more important tasks for the moment.

Sent from my iPad

On 4 Mar 2014, at 23:11, Peter Lawrey notifications@github.com wrote:

Refactoring is a nice to have for the alpha release, we should go back and refactor for the beta release.

On 5 March 2014 10:10, Rob Austin notifications@github.com wrote:

These methods although similar, are not identical, I will refactor out the commonalities though

Sent from my iPad

On 4 Mar 2014, at 23:00, Peter Lawrey notifications@github.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either. acquireUsing doesn't create any objects when used correctly, it is more like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always getXxxx => get if present. acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14> .

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub< https://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028>

.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36690859 .

— Reply to this email directly or view it on GitHub.

leventov commented 10 years ago

Don't forget about IDE autocomplete. If I forget acquireUsing method name (that's easy), I want to type "map.get", then Ctrl+Enter to see all kinds of get available. Simple get creates an object as well in sense we mean when consider getOrCreate name for acquireUsing, thus I'd suggest getOrReuse.

RobAustin commented 10 years ago

I agree

On 5 Mar 2014, at 04:30, Roman Leventov notifications@github.com wrote:

Don't forget about IDE autocomplete. If I forget acquireUsing method name (that's easy), I want to type "map.get", then Ctrl+Enter to see all kinds of get available. Simple get creates an object as well in sense we mean when consider getOrCreate name for acquireUsing, thus I'd suggest getOrReuse.

— Reply to this email directly or view it on GitHub.

peter-lawrey commented 10 years ago

getUsing will always reuse, not "get OR reuse". acquireUsing will also always reuse. The difference is that acquire will never return null.

On 5 March 2014 17:59, Rob Austin notifications@github.com wrote:

I agree

On 5 Mar 2014, at 04:30, Roman Leventov notifications@github.com wrote:

Don't forget about IDE autocomplete. If I forget acquireUsing method name (that's easy), I want to type "map.get", then Ctrl+Enter to see all kinds of get available. Simple get creates an object as well in sense we mean when consider getOrCreate name for acquireUsing, thus I'd suggest getOrReuse.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36715393 .

leventov commented 10 years ago

getUsingOrCreate

Cotton-Ben commented 10 years ago

We also initially felt awkward with the choice "acquireUsing" ... but that awkwardness truly wore off (and in very little time). We made the gentle effort= "let us try to adapt to its name" rather than "let it adapt to our name". For us it worked. "acquire' is a richer, more regal verb. As Peter points out, it overloads in-place full "getOrCreate" semantics (without the need of a literal in-order binary conjunctive). It took all of a 2 minutes of our practicing "you can 'get' a NULL" but you can't "acquire" a NULL. By the third minute, we were in love with "acquireUsing" ... so much so that we closed #13.

On 3/5/2014 6:21 AM, Peter Lawrey wrote:

getUsing will always reuse, not "get OR reuse". acquireUsing will also always reuse. The difference is that acquire will never return null.

On 5 March 2014 17:59, Rob Austin notifications@github.com wrote:

I agree

On 5 Mar 2014, at 04:30, Roman Leventov notifications@github.com wrote:

Don't forget about IDE autocomplete. If I forget acquireUsing method name (that's easy), I want to type "map.get", then Ctrl+Enter to see all kinds of get available. Simple get creates an object as well in sense we mean when consider getOrCreate name for acquireUsing, thus I'd suggest getOrReuse.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36715393 .

— Reply to this email directly or view it on GitHub https://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36732715.

leventov commented 10 years ago

OK, you convinced me.

peter-lawrey commented 10 years ago

get() creates an object.

acquireUsing(key, non-null) and getUsing(key, non-null) never create an object or use more memory.

I think it would be confusing to put "Create" on the method which doesn't create, while the method called just get() does create.

On 5 March 2014 22:26, Roman Leventov notifications@github.com wrote:

getUsingOrCreate

Reply to this email directly or view it on GitHubhttps://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36733094 .