Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRahulSharma committed Mar 13, 2024
1 parent b9f7ea5 commit 009268b
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@
import io.cdap.cdap.api.data.schema.Schema;
import io.cdap.plugin.servicenow.apiclient.ServiceNowTableAPIClientImpl;
import io.cdap.plugin.servicenow.connector.ServiceNowRecordConverter;
import io.cdap.plugin.servicenow.util.ServiceNowConstants;
import io.cdap.plugin.servicenow.util.ServiceNowTableInfo;
import io.cdap.plugin.servicenow.util.SourceQueryMode;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -50,7 +46,7 @@ public ServiceNowRecordReader(ServiceNowSourceConfig pluginConf) {
@Override
public void initialize(InputSplit split, TaskAttemptContext context) {
initialize(split);
fetchSchema(new ServiceNowJobConfiguration(context.getConfiguration()).getTableInfos(), tableName);
fetchAndInitializeSchema(new ServiceNowJobConfiguration(context.getConfiguration()).getTableInfos(), tableName);
}

/**
Expand Down Expand Up @@ -124,7 +120,13 @@ protected void initialize(InputSplit split) {
tableNameField = pluginConf.getTableNameField();
}

private void fetchSchema(List<ServiceNowTableInfo> tableInfos, String tableName) {
/**
* Fetches the schema of the given tableName from the tableInfos and initialize schema using it.
*
* @param tableInfos List of TableInfo objects containing TableName, RecordCount and Schema.
* @param tableName Table Name to initialize this reader for.
*/
private void fetchAndInitializeSchema(List<ServiceNowTableInfo> tableInfos, String tableName) {
Schema tempSchema = tableInfos.stream()
.filter((tableInfo) -> tableInfo.getTableName().equalsIgnoreCase(tableName))
.findFirst().get().getSchema();
Expand Down

0 comments on commit 009268b

Please sign in to comment.