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

docs: fixing errors #2536

Merged
merged 10 commits into from
Jul 21, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
/**
* Generic {@link AbstractLazyInitializer} for any heavy-weight object that might throw an exception
* during initialization. The underlying object is initialized at most once.
*
* @param <T> Object which is to be initialized lazily
*/
public abstract class AbstractLazyInitializer<T> {
private final Object lock = new Object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,17 @@ enum CallbackResponse {
CONTINUE,

/**
* Tell the cursor to suspend all callbacks until application calls {@link RowCursor#resume()}.
* Tell the cursor to suspend all callbacks until application calls {@link
* ForwardingAsyncResultSet#resume()}.
*/
PAUSE,

/**
* Tell the cursor you are done receiving results, even if there are more results sitting in the
* buffer. Once you return DONE, you will receive no further callbacks.
*
* <p>Approximately equivalent to calling {@link RowCursor#cancel()}, and then returning {@code
* PAUSE}, but more clear, immediate, and idiomatic.
* <p>Approximately equivalent to calling {@link ForwardingAsyncResultSet#cancel()}, and then
* returning {@code PAUSE}, but more clear, immediate, and idiomatic.
*
* <p>It is legal to commit a transaction that owns this read before actually returning {@code
* DONE}.
Expand Down Expand Up @@ -105,17 +106,18 @@ interface ReadyCallback {
* <li>Callback will stop being called once any of the following occurs:
* <ol>
* <li>Callback returns {@link CallbackResponse#DONE}.
* <li>{@link ResultSet#tryNext()} returns {@link CursorState#DONE}.
* <li>{@link ResultSet#tryNext()} throws an exception.
* <li>{@link ForwardingAsyncResultSet#tryNext()} returns {@link CursorState#DONE}.
* <li>{@link ForwardingAsyncResultSet#tryNext()} throws an exception.
* </ol>
* <li>Callback may possibly be invoked after a call to {@link ResultSet#cancel()} call, but the
* subsequent call to {@link #tryNext()} will yield a SpannerException.
* <li>Callback may possibly be invoked after a call to {@link
* ForwardingAsyncResultSet#cancel()} call, but the subsequent call to {@link #tryNext()}
* will yield a SpannerException.
* <li>Spurious callbacks are possible where cursors are not actually ready. Typically callback
* should return {@link CallbackResponse#CONTINUE} any time it sees {@link
* CursorState#NOT_READY}.
* </ul>
*
* <h3>Flow Control</h3>
* <h4>Flow Control</h4>
*
* If no flow control is needed (say because result sizes are known in advance to be finite in
* size) then async processing is simple. The following is a code example that transfers work from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.api.core.ApiFuture;
import com.google.cloud.Timestamp;
import io.grpc.Status.Code;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;

Expand All @@ -40,8 +41,8 @@ interface AsyncWork<R> {
* <p>In most cases, the implementation will not need to catch {@code SpannerException}s from
* Spanner operations, instead letting these propagate to the framework. The transaction runner
* will take appropriate action based on the type of exception. In particular, implementations
* should never catch an exception of type {@link SpannerErrors#isAborted}: these indicate that
* some reads may have returned inconsistent data and the transaction attempt must be aborted.
* should never catch an exception of type {@link Code#ABORTED}: these indicate that some reads
* may have returned inconsistent data and the transaction attempt must be aborted.
*
* @param txn the transaction
* @return future over the result of the work
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.api.core.ApiFuture;
import com.google.cloud.Timestamp;
import com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture;
import com.google.cloud.spanner.Options.TransactionOption;
import com.google.cloud.spanner.TransactionManager.TransactionState;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
Expand All @@ -43,7 +43,7 @@
* so can cause resources to be leaked and deadlocks. Easiest way to guarantee this is by calling
* {@link #close()} in a finally block.
*
* @see DatabaseClient#transactionManagerAsync()
* @see DatabaseClient#transactionManagerAsync(TransactionOption...)
*/
public interface AsyncTransactionManager extends AutoCloseable {
/**
Expand Down Expand Up @@ -91,10 +91,10 @@ Timestamp get(long timeout, TimeUnit unit)

/**
* {@link AsyncTransactionStep} is returned by {@link
* TransactionContextFuture#then(AsyncTransactionFunction)} and {@link
* AsyncTransactionStep#then(AsyncTransactionFunction)} and allows transaction steps that should
* be executed serially to be chained together. Each step can contain one or more statements that
* may execute in parallel.
* TransactionContextFuture#then(AsyncTransactionFunction, Executor)} and {@link
* AsyncTransactionStep#then(AsyncTransactionFunction, Executor)} and allows transaction steps
* that should be executed serially to be chained together. Each step can contain one or more
* statements that may execute in parallel.
*
* <p>Example usage:
*
Expand All @@ -115,6 +115,9 @@ Timestamp get(long timeout, TimeUnit unit)
* executor)
* .commitAsync();
* }</pre>
*
* @param <I>
* @param <O>
*/
interface AsyncTransactionStep<I, O> extends ApiFuture<O> {
/**
Expand All @@ -140,6 +143,9 @@ <RES> AsyncTransactionStep<O, RES> then(
* a {@link TransactionContext} and the output value of the previous transaction step as its input
* parameters. The method should return an {@link ApiFuture} that will return the result of this
* step.
*
* @param <I>
* @param <O>
*/
interface AsyncTransactionFunction<I, O> {
/**
Expand All @@ -151,16 +157,16 @@ interface AsyncTransactionFunction<I, O> {
* @param input the result of the previous transaction step.
* @return an {@link ApiFuture} that will return the result of this step, and that will be the
* input of the next transaction step. This method should never return <code>null</code>.
* Instead, if the method does not have a return value, the method should return {@link
* ApiFutures#immediateFuture(null)}.
* Instead, if the method does not have a return value, the method should return
* ApiFutures#immediateFuture(null).
*/
ApiFuture<O> apply(TransactionContext txn, I input) throws Exception;
}

/**
* Creates a new read write transaction. This must be called before doing any other operation and
* can only be called once. To create a new transaction for subsequent retries, see {@link
* #resetForRetry()}.
* #resetForRetryAsync()}.
*/
TransactionContextFuture beginAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ default OperationFuture<Database, CreateDatabaseMetadata> createDatabase(
* Database db = op.waitFor().getResult();
* }</pre>
*
* @see also #createDatabase(String, String, Iterable)
* @see #createDatabase(String, String, Iterable)
*/
OperationFuture<Database, CreateDatabaseMetadata> createDatabase(
Database database, Iterable<String> statements) throws SpannerException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ CommitResponse writeAtLeastOnceWithOptions(

/**
* Returns a transaction manager which allows manual management of transaction lifecycle. This API
* is meant for advanced users. Most users should instead use the {@link #readWriteTransaction()}
* API instead.
* is meant for advanced users. Most users should instead use the {@link
* #readWriteTransaction(TransactionOption...)} API instead.
*
* <p>Example of using {@link TransactionManager}.
*
Expand Down Expand Up @@ -412,7 +412,7 @@ CommitResponse writeAtLeastOnceWithOptions(
*
* <p>Example of a read write transaction.
*
* <pre> <code>
* <pre>{@code
* Executor executor = Executors.newSingleThreadExecutor();
* final long singerId = my_singer_id;
* AsyncRunner runner = client.runAsync();
Expand All @@ -432,7 +432,7 @@ CommitResponse writeAtLeastOnceWithOptions(
* .build());
* },
* executor);
* </code></pre>
* }</pre>
*
* Options for a transaction can include:
*
Expand All @@ -449,7 +449,7 @@ CommitResponse writeAtLeastOnceWithOptions(
/**
* Returns an asynchronous transaction manager which allows manual management of transaction
* lifecycle. This API is meant for advanced users. Most users should instead use the {@link
* #runAsync()} API instead.
* #runAsync(TransactionOption...)} API instead.
*
* <p>Example of using {@link AsyncTransactionManager}.
*
Expand Down Expand Up @@ -514,12 +514,13 @@ CommitResponse writeAtLeastOnceWithOptions(
*
* <p>Partitioned DML updates are used to execute a single DML statement with a different
* execution strategy that provides different, and often better, scalability properties for large,
* table-wide operations than DML in a {@link #readWriteTransaction()} transaction. Smaller scoped
* statements, such as an OLTP workload, should prefer using {@link
* TransactionContext#executeUpdate(Statement)} with {@link #readWriteTransaction()}.
* table-wide operations than DML in a {@link #readWriteTransaction(TransactionOption...)}
* transaction. Smaller scoped statements, such as an OLTP workload, should prefer using {@link
* TransactionContext#executeUpdate(Statement,UpdateOption...)} with {@link
* #readWriteTransaction(TransactionOption...)}.
*
* <p>That said, Partitioned DML is not a drop-in replacement for standard DML used in {@link
* #readWriteTransaction()}.
* #readWriteTransaction(TransactionOption...)}.
*
* <ul>
* <li>The DML statement must be fully-partitionable. Specifically, the statement must be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ public List<ReplicaInfo> getOptionalReplicas() {
}

/**
* Base configuration, e.g. projects/<project_name>/instanceConfigs/nam3, based on which this
* configuration is created. Only set for user managed configurations. The base config must refer
* to a configuration of type GOOGLE_MANAGED.
* Base configuration, e.g. {@code projects/<project_name>/instanceConfigs/nam3}, based on which
* this configuration is created. Only set for user managed configurations. The base config must
* refer to a configuration of type GOOGLE_MANAGED.
*/
public InstanceConfigInfo getBaseConfig() {
return baseConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
import javax.annotation.Nullable;
import org.threeten.bp.Duration;

/** Represents a long running operation. */
/**
* Represents a long-running operation.
*
* @param <R>
* @param <M>
*/
// TODO(user): Implement other operations on Operation.
public class Operation<R, M> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public static ListOption pageSize(int pageSize) {
}

/**
* If this is for a partitioned read & query and this field is set to `true`, the request will be
* executed via Spanner independent compute resources. The method is available in Beta mode (and
* is not generally available now).
* If this is for a partitioned read and query and this field is set to `true`, the request will
* be executed via Spanner independent compute resources. The method is available in Beta mode
* (and is not generally available now).
*/
@BetaApi
public static DataBoostQueryOption dataBoostEnabled(Boolean dataBoostEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.api.core.ApiFuture;
import com.google.api.core.InternalApi;
import com.google.cloud.spanner.Options.TransactionOption;
import com.google.protobuf.Empty;

/**
Expand Down Expand Up @@ -48,11 +49,12 @@ public interface Session extends DatabaseClient, AutoCloseable {
String getName();

/**
* Prepares a transaction for use by a subsequent {@link #readWriteTransaction()} or {@link
* #write(Iterable)} call. It is not necessary to call this method before running a transaction or
* performing a write, but doing so may allow one round trip of the protocol to be performed in
* advance; calling this method on an idle session that is expected to execute a transaction or
* write in the near future may reduce the latency of the subsequent transaction/write.
* Prepares a transaction for use by a subsequent {@link
* DatabaseClient#readWriteTransaction(TransactionOption...)} or {@link #write(Iterable)} call. It
* is not necessary to call this method before running a transaction or performing a write, but
* doing so may allow one round trip of the protocol to be performed in advance; calling this
* method on an idle session that is expected to execute a transaction or write in the near future
* may reduce the latency of the subsequent transaction/write.
*/
void prepareReadWriteTransaction();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.cloud.grpc.GcpManagedChannelOptions;
import com.google.cloud.grpc.GrpcTransportOptions;
import com.google.cloud.spanner.Options.QueryOption;
import com.google.cloud.spanner.Options.UpdateOption;
import com.google.cloud.spanner.admin.database.v1.DatabaseAdminSettings;
import com.google.cloud.spanner.admin.database.v1.stub.DatabaseAdminStubSettings;
import com.google.cloud.spanner.admin.instance.v1.InstanceAdminSettings;
Expand Down Expand Up @@ -134,10 +135,7 @@ public class SpannerOptions extends ServiceOptions<Spanner, SpannerOptions> {
private final String compressorName;
private final boolean leaderAwareRoutingEnabled;

/**
* Interface that can be used to provide {@link CallCredentials} instead of {@link Credentials} to
* {@link SpannerOptions}.
*/
/** Interface that can be used to provide {@link CallCredentials} to {@link SpannerOptions}. */
public interface CallCredentialsProvider {
/** Return the {@link CallCredentials} to use for a gRPC call. */
CallCredentials getCallCredentials();
Expand Down Expand Up @@ -970,7 +968,7 @@ public DatabaseAdminStubSettings.Builder getDatabaseAdminStubSettingsBuilder() {

/**
* Sets a timeout specifically for Partitioned DML statements executed through {@link
* DatabaseClient#executePartitionedUpdate(Statement)}. The default is 2 hours.
* DatabaseClient#executePartitionedUpdate(Statement, UpdateOption...)}. The default is 2 hours.
*/
public Builder setPartitionedDmlTimeout(Duration timeout) {
this.partitionedDmlTimeout = timeout;
Expand Down Expand Up @@ -1065,9 +1063,7 @@ QueryOptions getEnvironmentQueryOptions() {

/**
* Sets a {@link CallCredentialsProvider} that can deliver {@link CallCredentials} to use on a
* per-gRPC basis. Any credentials returned by this {@link CallCredentialsProvider} will have
* preference above any {@link Credentials} that may have been set on the {@link SpannerOptions}
* instance.
* per-gRPC basis.
*/
public Builder setCallCredentialsProvider(CallCredentialsProvider callCredentialsProvider) {
this.callCredentialsProvider = callCredentialsProvider;
Expand Down
Loading