From 8e14f150db81c8bf7827913d11a733d46af3fbdb Mon Sep 17 00:00:00 2001 From: Horia Chiorean Date: Tue, 23 Aug 2016 17:56:43 +0300 Subject: [PATCH] DBZ-3 Adds the structure for a Postgres connector which uses a Debezium Postgres docker image that has the decoderbufs plugin enabled to read WAL changes --- debezium-connector-postgres/pom.xml | 254 ++ .../connector/postgresql/proto/PgProto.java | 3640 +++++++++++++++++ .../src/main/proto/pg_logicaldec.proto | 40 + .../debezium/connector/postgres/build.version | 1 + .../postgres/PostgresConnection.java | 76 + .../postgres/PostgresConnectionIT.java | 129 + .../src/test/resources/log4j.properties | 12 + .../java/io/debezium/jdbc/JdbcConnection.java | 33 +- pom.xml | 1 + 9 files changed, 4184 insertions(+), 2 deletions(-) create mode 100644 debezium-connector-postgres/pom.xml create mode 100644 debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/proto/PgProto.java create mode 100644 debezium-connector-postgres/src/main/proto/pg_logicaldec.proto create mode 100644 debezium-connector-postgres/src/main/resources/io/debezium/connector/postgres/build.version create mode 100644 debezium-connector-postgres/src/test/java/io/debezium/connector/postgres/PostgresConnection.java create mode 100644 debezium-connector-postgres/src/test/java/io/debezium/connector/postgres/PostgresConnectionIT.java create mode 100644 debezium-connector-postgres/src/test/resources/log4j.properties diff --git a/debezium-connector-postgres/pom.xml b/debezium-connector-postgres/pom.xml new file mode 100644 index 000000000..51ffa2876 --- /dev/null +++ b/debezium-connector-postgres/pom.xml @@ -0,0 +1,254 @@ + + + + io.debezium + debezium-parent + 0.4.0-SNAPSHOT + ../ + + 4.0.0 + debezium-connector-postgres + Debezium Connector for PostgreSQL + jar + + 2.6.1 + + 9.6 + 5432 + postgres + postgres + postgres + debezium/postgres:${version.postgres.server} + false + true + + + + + io.debezium + debezium-core + + + org.postgresql + postgresql + 9.4.1209.jre7 + + + com.google.protobuf + protobuf-java + ${version.com.google.protobuf} + + + org.apache.kafka + connect-api + + + org.slf4j + slf4j-api + + + + + io.debezium + debezium-embedded + test-jar + test + + + io.debezium + debezium-core + test-jar + test + + + io.debezium + debezium-embedded + test + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + junit + junit + + + org.easytesting + fest-assert + + + io.confluent + kafka-connect-avro-converter + + + + + + + com.github.os72 + protoc-jar-maven-plugin + 3.0.0.1 + + + generate-sources + + run + + + ${version.com.google.protobuf} + ${project.build.sourceDirectory} + + src/main/proto + + + + + + + io.fabric8 + docker-maven-plugin + + 500 + default + true + off + + + + debezium/postgres:${version.postgres.server} + database + + alias + + ${database.user} + ${database.password} + ${database.name} + + + ${database.port}:5432 + + + postgres + true + yellow + + + ready to accept connections + + + + + + + + + + start + pre-integration-test + + start + + + + stop + post-integration-test + + stop + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + integration-test + + integration-test + + + + verify + + verify + + + + + ${skipITs} + true + + + ${docker.host.address} + ${database.port} + ${database.user} + ${database.password} + ${database.name} + ${skipLongRunningTests} + + + + + + + + true + src/main/resources + + * + **/* + + + + + + src/test/resources + true + + * + **/* + + + + + + + + + skip-integration-tests + + false + + skipITs + + + + true + + + + diff --git a/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/proto/PgProto.java b/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/proto/PgProto.java new file mode 100644 index 000000000..3bef7dd3d --- /dev/null +++ b/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/proto/PgProto.java @@ -0,0 +1,3640 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: pg_logicaldec.proto + +package io.debezium.connector.postgresql.proto; + +public final class PgProto { + private PgProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + /** + * Protobuf enum {@code decoderbufs.Op} + */ + public enum Op + implements com.google.protobuf.ProtocolMessageEnum { + /** + * INSERT = 0; + */ + INSERT(0, 0), + /** + * UPDATE = 1; + */ + UPDATE(1, 1), + /** + * DELETE = 2; + */ + DELETE(2, 2), + ; + + /** + * INSERT = 0; + */ + public static final int INSERT_VALUE = 0; + /** + * UPDATE = 1; + */ + public static final int UPDATE_VALUE = 1; + /** + * DELETE = 2; + */ + public static final int DELETE_VALUE = 2; + + + public final int getNumber() { return value; } + + public static Op valueOf(int value) { + switch (value) { + case 0: return INSERT; + case 1: return UPDATE; + case 2: return DELETE; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Op findValueByNumber(int number) { + return Op.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return io.debezium.connector.postgresql.proto.PgProto.getDescriptor().getEnumTypes().get(0); + } + + private static final Op[] VALUES = values(); + + public static Op valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private Op(int index, int value) { + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:decoderbufs.Op) + } + + public interface PointOrBuilder extends + // @@protoc_insertion_point(interface_extends:decoderbufs.Point) + com.google.protobuf.MessageOrBuilder { + + /** + * required double x = 1; + */ + boolean hasX(); + /** + * required double x = 1; + */ + double getX(); + + /** + * required double y = 2; + */ + boolean hasY(); + /** + * required double y = 2; + */ + double getY(); + } + /** + * Protobuf type {@code decoderbufs.Point} + */ + public static final class Point extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:decoderbufs.Point) + PointOrBuilder { + // Use Point.newBuilder() to construct. + private Point(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Point(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Point defaultInstance; + public static Point getDefaultInstance() { + return defaultInstance; + } + + public Point getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Point( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 9: { + bitField0_ |= 0x00000001; + x_ = input.readDouble(); + break; + } + case 17: { + bitField0_ |= 0x00000002; + y_ = input.readDouble(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_Point_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_Point_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.debezium.connector.postgresql.proto.PgProto.Point.class, io.debezium.connector.postgresql.proto.PgProto.Point.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Point parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Point(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int X_FIELD_NUMBER = 1; + private double x_; + /** + * required double x = 1; + */ + public boolean hasX() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required double x = 1; + */ + public double getX() { + return x_; + } + + public static final int Y_FIELD_NUMBER = 2; + private double y_; + /** + * required double y = 2; + */ + public boolean hasY() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required double y = 2; + */ + public double getY() { + return y_; + } + + private void initFields() { + x_ = 0D; + y_ = 0D; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasX()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasY()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeDouble(1, x_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeDouble(2, y_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(1, x_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(2, y_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static io.debezium.connector.postgresql.proto.PgProto.Point parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.Point parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(io.debezium.connector.postgresql.proto.PgProto.Point prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code decoderbufs.Point} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:decoderbufs.Point) + io.debezium.connector.postgresql.proto.PgProto.PointOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_Point_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_Point_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.debezium.connector.postgresql.proto.PgProto.Point.class, io.debezium.connector.postgresql.proto.PgProto.Point.Builder.class); + } + + // Construct using io.debezium.connector.postgresql.proto.PgProto.Point.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + x_ = 0D; + bitField0_ = (bitField0_ & ~0x00000001); + y_ = 0D; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_Point_descriptor; + } + + public io.debezium.connector.postgresql.proto.PgProto.Point getDefaultInstanceForType() { + return io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance(); + } + + public io.debezium.connector.postgresql.proto.PgProto.Point build() { + io.debezium.connector.postgresql.proto.PgProto.Point result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.debezium.connector.postgresql.proto.PgProto.Point buildPartial() { + io.debezium.connector.postgresql.proto.PgProto.Point result = new io.debezium.connector.postgresql.proto.PgProto.Point(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.x_ = x_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.y_ = y_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.debezium.connector.postgresql.proto.PgProto.Point) { + return mergeFrom((io.debezium.connector.postgresql.proto.PgProto.Point)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.debezium.connector.postgresql.proto.PgProto.Point other) { + if (other == io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance()) return this; + if (other.hasX()) { + setX(other.getX()); + } + if (other.hasY()) { + setY(other.getY()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasX()) { + + return false; + } + if (!hasY()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.debezium.connector.postgresql.proto.PgProto.Point parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.debezium.connector.postgresql.proto.PgProto.Point) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private double x_ ; + /** + * required double x = 1; + */ + public boolean hasX() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required double x = 1; + */ + public double getX() { + return x_; + } + /** + * required double x = 1; + */ + public Builder setX(double value) { + bitField0_ |= 0x00000001; + x_ = value; + onChanged(); + return this; + } + /** + * required double x = 1; + */ + public Builder clearX() { + bitField0_ = (bitField0_ & ~0x00000001); + x_ = 0D; + onChanged(); + return this; + } + + private double y_ ; + /** + * required double y = 2; + */ + public boolean hasY() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required double y = 2; + */ + public double getY() { + return y_; + } + /** + * required double y = 2; + */ + public Builder setY(double value) { + bitField0_ |= 0x00000002; + y_ = value; + onChanged(); + return this; + } + /** + * required double y = 2; + */ + public Builder clearY() { + bitField0_ = (bitField0_ & ~0x00000002); + y_ = 0D; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:decoderbufs.Point) + } + + static { + defaultInstance = new Point(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:decoderbufs.Point) + } + + public interface DatumMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:decoderbufs.DatumMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string column_name = 1; + */ + boolean hasColumnName(); + /** + * optional string column_name = 1; + */ + java.lang.String getColumnName(); + /** + * optional string column_name = 1; + */ + com.google.protobuf.ByteString + getColumnNameBytes(); + + /** + * optional int64 column_type = 2; + */ + boolean hasColumnType(); + /** + * optional int64 column_type = 2; + */ + long getColumnType(); + + /** + * optional int32 datum_int32 = 3; + */ + boolean hasDatumInt32(); + /** + * optional int32 datum_int32 = 3; + */ + int getDatumInt32(); + + /** + * optional int64 datum_int64 = 4; + */ + boolean hasDatumInt64(); + /** + * optional int64 datum_int64 = 4; + */ + long getDatumInt64(); + + /** + * optional float datum_float = 5; + */ + boolean hasDatumFloat(); + /** + * optional float datum_float = 5; + */ + float getDatumFloat(); + + /** + * optional double datum_double = 6; + */ + boolean hasDatumDouble(); + /** + * optional double datum_double = 6; + */ + double getDatumDouble(); + + /** + * optional bool datum_bool = 7; + */ + boolean hasDatumBool(); + /** + * optional bool datum_bool = 7; + */ + boolean getDatumBool(); + + /** + * optional string datum_string = 8; + */ + boolean hasDatumString(); + /** + * optional string datum_string = 8; + */ + java.lang.String getDatumString(); + /** + * optional string datum_string = 8; + */ + com.google.protobuf.ByteString + getDatumStringBytes(); + + /** + * optional bytes datum_bytes = 9; + */ + boolean hasDatumBytes(); + /** + * optional bytes datum_bytes = 9; + */ + com.google.protobuf.ByteString getDatumBytes(); + + /** + * optional .decoderbufs.Point datum_point = 10; + */ + boolean hasDatumPoint(); + /** + * optional .decoderbufs.Point datum_point = 10; + */ + io.debezium.connector.postgresql.proto.PgProto.Point getDatumPoint(); + /** + * optional .decoderbufs.Point datum_point = 10; + */ + io.debezium.connector.postgresql.proto.PgProto.PointOrBuilder getDatumPointOrBuilder(); + } + /** + * Protobuf type {@code decoderbufs.DatumMessage} + */ + public static final class DatumMessage extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:decoderbufs.DatumMessage) + DatumMessageOrBuilder { + // Use DatumMessage.newBuilder() to construct. + private DatumMessage(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private DatumMessage(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final DatumMessage defaultInstance; + public static DatumMessage getDefaultInstance() { + return defaultInstance; + } + + public DatumMessage getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DatumMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000001; + columnName_ = bs; + break; + } + case 16: { + bitField0_ |= 0x00000002; + columnType_ = input.readInt64(); + break; + } + case 24: { + datumCase_ = 3; + datum_ = input.readInt32(); + break; + } + case 32: { + datumCase_ = 4; + datum_ = input.readInt64(); + break; + } + case 45: { + datumCase_ = 5; + datum_ = input.readFloat(); + break; + } + case 49: { + datumCase_ = 6; + datum_ = input.readDouble(); + break; + } + case 56: { + datumCase_ = 7; + datum_ = input.readBool(); + break; + } + case 66: { + com.google.protobuf.ByteString bs = input.readBytes(); + datumCase_ = 8; + datum_ = bs; + break; + } + case 74: { + datumCase_ = 9; + datum_ = input.readBytes(); + break; + } + case 82: { + io.debezium.connector.postgresql.proto.PgProto.Point.Builder subBuilder = null; + if (datumCase_ == 10) { + subBuilder = ((io.debezium.connector.postgresql.proto.PgProto.Point) datum_).toBuilder(); + } + datum_ = input.readMessage(io.debezium.connector.postgresql.proto.PgProto.Point.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((io.debezium.connector.postgresql.proto.PgProto.Point) datum_); + datum_ = subBuilder.buildPartial(); + } + datumCase_ = 10; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_DatumMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_DatumMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.debezium.connector.postgresql.proto.PgProto.DatumMessage.class, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public DatumMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DatumMessage(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + private int datumCase_ = 0; + private java.lang.Object datum_; + public enum DatumCase + implements com.google.protobuf.Internal.EnumLite { + DATUM_INT32(3), + DATUM_INT64(4), + DATUM_FLOAT(5), + DATUM_DOUBLE(6), + DATUM_BOOL(7), + DATUM_STRING(8), + DATUM_BYTES(9), + DATUM_POINT(10), + DATUM_NOT_SET(0); + private int value = 0; + private DatumCase(int value) { + this.value = value; + } + public static DatumCase valueOf(int value) { + switch (value) { + case 3: return DATUM_INT32; + case 4: return DATUM_INT64; + case 5: return DATUM_FLOAT; + case 6: return DATUM_DOUBLE; + case 7: return DATUM_BOOL; + case 8: return DATUM_STRING; + case 9: return DATUM_BYTES; + case 10: return DATUM_POINT; + case 0: return DATUM_NOT_SET; + default: throw new java.lang.IllegalArgumentException( + "Value is undefined for this oneof enum."); + } + } + public int getNumber() { + return this.value; + } + }; + + public DatumCase + getDatumCase() { + return DatumCase.valueOf( + datumCase_); + } + + public static final int COLUMN_NAME_FIELD_NUMBER = 1; + private java.lang.Object columnName_; + /** + * optional string column_name = 1; + */ + public boolean hasColumnName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string column_name = 1; + */ + public java.lang.String getColumnName() { + java.lang.Object ref = columnName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + columnName_ = s; + } + return s; + } + } + /** + * optional string column_name = 1; + */ + public com.google.protobuf.ByteString + getColumnNameBytes() { + java.lang.Object ref = columnName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + columnName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int COLUMN_TYPE_FIELD_NUMBER = 2; + private long columnType_; + /** + * optional int64 column_type = 2; + */ + public boolean hasColumnType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional int64 column_type = 2; + */ + public long getColumnType() { + return columnType_; + } + + public static final int DATUM_INT32_FIELD_NUMBER = 3; + /** + * optional int32 datum_int32 = 3; + */ + public boolean hasDatumInt32() { + return datumCase_ == 3; + } + /** + * optional int32 datum_int32 = 3; + */ + public int getDatumInt32() { + if (datumCase_ == 3) { + return (java.lang.Integer) datum_; + } + return 0; + } + + public static final int DATUM_INT64_FIELD_NUMBER = 4; + /** + * optional int64 datum_int64 = 4; + */ + public boolean hasDatumInt64() { + return datumCase_ == 4; + } + /** + * optional int64 datum_int64 = 4; + */ + public long getDatumInt64() { + if (datumCase_ == 4) { + return (java.lang.Long) datum_; + } + return 0L; + } + + public static final int DATUM_FLOAT_FIELD_NUMBER = 5; + /** + * optional float datum_float = 5; + */ + public boolean hasDatumFloat() { + return datumCase_ == 5; + } + /** + * optional float datum_float = 5; + */ + public float getDatumFloat() { + if (datumCase_ == 5) { + return (java.lang.Float) datum_; + } + return 0F; + } + + public static final int DATUM_DOUBLE_FIELD_NUMBER = 6; + /** + * optional double datum_double = 6; + */ + public boolean hasDatumDouble() { + return datumCase_ == 6; + } + /** + * optional double datum_double = 6; + */ + public double getDatumDouble() { + if (datumCase_ == 6) { + return (java.lang.Double) datum_; + } + return 0D; + } + + public static final int DATUM_BOOL_FIELD_NUMBER = 7; + /** + * optional bool datum_bool = 7; + */ + public boolean hasDatumBool() { + return datumCase_ == 7; + } + /** + * optional bool datum_bool = 7; + */ + public boolean getDatumBool() { + if (datumCase_ == 7) { + return (java.lang.Boolean) datum_; + } + return false; + } + + public static final int DATUM_STRING_FIELD_NUMBER = 8; + /** + * optional string datum_string = 8; + */ + public boolean hasDatumString() { + return datumCase_ == 8; + } + /** + * optional string datum_string = 8; + */ + public java.lang.String getDatumString() { + java.lang.Object ref = ""; + if (datumCase_ == 8) { + ref = datum_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8() && (datumCase_ == 8)) { + datum_ = s; + } + return s; + } + } + /** + * optional string datum_string = 8; + */ + public com.google.protobuf.ByteString + getDatumStringBytes() { + java.lang.Object ref = ""; + if (datumCase_ == 8) { + ref = datum_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (datumCase_ == 8) { + datum_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATUM_BYTES_FIELD_NUMBER = 9; + /** + * optional bytes datum_bytes = 9; + */ + public boolean hasDatumBytes() { + return datumCase_ == 9; + } + /** + * optional bytes datum_bytes = 9; + */ + public com.google.protobuf.ByteString getDatumBytes() { + if (datumCase_ == 9) { + return (com.google.protobuf.ByteString) datum_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int DATUM_POINT_FIELD_NUMBER = 10; + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public boolean hasDatumPoint() { + return datumCase_ == 10; + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public io.debezium.connector.postgresql.proto.PgProto.Point getDatumPoint() { + if (datumCase_ == 10) { + return (io.debezium.connector.postgresql.proto.PgProto.Point) datum_; + } + return io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance(); + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public io.debezium.connector.postgresql.proto.PgProto.PointOrBuilder getDatumPointOrBuilder() { + if (datumCase_ == 10) { + return (io.debezium.connector.postgresql.proto.PgProto.Point) datum_; + } + return io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance(); + } + + private void initFields() { + columnName_ = ""; + columnType_ = 0L; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (hasDatumPoint()) { + if (!getDatumPoint().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getColumnNameBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeInt64(2, columnType_); + } + if (datumCase_ == 3) { + output.writeInt32( + 3, (int)((java.lang.Integer) datum_)); + } + if (datumCase_ == 4) { + output.writeInt64( + 4, (long)((java.lang.Long) datum_)); + } + if (datumCase_ == 5) { + output.writeFloat( + 5, (float)((java.lang.Float) datum_)); + } + if (datumCase_ == 6) { + output.writeDouble( + 6, (double)((java.lang.Double) datum_)); + } + if (datumCase_ == 7) { + output.writeBool( + 7, (boolean)((java.lang.Boolean) datum_)); + } + if (datumCase_ == 8) { + output.writeBytes(8, getDatumStringBytes()); + } + if (datumCase_ == 9) { + output.writeBytes( + 9, (com.google.protobuf.ByteString)((com.google.protobuf.ByteString) datum_)); + } + if (datumCase_ == 10) { + output.writeMessage(10, (io.debezium.connector.postgresql.proto.PgProto.Point) datum_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getColumnNameBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, columnType_); + } + if (datumCase_ == 3) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size( + 3, (int)((java.lang.Integer) datum_)); + } + if (datumCase_ == 4) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size( + 4, (long)((java.lang.Long) datum_)); + } + if (datumCase_ == 5) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize( + 5, (float)((java.lang.Float) datum_)); + } + if (datumCase_ == 6) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize( + 6, (double)((java.lang.Double) datum_)); + } + if (datumCase_ == 7) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize( + 7, (boolean)((java.lang.Boolean) datum_)); + } + if (datumCase_ == 8) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(8, getDatumStringBytes()); + } + if (datumCase_ == 9) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize( + 9, (com.google.protobuf.ByteString)((com.google.protobuf.ByteString) datum_)); + } + if (datumCase_ == 10) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(10, (io.debezium.connector.postgresql.proto.PgProto.Point) datum_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.DatumMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(io.debezium.connector.postgresql.proto.PgProto.DatumMessage prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code decoderbufs.DatumMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:decoderbufs.DatumMessage) + io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_DatumMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_DatumMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.debezium.connector.postgresql.proto.PgProto.DatumMessage.class, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder.class); + } + + // Construct using io.debezium.connector.postgresql.proto.PgProto.DatumMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + columnName_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + columnType_ = 0L; + bitField0_ = (bitField0_ & ~0x00000002); + datumCase_ = 0; + datum_ = null; + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_DatumMessage_descriptor; + } + + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage getDefaultInstanceForType() { + return io.debezium.connector.postgresql.proto.PgProto.DatumMessage.getDefaultInstance(); + } + + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage build() { + io.debezium.connector.postgresql.proto.PgProto.DatumMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage buildPartial() { + io.debezium.connector.postgresql.proto.PgProto.DatumMessage result = new io.debezium.connector.postgresql.proto.PgProto.DatumMessage(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.columnName_ = columnName_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.columnType_ = columnType_; + if (datumCase_ == 3) { + result.datum_ = datum_; + } + if (datumCase_ == 4) { + result.datum_ = datum_; + } + if (datumCase_ == 5) { + result.datum_ = datum_; + } + if (datumCase_ == 6) { + result.datum_ = datum_; + } + if (datumCase_ == 7) { + result.datum_ = datum_; + } + if (datumCase_ == 8) { + result.datum_ = datum_; + } + if (datumCase_ == 9) { + result.datum_ = datum_; + } + if (datumCase_ == 10) { + if (datumPointBuilder_ == null) { + result.datum_ = datum_; + } else { + result.datum_ = datumPointBuilder_.build(); + } + } + result.bitField0_ = to_bitField0_; + result.datumCase_ = datumCase_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.debezium.connector.postgresql.proto.PgProto.DatumMessage) { + return mergeFrom((io.debezium.connector.postgresql.proto.PgProto.DatumMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.debezium.connector.postgresql.proto.PgProto.DatumMessage other) { + if (other == io.debezium.connector.postgresql.proto.PgProto.DatumMessage.getDefaultInstance()) return this; + if (other.hasColumnName()) { + bitField0_ |= 0x00000001; + columnName_ = other.columnName_; + onChanged(); + } + if (other.hasColumnType()) { + setColumnType(other.getColumnType()); + } + switch (other.getDatumCase()) { + case DATUM_INT32: { + setDatumInt32(other.getDatumInt32()); + break; + } + case DATUM_INT64: { + setDatumInt64(other.getDatumInt64()); + break; + } + case DATUM_FLOAT: { + setDatumFloat(other.getDatumFloat()); + break; + } + case DATUM_DOUBLE: { + setDatumDouble(other.getDatumDouble()); + break; + } + case DATUM_BOOL: { + setDatumBool(other.getDatumBool()); + break; + } + case DATUM_STRING: { + datumCase_ = 8; + datum_ = other.datum_; + onChanged(); + break; + } + case DATUM_BYTES: { + setDatumBytes(other.getDatumBytes()); + break; + } + case DATUM_POINT: { + mergeDatumPoint(other.getDatumPoint()); + break; + } + case DATUM_NOT_SET: { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (hasDatumPoint()) { + if (!getDatumPoint().isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.debezium.connector.postgresql.proto.PgProto.DatumMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.debezium.connector.postgresql.proto.PgProto.DatumMessage) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int datumCase_ = 0; + private java.lang.Object datum_; + public DatumCase + getDatumCase() { + return DatumCase.valueOf( + datumCase_); + } + + public Builder clearDatum() { + datumCase_ = 0; + datum_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object columnName_ = ""; + /** + * optional string column_name = 1; + */ + public boolean hasColumnName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string column_name = 1; + */ + public java.lang.String getColumnName() { + java.lang.Object ref = columnName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + columnName_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string column_name = 1; + */ + public com.google.protobuf.ByteString + getColumnNameBytes() { + java.lang.Object ref = columnName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + columnName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string column_name = 1; + */ + public Builder setColumnName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + columnName_ = value; + onChanged(); + return this; + } + /** + * optional string column_name = 1; + */ + public Builder clearColumnName() { + bitField0_ = (bitField0_ & ~0x00000001); + columnName_ = getDefaultInstance().getColumnName(); + onChanged(); + return this; + } + /** + * optional string column_name = 1; + */ + public Builder setColumnNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + columnName_ = value; + onChanged(); + return this; + } + + private long columnType_ ; + /** + * optional int64 column_type = 2; + */ + public boolean hasColumnType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional int64 column_type = 2; + */ + public long getColumnType() { + return columnType_; + } + /** + * optional int64 column_type = 2; + */ + public Builder setColumnType(long value) { + bitField0_ |= 0x00000002; + columnType_ = value; + onChanged(); + return this; + } + /** + * optional int64 column_type = 2; + */ + public Builder clearColumnType() { + bitField0_ = (bitField0_ & ~0x00000002); + columnType_ = 0L; + onChanged(); + return this; + } + + /** + * optional int32 datum_int32 = 3; + */ + public boolean hasDatumInt32() { + return datumCase_ == 3; + } + /** + * optional int32 datum_int32 = 3; + */ + public int getDatumInt32() { + if (datumCase_ == 3) { + return (java.lang.Integer) datum_; + } + return 0; + } + /** + * optional int32 datum_int32 = 3; + */ + public Builder setDatumInt32(int value) { + datumCase_ = 3; + datum_ = value; + onChanged(); + return this; + } + /** + * optional int32 datum_int32 = 3; + */ + public Builder clearDatumInt32() { + if (datumCase_ == 3) { + datumCase_ = 0; + datum_ = null; + onChanged(); + } + return this; + } + + /** + * optional int64 datum_int64 = 4; + */ + public boolean hasDatumInt64() { + return datumCase_ == 4; + } + /** + * optional int64 datum_int64 = 4; + */ + public long getDatumInt64() { + if (datumCase_ == 4) { + return (java.lang.Long) datum_; + } + return 0L; + } + /** + * optional int64 datum_int64 = 4; + */ + public Builder setDatumInt64(long value) { + datumCase_ = 4; + datum_ = value; + onChanged(); + return this; + } + /** + * optional int64 datum_int64 = 4; + */ + public Builder clearDatumInt64() { + if (datumCase_ == 4) { + datumCase_ = 0; + datum_ = null; + onChanged(); + } + return this; + } + + /** + * optional float datum_float = 5; + */ + public boolean hasDatumFloat() { + return datumCase_ == 5; + } + /** + * optional float datum_float = 5; + */ + public float getDatumFloat() { + if (datumCase_ == 5) { + return (java.lang.Float) datum_; + } + return 0F; + } + /** + * optional float datum_float = 5; + */ + public Builder setDatumFloat(float value) { + datumCase_ = 5; + datum_ = value; + onChanged(); + return this; + } + /** + * optional float datum_float = 5; + */ + public Builder clearDatumFloat() { + if (datumCase_ == 5) { + datumCase_ = 0; + datum_ = null; + onChanged(); + } + return this; + } + + /** + * optional double datum_double = 6; + */ + public boolean hasDatumDouble() { + return datumCase_ == 6; + } + /** + * optional double datum_double = 6; + */ + public double getDatumDouble() { + if (datumCase_ == 6) { + return (java.lang.Double) datum_; + } + return 0D; + } + /** + * optional double datum_double = 6; + */ + public Builder setDatumDouble(double value) { + datumCase_ = 6; + datum_ = value; + onChanged(); + return this; + } + /** + * optional double datum_double = 6; + */ + public Builder clearDatumDouble() { + if (datumCase_ == 6) { + datumCase_ = 0; + datum_ = null; + onChanged(); + } + return this; + } + + /** + * optional bool datum_bool = 7; + */ + public boolean hasDatumBool() { + return datumCase_ == 7; + } + /** + * optional bool datum_bool = 7; + */ + public boolean getDatumBool() { + if (datumCase_ == 7) { + return (java.lang.Boolean) datum_; + } + return false; + } + /** + * optional bool datum_bool = 7; + */ + public Builder setDatumBool(boolean value) { + datumCase_ = 7; + datum_ = value; + onChanged(); + return this; + } + /** + * optional bool datum_bool = 7; + */ + public Builder clearDatumBool() { + if (datumCase_ == 7) { + datumCase_ = 0; + datum_ = null; + onChanged(); + } + return this; + } + + /** + * optional string datum_string = 8; + */ + public boolean hasDatumString() { + return datumCase_ == 8; + } + /** + * optional string datum_string = 8; + */ + public java.lang.String getDatumString() { + java.lang.Object ref = ""; + if (datumCase_ == 8) { + ref = datum_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (datumCase_ == 8) { + if (bs.isValidUtf8()) { + datum_ = s; + } + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string datum_string = 8; + */ + public com.google.protobuf.ByteString + getDatumStringBytes() { + java.lang.Object ref = ""; + if (datumCase_ == 8) { + ref = datum_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (datumCase_ == 8) { + datum_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string datum_string = 8; + */ + public Builder setDatumString( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + datumCase_ = 8; + datum_ = value; + onChanged(); + return this; + } + /** + * optional string datum_string = 8; + */ + public Builder clearDatumString() { + if (datumCase_ == 8) { + datumCase_ = 0; + datum_ = null; + onChanged(); + } + return this; + } + /** + * optional string datum_string = 8; + */ + public Builder setDatumStringBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + datumCase_ = 8; + datum_ = value; + onChanged(); + return this; + } + + /** + * optional bytes datum_bytes = 9; + */ + public boolean hasDatumBytes() { + return datumCase_ == 9; + } + /** + * optional bytes datum_bytes = 9; + */ + public com.google.protobuf.ByteString getDatumBytes() { + if (datumCase_ == 9) { + return (com.google.protobuf.ByteString) datum_; + } + return com.google.protobuf.ByteString.EMPTY; + } + /** + * optional bytes datum_bytes = 9; + */ + public Builder setDatumBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + datumCase_ = 9; + datum_ = value; + onChanged(); + return this; + } + /** + * optional bytes datum_bytes = 9; + */ + public Builder clearDatumBytes() { + if (datumCase_ == 9) { + datumCase_ = 0; + datum_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.Point, io.debezium.connector.postgresql.proto.PgProto.Point.Builder, io.debezium.connector.postgresql.proto.PgProto.PointOrBuilder> datumPointBuilder_; + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public boolean hasDatumPoint() { + return datumCase_ == 10; + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public io.debezium.connector.postgresql.proto.PgProto.Point getDatumPoint() { + if (datumPointBuilder_ == null) { + if (datumCase_ == 10) { + return (io.debezium.connector.postgresql.proto.PgProto.Point) datum_; + } + return io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance(); + } else { + if (datumCase_ == 10) { + return datumPointBuilder_.getMessage(); + } + return io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance(); + } + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public Builder setDatumPoint(io.debezium.connector.postgresql.proto.PgProto.Point value) { + if (datumPointBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + datum_ = value; + onChanged(); + } else { + datumPointBuilder_.setMessage(value); + } + datumCase_ = 10; + return this; + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public Builder setDatumPoint( + io.debezium.connector.postgresql.proto.PgProto.Point.Builder builderForValue) { + if (datumPointBuilder_ == null) { + datum_ = builderForValue.build(); + onChanged(); + } else { + datumPointBuilder_.setMessage(builderForValue.build()); + } + datumCase_ = 10; + return this; + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public Builder mergeDatumPoint(io.debezium.connector.postgresql.proto.PgProto.Point value) { + if (datumPointBuilder_ == null) { + if (datumCase_ == 10 && + datum_ != io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance()) { + datum_ = io.debezium.connector.postgresql.proto.PgProto.Point.newBuilder((io.debezium.connector.postgresql.proto.PgProto.Point) datum_) + .mergeFrom(value).buildPartial(); + } else { + datum_ = value; + } + onChanged(); + } else { + if (datumCase_ == 10) { + datumPointBuilder_.mergeFrom(value); + } + datumPointBuilder_.setMessage(value); + } + datumCase_ = 10; + return this; + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public Builder clearDatumPoint() { + if (datumPointBuilder_ == null) { + if (datumCase_ == 10) { + datumCase_ = 0; + datum_ = null; + onChanged(); + } + } else { + if (datumCase_ == 10) { + datumCase_ = 0; + datum_ = null; + } + datumPointBuilder_.clear(); + } + return this; + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public io.debezium.connector.postgresql.proto.PgProto.Point.Builder getDatumPointBuilder() { + return getDatumPointFieldBuilder().getBuilder(); + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + public io.debezium.connector.postgresql.proto.PgProto.PointOrBuilder getDatumPointOrBuilder() { + if ((datumCase_ == 10) && (datumPointBuilder_ != null)) { + return datumPointBuilder_.getMessageOrBuilder(); + } else { + if (datumCase_ == 10) { + return (io.debezium.connector.postgresql.proto.PgProto.Point) datum_; + } + return io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance(); + } + } + /** + * optional .decoderbufs.Point datum_point = 10; + */ + private com.google.protobuf.SingleFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.Point, io.debezium.connector.postgresql.proto.PgProto.Point.Builder, io.debezium.connector.postgresql.proto.PgProto.PointOrBuilder> + getDatumPointFieldBuilder() { + if (datumPointBuilder_ == null) { + if (!(datumCase_ == 10)) { + datum_ = io.debezium.connector.postgresql.proto.PgProto.Point.getDefaultInstance(); + } + datumPointBuilder_ = new com.google.protobuf.SingleFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.Point, io.debezium.connector.postgresql.proto.PgProto.Point.Builder, io.debezium.connector.postgresql.proto.PgProto.PointOrBuilder>( + (io.debezium.connector.postgresql.proto.PgProto.Point) datum_, + getParentForChildren(), + isClean()); + datum_ = null; + } + datumCase_ = 10; + return datumPointBuilder_; + } + + // @@protoc_insertion_point(builder_scope:decoderbufs.DatumMessage) + } + + static { + defaultInstance = new DatumMessage(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:decoderbufs.DatumMessage) + } + + public interface RowMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:decoderbufs.RowMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * optional uint32 transaction_id = 1; + */ + boolean hasTransactionId(); + /** + * optional uint32 transaction_id = 1; + */ + int getTransactionId(); + + /** + * optional uint64 commit_time = 2; + */ + boolean hasCommitTime(); + /** + * optional uint64 commit_time = 2; + */ + long getCommitTime(); + + /** + * optional string table = 3; + */ + boolean hasTable(); + /** + * optional string table = 3; + */ + java.lang.String getTable(); + /** + * optional string table = 3; + */ + com.google.protobuf.ByteString + getTableBytes(); + + /** + * optional .decoderbufs.Op op = 4; + */ + boolean hasOp(); + /** + * optional .decoderbufs.Op op = 4; + */ + io.debezium.connector.postgresql.proto.PgProto.Op getOp(); + + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + java.util.List + getNewTupleList(); + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + io.debezium.connector.postgresql.proto.PgProto.DatumMessage getNewTuple(int index); + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + int getNewTupleCount(); + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + java.util.List + getNewTupleOrBuilderList(); + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder getNewTupleOrBuilder( + int index); + + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + java.util.List + getOldTupleList(); + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + io.debezium.connector.postgresql.proto.PgProto.DatumMessage getOldTuple(int index); + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + int getOldTupleCount(); + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + java.util.List + getOldTupleOrBuilderList(); + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder getOldTupleOrBuilder( + int index); + } + /** + * Protobuf type {@code decoderbufs.RowMessage} + */ + public static final class RowMessage extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:decoderbufs.RowMessage) + RowMessageOrBuilder { + // Use RowMessage.newBuilder() to construct. + private RowMessage(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private RowMessage(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final RowMessage defaultInstance; + public static RowMessage getDefaultInstance() { + return defaultInstance; + } + + public RowMessage getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RowMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + transactionId_ = input.readUInt32(); + break; + } + case 16: { + bitField0_ |= 0x00000002; + commitTime_ = input.readUInt64(); + break; + } + case 26: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000004; + table_ = bs; + break; + } + case 32: { + int rawValue = input.readEnum(); + io.debezium.connector.postgresql.proto.PgProto.Op value = io.debezium.connector.postgresql.proto.PgProto.Op.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(4, rawValue); + } else { + bitField0_ |= 0x00000008; + op_ = value; + } + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + newTuple_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + newTuple_.add(input.readMessage(io.debezium.connector.postgresql.proto.PgProto.DatumMessage.PARSER, extensionRegistry)); + break; + } + case 50: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + oldTuple_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + oldTuple_.add(input.readMessage(io.debezium.connector.postgresql.proto.PgProto.DatumMessage.PARSER, extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + newTuple_ = java.util.Collections.unmodifiableList(newTuple_); + } + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + oldTuple_ = java.util.Collections.unmodifiableList(oldTuple_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_RowMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_RowMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.debezium.connector.postgresql.proto.PgProto.RowMessage.class, io.debezium.connector.postgresql.proto.PgProto.RowMessage.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public RowMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RowMessage(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int TRANSACTION_ID_FIELD_NUMBER = 1; + private int transactionId_; + /** + * optional uint32 transaction_id = 1; + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional uint32 transaction_id = 1; + */ + public int getTransactionId() { + return transactionId_; + } + + public static final int COMMIT_TIME_FIELD_NUMBER = 2; + private long commitTime_; + /** + * optional uint64 commit_time = 2; + */ + public boolean hasCommitTime() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional uint64 commit_time = 2; + */ + public long getCommitTime() { + return commitTime_; + } + + public static final int TABLE_FIELD_NUMBER = 3; + private java.lang.Object table_; + /** + * optional string table = 3; + */ + public boolean hasTable() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string table = 3; + */ + public java.lang.String getTable() { + java.lang.Object ref = table_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + table_ = s; + } + return s; + } + } + /** + * optional string table = 3; + */ + public com.google.protobuf.ByteString + getTableBytes() { + java.lang.Object ref = table_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + table_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OP_FIELD_NUMBER = 4; + private io.debezium.connector.postgresql.proto.PgProto.Op op_; + /** + * optional .decoderbufs.Op op = 4; + */ + public boolean hasOp() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional .decoderbufs.Op op = 4; + */ + public io.debezium.connector.postgresql.proto.PgProto.Op getOp() { + return op_; + } + + public static final int NEW_TUPLE_FIELD_NUMBER = 5; + private java.util.List newTuple_; + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public java.util.List getNewTupleList() { + return newTuple_; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public java.util.List + getNewTupleOrBuilderList() { + return newTuple_; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public int getNewTupleCount() { + return newTuple_.size(); + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage getNewTuple(int index) { + return newTuple_.get(index); + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder getNewTupleOrBuilder( + int index) { + return newTuple_.get(index); + } + + public static final int OLD_TUPLE_FIELD_NUMBER = 6; + private java.util.List oldTuple_; + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public java.util.List getOldTupleList() { + return oldTuple_; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public java.util.List + getOldTupleOrBuilderList() { + return oldTuple_; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public int getOldTupleCount() { + return oldTuple_.size(); + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage getOldTuple(int index) { + return oldTuple_.get(index); + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder getOldTupleOrBuilder( + int index) { + return oldTuple_.get(index); + } + + private void initFields() { + transactionId_ = 0; + commitTime_ = 0L; + table_ = ""; + op_ = io.debezium.connector.postgresql.proto.PgProto.Op.INSERT; + newTuple_ = java.util.Collections.emptyList(); + oldTuple_ = java.util.Collections.emptyList(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + for (int i = 0; i < getNewTupleCount(); i++) { + if (!getNewTuple(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + for (int i = 0; i < getOldTupleCount(); i++) { + if (!getOldTuple(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeUInt32(1, transactionId_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeUInt64(2, commitTime_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, getTableBytes()); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeEnum(4, op_.getNumber()); + } + for (int i = 0; i < newTuple_.size(); i++) { + output.writeMessage(5, newTuple_.get(i)); + } + for (int i = 0; i < oldTuple_.size(); i++) { + output.writeMessage(6, oldTuple_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(1, transactionId_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(2, commitTime_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, getTableBytes()); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(4, op_.getNumber()); + } + for (int i = 0; i < newTuple_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, newTuple_.get(i)); + } + for (int i = 0; i < oldTuple_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, oldTuple_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static io.debezium.connector.postgresql.proto.PgProto.RowMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(io.debezium.connector.postgresql.proto.PgProto.RowMessage prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code decoderbufs.RowMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:decoderbufs.RowMessage) + io.debezium.connector.postgresql.proto.PgProto.RowMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_RowMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_RowMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.debezium.connector.postgresql.proto.PgProto.RowMessage.class, io.debezium.connector.postgresql.proto.PgProto.RowMessage.Builder.class); + } + + // Construct using io.debezium.connector.postgresql.proto.PgProto.RowMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getNewTupleFieldBuilder(); + getOldTupleFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + transactionId_ = 0; + bitField0_ = (bitField0_ & ~0x00000001); + commitTime_ = 0L; + bitField0_ = (bitField0_ & ~0x00000002); + table_ = ""; + bitField0_ = (bitField0_ & ~0x00000004); + op_ = io.debezium.connector.postgresql.proto.PgProto.Op.INSERT; + bitField0_ = (bitField0_ & ~0x00000008); + if (newTupleBuilder_ == null) { + newTuple_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + newTupleBuilder_.clear(); + } + if (oldTupleBuilder_ == null) { + oldTuple_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + } else { + oldTupleBuilder_.clear(); + } + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.debezium.connector.postgresql.proto.PgProto.internal_static_decoderbufs_RowMessage_descriptor; + } + + public io.debezium.connector.postgresql.proto.PgProto.RowMessage getDefaultInstanceForType() { + return io.debezium.connector.postgresql.proto.PgProto.RowMessage.getDefaultInstance(); + } + + public io.debezium.connector.postgresql.proto.PgProto.RowMessage build() { + io.debezium.connector.postgresql.proto.PgProto.RowMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.debezium.connector.postgresql.proto.PgProto.RowMessage buildPartial() { + io.debezium.connector.postgresql.proto.PgProto.RowMessage result = new io.debezium.connector.postgresql.proto.PgProto.RowMessage(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.transactionId_ = transactionId_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.commitTime_ = commitTime_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.table_ = table_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.op_ = op_; + if (newTupleBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + newTuple_ = java.util.Collections.unmodifiableList(newTuple_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.newTuple_ = newTuple_; + } else { + result.newTuple_ = newTupleBuilder_.build(); + } + if (oldTupleBuilder_ == null) { + if (((bitField0_ & 0x00000020) == 0x00000020)) { + oldTuple_ = java.util.Collections.unmodifiableList(oldTuple_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.oldTuple_ = oldTuple_; + } else { + result.oldTuple_ = oldTupleBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.debezium.connector.postgresql.proto.PgProto.RowMessage) { + return mergeFrom((io.debezium.connector.postgresql.proto.PgProto.RowMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.debezium.connector.postgresql.proto.PgProto.RowMessage other) { + if (other == io.debezium.connector.postgresql.proto.PgProto.RowMessage.getDefaultInstance()) return this; + if (other.hasTransactionId()) { + setTransactionId(other.getTransactionId()); + } + if (other.hasCommitTime()) { + setCommitTime(other.getCommitTime()); + } + if (other.hasTable()) { + bitField0_ |= 0x00000004; + table_ = other.table_; + onChanged(); + } + if (other.hasOp()) { + setOp(other.getOp()); + } + if (newTupleBuilder_ == null) { + if (!other.newTuple_.isEmpty()) { + if (newTuple_.isEmpty()) { + newTuple_ = other.newTuple_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureNewTupleIsMutable(); + newTuple_.addAll(other.newTuple_); + } + onChanged(); + } + } else { + if (!other.newTuple_.isEmpty()) { + if (newTupleBuilder_.isEmpty()) { + newTupleBuilder_.dispose(); + newTupleBuilder_ = null; + newTuple_ = other.newTuple_; + bitField0_ = (bitField0_ & ~0x00000010); + newTupleBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getNewTupleFieldBuilder() : null; + } else { + newTupleBuilder_.addAllMessages(other.newTuple_); + } + } + } + if (oldTupleBuilder_ == null) { + if (!other.oldTuple_.isEmpty()) { + if (oldTuple_.isEmpty()) { + oldTuple_ = other.oldTuple_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureOldTupleIsMutable(); + oldTuple_.addAll(other.oldTuple_); + } + onChanged(); + } + } else { + if (!other.oldTuple_.isEmpty()) { + if (oldTupleBuilder_.isEmpty()) { + oldTupleBuilder_.dispose(); + oldTupleBuilder_ = null; + oldTuple_ = other.oldTuple_; + bitField0_ = (bitField0_ & ~0x00000020); + oldTupleBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getOldTupleFieldBuilder() : null; + } else { + oldTupleBuilder_.addAllMessages(other.oldTuple_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + for (int i = 0; i < getNewTupleCount(); i++) { + if (!getNewTuple(i).isInitialized()) { + + return false; + } + } + for (int i = 0; i < getOldTupleCount(); i++) { + if (!getOldTuple(i).isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.debezium.connector.postgresql.proto.PgProto.RowMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.debezium.connector.postgresql.proto.PgProto.RowMessage) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int transactionId_ ; + /** + * optional uint32 transaction_id = 1; + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional uint32 transaction_id = 1; + */ + public int getTransactionId() { + return transactionId_; + } + /** + * optional uint32 transaction_id = 1; + */ + public Builder setTransactionId(int value) { + bitField0_ |= 0x00000001; + transactionId_ = value; + onChanged(); + return this; + } + /** + * optional uint32 transaction_id = 1; + */ + public Builder clearTransactionId() { + bitField0_ = (bitField0_ & ~0x00000001); + transactionId_ = 0; + onChanged(); + return this; + } + + private long commitTime_ ; + /** + * optional uint64 commit_time = 2; + */ + public boolean hasCommitTime() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional uint64 commit_time = 2; + */ + public long getCommitTime() { + return commitTime_; + } + /** + * optional uint64 commit_time = 2; + */ + public Builder setCommitTime(long value) { + bitField0_ |= 0x00000002; + commitTime_ = value; + onChanged(); + return this; + } + /** + * optional uint64 commit_time = 2; + */ + public Builder clearCommitTime() { + bitField0_ = (bitField0_ & ~0x00000002); + commitTime_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object table_ = ""; + /** + * optional string table = 3; + */ + public boolean hasTable() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string table = 3; + */ + public java.lang.String getTable() { + java.lang.Object ref = table_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + table_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string table = 3; + */ + public com.google.protobuf.ByteString + getTableBytes() { + java.lang.Object ref = table_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + table_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string table = 3; + */ + public Builder setTable( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + table_ = value; + onChanged(); + return this; + } + /** + * optional string table = 3; + */ + public Builder clearTable() { + bitField0_ = (bitField0_ & ~0x00000004); + table_ = getDefaultInstance().getTable(); + onChanged(); + return this; + } + /** + * optional string table = 3; + */ + public Builder setTableBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + table_ = value; + onChanged(); + return this; + } + + private io.debezium.connector.postgresql.proto.PgProto.Op op_ = io.debezium.connector.postgresql.proto.PgProto.Op.INSERT; + /** + * optional .decoderbufs.Op op = 4; + */ + public boolean hasOp() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional .decoderbufs.Op op = 4; + */ + public io.debezium.connector.postgresql.proto.PgProto.Op getOp() { + return op_; + } + /** + * optional .decoderbufs.Op op = 4; + */ + public Builder setOp(io.debezium.connector.postgresql.proto.PgProto.Op value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + op_ = value; + onChanged(); + return this; + } + /** + * optional .decoderbufs.Op op = 4; + */ + public Builder clearOp() { + bitField0_ = (bitField0_ & ~0x00000008); + op_ = io.debezium.connector.postgresql.proto.PgProto.Op.INSERT; + onChanged(); + return this; + } + + private java.util.List newTuple_ = + java.util.Collections.emptyList(); + private void ensureNewTupleIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + newTuple_ = new java.util.ArrayList(newTuple_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.DatumMessage, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder, io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder> newTupleBuilder_; + + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public java.util.List getNewTupleList() { + if (newTupleBuilder_ == null) { + return java.util.Collections.unmodifiableList(newTuple_); + } else { + return newTupleBuilder_.getMessageList(); + } + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public int getNewTupleCount() { + if (newTupleBuilder_ == null) { + return newTuple_.size(); + } else { + return newTupleBuilder_.getCount(); + } + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage getNewTuple(int index) { + if (newTupleBuilder_ == null) { + return newTuple_.get(index); + } else { + return newTupleBuilder_.getMessage(index); + } + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder setNewTuple( + int index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage value) { + if (newTupleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNewTupleIsMutable(); + newTuple_.set(index, value); + onChanged(); + } else { + newTupleBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder setNewTuple( + int index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder builderForValue) { + if (newTupleBuilder_ == null) { + ensureNewTupleIsMutable(); + newTuple_.set(index, builderForValue.build()); + onChanged(); + } else { + newTupleBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder addNewTuple(io.debezium.connector.postgresql.proto.PgProto.DatumMessage value) { + if (newTupleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNewTupleIsMutable(); + newTuple_.add(value); + onChanged(); + } else { + newTupleBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder addNewTuple( + int index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage value) { + if (newTupleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNewTupleIsMutable(); + newTuple_.add(index, value); + onChanged(); + } else { + newTupleBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder addNewTuple( + io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder builderForValue) { + if (newTupleBuilder_ == null) { + ensureNewTupleIsMutable(); + newTuple_.add(builderForValue.build()); + onChanged(); + } else { + newTupleBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder addNewTuple( + int index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder builderForValue) { + if (newTupleBuilder_ == null) { + ensureNewTupleIsMutable(); + newTuple_.add(index, builderForValue.build()); + onChanged(); + } else { + newTupleBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder addAllNewTuple( + java.lang.Iterable values) { + if (newTupleBuilder_ == null) { + ensureNewTupleIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, newTuple_); + onChanged(); + } else { + newTupleBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder clearNewTuple() { + if (newTupleBuilder_ == null) { + newTuple_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + newTupleBuilder_.clear(); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public Builder removeNewTuple(int index) { + if (newTupleBuilder_ == null) { + ensureNewTupleIsMutable(); + newTuple_.remove(index); + onChanged(); + } else { + newTupleBuilder_.remove(index); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder getNewTupleBuilder( + int index) { + return getNewTupleFieldBuilder().getBuilder(index); + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder getNewTupleOrBuilder( + int index) { + if (newTupleBuilder_ == null) { + return newTuple_.get(index); } else { + return newTupleBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public java.util.List + getNewTupleOrBuilderList() { + if (newTupleBuilder_ != null) { + return newTupleBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(newTuple_); + } + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder addNewTupleBuilder() { + return getNewTupleFieldBuilder().addBuilder( + io.debezium.connector.postgresql.proto.PgProto.DatumMessage.getDefaultInstance()); + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder addNewTupleBuilder( + int index) { + return getNewTupleFieldBuilder().addBuilder( + index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.getDefaultInstance()); + } + /** + * repeated .decoderbufs.DatumMessage new_tuple = 5; + */ + public java.util.List + getNewTupleBuilderList() { + return getNewTupleFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.DatumMessage, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder, io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder> + getNewTupleFieldBuilder() { + if (newTupleBuilder_ == null) { + newTupleBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.DatumMessage, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder, io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder>( + newTuple_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + newTuple_ = null; + } + return newTupleBuilder_; + } + + private java.util.List oldTuple_ = + java.util.Collections.emptyList(); + private void ensureOldTupleIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + oldTuple_ = new java.util.ArrayList(oldTuple_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.DatumMessage, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder, io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder> oldTupleBuilder_; + + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public java.util.List getOldTupleList() { + if (oldTupleBuilder_ == null) { + return java.util.Collections.unmodifiableList(oldTuple_); + } else { + return oldTupleBuilder_.getMessageList(); + } + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public int getOldTupleCount() { + if (oldTupleBuilder_ == null) { + return oldTuple_.size(); + } else { + return oldTupleBuilder_.getCount(); + } + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage getOldTuple(int index) { + if (oldTupleBuilder_ == null) { + return oldTuple_.get(index); + } else { + return oldTupleBuilder_.getMessage(index); + } + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder setOldTuple( + int index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage value) { + if (oldTupleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOldTupleIsMutable(); + oldTuple_.set(index, value); + onChanged(); + } else { + oldTupleBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder setOldTuple( + int index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder builderForValue) { + if (oldTupleBuilder_ == null) { + ensureOldTupleIsMutable(); + oldTuple_.set(index, builderForValue.build()); + onChanged(); + } else { + oldTupleBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder addOldTuple(io.debezium.connector.postgresql.proto.PgProto.DatumMessage value) { + if (oldTupleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOldTupleIsMutable(); + oldTuple_.add(value); + onChanged(); + } else { + oldTupleBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder addOldTuple( + int index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage value) { + if (oldTupleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOldTupleIsMutable(); + oldTuple_.add(index, value); + onChanged(); + } else { + oldTupleBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder addOldTuple( + io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder builderForValue) { + if (oldTupleBuilder_ == null) { + ensureOldTupleIsMutable(); + oldTuple_.add(builderForValue.build()); + onChanged(); + } else { + oldTupleBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder addOldTuple( + int index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder builderForValue) { + if (oldTupleBuilder_ == null) { + ensureOldTupleIsMutable(); + oldTuple_.add(index, builderForValue.build()); + onChanged(); + } else { + oldTupleBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder addAllOldTuple( + java.lang.Iterable values) { + if (oldTupleBuilder_ == null) { + ensureOldTupleIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, oldTuple_); + onChanged(); + } else { + oldTupleBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder clearOldTuple() { + if (oldTupleBuilder_ == null) { + oldTuple_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + oldTupleBuilder_.clear(); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public Builder removeOldTuple(int index) { + if (oldTupleBuilder_ == null) { + ensureOldTupleIsMutable(); + oldTuple_.remove(index); + onChanged(); + } else { + oldTupleBuilder_.remove(index); + } + return this; + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder getOldTupleBuilder( + int index) { + return getOldTupleFieldBuilder().getBuilder(index); + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder getOldTupleOrBuilder( + int index) { + if (oldTupleBuilder_ == null) { + return oldTuple_.get(index); } else { + return oldTupleBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public java.util.List + getOldTupleOrBuilderList() { + if (oldTupleBuilder_ != null) { + return oldTupleBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(oldTuple_); + } + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder addOldTupleBuilder() { + return getOldTupleFieldBuilder().addBuilder( + io.debezium.connector.postgresql.proto.PgProto.DatumMessage.getDefaultInstance()); + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder addOldTupleBuilder( + int index) { + return getOldTupleFieldBuilder().addBuilder( + index, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.getDefaultInstance()); + } + /** + * repeated .decoderbufs.DatumMessage old_tuple = 6; + */ + public java.util.List + getOldTupleBuilderList() { + return getOldTupleFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.DatumMessage, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder, io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder> + getOldTupleFieldBuilder() { + if (oldTupleBuilder_ == null) { + oldTupleBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + io.debezium.connector.postgresql.proto.PgProto.DatumMessage, io.debezium.connector.postgresql.proto.PgProto.DatumMessage.Builder, io.debezium.connector.postgresql.proto.PgProto.DatumMessageOrBuilder>( + oldTuple_, + ((bitField0_ & 0x00000020) == 0x00000020), + getParentForChildren(), + isClean()); + oldTuple_ = null; + } + return oldTupleBuilder_; + } + + // @@protoc_insertion_point(builder_scope:decoderbufs.RowMessage) + } + + static { + defaultInstance = new RowMessage(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:decoderbufs.RowMessage) + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_decoderbufs_Point_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_decoderbufs_Point_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_decoderbufs_DatumMessage_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_decoderbufs_DatumMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_decoderbufs_RowMessage_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_decoderbufs_RowMessage_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\023pg_logicaldec.proto\022\013decoderbufs\"\035\n\005Po" + + "int\022\t\n\001x\030\001 \002(\001\022\t\n\001y\030\002 \002(\001\"\216\002\n\014DatumMessa" + + "ge\022\023\n\013column_name\030\001 \001(\t\022\023\n\013column_type\030\002" + + " \001(\003\022\025\n\013datum_int32\030\003 \001(\005H\000\022\025\n\013datum_int" + + "64\030\004 \001(\003H\000\022\025\n\013datum_float\030\005 \001(\002H\000\022\026\n\014dat" + + "um_double\030\006 \001(\001H\000\022\024\n\ndatum_bool\030\007 \001(\010H\000\022" + + "\026\n\014datum_string\030\010 \001(\tH\000\022\025\n\013datum_bytes\030\t" + + " \001(\014H\000\022)\n\013datum_point\030\n \001(\0132\022.decoderbuf" + + "s.PointH\000B\007\n\005datum\"\301\001\n\nRowMessage\022\026\n\016tra" + + "nsaction_id\030\001 \001(\r\022\023\n\013commit_time\030\002 \001(\004\022\r", + "\n\005table\030\003 \001(\t\022\033\n\002op\030\004 \001(\0162\017.decoderbufs." + + "Op\022,\n\tnew_tuple\030\005 \003(\0132\031.decoderbufs.Datu" + + "mMessage\022,\n\told_tuple\030\006 \003(\0132\031.decoderbuf" + + "s.DatumMessage*(\n\002Op\022\n\n\006INSERT\020\000\022\n\n\006UPDA" + + "TE\020\001\022\n\n\006DELETE\020\002B3\n&io.debezium.connecto" + + "r.postgresql.protoB\007PgProtoH\001" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_decoderbufs_Point_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_decoderbufs_Point_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_decoderbufs_Point_descriptor, + new java.lang.String[] { "X", "Y", }); + internal_static_decoderbufs_DatumMessage_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_decoderbufs_DatumMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_decoderbufs_DatumMessage_descriptor, + new java.lang.String[] { "ColumnName", "ColumnType", "DatumInt32", "DatumInt64", "DatumFloat", "DatumDouble", "DatumBool", "DatumString", "DatumBytes", "DatumPoint", "Datum", }); + internal_static_decoderbufs_RowMessage_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_decoderbufs_RowMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_decoderbufs_RowMessage_descriptor, + new java.lang.String[] { "TransactionId", "CommitTime", "Table", "Op", "NewTuple", "OldTuple", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/debezium-connector-postgres/src/main/proto/pg_logicaldec.proto b/debezium-connector-postgres/src/main/proto/pg_logicaldec.proto new file mode 100644 index 000000000..e9b8a7572 --- /dev/null +++ b/debezium-connector-postgres/src/main/proto/pg_logicaldec.proto @@ -0,0 +1,40 @@ +package decoderbufs; + +option java_package="io.debezium.connector.postgresql.proto"; +option java_outer_classname = "PgProto"; +option optimize_for = SPEED; + +enum Op { + INSERT = 0; + UPDATE = 1; + DELETE = 2; +} + +message Point { + required double x = 1; + required double y = 2; +} + +message DatumMessage { + optional string column_name = 1; + optional int64 column_type = 2; + oneof datum { + int32 datum_int32 = 3; + int64 datum_int64 = 4; + float datum_float = 5; + double datum_double = 6; + bool datum_bool = 7; + string datum_string = 8; + bytes datum_bytes = 9; + Point datum_point = 10; + } +} + +message RowMessage { + optional uint32 transaction_id = 1; + optional uint64 commit_time = 2; + optional string table = 3; + optional Op op = 4; + repeated DatumMessage new_tuple = 5; + repeated DatumMessage old_tuple = 6; +} diff --git a/debezium-connector-postgres/src/main/resources/io/debezium/connector/postgres/build.version b/debezium-connector-postgres/src/main/resources/io/debezium/connector/postgres/build.version new file mode 100644 index 000000000..e5683df88 --- /dev/null +++ b/debezium-connector-postgres/src/main/resources/io/debezium/connector/postgres/build.version @@ -0,0 +1 @@ +version=${project.version} \ No newline at end of file diff --git a/debezium-connector-postgres/src/test/java/io/debezium/connector/postgres/PostgresConnection.java b/debezium-connector-postgres/src/test/java/io/debezium/connector/postgres/PostgresConnection.java new file mode 100644 index 000000000..381fa33d8 --- /dev/null +++ b/debezium-connector-postgres/src/test/java/io/debezium/connector/postgres/PostgresConnection.java @@ -0,0 +1,76 @@ +/* + * Copyright Debezium Authors. + * + * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +package io.debezium.connector.postgres; + +import io.debezium.config.Configuration; +import io.debezium.jdbc.JdbcConfiguration; +import io.debezium.jdbc.JdbcConnection; + +/** + * A utility for integration test cases to connect the PostgreSQL server running in the Docker container created by this module's + * build. + * + * @author Randall Hauch + */ +public class PostgresConnection extends JdbcConnection { + + /** + * Obtain a connection instance to the named test database. + * + + * @return the PostgresConnection instance; never null + */ + public static PostgresConnection forTestDatabase() { + return new PostgresConnection(JdbcConfiguration.copy(Configuration.fromSystemProperties("database.")) + .build()); + } + + /** + * Obtain a connection instance to the named test database. + * + * @param databaseName the name of the test database + * @return the PostgresConnection instance; never null + */ + public static PostgresConnection forTestDatabase(String databaseName) { + return new PostgresConnection(JdbcConfiguration.copy(Configuration.fromSystemProperties("database.")) + .withDatabase(databaseName) + .build()); + } + + /** + * Obtain a connection instance to the named test database. + * + * @param databaseName the name of the test database + * @param username the username + * @param password the password + * @return the PostgresConnection instance; never null + */ + public static PostgresConnection forTestDatabase(String databaseName, String username, String password) { + return new PostgresConnection(JdbcConfiguration.copy(Configuration.fromSystemProperties("database.")) + .withDatabase(databaseName) + .withUser(username) + .withPassword(password) + .build()); + } + + protected static void addDefaults(Configuration.Builder builder) { + builder.withDefault(JdbcConfiguration.HOSTNAME, "localhost") + .withDefault(JdbcConfiguration.PORT, 5432) + .withDefault(JdbcConfiguration.USER, "postgres") + .withDefault(JdbcConfiguration.PASSWORD, "postgres"); + } + + protected static ConnectionFactory FACTORY = JdbcConnection.patternBasedFactory("jdbc:postgresql://${hostname}:${port}/${dbname}"); + + /** + * Create a new instance with the given configuration and connection factory. + * + * @param config the configuration; may not be null + */ + protected PostgresConnection(Configuration config) { + super(config, FACTORY, null, PostgresConnection::addDefaults); + } +} diff --git a/debezium-connector-postgres/src/test/java/io/debezium/connector/postgres/PostgresConnectionIT.java b/debezium-connector-postgres/src/test/java/io/debezium/connector/postgres/PostgresConnectionIT.java new file mode 100644 index 000000000..d2491ccfa --- /dev/null +++ b/debezium-connector-postgres/src/test/java/io/debezium/connector/postgres/PostgresConnectionIT.java @@ -0,0 +1,129 @@ +/* + * Copyright Debezium Authors. + * + * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +package io.debezium.connector.postgres; + +import java.sql.SQLException; +import java.sql.Types; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import org.junit.Ignore; +import org.junit.Test; +import org.postgresql.util.PGobject; +import com.google.protobuf.InvalidProtocolBufferException; + +import io.debezium.connector.postgresql.proto.PgProto; +import io.debezium.util.Testing; + +@Ignore +public class PostgresConnectionIT implements Testing { + + @Test + public void shouldInitWALReaderAndReadLog() throws SQLException { + try (PostgresConnection conn = PostgresConnection.forTestDatabase("postgres")) { + conn.connect(); + + conn.execute("DROP TABLE IF EXISTS table_with_pk "); + conn.execute("DROP TABLE IF EXISTS table_without_pk "); + conn.execute("CREATE TABLE table_with_pk (a SERIAL, b VARCHAR(30), c TIMESTAMP NOT NULL, PRIMARY KEY(a, c));", + "CREATE TABLE table_without_pk (a SERIAL, b NUMERIC(5,2), c TEXT);"); + + conn.execute("INSERT INTO table_with_pk (b, c) VALUES('Backup and Restore', now());"); + conn.execute("INSERT INTO table_with_pk (b, c) VALUES('Tuning', now());"); + conn.execute("DELETE FROM table_with_pk WHERE a < 3;"); + + initLogicalReplication(conn); + consumeChanges(conn); + + // Postgres WILL NOT fire any changes (UPDATES or DELETES) for tables which don't have a PK by default EXCEPT + // if that table has a REPLICA IDENTITY of FULL. + // See http://michael.otacoo.com/postgresql-2/postgres-9-4-feature-highlight-replica-identity-logical-replication/ + conn.execute("ALTER TABLE table_without_pk REPLICA IDENTITY FULL"); + + conn.execute("INSERT INTO table_with_pk (b, c) VALUES('Backup and Restore', now());"); + conn.execute("INSERT INTO table_with_pk (b, c) VALUES('Tuning', now());"); + conn.execute("DELETE FROM table_with_pk WHERE a < 3;"); + + conn.execute("INSERT INTO table_without_pk (b,c) VALUES (1, 'Tapir');"); + conn.execute("UPDATE table_without_pk SET c = 'Anita' WHERE c = 'Tapir';"); + + consumeChanges(conn); +// peekChanges(conn); +// consumeChanges(conn); + } + } + + private void stopLogicalReplication(PostgresConnection conn) throws Exception { + conn.call("SELECT * FROM pg_drop_replication_slot(?);", statement -> statement.setString(1, "test_slot"), null); + } + + @Test + public void startMonitoring() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(1); + try (PostgresConnection conn = PostgresConnection.forTestDatabase("postgres")) { + conn.connect(); + initLogicalReplication(conn); + executorService.submit(() -> { + try { + while (true) { + consumeChanges(conn); + Thread.sleep(1000); + } + } catch (InterruptedException e) { + return null; + } + }).get(); + } finally { + executorService.shutdown(); + } + } + + private void peekChanges(PostgresConnection conn) throws SQLException { + callStatementAndPrintMessage(conn, "SELECT data FROM pg_logical_slot_peek_binary_changes(?, ?, ?, ?, ?);"); + } + + private void consumeChanges(PostgresConnection conn) throws SQLException { + callStatementAndPrintMessage(conn, "SELECT data FROM pg_logical_slot_get_binary_changes(?, ?, ?, ?, ?);"); + } + + private void callStatementAndPrintMessage(PostgresConnection conn, String stmt) throws SQLException { + conn.call(stmt, + statement -> { + statement.setString(1, "test_slot"); + PGobject pgLSN = new PGobject(); + pgLSN.setType("pg_lsn"); + pgLSN.setValue(null); + statement.setObject(2, null); + statement.setNull(3, Types.INTEGER); + statement.setString(4, "debug-mode"); + statement.setString(5, "0"); + }, rs -> { + while (rs.next()) { + byte[] protobufContent = rs.getBytes(1); + PgProto.RowMessage message = null; + try { + message = PgProto.RowMessage.parseFrom(protobufContent); + System.out.println(message.toString()); + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException(e); + } + + } + }); + } + + private void initLogicalReplication(PostgresConnection conn) throws SQLException { + try { + conn.call("SELECT * FROM pg_create_logical_replication_slot(?, ?)", statement -> { + statement.setString(1, "test_slot"); + statement.setString(2, "decoderbufs"); + }, null); + } catch (SQLException e) { + if (!e.getMessage().toLowerCase().contains("already exists")) { + throw e; + } + } + } +} diff --git a/debezium-connector-postgres/src/test/resources/log4j.properties b/debezium-connector-postgres/src/test/resources/log4j.properties new file mode 100644 index 000000000..e99c0fbd6 --- /dev/null +++ b/debezium-connector-postgres/src/test/resources/log4j.properties @@ -0,0 +1,12 @@ +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p %X{dbz.connectorType}|%X{dbz.connectorName}|%X{dbz.connectorContext} %m [%c]%n + +# Root logger option +log4j.rootLogger=INFO, stdout + +# Set up the default logging to be INFO level, then override specific units +log4j.logger.io.debezium=INFO +log4j.logger.io.debezium.embedded.EmbeddedEngine$EmbeddedConfig=WARN \ No newline at end of file diff --git a/debezium-core/src/main/java/io/debezium/jdbc/JdbcConnection.java b/debezium-core/src/main/java/io/debezium/jdbc/JdbcConnection.java index aaa20f16f..d4436df93 100644 --- a/debezium-core/src/main/java/io/debezium/jdbc/JdbcConnection.java +++ b/debezium-core/src/main/java/io/debezium/jdbc/JdbcConnection.java @@ -5,6 +5,7 @@ */ package io.debezium.jdbc; +import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.DriverManager; @@ -27,7 +28,6 @@ import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; import java.util.stream.Stream; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -273,6 +273,11 @@ public static interface SingleParameterResultSetConsumer { public static interface StatementPreparer { void accept(PreparedStatement statement) throws SQLException; } + + @FunctionalInterface + public static interface CallPreparer { + void accept(CallableStatement statement) throws SQLException; + } /** * Execute a SQL query. @@ -286,7 +291,31 @@ public static interface StatementPreparer { public JdbcConnection query(String query, ResultSetConsumer resultConsumer) throws SQLException { return query(query,conn->conn.createStatement(),resultConsumer); } - + + /** + * Execute a stored procedure. + * + * @param sql the SQL query; may not be {@code null} + * @param callPreparer a {@link CallPreparer} instance which can be used to set additional parameters; may be null + * @param resultSetConsumer a {@link ResultSetConsumer} instance which can be used to process the results; may be null + * @return this object for chaining methods together + * @throws SQLException if anything unexpected fails + */ + public JdbcConnection call(String sql, CallPreparer callPreparer, ResultSetConsumer resultSetConsumer) throws SQLException { + Connection conn = connection(); + try (CallableStatement callableStatement = conn.prepareCall(sql)) { + if (callPreparer != null) { + callPreparer.accept(callableStatement); + } + try (ResultSet rs = callableStatement.executeQuery()) { + if (resultSetConsumer != null) { + resultSetConsumer.accept(rs); + } + } + } + return this; + } + /** * Execute a SQL query. * diff --git a/pom.xml b/pom.xml index 4c80982a7..7e6a70b16 100644 --- a/pom.xml +++ b/pom.xml @@ -98,6 +98,7 @@ debezium-core debezium-embedded debezium-connector-mysql + debezium-connector-postgres debezium-connector-mongodb