[
https://issues.apache.org/jira/browse/SQOOP-2007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14275495#comment-14275495
]
Veena Basavaraj commented on SQOOP-2007:
----------------------------------------
the new code can be
{code}
public class NameMatcher extends Matcher {
public NameMatcher(Schema from, Schema to) {
super(from, to);
}
@Override
public Object[] getMatchingData(Object[] fields) {
Object[] out = new Object[getToSchema().getColumnsCount()];
Column[] columns = getToSchema().getColumnsArray();
for (int i = 0; i < columns.length; i++) {
Integer columnArrayIndex =
getFromSchema().getColumnNameIndex(columns[i].getName());
if (columnArrayIndex < fields.length) {
Object value = fields[columnArrayIndex];
out[i] = isNull(value) ? null : value;
} else {
tryFillNullInArrayForUnexpectedColumn(columns[i], out, i);
}
}
return out;
}
}
{code}
> Schema NameMatcher cleanup
> --------------------------
>
> Key: SQOOP-2007
> URL: https://issues.apache.org/jira/browse/SQOOP-2007
> Project: Sqoop
> Issue Type: Sub-task
> Reporter: Veena Basavaraj
> Fix For: 2.0.0
>
>
> {code}
> fromColNameIndexMap = new HashMap<String, Integer>();
> int fromIndex = 0;
> for (Column fromCol : getFromSchema().getColumnsList()) {
> fromColNameIndexMap.put(fromCol.getName(), fromIndex);
> fromIndex++;
> }
> {code}
> we can clean this code up, since this index map is already in schema now,
> since e needed it for JSON and Avro IDF
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)