Skip to content

Commit 36fd5d5

Browse files
Merge branch 'partitioned-query' of github.com:pratickchokhani/java-spanner into partitioned-query
2 parents 13b94e3 + 00a2578 commit 36fd5d5

File tree

7 files changed

+11
-34
lines changed

7 files changed

+11
-34
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchClientImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ public BatchReadOnlyTransaction batchReadOnlyTransaction(TimestampBound bound) {
7979
@Override
8080
public BatchReadOnlyTransaction batchReadOnlyTransaction(BatchTransactionId batchTransactionId) {
8181
SessionImpl session =
82-
sessionClient.sessionWithId(
83-
checkNotNull(batchTransactionId).getSessionId(),
84-
batchTransactionId.isMultiplexedSession());
82+
sessionClient.sessionWithId(checkNotNull(batchTransactionId).getSessionId());
8583
return new BatchReadOnlyTransactionImpl(
8684
MultiUseReadOnlyTransaction.newBuilder()
8785
.setSession(session)

google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchTransactionId.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class BatchTransactionId implements Serializable {
3232
private final ByteString transactionId;
3333
private final String sessionId;
3434
private final Timestamp timestamp;
35-
private final boolean isMultiplexedSession;
3635
private static final long serialVersionUID = 8067099123096783939L;
3736

3837
BatchTransactionId(
@@ -43,7 +42,6 @@ public class BatchTransactionId implements Serializable {
4342
this.transactionId = Preconditions.checkNotNull(transactionId);
4443
this.sessionId = Preconditions.checkNotNull(sessionId);
4544
this.timestamp = Preconditions.checkNotNull(timestamp);
46-
this.isMultiplexedSession = isMultiplexedSession;
4745
}
4846

4947
ByteString getTransactionId() {
@@ -58,15 +56,11 @@ Timestamp getTimestamp() {
5856
return timestamp;
5957
}
6058

61-
public boolean isMultiplexedSession() {
62-
return isMultiplexedSession;
63-
}
64-
6559
@Override
6660
public String toString() {
6761
return String.format(
68-
"transactionId: %s, sessionId: %s, timestamp: %s, isMultiplexedSession: %s",
69-
transactionId.toStringUtf8(), sessionId, timestamp, isMultiplexedSession);
62+
"transactionId: %s, sessionId: %s, timestamp: %s",
63+
transactionId.toStringUtf8(), sessionId, timestamp);
7064
}
7165

7266
@Override

google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public long executePartitionedUpdate(final Statement stmt, final UpdateOption...
317317
if (useMultiplexedSessionPartitionedOps) {
318318
return getMultiplexedSession().executePartitionedUpdate(stmt, options);
319319
}
320-
return executePartitionedUpdateSession(stmt, options);
320+
return executePartitionedUpdateWithPooledSession(stmt, options);
321321
}
322322

323323
private long executePartitionedUpdateWithPooledSession(

google-cloud-spanner/src/main/java/com/google/cloud/spanner/DelayedMultiplexedSessionTransaction.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,9 @@ private SessionReference getSessionReference() {
232232
*/
233233
@Override
234234
public long executePartitionedUpdate(Statement stmt, UpdateOption... options) {
235-
try {
236-
SessionReference sessionReference = getSessionReference();
237-
return new MultiplexedSessionTransaction(
238-
client, span, sessionReference, NO_CHANNEL_HINT, /* singleUse = */ true)
239-
.executePartitionedUpdate(stmt, options);
240-
} catch (InterruptedException e) {
241-
throw new RuntimeException(e);
242-
} catch (ExecutionException e) {
243-
throw new RuntimeException(e);
244-
}
235+
SessionReference sessionReference = getSessionReference();
236+
return new MultiplexedSessionTransaction(
237+
client, span, sessionReference, NO_CHANNEL_HINT, /* singleUse = */ true)
238+
.executePartitionedUpdate(stmt, options);
245239
}
246240
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ public AsyncTransactionManager transactionManagerAsync(TransactionOption... opti
556556

557557
@Override
558558
public long executePartitionedUpdate(Statement stmt, UpdateOption... options) {
559-
return createMultiplexedSessionTransaction(/* singleUse = */ true).executePartitionedUpdate(stmt, options);
559+
return createMultiplexedSessionTransaction(/* singleUse = */ true)
560+
.executePartitionedUpdate(stmt, options);
560561
}
561562

562563
/**

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionClient.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,10 @@ private List<SessionImpl> internalBatchCreateSessions(
414414

415415
/** Returns a {@link SessionImpl} that references the existing session with the given name. */
416416
SessionImpl sessionWithId(String name) {
417-
return sessionWithId(name, /*isMultiplexedSession= */ false);
418-
}
419-
420-
/** Returns a {@link SessionImpl} that references the existing session with the given name. */
421-
SessionImpl sessionWithId(String name, boolean isMultiplexedSession) {
422417
final Map<SpannerRpc.Option, ?> options;
423418
synchronized (this) {
424419
options = optionMap(SessionOption.channelHint(sessionChannelCounter++));
425420
}
426-
return new SessionImpl(
427-
spanner, new SessionReference(name, /*createTime= */ null, isMultiplexedSession, options));
421+
return new SessionImpl(spanner, new SessionReference(name, options));
428422
}
429423
}

google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchClientImplTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,12 @@ public void testBatchReadOnlyTxnWithBound() throws Exception {
132132
assertThat(batchTxn.getReadTimestamp()).isEqualTo(t);
133133
assertThat(batchTxn.getReadTimestamp())
134134
.isEqualTo(batchTxn.getBatchTransactionId().getTimestamp());
135-
assertEquals(batchTxn.getBatchTransactionId().isMultiplexedSession(), isMultiplexedSession);
136135
}
137136

138137
@Test
139138
public void testBatchReadOnlyTxnWithTxnId() {
140139
when(txnID.getSessionId()).thenReturn(SESSION_NAME);
141140
when(txnID.getTransactionId()).thenReturn(TXN_ID);
142-
when(txnID.isMultiplexedSession()).thenReturn(isMultiplexedSession);
143141
Timestamp t = Timestamp.parseTimestamp(TIMESTAMP);
144142
when(txnID.getTimestamp()).thenReturn(t);
145143

@@ -149,8 +147,6 @@ public void testBatchReadOnlyTxnWithTxnId() {
149147
assertThat(batchTxn.getReadTimestamp()).isEqualTo(t);
150148
assertThat(batchTxn.getReadTimestamp())
151149
.isEqualTo(batchTxn.getBatchTransactionId().getTimestamp());
152-
assertThat(batchTxn.getBatchTransactionId().isMultiplexedSession())
153-
.isEqualTo(isMultiplexedSession);
154150
}
155151

156152
@Test

0 commit comments

Comments
 (0)