In SegmentCreationJob, fix the issue where ControllerRestApi is used when _pushLocations is not set
When extending SegmentCreationJob class, the ControllerRestApi can be constructed without _pushLocations
Change getTableConfig() and getSchema() so that they work without setting _pushLocations
@@ -211,33 +211,30 @@ public class SegmentCreationJob extends BaseSegmentJob {
@Nullable
protected TableConfig getTableConfig()
throws IOException {
- if (_pushLocations != null) {
try (ControllerRestApi controllerRestApi = getControllerRestApi()) {
- return controllerRestApi.getTableConfig();
- }
- } else {
- return null;
+ return controllerRestApi != null ? controllerRestApi.getTableConfig() : null;
}
}
protected Schema getSchema()
throws IOException {
- if (_pushLocations != null) {
try (ControllerRestApi controllerRestApi = getControllerRestApi()) {
+ if (controllerRestApi != null) {
return controllerRestApi.getSchema();
- }
} else {
try (InputStream inputStream = _fileSystem.open(_schemaFile)) {
return Schema.fromInputSteam(inputStream);
}
}
}
+ }
/**
* Can be overridden to provide custom controller Rest API.
*/
+ @Nullable
protected ControllerRestApi getControllerRestApi() {
- return new DefaultControllerRestApi(_pushLocations, _rawTableName);
+ return _pushLocations != null ? new DefaultControllerRestApi(_pushLocations, _rawTableName) : null;
}
protected void validateTableConfig(TableConfig tableConfig) {
