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

Allow library models to define custom stream classes. #807

Merged
merged 3 commits into from
Aug 22, 2023

Conversation

lazaroclapp
Copy link
Collaborator

This is needed to support both fully custom stream libraries, as well as backports/shadowed versions
of existing stream libraries.

@lazaroclapp lazaroclapp marked this pull request as draft August 15, 2023 21:09
@coveralls
Copy link

coveralls commented Aug 15, 2023

Pull Request Test Coverage Report for Build #1172

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 22 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.03%) to 93.119%

Files with Coverage Reduction New Missed Lines %
../nullaway/src/main/java/com/uber/nullaway/handlers/Handlers.java 1 96.88%
../nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPath.java 3 95.26%
../nullaway/src/main/java/com/uber/nullaway/LibraryModels.java 3 88.46%
../nullaway/src/main/java/com/uber/nullaway/handlers/stream/StreamModelBuilder.java 5 89.36%
../nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java 10 97.93%
Totals Coverage Status
Change from base Build #1170: -0.03%
Covered Lines: 5724
Relevant Lines: 6147

💛 - Coveralls

@lazaroclapp lazaroclapp marked this pull request as ready for review August 16, 2023 18:41
@msridhar
Copy link
Collaborator

/benchmark

Copy link
Collaborator

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

Couple of nits and one genuine question, but overall this looks fine

Comment on lines 304 to 307
// Note: Currently, OptimizedLibraryModels doesn't carry the information about stream type
// records,
// it is not clear what it means to "optimize" lookup for those and they get access only once:
// here.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: formatting

@@ -90,6 +92,10 @@ public StreamModelBuilder addStreamType(TypePredicate tp) {
return this;
}

public StreamModelBuilder addStreamTypeFromName(String fullyQualifiedName) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Javadoc?

* <p>This handler must be registered in Handlers.java separatedly from the LibraryModelsHandler
* itself.
*/
public StreamNullabilityPropagator getStreamNullabilityPropagatorFromModels() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems a bit awkward to put this method here as opposed to StreamNullabilityPropagatorFactory. Is it here because it needs access to the libraryModels object which is encapsulated within this class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, libraryModels combines all loaded library models from auto-service, and I am not sure I want to provide a way to retrieve it from this class. What we could do is:

  1. Add getCustomStreamNullabilitySpecs() to this handler, which returns libraryModels.customStreamNullabilitySpecs()
  2. Add a static method to StreamNullabilityPropagatorFactory which takes that and returns the StreamNullabilityPropagator

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with whatever you think is cleanest

@github-actions
Copy link

Main Branch:

Benchmark                          Mode  Cnt   Score   Error  Units
AutodisposeBenchmark.compile      thrpt   25   9.062 ± 0.083  ops/s
CaffeineBenchmark.compile         thrpt   25   2.100 ± 0.011  ops/s
DFlowMicroBenchmark.compile       thrpt   25  25.089 ± 0.267  ops/s
NullawayReleaseBenchmark.compile  thrpt   25   1.277 ± 0.018  ops/s

With This PR:

Benchmark                          Mode  Cnt   Score   Error  Units
AutodisposeBenchmark.compile      thrpt   25   9.095 ± 0.102  ops/s
CaffeineBenchmark.compile         thrpt   25   2.091 ± 0.025  ops/s
DFlowMicroBenchmark.compile       thrpt   25  24.758 ± 0.354  ops/s
NullawayReleaseBenchmark.compile  thrpt   25   1.265 ± 0.018  ops/s

Copy link
Collaborator

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

Going ahead and approving this as I don't think I need to check again about the previous comments

@lazaroclapp lazaroclapp force-pushed the lazaro_stream_handler_with_method_refs branch from 364adc6 to 1b4c6fe Compare August 21, 2023 20:39
@lazaroclapp lazaroclapp merged commit 5c83604 into master Aug 22, 2023
8 of 9 checks passed
@lazaroclapp lazaroclapp deleted the lazaro_stream_handler_with_method_refs branch August 22, 2023 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants