Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit 7bd7aef

Browse files
authored
[BitSail]Supprt bitsail table catalog. (#181)
Support table catalog in bitsail.
1 parent bb3f423 commit 7bd7aef

82 files changed

Lines changed: 2321 additions & 1944 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.bytedance.bitsail.base.catalog;
21+
22+
import com.bytedance.bitsail.base.component.ComponentBuilder;
23+
import com.bytedance.bitsail.base.connector.BuilderGroup;
24+
import com.bytedance.bitsail.base.execution.ExecutionEnviron;
25+
import com.bytedance.bitsail.common.catalog.table.TableCatalog;
26+
import com.bytedance.bitsail.common.configuration.BitSailConfiguration;
27+
28+
import java.io.Serializable;
29+
30+
/**
31+
* Created 2022/5/23
32+
*/
33+
public interface TableCatalogFactory extends Serializable, ComponentBuilder {
34+
35+
/**
36+
* Create a table catalog.
37+
*
38+
* @param executionEnviron execution environment
39+
* @param connectorConfiguration configuration for the reader/writer
40+
*/
41+
TableCatalog createTableCatalog(BuilderGroup builderGroup,
42+
ExecutionEnviron executionEnviron,
43+
BitSailConfiguration connectorConfiguration);
44+
45+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.bytedance.bitsail.base.catalog;
21+
22+
import com.bytedance.bitsail.base.component.DefaultComponentBuilderLoader;
23+
24+
import org.apache.commons.lang3.StringUtils;
25+
26+
public class TableCatalogFactoryHelper {
27+
28+
public static TableCatalogFactory getTableCatalogFactory(String connectorName) {
29+
DefaultComponentBuilderLoader<TableCatalogFactory> loader =
30+
new DefaultComponentBuilderLoader<>(TableCatalogFactory.class);
31+
32+
return loader.loadComponent(StringUtils.lowerCase(connectorName), false);
33+
}
34+
}

bitsail-base/src/main/java/com/bytedance/bitsail/base/component/DefaultComponentBuilderLoader.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,21 @@ public DefaultComponentBuilderLoader(Class<T> clazz) {
4545
}
4646

4747
public T loadComponent(String componentName) {
48+
return this.loadComponent(componentName, true);
49+
}
50+
51+
public T loadComponent(String componentName, boolean failOnMiss) {
4852
if (!loaded) {
4953
loadAllComponents();
5054
loaded = true;
5155
}
5256
componentName = StringUtils.lowerCase(componentName);
5357
if (!components.containsKey(componentName)) {
54-
throw new BitSailException(CommonErrorCode.CONFIG_ERROR,
55-
String.format("Component %s not in interface %s support until now.", componentName, clazz));
58+
if (failOnMiss) {
59+
throw new BitSailException(CommonErrorCode.CONFIG_ERROR,
60+
String.format("Component %s not in interface %s support until now.", componentName, clazz));
61+
}
62+
return null;
5663
}
5764
return components.get(componentName);
5865
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.bytedance.bitsail.base.connector;
21+
22+
public enum BuilderGroup {
23+
24+
READER,
25+
WRITER,
26+
TRANSFORMER;
27+
}

bitsail-base/src/main/java/com/bytedance/bitsail/base/connector/reader/v1/Source.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package com.bytedance.bitsail.base.connector.reader.v1;
2121

2222
import com.bytedance.bitsail.base.execution.ExecutionEnviron;
23+
import com.bytedance.bitsail.base.extension.TypeInfoConverterFactory;
2324
import com.bytedance.bitsail.base.serializer.BinarySerializer;
2425
import com.bytedance.bitsail.base.serializer.SimpleBinarySerializer;
2526
import com.bytedance.bitsail.common.configuration.BitSailConfiguration;
@@ -29,7 +30,8 @@
2930
import java.io.IOException;
3031
import java.io.Serializable;
3132

32-
public interface Source<T, SplitT extends SourceSplit, StateT extends Serializable> extends Serializable {
33+
public interface Source<T, SplitT extends SourceSplit, StateT extends Serializable>
34+
extends Serializable, TypeInfoConverterFactory {
3335

3436
/**
3537
* Run in client side for source initialize;

bitsail-base/src/main/java/com/bytedance/bitsail/base/connector/writer/v1/Sink.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.bytedance.bitsail.base.connector.writer.v1;
1919

20+
import com.bytedance.bitsail.base.extension.TypeInfoConverterFactory;
2021
import com.bytedance.bitsail.base.serializer.BinarySerializer;
2122
import com.bytedance.bitsail.base.serializer.SimpleBinarySerializer;
2223
import com.bytedance.bitsail.common.configuration.BitSailConfiguration;
@@ -31,7 +32,8 @@
3132
/**
3233
* Created 2022/6/10
3334
*/
34-
public interface Sink<InputT, CommitT extends Serializable, WriterStateT extends Serializable> extends Serializable {
35+
public interface Sink<InputT, CommitT extends Serializable, WriterStateT extends Serializable>
36+
extends Serializable, TypeInfoConverterFactory {
3537

3638
/**
3739
* @return The name of writer operation.

bitsail-base/src/main/java/com/bytedance/bitsail/base/extension/SchemaAlignmentable.java

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.bytedance.bitsail.base.extension;
21+
22+
import com.bytedance.bitsail.common.type.TypeInfoConverter;
23+
24+
import java.io.Serializable;
25+
26+
public interface TypeInfoConverterFactory extends Serializable {
27+
28+
TypeInfoConverter createTypeInfoConverter();
29+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.bytedance.bitsail.common.catalog;
21+
22+
import com.bytedance.bitsail.common.exception.ErrorCode;
23+
24+
public enum TableCatalogErrorCode implements ErrorCode {
25+
26+
TABLE_CATALOG_TABLE_NOT_EXISTS("Table-Catalog-1", "Catalog table not exists."),
27+
28+
;
29+
private final String code;
30+
31+
private final String description;
32+
33+
TableCatalogErrorCode(String code, String description) {
34+
this.code = code;
35+
this.description = description;
36+
}
37+
38+
@Override
39+
public String getCode() {
40+
return code;
41+
}
42+
43+
@Override
44+
public String getDescription() {
45+
return description;
46+
}
47+
}

0 commit comments

Comments
 (0)