Skip to content

Commit 3553da3

Browse files
authored
Merge branch 'main' into support-begin-with-aborted-exception-for-manager
2 parents a149a4f + 6e220ff commit 3553da3

29 files changed

+1237
-19
lines changed

google-cloud-spanner/clirr-ignored-differences.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,38 @@
566566
<method>java.util.List getFloat32Array()</method>
567567
</difference>
568568

569+
<!-- UUID -->
570+
<difference>
571+
<differenceType>7012</differenceType>
572+
<className>com/google/cloud/spanner/StructReader</className>
573+
<method>java.util.UUID getUuid(int)</method>
574+
</difference>
575+
<difference>
576+
<differenceType>7012</differenceType>
577+
<className>com/google/cloud/spanner/StructReader</className>
578+
<method>java.util.UUID getUuid(java.lang.String)</method>
579+
</difference>
580+
<difference>
581+
<differenceType>7012</differenceType>
582+
<className>com/google/cloud/spanner/StructReader</className>
583+
<method>java.util.List getUuidList(int)</method>
584+
</difference>
585+
<difference>
586+
<differenceType>7012</differenceType>
587+
<className>com/google/cloud/spanner/StructReader</className>
588+
<method>java.util.List getUuidList(java.lang.String)</method>
589+
</difference>
590+
<difference>
591+
<differenceType>7013</differenceType>
592+
<className>com/google/cloud/spanner/Value</className>
593+
<method>java.util.UUID getUuid()</method>
594+
</difference>
595+
<difference>
596+
<differenceType>7013</differenceType>
597+
<className>com/google/cloud/spanner/Value</className>
598+
<method>java.util.List getUuidArray()</method>
599+
</difference>
600+
569601
<!-- INTERVAL -->
570602
<difference>
571603
<differenceType>7012</differenceType>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.Iterator;
3939
import java.util.List;
4040
import java.util.Objects;
41+
import java.util.UUID;
4142
import java.util.function.Function;
4243
import javax.annotation.Nonnull;
4344
import javax.annotation.Nullable;
@@ -434,6 +435,11 @@ protected Date getDateInternal(int columnIndex) {
434435
return currRow().getDateInternal(columnIndex);
435436
}
436437

438+
@Override
439+
protected UUID getUuidInternal(int columnIndex) {
440+
return currRow().getUuidInternal(columnIndex);
441+
}
442+
437443
@Override
438444
protected Interval getIntervalInternal(int columnIndex) {
439445
return currRow().getIntervalInternal(columnIndex);
@@ -531,6 +537,11 @@ protected List<Date> getDateListInternal(int columnIndex) {
531537
return currRow().getDateListInternal(columnIndex);
532538
}
533539

540+
@Override
541+
protected List<UUID> getUuidListInternal(int columnIndex) {
542+
return currRow().getUuidListInternal(columnIndex);
543+
}
544+
534545
@Override
535546
protected List<Interval> getIntervalListInternal(int columnIndex) {
536547
return currRow().getIntervalListInternal(columnIndex);

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Arrays;
2929
import java.util.Collections;
3030
import java.util.List;
31+
import java.util.UUID;
3132
import java.util.function.Function;
3233

3334
/**
@@ -67,6 +68,10 @@ protected String getPgJsonbInternal(int columnIndex) {
6768

6869
protected abstract Date getDateInternal(int columnIndex);
6970

71+
protected UUID getUuidInternal(int columnIndex) {
72+
throw new UnsupportedOperationException("Not implemented");
73+
}
74+
7075
protected Interval getIntervalInternal(int columnIndex) {
7176
throw new UnsupportedOperationException("Not implemented");
7277
}
@@ -132,6 +137,10 @@ protected List<String> getPgJsonbListInternal(int columnIndex) {
132137

133138
protected abstract List<Date> getDateListInternal(int columnIndex);
134139

140+
protected List<UUID> getUuidListInternal(int columnIndex) {
141+
throw new UnsupportedOperationException("Not implemented");
142+
}
143+
135144
protected List<Interval> getIntervalListInternal(int columnIndex) {
136145
throw new UnsupportedOperationException("Not implemented");
137146
}
@@ -307,6 +316,19 @@ public Date getDate(String columnName) {
307316
return getDateInternal(columnIndex);
308317
}
309318

319+
@Override
320+
public UUID getUuid(int columnIndex) {
321+
checkNonNullOfType(columnIndex, Type.uuid(), columnIndex);
322+
return getUuidInternal(columnIndex);
323+
}
324+
325+
@Override
326+
public UUID getUuid(String columnName) {
327+
final int columnIndex = getColumnIndex(columnName);
328+
checkNonNullOfType(columnIndex, Type.uuid(), columnName);
329+
return getUuidInternal(columnIndex);
330+
}
331+
310332
@Override
311333
public Interval getInterval(int columnIndex) {
312334
checkNonNullOfType(columnIndex, Type.interval(), columnIndex);
@@ -604,6 +626,19 @@ public List<Date> getDateList(String columnName) {
604626
return getDateListInternal(columnIndex);
605627
}
606628

629+
@Override
630+
public List<UUID> getUuidList(int columnIndex) {
631+
checkNonNullOfType(columnIndex, Type.array(Type.uuid()), columnIndex);
632+
return getUuidListInternal(columnIndex);
633+
}
634+
635+
@Override
636+
public List<UUID> getUuidList(String columnName) {
637+
final int columnIndex = getColumnIndex(columnName);
638+
checkNonNullOfType(columnIndex, Type.array(Type.uuid()), columnName);
639+
return getUuidListInternal(columnIndex);
640+
}
641+
607642
@Override
608643
public List<Interval> getIntervalList(int columnIndex) {
609644
checkNonNullOfType(columnIndex, Type.array(Type.interval()), columnIndex);

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.google.protobuf.ProtocolMessageEnum;
2727
import java.math.BigDecimal;
2828
import java.util.List;
29+
import java.util.UUID;
2930
import java.util.function.Function;
3031

3132
/** Forwarding implements of StructReader */
@@ -231,6 +232,18 @@ public Date getDate(String columnName) {
231232
return delegate.get().getDate(columnName);
232233
}
233234

235+
@Override
236+
public UUID getUuid(int columnIndex) {
237+
checkValidState();
238+
return delegate.get().getUuid(columnIndex);
239+
}
240+
241+
@Override
242+
public UUID getUuid(String columnName) {
243+
checkValidState();
244+
return delegate.get().getUuid(columnName);
245+
}
246+
234247
@Override
235248
public Interval getInterval(int columnIndex) {
236249
checkValidState();
@@ -421,6 +434,18 @@ public List<Date> getDateList(String columnName) {
421434
return delegate.get().getDateList(columnName);
422435
}
423436

437+
@Override
438+
public List<UUID> getUuidList(int columnIndex) {
439+
checkValidState();
440+
return delegate.get().getUuidList(columnIndex);
441+
}
442+
443+
@Override
444+
public List<UUID> getUuidList(String columnName) {
445+
checkValidState();
446+
return delegate.get().getUuidList(columnName);
447+
}
448+
424449
@Override
425450
public List<Interval> getIntervalList(int columnIndex) {
426451
checkValidState();

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.Collections;
5050
import java.util.Iterator;
5151
import java.util.List;
52+
import java.util.UUID;
5253
import java.util.concurrent.atomic.AtomicBoolean;
5354
import java.util.function.Function;
5455
import java.util.stream.Collectors;
@@ -131,6 +132,9 @@ private Object writeReplace() {
131132
case DATE:
132133
builder.set(fieldName).to((Date) value);
133134
break;
135+
case UUID:
136+
builder.set(fieldName).to((UUID) value);
137+
break;
134138
case INTERVAL:
135139
builder.set(fieldName).to((Interval) value);
136140
break;
@@ -187,6 +191,9 @@ private Object writeReplace() {
187191
case DATE:
188192
builder.set(fieldName).toDateArray((Iterable<Date>) value);
189193
break;
194+
case UUID:
195+
builder.set(fieldName).toUuidArray((Iterable<UUID>) value);
196+
break;
190197
case INTERVAL:
191198
builder.set(fieldName).toIntervalArray((Iterable<Interval>) value);
192199
break;
@@ -304,6 +311,9 @@ private static Object decodeValue(Type fieldType, com.google.protobuf.Value prot
304311
case DATE:
305312
checkType(fieldType, proto, KindCase.STRING_VALUE);
306313
return Date.parseDate(proto.getStringValue());
314+
case UUID:
315+
checkType(fieldType, proto, KindCase.STRING_VALUE);
316+
return UUID.fromString(proto.getStringValue());
307317
case INTERVAL:
308318
checkType(fieldType, proto, KindCase.STRING_VALUE);
309319
return Interval.parseFromString(proto.getStringValue());
@@ -356,6 +366,7 @@ static Object decodeArrayValue(Type elementType, ListValue listValue) {
356366
case BYTES:
357367
case TIMESTAMP:
358368
case DATE:
369+
case UUID:
359370
case INTERVAL:
360371
case STRUCT:
361372
case PROTO:
@@ -513,6 +524,12 @@ protected Date getDateInternal(int columnIndex) {
513524
return (Date) rowData.get(columnIndex);
514525
}
515526

527+
@Override
528+
protected UUID getUuidInternal(int columnIndex) {
529+
ensureDecoded(columnIndex);
530+
return (UUID) rowData.get(columnIndex);
531+
}
532+
516533
@Override
517534
protected Interval getIntervalInternal(int columnIndex) {
518535
ensureDecoded(columnIndex);
@@ -640,6 +657,8 @@ protected Value getValueInternal(int columnIndex) {
640657
return Value.timestamp(isNull ? null : getTimestampInternal(columnIndex));
641658
case DATE:
642659
return Value.date(isNull ? null : getDateInternal(columnIndex));
660+
case UUID:
661+
return Value.uuid(isNull ? null : getUuidInternal(columnIndex));
643662
case INTERVAL:
644663
return Value.interval(isNull ? null : getIntervalInternal(columnIndex));
645664
case STRUCT:
@@ -682,6 +701,8 @@ protected Value getValueInternal(int columnIndex) {
682701
return Value.timestampArray(isNull ? null : getTimestampListInternal(columnIndex));
683702
case DATE:
684703
return Value.dateArray(isNull ? null : getDateListInternal(columnIndex));
704+
case UUID:
705+
return Value.uuidArray(isNull ? null : getUuidListInternal(columnIndex));
685706
case INTERVAL:
686707
return Value.intervalArray(isNull ? null : getIntervalListInternal(columnIndex));
687708
case STRUCT:
@@ -867,6 +888,13 @@ protected List<Date> getDateListInternal(int columnIndex) {
867888
return Collections.unmodifiableList((List<Date>) rowData.get(columnIndex));
868889
}
869890

891+
@Override
892+
@SuppressWarnings("unchecked") // We know ARRAY<UUID> produces a List<UUID>.
893+
protected List<UUID> getUuidListInternal(int columnIndex) {
894+
ensureDecoded(columnIndex);
895+
return Collections.unmodifiableList((List<UUID>) rowData.get(columnIndex));
896+
}
897+
870898
@Override
871899
@SuppressWarnings("unchecked") // We know ARRAY<Interval> produces a List<Interval>.
872900
protected List<Interval> getIntervalListInternal(int columnIndex) {

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.google.spanner.v1.ResultSetStats;
3636
import java.math.BigDecimal;
3737
import java.util.List;
38+
import java.util.UUID;
3839
import java.util.function.Function;
3940

4041
/** Utility methods for working with {@link com.google.cloud.spanner.ResultSet}. */
@@ -326,6 +327,16 @@ public Date getDate(String columnName) {
326327
return getCurrentRowAsStruct().getDate(columnName);
327328
}
328329

330+
@Override
331+
public UUID getUuid(int columnIndex) {
332+
return getCurrentRowAsStruct().getUuid(columnIndex);
333+
}
334+
335+
@Override
336+
public UUID getUuid(String columnName) {
337+
return getCurrentRowAsStruct().getUuid(columnName);
338+
}
339+
329340
@Override
330341
public Interval getInterval(int columnIndex) {
331342
return getCurrentRowAsStruct().getInterval(columnIndex);
@@ -518,6 +529,16 @@ public List<Date> getDateList(String columnName) {
518529
return getCurrentRowAsStruct().getDateList(columnName);
519530
}
520531

532+
@Override
533+
public List<UUID> getUuidList(int columnIndex) {
534+
return getCurrentRowAsStruct().getUuidList(columnIndex);
535+
}
536+
537+
@Override
538+
public List<UUID> getUuidList(String columnName) {
539+
return getCurrentRowAsStruct().getUuidList(columnName);
540+
}
541+
521542
@Override
522543
public List<Interval> getIntervalList(int columnIndex) {
523544
return getCurrentRowAsStruct().getIntervalList(columnIndex);

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.ArrayList;
3737
import java.util.List;
3838
import java.util.Objects;
39+
import java.util.UUID;
3940
import java.util.function.Function;
4041
import javax.annotation.concurrent.Immutable;
4142

@@ -226,6 +227,11 @@ protected Date getDateInternal(int columnIndex) {
226227
return values.get(columnIndex).getDate();
227228
}
228229

230+
@Override
231+
protected UUID getUuidInternal(int columnIndex) {
232+
return values.get(columnIndex).getUuid();
233+
}
234+
229235
@Override
230236
protected Interval getIntervalInternal(int columnIndex) {
231237
return values.get(columnIndex).getInterval();
@@ -339,6 +345,11 @@ protected List<Date> getDateListInternal(int columnIndex) {
339345
return values.get(columnIndex).getDateArray();
340346
}
341347

348+
@Override
349+
protected List<UUID> getUuidListInternal(int columnIndex) {
350+
return values.get(columnIndex).getUuidArray();
351+
}
352+
342353
@Override
343354
protected List<Interval> getIntervalListInternal(int columnIndex) {
344355
return values.get(columnIndex).getIntervalArray();
@@ -430,6 +441,8 @@ private Object getAsObject(int columnIndex) {
430441
return getTimestampInternal(columnIndex);
431442
case DATE:
432443
return getDateInternal(columnIndex);
444+
case UUID:
445+
return getUuidInternal(columnIndex);
433446
case INTERVAL:
434447
return getIntervalInternal(columnIndex);
435448
case STRUCT:
@@ -463,6 +476,8 @@ private Object getAsObject(int columnIndex) {
463476
return getTimestampListInternal(columnIndex);
464477
case DATE:
465478
return getDateListInternal(columnIndex);
479+
case UUID:
480+
return getUuidListInternal(columnIndex);
466481
case INTERVAL:
467482
return getIntervalListInternal(columnIndex);
468483
case STRUCT:

0 commit comments

Comments
 (0)