implements
+ // @@protoc_insertion_point(builder_implements:io.mycat.meta.protocol.TableMeta)
+ io.mycat.meta.protocol.MyCatMeta.TableMetaOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_TableMeta_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_TableMeta_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ io.mycat.meta.protocol.MyCatMeta.TableMeta.class, io.mycat.meta.protocol.MyCatMeta.TableMeta.Builder.class);
+ }
+
+ // Construct using io.mycat.meta.protocol.MyCatMeta.TableMeta.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ getAllColumnsFieldBuilder();
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ catalog_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ tableName_ = "";
+ bitField0_ = (bitField0_ & ~0x00000002);
+ if (allColumnsBuilder_ == null) {
+ allColumns_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000004);
+ } else {
+ allColumnsBuilder_.clear();
+ }
+ isView_ = false;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ createSql_ = "";
+ bitField0_ = (bitField0_ & ~0x00000010);
+ version_ = 0L;
+ bitField0_ = (bitField0_ & ~0x00000020);
+ aiOffset_ = -1L;
+ bitField0_ = (bitField0_ & ~0x00000040);
+ type_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000080);
+ aiColPos_ = -1;
+ bitField0_ = (bitField0_ & ~0x00000100);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_TableMeta_descriptor;
+ }
+
+ public io.mycat.meta.protocol.MyCatMeta.TableMeta getDefaultInstanceForType() {
+ return io.mycat.meta.protocol.MyCatMeta.TableMeta.getDefaultInstance();
+ }
+
+ public io.mycat.meta.protocol.MyCatMeta.TableMeta build() {
+ io.mycat.meta.protocol.MyCatMeta.TableMeta result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public io.mycat.meta.protocol.MyCatMeta.TableMeta buildPartial() {
+ io.mycat.meta.protocol.MyCatMeta.TableMeta result = new io.mycat.meta.protocol.MyCatMeta.TableMeta(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.catalog_ = catalog_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.tableName_ = tableName_;
+ if (allColumnsBuilder_ == null) {
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ allColumns_ = java.util.Collections.unmodifiableList(allColumns_);
+ bitField0_ = (bitField0_ & ~0x00000004);
+ }
+ result.allColumns_ = allColumns_;
+ } else {
+ result.allColumns_ = allColumnsBuilder_.build();
+ }
+ if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.isView_ = isView_;
+ if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
+ to_bitField0_ |= 0x00000008;
+ }
+ result.createSql_ = createSql_;
+ if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
+ to_bitField0_ |= 0x00000010;
+ }
+ result.version_ = version_;
+ if (((from_bitField0_ & 0x00000040) == 0x00000040)) {
+ to_bitField0_ |= 0x00000020;
+ }
+ result.aiOffset_ = aiOffset_;
+ if (((from_bitField0_ & 0x00000080) == 0x00000080)) {
+ to_bitField0_ |= 0x00000040;
+ }
+ result.type_ = type_;
+ if (((from_bitField0_ & 0x00000100) == 0x00000100)) {
+ to_bitField0_ |= 0x00000080;
+ }
+ result.aiColPos_ = aiColPos_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof io.mycat.meta.protocol.MyCatMeta.TableMeta) {
+ return mergeFrom((io.mycat.meta.protocol.MyCatMeta.TableMeta)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(io.mycat.meta.protocol.MyCatMeta.TableMeta other) {
+ if (other == io.mycat.meta.protocol.MyCatMeta.TableMeta.getDefaultInstance()) return this;
+ if (other.hasCatalog()) {
+ bitField0_ |= 0x00000001;
+ catalog_ = other.catalog_;
+ onChanged();
+ }
+ if (other.hasTableName()) {
+ bitField0_ |= 0x00000002;
+ tableName_ = other.tableName_;
+ onChanged();
+ }
+ if (allColumnsBuilder_ == null) {
+ if (!other.allColumns_.isEmpty()) {
+ if (allColumns_.isEmpty()) {
+ allColumns_ = other.allColumns_;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ } else {
+ ensureAllColumnsIsMutable();
+ allColumns_.addAll(other.allColumns_);
+ }
+ onChanged();
+ }
+ } else {
+ if (!other.allColumns_.isEmpty()) {
+ if (allColumnsBuilder_.isEmpty()) {
+ allColumnsBuilder_.dispose();
+ allColumnsBuilder_ = null;
+ allColumns_ = other.allColumns_;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ allColumnsBuilder_ =
+ com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
+ getAllColumnsFieldBuilder() : null;
+ } else {
+ allColumnsBuilder_.addAllMessages(other.allColumns_);
+ }
+ }
+ }
+ if (other.hasIsView()) {
+ setIsView(other.getIsView());
+ }
+ if (other.hasCreateSql()) {
+ bitField0_ |= 0x00000010;
+ createSql_ = other.createSql_;
+ onChanged();
+ }
+ if (other.hasVersion()) {
+ setVersion(other.getVersion());
+ }
+ if (other.hasAiOffset()) {
+ setAiOffset(other.getAiOffset());
+ }
+ if (other.hasType()) {
+ setType(other.getType());
+ }
+ if (other.hasAiColPos()) {
+ setAiColPos(other.getAiColPos());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ io.mycat.meta.protocol.MyCatMeta.TableMeta parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (io.mycat.meta.protocol.MyCatMeta.TableMeta) e.getUnfinishedMessage();
+ throw e;
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ private java.lang.Object catalog_ = "";
+ /**
+ * optional string catalog = 1;
+ */
+ public boolean hasCatalog() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * optional string catalog = 1;
+ */
+ public java.lang.String getCatalog() {
+ java.lang.Object ref = catalog_;
+ 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()) {
+ catalog_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * optional string catalog = 1;
+ */
+ public com.google.protobuf.ByteString
+ getCatalogBytes() {
+ java.lang.Object ref = catalog_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ catalog_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * optional string catalog = 1;
+ */
+ public Builder setCatalog(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ catalog_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional string catalog = 1;
+ */
+ public Builder clearCatalog() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ catalog_ = getDefaultInstance().getCatalog();
+ onChanged();
+ return this;
+ }
+ /**
+ * optional string catalog = 1;
+ */
+ public Builder setCatalogBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ catalog_ = value;
+ onChanged();
+ return this;
+ }
+
+ private java.lang.Object tableName_ = "";
+ /**
+ * optional string tableName = 2;
+ *
+ *
+ *不带dbname的表名:如table1
+ *
+ */
+ public boolean hasTableName() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * optional string tableName = 2;
+ *
+ *
+ *不带dbname的表名:如table1
+ *
+ */
+ public java.lang.String getTableName() {
+ java.lang.Object ref = tableName_;
+ 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()) {
+ tableName_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * optional string tableName = 2;
+ *
+ *
+ *不带dbname的表名:如table1
+ *
+ */
+ public com.google.protobuf.ByteString
+ getTableNameBytes() {
+ java.lang.Object ref = tableName_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ tableName_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * optional string tableName = 2;
+ *
+ *
+ *不带dbname的表名:如table1
+ *
+ */
+ public Builder setTableName(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ tableName_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional string tableName = 2;
+ *
+ *
+ *不带dbname的表名:如table1
+ *
+ */
+ public Builder clearTableName() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ tableName_ = getDefaultInstance().getTableName();
+ onChanged();
+ return this;
+ }
+ /**
+ * optional string tableName = 2;
+ *
+ *
+ *不带dbname的表名:如table1
+ *
+ */
+ public Builder setTableNameBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ tableName_ = value;
+ onChanged();
+ return this;
+ }
+
+ private java.util.List allColumns_ =
+ java.util.Collections.emptyList();
+ private void ensureAllColumnsIsMutable() {
+ if (!((bitField0_ & 0x00000004) == 0x00000004)) {
+ allColumns_ = new java.util.ArrayList(allColumns_);
+ bitField0_ |= 0x00000004;
+ }
+ }
+
+ private com.google.protobuf.RepeatedFieldBuilder<
+ io.mycat.meta.protocol.MyCatMeta.ColumnMeta, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder, io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder> allColumnsBuilder_;
+
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public java.util.List getAllColumnsList() {
+ if (allColumnsBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(allColumns_);
+ } else {
+ return allColumnsBuilder_.getMessageList();
+ }
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public int getAllColumnsCount() {
+ if (allColumnsBuilder_ == null) {
+ return allColumns_.size();
+ } else {
+ return allColumnsBuilder_.getCount();
+ }
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public io.mycat.meta.protocol.MyCatMeta.ColumnMeta getAllColumns(int index) {
+ if (allColumnsBuilder_ == null) {
+ return allColumns_.get(index);
+ } else {
+ return allColumnsBuilder_.getMessage(index);
+ }
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder setAllColumns(
+ int index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta value) {
+ if (allColumnsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureAllColumnsIsMutable();
+ allColumns_.set(index, value);
+ onChanged();
+ } else {
+ allColumnsBuilder_.setMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder setAllColumns(
+ int index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder builderForValue) {
+ if (allColumnsBuilder_ == null) {
+ ensureAllColumnsIsMutable();
+ allColumns_.set(index, builderForValue.build());
+ onChanged();
+ } else {
+ allColumnsBuilder_.setMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder addAllColumns(io.mycat.meta.protocol.MyCatMeta.ColumnMeta value) {
+ if (allColumnsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureAllColumnsIsMutable();
+ allColumns_.add(value);
+ onChanged();
+ } else {
+ allColumnsBuilder_.addMessage(value);
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder addAllColumns(
+ int index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta value) {
+ if (allColumnsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureAllColumnsIsMutable();
+ allColumns_.add(index, value);
+ onChanged();
+ } else {
+ allColumnsBuilder_.addMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder addAllColumns(
+ io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder builderForValue) {
+ if (allColumnsBuilder_ == null) {
+ ensureAllColumnsIsMutable();
+ allColumns_.add(builderForValue.build());
+ onChanged();
+ } else {
+ allColumnsBuilder_.addMessage(builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder addAllColumns(
+ int index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder builderForValue) {
+ if (allColumnsBuilder_ == null) {
+ ensureAllColumnsIsMutable();
+ allColumns_.add(index, builderForValue.build());
+ onChanged();
+ } else {
+ allColumnsBuilder_.addMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder addAllAllColumns(
+ java.lang.Iterable extends io.mycat.meta.protocol.MyCatMeta.ColumnMeta> values) {
+ if (allColumnsBuilder_ == null) {
+ ensureAllColumnsIsMutable();
+ com.google.protobuf.AbstractMessageLite.Builder.addAll(
+ values, allColumns_);
+ onChanged();
+ } else {
+ allColumnsBuilder_.addAllMessages(values);
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder clearAllColumns() {
+ if (allColumnsBuilder_ == null) {
+ allColumns_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000004);
+ onChanged();
+ } else {
+ allColumnsBuilder_.clear();
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public Builder removeAllColumns(int index) {
+ if (allColumnsBuilder_ == null) {
+ ensureAllColumnsIsMutable();
+ allColumns_.remove(index);
+ onChanged();
+ } else {
+ allColumnsBuilder_.remove(index);
+ }
+ return this;
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder getAllColumnsBuilder(
+ int index) {
+ return getAllColumnsFieldBuilder().getBuilder(index);
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder getAllColumnsOrBuilder(
+ int index) {
+ if (allColumnsBuilder_ == null) {
+ return allColumns_.get(index); } else {
+ return allColumnsBuilder_.getMessageOrBuilder(index);
+ }
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public java.util.List extends io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder>
+ getAllColumnsOrBuilderList() {
+ if (allColumnsBuilder_ != null) {
+ return allColumnsBuilder_.getMessageOrBuilderList();
+ } else {
+ return java.util.Collections.unmodifiableList(allColumns_);
+ }
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder addAllColumnsBuilder() {
+ return getAllColumnsFieldBuilder().addBuilder(
+ io.mycat.meta.protocol.MyCatMeta.ColumnMeta.getDefaultInstance());
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder addAllColumnsBuilder(
+ int index) {
+ return getAllColumnsFieldBuilder().addBuilder(
+ index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.getDefaultInstance());
+ }
+ /**
+ * repeated .io.mycat.meta.protocol.ColumnMeta allColumns = 3;
+ *
+ *
+ *所有的列属性,有序
+ *
+ */
+ public java.util.List
+ getAllColumnsBuilderList() {
+ return getAllColumnsFieldBuilder().getBuilderList();
+ }
+ private com.google.protobuf.RepeatedFieldBuilder<
+ io.mycat.meta.protocol.MyCatMeta.ColumnMeta, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder, io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder>
+ getAllColumnsFieldBuilder() {
+ if (allColumnsBuilder_ == null) {
+ allColumnsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
+ io.mycat.meta.protocol.MyCatMeta.ColumnMeta, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder, io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder>(
+ allColumns_,
+ ((bitField0_ & 0x00000004) == 0x00000004),
+ getParentForChildren(),
+ isClean());
+ allColumns_ = null;
+ }
+ return allColumnsBuilder_;
+ }
+
+ private boolean isView_ ;
+ /**
+ * optional bool isView = 4 [default = false];
+ */
+ public boolean hasIsView() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ /**
+ * optional bool isView = 4 [default = false];
+ */
+ public boolean getIsView() {
+ return isView_;
+ }
+ /**
+ * optional bool isView = 4 [default = false];
+ */
+ public Builder setIsView(boolean value) {
+ bitField0_ |= 0x00000008;
+ isView_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional bool isView = 4 [default = false];
+ */
+ public Builder clearIsView() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ isView_ = false;
+ onChanged();
+ return this;
+ }
+
+ private java.lang.Object createSql_ = "";
+ /**
+ * optional string createSql = 5;
+ */
+ public boolean hasCreateSql() {
+ return ((bitField0_ & 0x00000010) == 0x00000010);
+ }
+ /**
+ * optional string createSql = 5;
+ */
+ public java.lang.String getCreateSql() {
+ java.lang.Object ref = createSql_;
+ 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()) {
+ createSql_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * optional string createSql = 5;
+ */
+ public com.google.protobuf.ByteString
+ getCreateSqlBytes() {
+ java.lang.Object ref = createSql_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ createSql_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * optional string createSql = 5;
+ */
+ public Builder setCreateSql(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000010;
+ createSql_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional string createSql = 5;
+ */
+ public Builder clearCreateSql() {
+ bitField0_ = (bitField0_ & ~0x00000010);
+ createSql_ = getDefaultInstance().getCreateSql();
+ onChanged();
+ return this;
+ }
+ /**
+ * optional string createSql = 5;
+ */
+ public Builder setCreateSqlBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000010;
+ createSql_ = value;
+ onChanged();
+ return this;
+ }
+
+ private long version_ ;
+ /**
+ * optional int64 version = 6;
+ */
+ public boolean hasVersion() {
+ return ((bitField0_ & 0x00000020) == 0x00000020);
+ }
+ /**
+ * optional int64 version = 6;
+ */
+ public long getVersion() {
+ return version_;
+ }
+ /**
+ * optional int64 version = 6;
+ */
+ public Builder setVersion(long value) {
+ bitField0_ |= 0x00000020;
+ version_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional int64 version = 6;
+ */
+ public Builder clearVersion() {
+ bitField0_ = (bitField0_ & ~0x00000020);
+ version_ = 0L;
+ onChanged();
+ return this;
+ }
+
+ private long aiOffset_ = -1L;
+ /**
+ * optional int64 aiOffset = 7 [default = -1];
+ */
+ public boolean hasAiOffset() {
+ return ((bitField0_ & 0x00000040) == 0x00000040);
+ }
+ /**
+ * optional int64 aiOffset = 7 [default = -1];
+ */
+ public long getAiOffset() {
+ return aiOffset_;
+ }
+ /**
+ * optional int64 aiOffset = 7 [default = -1];
+ */
+ public Builder setAiOffset(long value) {
+ bitField0_ |= 0x00000040;
+ aiOffset_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional int64 aiOffset = 7 [default = -1];
+ */
+ public Builder clearAiOffset() {
+ bitField0_ = (bitField0_ & ~0x00000040);
+ aiOffset_ = -1L;
+ onChanged();
+ return this;
+ }
+
+ private int type_ ;
+ /**
+ * optional int32 type = 8;
+ */
+ public boolean hasType() {
+ return ((bitField0_ & 0x00000080) == 0x00000080);
+ }
+ /**
+ * optional int32 type = 8;
+ */
+ public int getType() {
+ return type_;
+ }
+ /**
+ * optional int32 type = 8;
+ */
+ public Builder setType(int value) {
+ bitField0_ |= 0x00000080;
+ type_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional int32 type = 8;
+ */
+ public Builder clearType() {
+ bitField0_ = (bitField0_ & ~0x00000080);
+ type_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int aiColPos_ = -1;
+ /**
+ * optional int32 aiColPos = 9 [default = -1];
+ */
+ public boolean hasAiColPos() {
+ return ((bitField0_ & 0x00000100) == 0x00000100);
+ }
+ /**
+ * optional int32 aiColPos = 9 [default = -1];
+ */
+ public int getAiColPos() {
+ return aiColPos_;
+ }
+ /**
+ * optional int32 aiColPos = 9 [default = -1];
+ */
+ public Builder setAiColPos(int value) {
+ bitField0_ |= 0x00000100;
+ aiColPos_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional int32 aiColPos = 9 [default = -1];
+ */
+ public Builder clearAiColPos() {
+ bitField0_ = (bitField0_ & ~0x00000100);
+ aiColPos_ = -1;
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:io.mycat.meta.protocol.TableMeta)
+ }
+
+ static {
+ defaultInstance = new TableMeta(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:io.mycat.meta.protocol.TableMeta)
+ }
+
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_io_mycat_meta_protocol_ColumnMeta_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_io_mycat_meta_protocol_ColumnMeta_fieldAccessorTable;
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_io_mycat_meta_protocol_TableMeta_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_io_mycat_meta_protocol_TableMeta_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\022MyCatMeta.protocol\022\026io.mycat.meta.prot" +
+ "ocol\"\215\002\n\nColumnMeta\022\021\n\ttableName\030\001 \001(\t\022\014" +
+ "\n\004name\030\002 \001(\t\0227\n\010dataType\030\003 \001(\0162%.io.myca" +
+ "t.meta.protocol.MySqlDataType\022\016\n\006length\030" +
+ "\004 \001(\005\022\021\n\tprecision\030\005 \001(\005\022\r\n\005scale\030\006 \001(\005\022" +
+ "\017\n\007canNull\030\007 \001(\010\022\020\n\010sdefault\030\010 \001(\t\022\022\n\nau" +
+ "to_incre\030\t \001(\010\022\022\n\nisUnsigned\030\n \001(\010\022\r\n\003ke" +
+ "y\030\013 \001(\t:\000\022\031\n\013charsetname\030\014 \001(\t:\004utf8\"\334\001\n" +
+ "\tTableMeta\022\017\n\007catalog\030\001 \001(\t\022\021\n\ttableName" +
+ "\030\002 \001(\t\0226\n\nallColumns\030\003 \003(\0132\".io.mycat.me",
+ "ta.protocol.ColumnMeta\022\025\n\006isView\030\004 \001(\010:\005" +
+ "false\022\021\n\tcreateSql\030\005 \001(\t\022\017\n\007version\030\006 \001(" +
+ "\003\022\024\n\010aiOffset\030\007 \001(\003:\002-1\022\014\n\004type\030\010 \001(\005\022\024\n" +
+ "\010aiColPos\030\t \001(\005:\002-1*\211\003\n\rMySqlDataType\022\013\n" +
+ "\007DECIMAL\020\000\022\010\n\004TINY\020\001\022\t\n\005SHORT\020\002\022\010\n\004LONG\020" +
+ "\003\022\t\n\005FLOAT\020\004\022\n\n\006DOUBLE\020\005\022\010\n\004NULL\020\006\022\r\n\tTI" +
+ "MESTAMP\020\007\022\014\n\010LONGLONG\020\010\022\t\n\005INT24\020\t\022\010\n\004DA" +
+ "TE\020\n\022\010\n\004TIME\020\013\022\014\n\010DATETIME\020\014\022\010\n\004YEAR\020\r\022\013" +
+ "\n\007NEWDATE\020\016\022\013\n\007VARCHAR\020\017\022\007\n\003BIT\020\020\022\016\n\nTIM" +
+ "ESTAMP2\020\021\022\r\n\tDATETIME2\020\022\022\t\n\005TIME2\020\023\022\017\n\nN",
+ "EWDECIMAL\020\366\001\022\t\n\004ENUM\020\367\001\022\010\n\003SET\020\370\001\022\r\n\010TIN" +
+ "YBLOB\020\371\001\022\017\n\nMEDIUMBLOB\020\372\001\022\r\n\010LONGBLOB\020\373\001" +
+ "\022\t\n\004BLOB\020\374\001\022\016\n\tVARSTRING\020\375\001\022\013\n\006STRING\020\376\001" +
+ "\022\r\n\010GEOMETRY\020\377\001B%\n\026io.mycat.meta.protoco" +
+ "lB\tMyCatMetaH\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_io_mycat_meta_protocol_ColumnMeta_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_io_mycat_meta_protocol_ColumnMeta_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_io_mycat_meta_protocol_ColumnMeta_descriptor,
+ new java.lang.String[] { "TableName", "Name", "DataType", "Length", "Precision", "Scale", "CanNull", "Sdefault", "AutoIncre", "IsUnsigned", "Key", "Charsetname", });
+ internal_static_io_mycat_meta_protocol_TableMeta_descriptor =
+ getDescriptor().getMessageTypes().get(1);
+ internal_static_io_mycat_meta_protocol_TableMeta_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_io_mycat_meta_protocol_TableMeta_descriptor,
+ new java.lang.String[] { "Catalog", "TableName", "AllColumns", "IsView", "CreateSql", "Version", "AiOffset", "Type", "AiColPos", });
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/src/main/java/io/mycat/meta/protocol/MyCatMeta.protocol b/src/main/java/io/mycat/meta/protocol/MyCatMeta.protocol
new file mode 100644
index 000000000..93ad3427a
--- /dev/null
+++ b/src/main/java/io/mycat/meta/protocol/MyCatMeta.protocol
@@ -0,0 +1,65 @@
+package io.mycat.meta.protocol;
+
+option java_package = "io.mycat.meta.protocol";
+option java_outer_classname = "MyCatMeta";
+option optimize_for = SPEED;
+
+enum MySqlDataType {
+ DECIMAL = 0;
+ TINY = 1;
+ SHORT = 2;
+ LONG = 3;
+ FLOAT = 4;
+ DOUBLE = 5;
+ NULL = 6;
+ TIMESTAMP = 7;
+ LONGLONG = 8;
+ INT24 = 9;
+ DATE = 10;
+ TIME = 11;
+ DATETIME = 12;
+ YEAR = 13;
+ NEWDATE = 14;
+ VARCHAR = 15;
+ BIT = 16;
+ TIMESTAMP2 = 17;
+ DATETIME2 = 18;
+ TIME2 = 19;
+ NEWDECIMAL = 246;
+ ENUM = 247;
+ SET = 248;
+ TINYBLOB = 249;
+ MEDIUMBLOB = 250;
+ LONGBLOB = 251;
+ BLOB = 252;
+ VARSTRING = 253;
+ STRING = 254;
+ GEOMETRY = 255;
+}
+
+message ColumnMeta{
+ optional string tableName = 1;
+ optional string name = 2;
+ optional MySqlDataType dataType = 3;
+ optional int32 length = 4;
+ optional int32 precision = 5;
+ optional int32 scale = 6;
+ optional bool canNull = 7;
+ optional string sdefault = 8;
+ optional bool auto_incre = 9;
+ optional bool isUnsigned = 10;
+ optional string key = 11[default = ""];//有pri,unique
+ optional string charsetname = 12 [default = "utf8"];
+}
+
+message TableMeta{
+ optional string catalog = 1;
+ optional string tableName = 2;//不带dbname的表名:如table1
+ repeated ColumnMeta allColumns = 3;//所有的列属性,有序
+ optional bool isView = 4[default = false];
+ optional string createSql = 5;
+ optional int64 version = 6;
+ optional int64 aiOffset = 7[default=-1];
+ optional int32 type = 8;
+ optional int32 aiColPos = 9[default=-1];
+}
diff --git a/src/main/java/io/mycat/meta/table/MultiTableMetaHandler.java b/src/main/java/io/mycat/meta/table/MultiTableMetaHandler.java
new file mode 100644
index 000000000..db7ac22ce
--- /dev/null
+++ b/src/main/java/io/mycat/meta/table/MultiTableMetaHandler.java
@@ -0,0 +1,35 @@
+package io.mycat.meta.table;
+
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import io.mycat.MycatServer;
+import io.mycat.config.model.SchemaConfig;
+import io.mycat.config.model.TableConfig;
+
+public class MultiTableMetaHandler {
+ private AtomicInteger tableNumbers;
+ private String schema;
+ private SchemaConfig config;
+ private SchemaMetaHandler schemaMetaHandler;
+
+ public MultiTableMetaHandler(SchemaMetaHandler schemaMetaHandler, SchemaConfig config) {
+ this.schemaMetaHandler = schemaMetaHandler;
+ this.config = config;
+ this.schema = config.getName();
+ tableNumbers = new AtomicInteger(config.getTables().size());
+ }
+
+ public void execute() {
+ MycatServer.getInstance().getTmManager().createDatabase(schema);
+ for (Entry entry : config.getTables().entrySet()) {
+ TableMetaHandler table = new TableMetaHandler(this, schema, entry.getValue());
+ table.execute();
+ }
+ }
+
+ public void countDown() {
+ if (tableNumbers.decrementAndGet() == 0)
+ schemaMetaHandler.countDown();
+ }
+}
diff --git a/src/main/java/io/mycat/meta/table/SchemaMetaHandler.java b/src/main/java/io/mycat/meta/table/SchemaMetaHandler.java
new file mode 100644
index 000000000..324ecdac2
--- /dev/null
+++ b/src/main/java/io/mycat/meta/table/SchemaMetaHandler.java
@@ -0,0 +1,61 @@
+package io.mycat.meta.table;
+
+import java.util.Map.Entry;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import io.mycat.config.MycatConfig;
+import io.mycat.config.model.SchemaConfig;
+
+public class SchemaMetaHandler {
+
+ // 1、根据用户、DataSourceConfig获取所有的节点数据源。
+ // 2、show databases 获取当前节点的schema。
+ // 3、如果是分库schema,只有节点0需要获取table信息。
+ // 4、一次获取每个schema下的表信息、索引信息。(如配置了二级拆分规则,则该表忽略)
+
+ private Lock lock;
+ private Condition allSchemaDone;
+ private int schemaNumber;
+
+ private MycatConfig config;
+
+ public SchemaMetaHandler(MycatConfig config) {
+ this.lock = new ReentrantLock();
+ this.allSchemaDone = lock.newCondition();
+ this.config = config;
+ schemaNumber = config.getSchemas().size();
+ }
+
+ public void execute() {
+ for (Entry entry : config.getSchemas().entrySet()) {
+ MultiTableMetaHandler multiTableMeta = new MultiTableMetaHandler(this, entry.getValue());
+ multiTableMeta.execute();
+ }
+ waitAllNodeDone();
+ }
+
+ public void countDown() {
+ lock.lock();
+ try {
+ if (--schemaNumber == 0)
+ allSchemaDone.signal();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ public void waitAllNodeDone() {
+ lock.lock();
+ try {
+ if (schemaNumber == 0)
+ return;
+ allSchemaDone.await();
+ } catch (InterruptedException e) {
+ // ignore
+ } finally {
+ lock.unlock();
+ }
+ }
+}
diff --git a/src/main/java/io/mycat/meta/table/TableMetaHandler.java b/src/main/java/io/mycat/meta/table/TableMetaHandler.java
new file mode 100644
index 000000000..e83c13606
--- /dev/null
+++ b/src/main/java/io/mycat/meta/table/TableMetaHandler.java
@@ -0,0 +1,195 @@
+package io.mycat.meta.table;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
+import com.alibaba.druid.sql.ast.statement.SQLColumnConstraint;
+import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
+import com.alibaba.druid.sql.ast.statement.SQLColumnPrimaryKey;
+import com.alibaba.druid.sql.ast.statement.SQLColumnUniqueKey;
+import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
+import com.alibaba.druid.sql.ast.statement.SQLNotNullConstraint;
+import com.alibaba.druid.sql.ast.statement.SQLNullConstraint;
+import com.alibaba.druid.sql.ast.statement.SQLTableElement;
+import com.alibaba.druid.sql.dialect.mysql.ast.MySqlPrimaryKey;
+import com.alibaba.druid.sql.dialect.mysql.ast.MySqlUnique;
+import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlTableIndex;
+import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
+import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor;
+import com.alibaba.druid.sql.parser.SQLStatementParser;
+
+import io.mycat.MycatServer;
+import io.mycat.backend.datasource.PhysicalDBNode;
+import io.mycat.config.model.TableConfig;
+import io.mycat.meta.IndexMeta;
+import io.mycat.meta.MySQLTableStructureDetector;
+import io.mycat.meta.protocol.MyCatMeta.ColumnMeta;
+import io.mycat.meta.protocol.MyCatMeta.TableMeta;
+import io.mycat.sqlengine.OneRawSQLQueryResultHandler;
+import io.mycat.sqlengine.SQLJob;
+import io.mycat.sqlengine.SQLQueryResult;
+import io.mycat.sqlengine.SQLQueryResultListener;
+
+public class TableMetaHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MySQLTableStructureDetector.class);
+ private static final String[] MYSQL_SHOW_CREATE_TABLE_COLMS = new String[]{
+ "Table",
+ "Create Table"};
+ private static final String sqlPrefix = "show create table ";
+
+ private MultiTableMetaHandler multiTableMetaHandler;
+ private TableConfig tbConfig;
+ private AtomicInteger nodesNumber;
+ private TableMeta.Builder tmBuilder;
+ private String schema;
+ public TableMetaHandler(MultiTableMetaHandler multiTableMetaHandler, String schema, TableConfig tbConfig){
+ this.multiTableMetaHandler = multiTableMetaHandler;
+ this.tbConfig = tbConfig;
+ this.nodesNumber = new AtomicInteger(tbConfig.getDataNodes().size());
+ this.tmBuilder = TableMeta.newBuilder();
+ tmBuilder.setCatalog(schema).setTableName(tbConfig.getName());
+ this.schema = schema;
+ }
+ public void execute(){
+ for (String dataNode : tbConfig.getDataNodes()) {
+ try {
+ tbConfig.getReentrantReadWriteLock().writeLock().lock();
+ ConcurrentHashMap> map = new ConcurrentHashMap<>();
+ tbConfig.setDataNodeTableStructureSQLMap(map);
+ } finally {
+ tbConfig.getReentrantReadWriteLock().writeLock().unlock();
+ }
+ OneRawSQLQueryResultHandler resultHandler = new OneRawSQLQueryResultHandler(MYSQL_SHOW_CREATE_TABLE_COLMS, new MySQLTableStructureListener(dataNode));
+ resultHandler.setMark("Table Structure");
+ PhysicalDBNode dn = MycatServer.getInstance().getConfig().getDataNodes().get(dataNode);
+ SQLJob sqlJob = new SQLJob(sqlPrefix + tbConfig.getName(), dn.getDatabase(), resultHandler, dn.getDbPool().getSource());
+ sqlJob.run();
+ }
+ }
+ private class MySQLTableStructureListener implements SQLQueryResultListener>> {
+ private String dataNode;
+
+ public MySQLTableStructureListener(String dataNode) {
+ this.dataNode = dataNode;
+ }
+
+ @Override
+ public void onResult(SQLQueryResult