zachjsh commented on code in PR #13627:
URL: https://github.com/apache/druid/pull/13627#discussion_r1066568661
##########
server/src/main/java/org/apache/druid/catalog/model/TableDefnRegistry.java:
##########
@@ -55,40 +61,76 @@
{
// Temporary list of Druid-define table definitions. This should come from
// Guice later to allow extensions to define table types.
- private static final TableDefn[] TABLE_DEFNS = {
+ private static final List<TableDefn> BUILTIN_TABLE_DEFNS = Arrays.asList(
new DatasourceDefn(),
- new InlineTableDefn(),
- new HttpTableDefn(),
- new LocalTableDefn()
- };
+ new ExternalTableDefn()
+ );
+ private static final List<InputSourceDefn> BUILTIN_INPUT_SOURCE_DEFNS =
Arrays.asList(
+ new InlineInputSourceDefn(),
+ new HttpInputSourceDefn(),
+ new LocalInputSourceDefn()
+ );
+ private static final List<InputFormatDefn> BUILTIN_INPUT_FORMAT_DEFNS =
Arrays.asList(
+ new InputFormats.CsvFormatDefn(),
+ new InputFormats.DelimitedFormatDefn(),
+ new InputFormats.JsonFormatDefn()
+ );
- private final Map<String, TableDefn> defns;
+ private final Map<String, TableDefn> tableDefns;
+ private final Map<String, InputSourceDefn> inputSourceDefns;
+ private final Map<String, InputFormatDefn> inputFormatDefns;
private final ObjectMapper jsonMapper;
public TableDefnRegistry(
- final TableDefn[] defns,
+ @Nullable final List<TableDefn> tableDefnExtns,
+ @Nullable final List<InputSourceDefn> inputSourceDefnExtns,
+ @Nullable final List<InputFormatDefn> inputFormatDefnExtns,
final ObjectMapper jsonMapper
)
{
- ImmutableMap.Builder<String, TableDefn> builder = ImmutableMap.builder();
- for (TableDefn defn : defns) {
- builder.put(defn.typeValue(), defn);
- }
- this.defns = builder.build();
this.jsonMapper = jsonMapper;
+ final List<TableDefn> tableDefns =
CatalogUtils.concatLists(tableDefnExtns, BUILTIN_TABLE_DEFNS);
+ final List<InputSourceDefn> inputSourceDefns =
CatalogUtils.concatLists(inputSourceDefnExtns, BUILTIN_INPUT_SOURCE_DEFNS);
+ final List<InputFormatDefn> inputFormatDefns =
CatalogUtils.concatLists(inputFormatDefnExtns, BUILTIN_INPUT_FORMAT_DEFNS);
+
+ ImmutableMap.Builder<String, TableDefn> tableBuilder =
ImmutableMap.builder();
+ for (TableDefn defn : tableDefns) {
+ tableBuilder.put(defn.typeValue(), defn);
+ }
+ this.tableDefns = tableBuilder.build();
+
+ ImmutableMap.Builder<String, InputSourceDefn> sourceBuilder =
ImmutableMap.builder();
+ for (InputSourceDefn defn : inputSourceDefns) {
+ sourceBuilder.put(defn.typeValue(), defn);
+ }
+ this.inputSourceDefns = sourceBuilder.build();
+
+ ImmutableMap.Builder<String, InputFormatDefn> formatBuilder =
ImmutableMap.builder();
+ for (InputFormatDefn defn : inputFormatDefns) {
+ formatBuilder.put(defn.typeValue(), defn);
+ }
+ this.inputFormatDefns = formatBuilder.build();
+
+ // Initialize all items once the entire set of bindings is defined.
+ for (InputSourceDefn defn : inputSourceDefns) {
+ defn.bind(this);
+ }
+ for (TableDefn defn : tableDefns) {
+ defn.bind(this);
+ }
Review Comment:
should we bind the inputFormatDefns too?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]