Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix previous value of EmptyCache map representation #14702

Merged
merged 2 commits into from
Oct 24, 2022

Conversation

kokosing
Copy link
Member

Fix previous value of EmptyCache map representation

putIfAbsent returns previous value and since EmptyCache is not storing
anything there is no previous value, so null should be returned.

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Would it be possible to have a test for this?
for empty and non-empty caches?

@kokosing kokosing force-pushed the origin/master/153_empty_cache branch from 2a79241 to cf23167 Compare October 22, 2022 19:43
@kokosing
Copy link
Member Author

Added tests. PTAL

@@ -116,7 +116,7 @@ public ConcurrentMap<K, V> asMap()
public V putIfAbsent(K key, V value)
{
// Cache, even if configured to evict everything immediately, should allow writes.
return value;
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the above comment looks weird now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed myself

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you forced pushed.
Would you consider

// putIfAbsent returns the previous value

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that 🤦

Notice that the put method has the old comment still, I find old comment still useful. It is more about empty cache, not the put method. I will leave both ones.

@findepi findepi force-pushed the origin/master/153_empty_cache branch from cf23167 to 8ad23f4 Compare October 24, 2022 07:24
}

@Test(dataProvider = "disabledCacheImplementations")
public void testPutOnNonEmptyCache(DisabledCacheImplementation disabledCacheImplementation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache constructed in this test looks to be empty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to stress that it is not EmptyCache implementation

@kokosing kokosing force-pushed the origin/master/153_empty_cache branch from 8ad23f4 to b7ac8d0 Compare October 24, 2022 11:20
@kokosing kokosing force-pushed the origin/master/153_empty_cache branch from b7ac8d0 to d8a631c Compare October 24, 2022 12:11
Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Move DataProviders to trino-testing-services" LGTM

Comment on lines +57 to +59
<exclusion>
<!-- conflicts with test-scoped dependency declared below -->
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
</exclusion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me do it as follow up.

@@ -116,7 +116,7 @@ public ConcurrentMap<K, V> asMap()
public V putIfAbsent(K key, V value)
{
// Cache, even if configured to evict everything immediately, should allow writes.
return value;
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you forced pushed.
Would you consider

// putIfAbsent returns the previous value

}

@Test
public void testPutOnNonEmptyCache()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache under test is empty.
Add a comment capturing #14702 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to rename the test

putIfAbsent returns previous value and since EmptyCache is not storing
anything there is no previous value, so null should be returned.
@kokosing kokosing force-pushed the origin/master/153_empty_cache branch from d8a631c to 5d3202f Compare October 24, 2022 16:21
@github-actions github-actions bot added the jdbc Relates to Trino JDBC driver label Oct 24, 2022
@kokosing kokosing merged commit 4ba2126 into trinodb:master Oct 24, 2022
@kokosing kokosing deleted the origin/master/153_empty_cache branch October 24, 2022 18:02
@github-actions github-actions bot added this to the 401 milestone Oct 24, 2022
@colebow
Copy link
Member

colebow commented Oct 25, 2022

Do we need a release note for this?

@kokosing
Copy link
Member Author

No. It is not changing anything from point of the view of user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed jdbc Relates to Trino JDBC driver
Development

Successfully merging this pull request may close these issues.

4 participants