Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Spanner added bounded staleness option and tests #1727

Merged
merged 8 commits into from
Jul 9, 2019

Conversation

ChengyuanZhao
Copy link
Contributor

fixes #1723
added bounded staleness support and tests and ref doc update

@codecov
Copy link

codecov bot commented Jul 8, 2019

Codecov Report

Merging #1727 into master will increase coverage by 0.07%.
The diff coverage is 64%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1727      +/-   ##
============================================
+ Coverage     67.21%   67.28%   +0.07%     
- Complexity     1715     1725      +10     
============================================
  Files           257      257              
  Lines          6911     6927      +16     
  Branches        692      694       +2     
============================================
+ Hits           4645     4661      +16     
- Misses         1948     1949       +1     
+ Partials        318      317       -1
Flag Coverage Δ Complexity Δ
#integration ? ?
#unittests 67.28% <64%> (+0.07%) 1725 <8> (+10) ⬆️
Impacted Files Coverage Δ Complexity Δ
...anner/core/ReadOnlyTransactionSpannerTemplate.java 55.55% <ø> (ø) 3 <0> (ø) ⬇️
...nner/core/ReadWriteTransactionSpannerTemplate.java 70% <ø> (ø) 4 <0> (ø) ⬇️
...data/spanner/core/SpannerPageableQueryOptions.java 100% <100%> (ø) 10 <2> (+2) ⬆️
...loud/gcp/data/spanner/core/SpannerReadOptions.java 91.3% <100%> (+1.83%) 12 <2> (+2) ⬆️
...k/cloud/gcp/data/spanner/core/SpannerTemplate.java 74.58% <38.46%> (+1.27%) 78 <3> (+4) ⬆️
...oud/gcp/data/spanner/core/SpannerQueryOptions.java 90.47% <75%> (+14%) 9 <1> (+2) ⬆️
...tastore/GcpDatastoreEmulatorAutoConfiguration.java 58.62% <0%> (-13.8%) 6% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc012e3...6f51f15. Read the comment docs.

@codecov
Copy link

codecov bot commented Jul 8, 2019

Codecov Report

Merging #1727 into master will increase coverage by 0.09%.
The diff coverage is 67.74%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #1727      +/-   ##
===========================================
+ Coverage     67.21%   67.3%   +0.09%     
- Complexity     1715    1724       +9     
===========================================
  Files           257     258       +1     
  Lines          6911    6931      +20     
  Branches        692     692              
===========================================
+ Hits           4645    4665      +20     
- Misses         1948    1949       +1     
+ Partials        318     317       -1
Flag Coverage Δ Complexity Δ
#integration ? ?
#unittests 67.3% <67.74%> (+0.09%) 1724 <21> (+9) ⬆️
Impacted Files Coverage Δ Complexity Δ
...nner/core/ReadWriteTransactionSpannerTemplate.java 70% <ø> (ø) 4 <0> (ø) ⬇️
...anner/core/ReadOnlyTransactionSpannerTemplate.java 55.55% <ø> (ø) 3 <0> (ø) ⬇️
...k/cloud/gcp/data/spanner/core/SpannerTemplate.java 75.21% <35.29%> (+1.9%) 76 <1> (+2) ⬆️
...data/spanner/core/SpannerPageableQueryOptions.java 90.9% <75%> (-9.1%) 11 <3> (+3)
...oud/gcp/data/spanner/core/SpannerQueryOptions.java 80% <77.77%> (+3.52%) 5 <3> (-2) ⬇️
...loud/gcp/data/spanner/core/SpannerReadOptions.java 83.33% <81.81%> (-6.15%) 7 <5> (-3)
...ta/spanner/core/AbstractSpannerRequestOptions.java 82.35% <82.35%> (ø) 9 <9> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc012e3...1fe67f9. Read the comment docs.

dmitry-s
dmitry-s previously approved these changes Jul 9, 2019
Copy link
Contributor

@dmitry-s dmitry-s left a comment

Choose a reason for hiding this comment

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

LGTM

*
* @author Chengyuan Zhao
*/
public class AbstractSpannerRequestOptions<A, B extends AbstractSpannerRequestOptions> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need this second class parameter B extends AbstractSpannerRequestOptions. The cast to B is not really safe anyway.
Why not just return AbstractSpannerRequestOptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The B is for the inheriting children class to provide their own class type. The reason is we return this at the end of the setter methods so the user can chain them together. Without the B and returning just the abstract class the child classes' setters would return the parent abstract class on the final setter call so the following wouldn't compile because the final setter returns the parent abstract class type and not the child type:

SpannerReadOptions = new SpannerReadOptions.setblah(xyz).setblahblah(abc).setblahblahblah(123);

The final setter call still just returns the abstract parent class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@meltsufin the cast is safe here because B must extend the abstract parent class in the class definition and this is clearly of that same type.


protected transient List<A> requestOptions = new ArrayList<>();

protected Class<A> requestOptionType;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually work? This member is never assigned? Would it not be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's assigned in the constructors of the child classes. It's needed to create that array of ReadOption or QueryOption that the client lib requires.

@@ -73,4 +73,13 @@ public SpannerQueryOptions setAllowPartialRead(boolean allowPartialRead) {
return this;
}

/**
* Deprecated. Please use {@code getOptions}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use @deprecated like we do in other parts of the code base?

@ChengyuanZhao ChengyuanZhao merged commit 1a65e18 into master Jul 9, 2019
@ChengyuanZhao ChengyuanZhao deleted the spanner-bounded-staleness branch July 9, 2019 19:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

Spanner Template :: Is there a way to read Bounded Staleness
3 participants