|
21 | 21 |
|
22 | 22 | import org.apache.seatunnel.api.configuration.Option;
|
23 | 23 | import org.apache.seatunnel.api.configuration.Options;
|
| 24 | +import org.apache.seatunnel.api.sink.DataSaveMode; |
| 25 | +import org.apache.seatunnel.api.sink.SchemaSaveMode; |
24 | 26 |
|
25 | 27 | import org.apache.hudi.common.model.HoodieTableType;
|
26 | 28 | import org.apache.hudi.common.model.WriteOperationType;
|
27 | 29 | import org.apache.hudi.index.HoodieIndex;
|
28 | 30 |
|
29 |
| -public interface HudiTableOptions { |
| 31 | +import java.util.List; |
30 | 32 |
|
31 |
| - Option<String> TABLE_NAME = |
| 33 | +public class HudiSinkOptions { |
| 34 | + |
| 35 | + public static Option<String> TABLE_DFS_PATH = |
| 36 | + Options.key("table_dfs_path") |
| 37 | + .stringType() |
| 38 | + .noDefaultValue() |
| 39 | + .withDescription("the dfs path of hudi table"); |
| 40 | + |
| 41 | + public static Option<String> CONF_FILES_PATH = |
| 42 | + Options.key("conf_files_path") |
| 43 | + .stringType() |
| 44 | + .noDefaultValue() |
| 45 | + .withDescription("hudi conf files"); |
| 46 | + |
| 47 | + public static Option<List<HudiTableConfig>> TABLE_LIST = |
| 48 | + Options.key("table_list") |
| 49 | + .listType(HudiTableConfig.class) |
| 50 | + .noDefaultValue() |
| 51 | + .withDescription("table_list"); |
| 52 | + |
| 53 | + public static Option<SchemaSaveMode> SCHEMA_SAVE_MODE = |
| 54 | + Options.key("schema_save_mode") |
| 55 | + .enumType(SchemaSaveMode.class) |
| 56 | + .defaultValue(SchemaSaveMode.CREATE_SCHEMA_WHEN_NOT_EXIST) |
| 57 | + .withDescription("schema save mode"); |
| 58 | + |
| 59 | + public static Option<DataSaveMode> DATA_SAVE_MODE = |
| 60 | + Options.key("data_save_mode") |
| 61 | + .enumType(DataSaveMode.class) |
| 62 | + .defaultValue(DataSaveMode.APPEND_DATA) |
| 63 | + .withDescription("data save mode"); |
| 64 | + |
| 65 | + public static Option<String> TABLE_NAME = |
32 | 66 | Options.key("table_name")
|
33 | 67 | .stringType()
|
34 | 68 | .noDefaultValue()
|
35 | 69 | .withDescription("hudi table name");
|
36 | 70 |
|
37 |
| - Option<String> DATABASE = |
| 71 | + public static Option<String> DATABASE = |
38 | 72 | Options.key("database")
|
39 | 73 | .stringType()
|
40 | 74 | .defaultValue("default")
|
41 | 75 | .withDescription("hudi database name");
|
42 | 76 |
|
43 |
| - Option<HoodieTableType> TABLE_TYPE = |
| 77 | + public static Option<HoodieTableType> TABLE_TYPE = |
44 | 78 | Options.key("table_type")
|
45 | 79 | .type(new TypeReference<HoodieTableType>() {})
|
46 | 80 | .defaultValue(HoodieTableType.COPY_ON_WRITE)
|
47 | 81 | .withDescription("hudi table type");
|
48 | 82 |
|
49 |
| - Option<Boolean> CDC_ENABLED = |
| 83 | + public static Option<Boolean> CDC_ENABLED = |
50 | 84 | Options.key("cdc_enabled")
|
51 | 85 | .booleanType()
|
52 | 86 | .defaultValue(false)
|
53 | 87 | .withDescription(
|
54 | 88 | "When enable, persist the change data if necessary, and can be queried as a CDC query mode.");
|
55 | 89 |
|
56 |
| - Option<String> RECORD_KEY_FIELDS = |
| 90 | + public static Option<String> RECORD_KEY_FIELDS = |
57 | 91 | Options.key("record_key_fields")
|
58 | 92 | .stringType()
|
59 | 93 | .noDefaultValue()
|
60 | 94 | .withDescription("the record key fields of hudi table");
|
61 | 95 |
|
62 |
| - Option<String> PARTITION_FIELDS = |
| 96 | + public static Option<String> PARTITION_FIELDS = |
63 | 97 | Options.key("partition_fields")
|
64 | 98 | .stringType()
|
65 | 99 | .noDefaultValue()
|
66 | 100 | .withDescription("the partition fields of hudi table");
|
67 | 101 |
|
68 |
| - Option<HoodieIndex.IndexType> INDEX_TYPE = |
| 102 | + public static Option<HoodieIndex.IndexType> INDEX_TYPE = |
69 | 103 | Options.key("index_type")
|
70 | 104 | .type(new TypeReference<HoodieIndex.IndexType>() {})
|
71 | 105 | .defaultValue(HoodieIndex.IndexType.BLOOM)
|
72 | 106 | .withDescription(
|
73 | 107 | "the index type of hudi table, currently supported: [BLOOM, SIMPLE, GLOBAL_BLOOM]");
|
74 | 108 |
|
75 |
| - Option<String> INDEX_CLASS_NAME = |
| 109 | + public static Option<String> INDEX_CLASS_NAME = |
76 | 110 | Options.key("index_class_name")
|
77 | 111 | .stringType()
|
78 | 112 | .noDefaultValue()
|
79 | 113 | .withDescription(
|
80 | 114 | "customized hudi index type, the index classpath is configured here");
|
81 | 115 |
|
82 |
| - Option<Integer> RECORD_BYTE_SIZE = |
| 116 | + public static Option<Integer> RECORD_BYTE_SIZE = |
83 | 117 | Options.key("record_byte_size")
|
84 | 118 | .intType()
|
85 | 119 | .defaultValue(1024)
|
86 | 120 | .withDescription("The byte size of each record");
|
87 | 121 |
|
88 |
| - Option<WriteOperationType> OP_TYPE = |
| 122 | + public static Option<WriteOperationType> OP_TYPE = |
89 | 123 | Options.key("op_type")
|
90 | 124 | .type(new TypeReference<WriteOperationType>() {})
|
91 | 125 | .defaultValue(WriteOperationType.INSERT)
|
92 | 126 | .withDescription("op_type");
|
93 | 127 |
|
94 |
| - Option<Integer> BATCH_SIZE = |
| 128 | + public static Option<Integer> BATCH_SIZE = |
95 | 129 | Options.key("batch_size")
|
96 | 130 | .intType()
|
97 | 131 | .defaultValue(1000)
|
98 | 132 | .withDescription("the size of each insert batch");
|
99 | 133 |
|
100 |
| - Option<Integer> BATCH_INTERVAL_MS = |
| 134 | + public static Option<Integer> BATCH_INTERVAL_MS = |
101 | 135 | Options.key("batch_interval_ms")
|
102 | 136 | .intType()
|
103 | 137 | .defaultValue(1000)
|
104 | 138 | .withDescription("batch interval milliSecond");
|
105 | 139 |
|
106 |
| - Option<Integer> INSERT_SHUFFLE_PARALLELISM = |
| 140 | + public static Option<Integer> INSERT_SHUFFLE_PARALLELISM = |
107 | 141 | Options.key("insert_shuffle_parallelism")
|
108 | 142 | .intType()
|
109 | 143 | .defaultValue(2)
|
110 | 144 | .withDescription("insert_shuffle_parallelism");
|
111 | 145 |
|
112 |
| - Option<Integer> UPSERT_SHUFFLE_PARALLELISM = |
| 146 | + public static Option<Integer> UPSERT_SHUFFLE_PARALLELISM = |
113 | 147 | Options.key("upsert_shuffle_parallelism")
|
114 | 148 | .intType()
|
115 | 149 | .defaultValue(2)
|
116 | 150 | .withDescription("upsert_shuffle_parallelism");
|
117 | 151 |
|
118 |
| - Option<Integer> MIN_COMMITS_TO_KEEP = |
| 152 | + public static Option<Integer> MIN_COMMITS_TO_KEEP = |
119 | 153 | Options.key("min_commits_to_keep")
|
120 | 154 | .intType()
|
121 | 155 | .defaultValue(20)
|
122 | 156 | .withDescription("hoodie.keep.min.commits");
|
123 | 157 |
|
124 |
| - Option<Integer> MAX_COMMITS_TO_KEEP = |
| 158 | + public static Option<Integer> MAX_COMMITS_TO_KEEP = |
125 | 159 | Options.key("max_commits_to_keep")
|
126 | 160 | .intType()
|
127 | 161 | .defaultValue(30)
|
|
0 commit comments