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

feat: introduce java.time #2415

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

feat: introduce java.time #2415

wants to merge 21 commits into from

Conversation

diegomarquezp
Copy link
Contributor

@diegomarquezp diegomarquezp commented Nov 14, 2024

This PR introduces java.time alternatives to existing org.threeten.bp.* methods, as well as switching internal variables (if any) to java.time

The main constraint is to keep the changes backwards compatible, so for each existing threeten method "method1(org.threeten.bp.Duration)" we will add an alternative with a Duration (or Timestamp when applicable) suffix: "method1Duration(java.time.Duration)".

For most cases, the implementation will be held in the java.time method and the old threeten method will just delegate the call to it. However, for the case of abstract classes, the implementation will be kept in the threeten method to avoid breaking changes (i.e. users that already overloaded the method in their user code).

Note: https://cloud.google.com/bigtable/docs/reference/sql/data-types#timestamp_type implies that nanosecond precision will be ignored.

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigtable Issues related to the googleapis/java-bigtable API. labels Nov 14, 2024
@diegomarquezp diegomarquezp added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 20, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 20, 2024
@diegomarquezp
Copy link
Contributor Author

ci / windows failing in several PRs - see this job from #2425

@@ -23,8 +23,8 @@
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.ByteString;
import java.time.Instant;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@InternalApi

@@ -150,7 +149,7 @@ static SqlType<Boolean> bool() {
}

/** returns a {@link SqlType} for the {@code TIMESTAMP} type. */
static SqlType<Instant> timestamp() {
static SqlType<java.time.Instant> timestamp() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Types.Timestamp is @InternalApi

@@ -239,7 +249,7 @@ private static Value booleanParamOf(@Nullable Boolean value) {
return builder.build();
}

private static Value timestampParamOf(@Nullable Instant value) {
private static Value timestampParamOf(@Nullable java.time.Instant value) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Timestamp is @InternalApi

@@ -30,13 +30,13 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.util.concurrent.RateLimiter;
import java.time.Duration;
import java.time.Instant;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this class is package private

@diegomarquezp diegomarquezp marked this pull request as ready for review November 22, 2024 02:12
@diegomarquezp diegomarquezp requested review from a team as code owners November 22, 2024 02:12
}

/** Sets the heartbeat duration for the change stream. */
public ReadChangeStreamQuery heartbeatDurationDuration(java.time.Duration duration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is durationduration again

Copy link
Contributor Author

@diegomarquezp diegomarquezp Nov 25, 2024

Choose a reason for hiding this comment

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

Changed to heartbeatDurationJavaTime in the meantime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@igorbernstein2 we still haven't decided about how to rename this method. So far we have heartBeatDurationJavaTime as it would keep the prefix.

Comment on lines +148 to +150
// From java 15, now() provides nanosecond precision. We trim micros and nanos, so it matches
// bigtable's millisecond precision api.
// see https://bugs.openjdk.org/browse/JDK-8242504
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for calling this out. Let's make sure Bigtable is aware of this.

Let's keep it as ms precision for this PR and they can choose to keep it or update it to nanosecond in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -100,10 +102,10 @@ public ChangeStreamRecord onCloseStream(ReadChangeStreamResponse.CloseStream clo

/** {@inheritDoc} */
@Override
public void startUserMutation(
public void startUserMutationInstant(
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is marked with @InternalApi. Let's double check that this is fine (hopefully no BigTable users are using internalApi marked apis)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@igorbernstein2 is it ok to change the signature of this method directly since it's marked as @InternalApi?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/java-bigtable API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants