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

feat: add PG OID support #2736

Merged
merged 53 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6b3f572
feat: add PG OID support
tlhquynh Nov 20, 2023
929abf4
chore: fix lint errors
tlhquynh Nov 20, 2023
4e7ea9d
Resolved merge conflict from branch 'main' into pg-oid.
tlhquynh Dec 29, 2023
0489d9a
Merge branch 'main' into pg-oid
tlhquynh Mar 14, 2024
e5a39c5
Update PG.OID implementation according to recent changes.
tlhquynh Mar 18, 2024
537de96
Update PG.OID implementation according to recent changes.
tlhquynh Mar 18, 2024
f9ea807
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 22, 2024
4cb354a
chore: keep session pool ordering when pinging (#2695)
olavloite Mar 15, 2024
e505b9e
deps: update dependency com.google.cloud:google-cloud-monitoring to v…
renovate-bot Mar 18, 2024
0184554
feat: allow attempt direct path xds via env var (#2950)
HailongWen Mar 19, 2024
1d756a3
build(deps): update dependency org.apache.maven.plugins:maven-compile…
renovate-bot Mar 19, 2024
f6193f9
build(deps): update dependency org.apache.maven.plugins:maven-assembl…
renovate-bot Mar 19, 2024
aed1223
deps: update dependency com.google.cloud:sdk-platform-java-config to …
renovate-bot Mar 19, 2024
bf2361b
refactor: move skip methods to abstract parser (#2948)
olavloite Mar 19, 2024
57edce9
fix: return type of max commit delay option. (#2953)
arpan14 Mar 19, 2024
d7ba42b
refactor: generalize skip methods (#2949)
olavloite Mar 19, 2024
50e2887
perf: keep comments when searching for params (#2951)
olavloite Mar 19, 2024
6258293
chore: randomize session pool order based on TPS (#2792)
olavloite Mar 19, 2024
d94922f
chore(main): release 6.62.0 (#2940)
release-please[bot] Mar 19, 2024
bd82e0c
chore(main): release 6.62.1-SNAPSHOT (#2957)
release-please[bot] Mar 19, 2024
a0a2e8d
chore(deps): update dependency com.google.cloud:google-cloud-spanner …
renovate-bot Mar 20, 2024
eaa05da
chore: add session pool options for multiplexed session. (#2960)
arpan14 Mar 22, 2024
8e4ee03
deps: update dependency com.google.cloud:google-cloud-trace to v2.38.…
renovate-bot Mar 24, 2024
ebf8723
chore: add new members in SessionImpl for multiplexed session. Add a …
arpan14 Mar 24, 2024
358e8d3
Update .gitignore to remove IDE specific files and remove unnecessary…
tlhquynh Mar 25, 2024
1e99310
Remove PG.OID external getters.
tlhquynh Mar 25, 2024
039079e
chore: generalise session pool class for multiplexed session. (#2964)
arpan14 Mar 25, 2024
b21e262
Merge branch 'main' into pg-oid
tlhquynh Mar 26, 2024
6f971a7
Merge branch 'main' into pg-oid
tlhquynh Mar 28, 2024
5df12ca
chore: emove unnecessary debug.
tlhquynh Mar 28, 2024
4b12761
chore: add multiplexed session implementations for CachedSession/Sess…
arpan14 Mar 28, 2024
60712bd
Remove internal PG.OID getters.
tlhquynh Apr 3, 2024
19fbdfb
deps: update dependency com.google.cloud:google-cloud-monitoring to v…
renovate-bot Mar 28, 2024
f3f6113
chore(main): release 6.62.1 (#2968)
release-please[bot] Mar 28, 2024
8ac2a16
chore(main): release 6.62.2-SNAPSHOT (#2983)
release-please[bot] Mar 28, 2024
231273e
feat: add support for transaction-level exclusion from change streams…
dengwe1 Mar 28, 2024
80ade2e
deps: update dependency com.google.cloud:google-cloud-trace to v2.39.…
renovate-bot Mar 29, 2024
ecb87e7
deps: update dependency commons-io:commons-io to v2.16.0 (#2986)
renovate-bot Mar 29, 2024
7444b29
deps: update dependency com.google.cloud:google-cloud-monitoring to v…
renovate-bot Mar 30, 2024
8a9584b
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Mar 30, 2024
f103f18
chore(main): release 6.63.0 (#2985)
release-please[bot] Mar 30, 2024
a8531fd
chore(main): release 6.63.1-SNAPSHOT (#2991)
release-please[bot] Mar 30, 2024
e74319c
chore: clean up some warnings and malformed comments (#2977)
olavloite Apr 1, 2024
248744b
chore(deps): update dependency com.google.cloud:google-cloud-spanner …
renovate-bot Apr 1, 2024
629fb32
feat: add endpoint connection URL property (#2969)
olavloite Apr 2, 2024
b72581c
feat: support max_commit_delay in Connection API (#2954)
olavloite Apr 2, 2024
d05695b
chore: minor improvements to default benchmarks. (#2993)
arpan14 Apr 2, 2024
417a83c
build(deps): update dependency org.jacoco:jacoco-maven-plugin to v0.8…
renovate-bot Apr 3, 2024
2d6f4f3
chore: add regex to match unmanaged dependency check (#1941) (#2971)
gcf-owl-bot[bot] Apr 3, 2024
d2b4862
feat: Add SessionPoolOptions, SpannerOptions protos in executor proto…
gcf-owl-bot[bot] Apr 3, 2024
b8074b5
Merge branch 'main' into pg-oid
tlhquynh Apr 3, 2024
cdd1c91
Merge branch 'main' into pg-oid
tlhquynh Apr 4, 2024
b63740d
chore: Remove unused CLIRR entries
tlhquynh Apr 4, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ docs/
*.pyc

.flattened-pom.xml
.java-version
.vscode/
12 changes: 12 additions & 0 deletions google-cloud-spanner/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@
<className>com/google/cloud/spanner/StructReader</className>
<method>java.util.List getPgJsonbList(java.lang.String)</method>
</difference>
<!-- PG OID -->
<difference>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not be necessary to add the internal methods to this file, if those methods are given a default implementation that just throws UnsupportedOperationException

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These entries in clirr-ignored-differences.xml for StructReader can be removed, as we don't have those methods anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final nit (I promise :-)): I think that the two remaining additions to this file for getPgOid() and getPgOidArray() can also be removed, as these methods are no longer added to the Value class.

<differenceType>7013</differenceType>
<className>com/google/cloud/spanner/Value</className>
<method>long getPgOid()</method>
</difference>
<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/spanner/Value</className>
<method>java.util.List getPgOidArray()</method>
</difference>

<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/spanner/StructReader</className>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,15 @@ public boolean getBoolean(String columnName) {

@Override
public long getLong(int columnIndex) {
checkNonNullOfCodes(columnIndex, Arrays.asList(Code.ENUM, Code.INT64), columnIndex);
checkNonNullOfCodes(
columnIndex, Arrays.asList(Code.ENUM, Code.PG_OID, Code.INT64), columnIndex);
return getLongInternal(columnIndex);
}

@Override
public long getLong(String columnName) {
int columnIndex = getColumnIndex(columnName);
checkNonNullOfCodes(columnIndex, Arrays.asList(Code.ENUM, Code.INT64), columnName);
checkNonNullOfCodes(columnIndex, Arrays.asList(Code.ENUM, Code.PG_OID, Code.INT64), columnName);
return getLongInternal(columnIndex);
}

Expand Down Expand Up @@ -366,30 +367,34 @@ public List<Boolean> getBooleanList(String columnName) {
@Override
public long[] getLongArray(int columnIndex) {
checkNonNullOfCodes(columnIndex, Collections.singletonList(Code.ARRAY), columnIndex);
checkArrayElementType(columnIndex, Arrays.asList(Code.ENUM, Code.INT64), columnIndex);
checkArrayElementType(
columnIndex, Arrays.asList(Code.ENUM, Code.PG_OID, Code.INT64), columnIndex);
return getLongArrayInternal(columnIndex);
}

@Override
public long[] getLongArray(String columnName) {
int columnIndex = getColumnIndex(columnName);
checkNonNullOfCodes(columnIndex, Collections.singletonList(Code.ARRAY), columnName);
checkArrayElementType(columnIndex, Arrays.asList(Code.ENUM, Code.INT64), columnName);
checkArrayElementType(
columnIndex, Arrays.asList(Code.ENUM, Code.PG_OID, Code.INT64), columnName);
return getLongArrayInternal(columnIndex);
}

@Override
public List<Long> getLongList(int columnIndex) {
checkNonNullOfCodes(columnIndex, Collections.singletonList(Code.ARRAY), columnIndex);
checkArrayElementType(columnIndex, Arrays.asList(Code.ENUM, Code.INT64), columnIndex);
checkArrayElementType(
columnIndex, Arrays.asList(Code.ENUM, Code.PG_OID, Code.INT64), columnIndex);
return getLongListInternal(columnIndex);
}

@Override
public List<Long> getLongList(String columnName) {
int columnIndex = getColumnIndex(columnName);
checkNonNullOfCodes(columnIndex, Collections.singletonList(Code.ARRAY), columnName);
checkArrayElementType(columnIndex, Arrays.asList(Code.ENUM, Code.INT64), columnName);
checkArrayElementType(
columnIndex, Arrays.asList(Code.ENUM, Code.PG_OID, Code.INT64), columnName);
return getLongListInternal(columnIndex);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ private Object writeReplace() {
case PG_JSONB:
builder.set(fieldName).to(Value.pgJsonb((String) value));
break;
case PG_OID:
builder.set(fieldName).to(Value.pgOid((Long) value));
break;
case BYTES:
builder
.set(fieldName)
Expand Down Expand Up @@ -158,6 +161,9 @@ private Object writeReplace() {
case PG_JSONB:
builder.set(fieldName).toPgJsonbArray((Iterable<String>) value);
break;
case PG_OID:
builder.set(fieldName).toPgOidArray((Iterable<Long>) value);
break;
case BYTES:
case PROTO:
builder
Expand Down Expand Up @@ -262,6 +268,7 @@ private static Object decodeValue(Type fieldType, com.google.protobuf.Value prot
checkType(fieldType, proto, KindCase.BOOL_VALUE);
return proto.getBoolValue();
case INT64:
case PG_OID:
case ENUM:
checkType(fieldType, proto, KindCase.STRING_VALUE);
return Long.parseLong(proto.getStringValue());
Expand Down Expand Up @@ -319,6 +326,7 @@ private static Struct decodeStructValue(Type structType, ListValue structValue)
static Object decodeArrayValue(Type elementType, ListValue listValue) {
switch (elementType.getCode()) {
case INT64:
case PG_OID:
case ENUM:
// For int64/float64/float32/enum types, use custom containers.
// These avoid wrapper object creation for non-null arrays.
Expand Down Expand Up @@ -563,6 +571,8 @@ protected Value getValueInternal(int columnIndex) {
return Value.json(isNull ? null : getJsonInternal(columnIndex));
case PG_JSONB:
return Value.pgJsonb(isNull ? null : getPgJsonbInternal(columnIndex));
case PG_OID:
return Value.pgOid(isNull ? null : getLongInternal(columnIndex));
case BYTES:
return Value.internalBytes(isNull ? null : getLazyBytesInternal(columnIndex));
case PROTO:
Expand Down Expand Up @@ -598,6 +608,8 @@ protected Value getValueInternal(int columnIndex) {
return Value.jsonArray(isNull ? null : getJsonListInternal(columnIndex));
case PG_JSONB:
return Value.pgJsonbArray(isNull ? null : getPgJsonbListInternal(columnIndex));
case PG_OID:
return Value.pgOidArray(isNull ? null : getLongListInternal(columnIndex));
case BYTES:
return Value.bytesArray(isNull ? null : getBytesListInternal(columnIndex));
case PROTO:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ private Object getAsObject(int columnIndex) {
case BOOL:
return getBooleanInternal(columnIndex);
case INT64:
case PG_OID:
case ENUM:
return getLongInternal(columnIndex);
case FLOAT32:
Expand Down Expand Up @@ -426,6 +427,7 @@ private Object getAsObject(int columnIndex) {
case BOOL:
return getBooleanListInternal(columnIndex);
case INT64:
case PG_OID:
case ENUM:
return getLongListInternal(columnIndex);
case FLOAT32:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public final class Type implements Serializable {
private static final Type TYPE_STRING = new Type(Code.STRING, null, null);
private static final Type TYPE_JSON = new Type(Code.JSON, null, null);
private static final Type TYPE_PG_JSONB = new Type(Code.PG_JSONB, null, null);
private static final Type TYPE_PG_OID = new Type(Code.PG_OID, null, null);
private static final Type TYPE_BYTES = new Type(Code.BYTES, null, null);
private static final Type TYPE_TIMESTAMP = new Type(Code.TIMESTAMP, null, null);
private static final Type TYPE_DATE = new Type(Code.DATE, null, null);
Expand All @@ -67,6 +68,7 @@ public final class Type implements Serializable {
private static final Type TYPE_ARRAY_STRING = new Type(Code.ARRAY, TYPE_STRING, null);
private static final Type TYPE_ARRAY_JSON = new Type(Code.ARRAY, TYPE_JSON, null);
private static final Type TYPE_ARRAY_PG_JSONB = new Type(Code.ARRAY, TYPE_PG_JSONB, null);
private static final Type TYPE_ARRAY_PG_OID = new Type(Code.ARRAY, TYPE_PG_OID, null);
private static final Type TYPE_ARRAY_BYTES = new Type(Code.ARRAY, TYPE_BYTES, null);
private static final Type TYPE_ARRAY_TIMESTAMP = new Type(Code.ARRAY, TYPE_TIMESTAMP, null);
private static final Type TYPE_ARRAY_DATE = new Type(Code.ARRAY, TYPE_DATE, null);
Expand Down Expand Up @@ -137,6 +139,11 @@ public static Type pgJsonb() {
return TYPE_PG_JSONB;
}

/** Returns the descriptor for the {@code PG_OID} type. */
public static Type pgOid() {
return TYPE_PG_OID;
}

/**
* To get the descriptor for the {@code PROTO} type.
*
Expand Down Expand Up @@ -198,6 +205,8 @@ public static Type array(Type elementType) {
return TYPE_ARRAY_JSON;
case PG_JSONB:
return TYPE_ARRAY_PG_JSONB;
case PG_OID:
return TYPE_ARRAY_PG_OID;
case BYTES:
return TYPE_ARRAY_BYTES;
case TIMESTAMP:
Expand Down Expand Up @@ -280,6 +289,7 @@ public enum Code {
STRING(TypeCode.STRING, "character varying"),
JSON(TypeCode.JSON, "unknown"),
PG_JSONB(TypeCode.JSON, "jsonb", TypeAnnotationCode.PG_JSONB),
PG_OID(TypeCode.INT64, "oid", TypeAnnotationCode.PG_OID),
PROTO(TypeCode.PROTO, "proto"),
ENUM(TypeCode.ENUM, "enum"),
BYTES(TypeCode.BYTES, "bytea"),
Expand Down Expand Up @@ -592,6 +602,8 @@ static Type fromProto(com.google.spanner.v1.Type proto) {
return json();
case PG_JSONB:
return pgJsonb();
case PG_OID:
return pgOid();
case BYTES:
return bytes();
case TIMESTAMP:
Expand Down
Loading
Loading