|
28 | 28 | import com.google.cloud.ByteArray;
|
29 | 29 | import com.google.cloud.Date;
|
30 | 30 | import com.google.cloud.Timestamp;
|
| 31 | +import com.google.cloud.spanner.Type.StructField; |
31 | 32 | import com.google.cloud.spanner.spi.v1.SpannerRpc;
|
32 | 33 | import com.google.cloud.spanner.v1.stub.SpannerStubSettings;
|
33 | 34 | import com.google.common.annotations.VisibleForTesting;
|
@@ -679,6 +680,62 @@ protected Date getDateInternal(int columnIndex) {
|
679 | 680 | return (Date) rowData.get(columnIndex);
|
680 | 681 | }
|
681 | 682 |
|
| 683 | +@Override |
| 684 | +protected Value getValueInternal(int columnIndex) { |
| 685 | +final List<Type.StructField> structFields = getType().getStructFields(); |
| 686 | +final StructField structField = structFields.get(columnIndex); |
| 687 | +final Type columnType = structField.getType(); |
| 688 | +final boolean isNull = rowData.get(columnIndex) == null; |
| 689 | +switch (columnType.getCode()) { |
| 690 | +case BOOL: |
| 691 | +return Value.bool(isNull ? null : getBooleanInternal(columnIndex)); |
| 692 | +case INT64: |
| 693 | +return Value.int64(isNull ? null : getLongInternal(columnIndex)); |
| 694 | +case NUMERIC: |
| 695 | +return Value.numeric(isNull ? null : getBigDecimalInternal(columnIndex)); |
| 696 | +case FLOAT64: |
| 697 | +return Value.float64(isNull ? null : getDoubleInternal(columnIndex)); |
| 698 | +case STRING: |
| 699 | +return Value.string(isNull ? null : getStringInternal(columnIndex)); |
| 700 | +case BYTES: |
| 701 | +return Value.bytes(isNull ? null : getBytesInternal(columnIndex)); |
| 702 | +case TIMESTAMP: |
| 703 | +return Value.timestamp(isNull ? null : getTimestampInternal(columnIndex)); |
| 704 | +case DATE: |
| 705 | +return Value.date(isNull ? null : getDateInternal(columnIndex)); |
| 706 | +case STRUCT: |
| 707 | +return Value.struct(isNull ? null : getStructInternal(columnIndex)); |
| 708 | +case ARRAY: |
| 709 | +switch (columnType.getArrayElementType().getCode()) { |
| 710 | +case BOOL: |
| 711 | +return Value.boolArray(isNull ? null : getBooleanListInternal(columnIndex)); |
| 712 | +case INT64: |
| 713 | +return Value.int64Array(isNull ? null : getLongListInternal(columnIndex)); |
| 714 | +case NUMERIC: |
| 715 | +return Value.numericArray(isNull ? null : getBigDecimalListInternal(columnIndex)); |
| 716 | +case FLOAT64: |
| 717 | +return Value.float64Array(isNull ? null : getDoubleListInternal(columnIndex)); |
| 718 | +case STRING: |
| 719 | +return Value.stringArray(isNull ? null : getStringListInternal(columnIndex)); |
| 720 | +case BYTES: |
| 721 | +return Value.bytesArray(isNull ? null : getBytesListInternal(columnIndex)); |
| 722 | +case TIMESTAMP: |
| 723 | +return Value.timestampArray(isNull ? null : getTimestampListInternal(columnIndex)); |
| 724 | +case DATE: |
| 725 | +return Value.dateArray(isNull ? null : getDateListInternal(columnIndex)); |
| 726 | +case STRUCT: |
| 727 | +return Value.structArray( |
| 728 | +columnType.getArrayElementType(), |
| 729 | +isNull ? null : getStructListInternal(columnIndex)); |
| 730 | +default: |
| 731 | +throw new IllegalArgumentException( |
| 732 | +"Invalid array value type " + this.type.getArrayElementType()); |
| 733 | +} |
| 734 | +default: |
| 735 | +throw new IllegalArgumentException("Invalid value type " + this.type); |
| 736 | +} |
| 737 | +} |
| 738 | + |
682 | 739 | @Override
|
683 | 740 | protected Struct getStructInternal(int columnIndex) {
|
684 | 741 | return (Struct) rowData.get(columnIndex);
|
@@ -1280,6 +1337,11 @@ protected Date getDateInternal(int columnIndex) {
|
1280 | 1337 | return currRow().getDateInternal(columnIndex);
|
1281 | 1338 | }
|
1282 | 1339 |
|
| 1340 | +@Override |
| 1341 | +protected Value getValueInternal(int columnIndex) { |
| 1342 | +return currRow().getValueInternal(columnIndex); |
| 1343 | +} |
| 1344 | + |
1283 | 1345 | @Override
|
1284 | 1346 | protected boolean[] getBooleanArrayInternal(int columnIndex) {
|
1285 | 1347 | return currRow().getBooleanArrayInternal(columnIndex);
|
|
0 commit comments