mirror of
https://github.com/apache/sqoop.git
synced 2025-05-20 19:00:48 +08:00
SQOOP-1899: Minor change to CSVIDF to use Set instead of Lists
(Veena Basavaraj via Jarek Jarcec Cecho)
This commit is contained in:
parent
4527916766
commit
5abcdd4d6d
@ -37,7 +37,6 @@
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -57,14 +56,14 @@ public class CSVIntermediateDataFormat extends IntermediateDataFormat<String> {
|
||||
|
||||
public static final Logger LOG = Logger.getLogger(CSVIntermediateDataFormat.class);
|
||||
|
||||
private final List<Integer> stringTypeColumnIndices = new ArrayList<Integer>();
|
||||
private final List<Integer> bitTypeColumnIndices = new ArrayList<Integer>();
|
||||
private final List<Integer> byteTypeColumnIndices = new ArrayList<Integer>();
|
||||
private final List<Integer> listTypeColumnIndices = new ArrayList<Integer>();
|
||||
private final List<Integer> mapTypeColumnIndices = new ArrayList<Integer>();
|
||||
private final List<Integer> dateTimeTypeColumnIndices = new ArrayList<Integer>();
|
||||
private final List<Integer> dateTypeColumnIndices = new ArrayList<Integer>();
|
||||
private final List<Integer> timeColumnIndices = new ArrayList<Integer>();
|
||||
private final Set<Integer> stringTypeColumnIndices = new HashSet<Integer>();
|
||||
private final Set<Integer> bitTypeColumnIndices = new HashSet<Integer>();
|
||||
private final Set<Integer> byteTypeColumnIndices = new HashSet<Integer>();
|
||||
private final Set<Integer> listTypeColumnIndices = new HashSet<Integer>();
|
||||
private final Set<Integer> mapTypeColumnIndices = new HashSet<Integer>();
|
||||
private final Set<Integer> dateTimeTypeColumnIndices = new HashSet<Integer>();
|
||||
private final Set<Integer> dateTypeColumnIndices = new HashSet<Integer>();
|
||||
private final Set<Integer> timeColumnIndices = new HashSet<Integer>();
|
||||
|
||||
|
||||
private Schema schema;
|
||||
@ -126,12 +125,11 @@ public void setSchema(Schema schema) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom CSV parser that honors quoting and escaped quotes. All other
|
||||
* escaping is handled elsewhere.
|
||||
* Custom CSV Text parser that honors quoting and escaped quotes.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
private String[] getFieldStringArray() {
|
||||
private String[] parseCSVString() {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
@ -188,7 +186,7 @@ public Object[] getObjectData() {
|
||||
}
|
||||
|
||||
// fieldStringArray represents the csv fields parsed into string array
|
||||
String[] fieldStringArray = getFieldStringArray();
|
||||
String[] fieldStringArray = parseCSVString();
|
||||
|
||||
if (fieldStringArray == null) {
|
||||
return null;
|
||||
@ -207,12 +205,12 @@ public Object[] getObjectData() {
|
||||
objectArray[i] = null;
|
||||
continue;
|
||||
}
|
||||
objectArray[i] = parseCSVStringArrayElement(fieldStringArray[i], columnArray[i]);
|
||||
objectArray[i] = toObject(fieldStringArray[i], columnArray[i]);
|
||||
}
|
||||
return objectArray;
|
||||
}
|
||||
|
||||
private Object parseCSVStringArrayElement(String csvString, Column column) {
|
||||
private Object toObject(String csvString, Column column) {
|
||||
Object returnValue = null;
|
||||
|
||||
switch (column.getType()) {
|
||||
|
Loading…
Reference in New Issue
Block a user