LadyForest commented on a change in pull request #54:
URL: https://github.com/apache/flink-table-store/pull/54#discussion_r831722461



##########
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:
       > I don't get it. In my understanding, this is only index adjustment, 
why must need schema.
   
   So in your understanding, index adjustment is based on what?  Below is the 
current index adjusting in `TableStoreFactory`
   
   ```java
   primaryKeys =
                       schema.getPrimaryKey().get().getColumns().stream()
                               .mapToInt(rowType.getFieldNames()::indexOf)
                               .toArray()
   ```
   
   without schema, how could `mapToInt` be accomplished?




-- 
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


Reply via email to