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

Clean up snippets for BatchClient and Spanner #3684

Merged
merged 2 commits into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public interface BatchClient {
*
* <!--SNIPPET batch_client_read_with_id-->
* <pre>{@code
* BatchTransactionId txnId = my_txn.getBatchTransactionId();
* BatchTransactionId txnId = prevTxn.getBatchTransactionId();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* BatchReadOnlyTransaction txn = batchClient.batchReadOnlyTransaction(txnId);
* }</pre>
* <!--SNIPPET batch_client_read_with_id-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public interface BatchReadOnlyTransaction extends ReadOnlyTransaction {
* long singerId = results.getLong(0);
* String firstName = results.getString(1);
* String lastName = results.getString(2);
* System.out.println("P2 [" + singerId + "] " + firstName + " " + lastName);
* System.out.println("P[" + singerId + "] " + firstName + " " + lastName);

This comment was marked as spam.

This comment was marked as spam.

* }
* }
* }
Expand Down Expand Up @@ -110,14 +110,15 @@ List<Partition> partitionRead(
* "Singers",
* "SingerId",
* KeySet.all(),
* Arrays.asList("FirstName"));
* BatchTransactionId txnID = txn.getBatchTransactionId();
* int numRowsRead = 0;
* Arrays.asList("SingerId", "FirstName", "LastName"));
*
* for (Partition p : partitions) {
* BatchReadOnlyTransaction batchTxnOnEachWorker = batchClient.batchReadOnlyTransaction(txnID);
* try (ResultSet results = batchTxnOnEachWorker.execute(p)) {
* try (ResultSet results = txn.execute(p)) {
* while (results.next()) {
* System.out.println(results.getString(0));
* long singerId = results.getLong(0);
* String firstName = results.getString(1);
* String lastName = results.getString(2);
* System.out.println("P[" + singerId + "] " + firstName + " " + lastName);
* }
* }
* }
Expand Down Expand Up @@ -200,7 +201,7 @@ List<Partition> partitionQuery(
*
* <!--SNIPPET batch_client_read_with_id-->
* <pre>{@code
* BatchTransactionId txnId = my_txn.getBatchTransactionId();
* BatchTransactionId txnId = prevTxn.getBatchTransactionId();

This comment was marked as spam.

* BatchReadOnlyTransaction txn = batchClient.batchReadOnlyTransaction(txnId);
* }</pre>
* <!--SNIPPET batch_client_read_with_id-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public interface Spanner extends Service<SpannerOptions> {
* final String instance = "test-instance";
* final String database = "example-db";
* DatabaseId db =
* DatabaseId.of("span-cloud-testing", "nsujir-ins", "example-db");
* DatabaseId.of(project, instance, database);
* DatabaseClient dbClient = spanner.getDatabaseClient(db);
* }</pre>
* <!--SNIPPET get_db_client-->
Expand All @@ -85,7 +85,7 @@ public interface Spanner extends Service<SpannerOptions> {
* final String instance = "test-instance";
* final String database = "example-db";
* DatabaseId db =
* DatabaseId.of("span-cloud-testing", "nsujir-ins", "example-db");
* DatabaseId.of(project, instance, database);
* BatchClient batchClient = spanner.getBatchClient(db);
* }</pre>
* <!--SNIPPET get_batch_client-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ BatchReadOnlyTransaction readStrong() {
/**
* Example to do a batch read with txn id.
*/
BatchReadOnlyTransaction readWithId(BatchReadOnlyTransaction my_txn) {
BatchReadOnlyTransaction readWithId(BatchReadOnlyTransaction prevTxn) {
// [START batch_client_read_with_id]
BatchTransactionId txnId = my_txn.getBatchTransactionId();
BatchTransactionId txnId = prevTxn.getBatchTransactionId();
BatchReadOnlyTransaction txn = batchClient.batchReadOnlyTransaction(txnId);
// [END batch_client_read_with_id]

Expand Down Expand Up @@ -104,7 +104,7 @@ void partitionRead() {
long singerId = results.getLong(0);
String firstName = results.getString(1);
String lastName = results.getString(2);
System.out.println("P2 [" + singerId + "] " + firstName + " " + lastName);
System.out.println("P[" + singerId + "] " + firstName + " " + lastName);
}
}
}
Expand All @@ -121,14 +121,15 @@ void partitionReadUsingIndex() {
"Singers",
"SingerId",
KeySet.all(),
Arrays.asList("FirstName"));
BatchTransactionId txnID = txn.getBatchTransactionId();
int numRowsRead = 0;
Arrays.asList("SingerId", "FirstName", "LastName"));

for (Partition p : partitions) {
BatchReadOnlyTransaction batchTxnOnEachWorker = batchClient.batchReadOnlyTransaction(txnID);
try (ResultSet results = batchTxnOnEachWorker.execute(p)) {
try (ResultSet results = txn.execute(p)) {
while (results.next()) {
System.out.println(results.getString(0));
long singerId = results.getLong(0);
String firstName = results.getString(1);
String lastName = results.getString(2);
System.out.println("P[" + singerId + "] " + firstName + " " + lastName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ DatabaseClient getDatabaseClient() {
final String instance = "test-instance";
final String database = "example-db";
DatabaseId db =
DatabaseId.of("span-cloud-testing", "nsujir-ins", "example-db");
DatabaseId.of(project, instance, database);
DatabaseClient dbClient = spanner.getDatabaseClient(db);
// [END get_db_client]

Expand All @@ -78,7 +78,7 @@ BatchClient getBatchClient() {
final String instance = "test-instance";
final String database = "example-db";
DatabaseId db =
DatabaseId.of("span-cloud-testing", "nsujir-ins", "example-db");
DatabaseId.of(project, instance, database);
BatchClient batchClient = spanner.getBatchClient(db);
// [END get_batch_client]

Expand Down