LadyForest commented on a change in pull request #54: URL: https://github.com/apache/flink-table-store/pull/54#discussion_r831717136
########## File path: flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/TableStore.java ########## @@ -171,6 +181,83 @@ private FileStore buildFileStore() { tableIdentifier, options, user, partitionType, keyType, valueType, mergeFunction); } + // -------------------------------------------------------------------------------------------- + + /** A builder for constructing a immutable {@link TableStore}. */ + public static final class TableStoreBuilder { + + private Configuration options; + private ObjectIdentifier tableIdentifier; + private RowType type; + + private List<String> primaryKeys = new ArrayList<>(); + private List<String> partitionKeys = new ArrayList<>(); + private String user = UUID.randomUUID().toString(); + + public TableStoreBuilder withConfiguration(Configuration options) { + this.options = options; + return this; + } + + public TableStoreBuilder withTableIdentifier(ObjectIdentifier tableIdentifier) { + this.tableIdentifier = tableIdentifier; + return this; + } + + public TableStoreBuilder withSchema(RowType type) { + this.type = type; + return this; + } + + public TableStoreBuilder withPrimaryKeys(List<String> primaryKeys) { + this.primaryKeys = primaryKeys; + return this; + } + + public TableStoreBuilder withPartitionKeys(List<String> partitionKeys) { + this.partitionKeys = partitionKeys; + return this; + } + + public TableStoreBuilder withUser(String user) { + this.user = user; + return this; + } + + public TableStore build() { + List<int[]> indices = adjustAndValidate(); + return new TableStore( + options, tableIdentifier, type, indices.get(0), indices.get(1), user); + } + + private List<int[]> adjustAndValidate() { Review comment: It's weird that `TableStore` must be first specified with schema then specified with pk and partitions, why do we impose the order? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org