Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Introducing interfaces for new Batching API #692

Merged
merged 10 commits into from
May 29, 2019

Conversation

rahulKQL
Copy link
Contributor

@rahulKQL rahulKQL commented Mar 18, 2019

What this PR contains

Introducing new Batcher API, which gives an option to perform batching with element object(eg. for bigtable MutateRowsRequest.Entry or for logging LogEntry) directly instead of Request wrappers. This returns a future of result/response(eg. for bigtable MutateRowsResponse.Entry or for logging Void type) corresponding to each element, which would resolve once the batching is finished.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 18, 2019
@codecov
Copy link

codecov bot commented Mar 18, 2019

Codecov Report

Merging #692 into master will increase coverage by 0.3%.
The diff coverage is 86.92%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #692     +/-   ##
===========================================
+ Coverage     75.46%   75.77%   +0.3%     
- Complexity     1037     1056     +19     
===========================================
  Files           196      198      +2     
  Lines          4675     4805    +130     
  Branches        363      371      +8     
===========================================
+ Hits           3528     3641    +113     
- Misses          986     1000     +14     
- Partials        161      164      +3
Impacted Files Coverage Δ Complexity Δ
.../com/google/api/gax/batching/BatchingSettings.java 80.95% <ø> (ø) 2 <0> (ø) ⬇️
...va/com/google/api/gax/batching/FlowController.java 70.58% <0%> (-6.84%) 17 <0> (ø)
...va/com/google/api/gax/batching/v2/BatcherImpl.java 88.88% <88.88%> (ø) 15 <15> (?)
...gle/api/gax/batching/v2/DefaultBatcherFactory.java 97.05% <97.05%> (ø) 4 <4> (?)

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 8c9f9a5...671e6f5. Read the comment docs.

@rahulKQL
Copy link
Contributor Author

@igorbernstein2 @sduskis
Please have a look at this change.

@igorbernstein2
Copy link
Contributor

Thanks for working on this!
However I'm having a bit of a hard time following the code. Can you add some docs describing how everything fits together and provide sample usage? Eventually the docs should live in package-info, but while we are working out the initial design it might be better to collaborate in a shared google doc. Please put together a doc with the interfaces of the components and how they interact.

For example:

// Intended usage for MutateRows:
// Bigtable developer will implement a BatchingDescriptor:
class BigtableDescriptor implements BatchingDescriptor  {
// ...
}
// Then they will build a BatcherFactory like so:
// ....

// This factory will be exposed the end user and they will use it to create a batcher like so:
// ..


// Implementation details:
// This is the user visible entrypoint for batching.
class BatcherFactory {
  Batcher createBatcher();
}

// This is the user visible batching context. It will transparently create many batches from the added entries delineated by the thresholds configured in batching settings 
class Batcher<EntryT, EntryResultT> {
  ApiFuture<EntryResultT> add(EntryT entry);
  // ...
  void flush();
  //. ..
}

// This is an internal class that represents an open Batch, it's used to accumulate entries before they are flushed as a batch
class BatchAccumulator {
  // ...
}

General feedback:

  • It's very hard to understand the separation of responsibility between Batcher/BatcherImpl/Builder, BatchAccumalator and RequestBuilder.

  • Having a Builder for a BatcherFactory and having Batcher Builder and a BatcherFactory smells weird

  • Prefixing interface with I doesn't quite fit with the code style of this repo.

  • How do you pass context to a Batcher? ie, in Bigtable batching we need a target table

  • Everything in gax-java is intended to be used with the gapic generator, I'm having a

Is this implementation intended for bigtable? If so, I think it would be better to move discussion to bigtable's gaxx package.

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Mar 25, 2019
@sduskis sduskis added needs work This is a pull request that needs a little love. do not merge Indicates a pull request not ready for merge, due to either quality or timing. and removed 🚨 This issue needs some love. labels Mar 25, 2019
@rahulKQL rahulKQL force-pushed the new_batching_changes branch from 671e6f5 to e4f0f11 Compare March 29, 2019 12:15
@codecov-io
Copy link

codecov-io commented Mar 29, 2019

Codecov Report

Merging #692 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #692   +/-   ##
=========================================
  Coverage     75.74%   75.74%           
  Complexity     1041     1041           
=========================================
  Files           196      196           
  Lines          4679     4679           
  Branches        363      363           
=========================================
  Hits           3544     3544           
  Misses          975      975           
  Partials        160      160

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 c975bd9...b1a9066. Read the comment docs.

@codecov-io
Copy link

Codecov Report

Merging #692 into master will increase coverage by 0.3%.
The diff coverage is 86.92%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #692     +/-   ##
===========================================
+ Coverage     75.46%   75.77%   +0.3%     
- Complexity     1037     1056     +19     
===========================================
  Files           196      198      +2     
  Lines          4675     4805    +130     
  Branches        363      371      +8     
===========================================
+ Hits           3528     3641    +113     
- Misses          986     1000     +14     
- Partials        161      164      +3
Impacted Files Coverage Δ Complexity Δ
.../com/google/api/gax/batching/BatchingSettings.java 80.95% <ø> (ø) 2 <0> (ø) ⬇️
...va/com/google/api/gax/batching/FlowController.java 70.58% <0%> (-6.84%) 17 <0> (ø)
...va/com/google/api/gax/batching/v2/BatcherImpl.java 88.88% <88.88%> (ø) 15 <15> (?)
...gle/api/gax/batching/v2/DefaultBatcherFactory.java 97.05% <97.05%> (ø) 4 <4> (?)

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 d24940b...e4f0f11. Read the comment docs.

@rahulKQL rahulKQL force-pushed the new_batching_changes branch from 6ae98b0 to f126cda Compare April 25, 2019 14:56
rahulKQL added 3 commits May 16, 2019 14:37
## What this PR contain
This contains interfaces required to perform batching with elements(`MutateRowsRequest.Entry` or `LogEntry`) object directly instead of RequestWrappers(`MutateRowsRequest` or `WriteLogEntriesRequest`).
@rahulKQL rahulKQL force-pushed the new_batching_changes branch from f126cda to cd61543 Compare May 16, 2019 09:08
@rahulKQL rahulKQL changed the title WIP: Fresh Batcher API for batching using single entry object Introducing interfaces for new Batching API May 16, 2019
@rahulKQL
Copy link
Contributor Author

@igorbernstein2 please have a look and let me know your thoughts on this.

@rahulKQL
Copy link
Contributor Author

@igorbernstein2 Thanks a lot for detailed review comments. I have addressed them in the last commit.
Please have a fresh look at this PR.

Copy link
Contributor

@igorbernstein2 igorbernstein2 left a comment

Choose a reason for hiding this comment

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

LGTM

@igorbernstein2 igorbernstein2 removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. needs work This is a pull request that needs a little love. labels May 16, 2019
@igorbernstein2 igorbernstein2 requested a review from vam-google May 16, 2019 22:08
@igorbernstein2
Copy link
Contributor

@vam-google Do you mind taking a look before I merge this?

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label May 16, 2019
@vam-google
Copy link
Contributor

@igorbernstein2 Basically LGTM with several comments. My only real concern is the naming of th 4 type params in BatchingDescriptor, the way they are named and put now is very confusing.

Have updated type names to increase user understanding by their name.
Address some sample changes according to feedback.
@rahulKQL
Copy link
Contributor Author

@vam-google @igorbernstein2
Please let me know about your views on RequestBuilder#add & types sequence. I would update this PR accordingly.

Copy link
Contributor

@vam-google vam-google left a comment

Choose a reason for hiding this comment

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

LGTM

@rahulKQL
Copy link
Contributor Author

@igorbernstein2 Please take a fresh review, If looks good then please merge.

* }
* }</pre>
*
* @param <ElementT> The request type to perform batching.
Copy link
Contributor

Choose a reason for hiding this comment

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

@param <ElementT> the type of each individual element to be batched
@param <ElementResultT> the type of the result for each individual element
@param <RequestT> the type of the request that will contain the accumulated elements
@param <ResponseT> the type of the response will be unpacked into the individual element results

* generated by the gapic-generator.
*
* @param <ElementT> The request type to perform batching.
* @param <RequestT> The request wrapper type which bundles {@link ElementT}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the javadoc suggestion from above

Copy link
Contributor

@igorbernstein2 igorbernstein2 left a comment

Choose a reason for hiding this comment

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

LGTM after the javadoc tweak

@rahulKQL
Copy link
Contributor Author

@igorbernstein2
Updated interfaces with updated Javadoc, Please merge if looks good to you.

@igorbernstein2 igorbernstein2 merged commit 90e45b5 into googleapis:master May 29, 2019
@igorbernstein
Copy link

Just noticed that the ‘@BetaApi’ annotations are missing. Please add them in a follow up pr

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement. 🚨 This issue needs some love.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants