Search in sources :

Example 1 with ListFormat

use of com.baidu.hugegraph.entity.load.ListFormat in project incubator-hugegraph-toolchain by apache.

the class LoadTaskService method buildFileSource.

private FileSource buildFileSource(FileMapping fileMapping) {
    // Set input source
    FileSource source = new FileSource();
    source.path(fileMapping.getPath());
    FileSetting setting = fileMapping.getFileSetting();
    Ex.check(setting.getColumnNames() != null, "Must do file setting firstly");
    source.header(setting.getColumnNames().toArray(new String[] {}));
    // NOTE: format and delimiter must be CSV and "," temporarily
    source.format(FileFormat.valueOf(setting.getFormat()));
    source.delimiter(setting.getDelimiter());
    source.charset(setting.getCharset());
    source.dateFormat(setting.getDateFormat());
    source.timeZone(setting.getTimeZone());
    source.skippedLine().regex(setting.getSkippedLine());
    // Set list format
    source.listFormat(new com.baidu.hugegraph.loader.source.file.ListFormat());
    ListFormat listFormat = setting.getListFormat();
    source.listFormat().startSymbol(listFormat.getStartSymbol());
    source.listFormat().endSymbol(listFormat.getEndSymbol());
    source.listFormat().elemDelimiter(listFormat.getElemDelimiter());
    return source;
}
Also used : FileSetting(com.baidu.hugegraph.entity.load.FileSetting) FileSource(com.baidu.hugegraph.loader.source.file.FileSource) ListFormat(com.baidu.hugegraph.entity.load.ListFormat)

Aggregations

FileSetting (com.baidu.hugegraph.entity.load.FileSetting)1 ListFormat (com.baidu.hugegraph.entity.load.ListFormat)1 FileSource (com.baidu.hugegraph.loader.source.file.FileSource)1