Search in sources :

Example 1 with InitException

use of com.baidu.hugegraph.loader.exception.InitException in project incubator-hugegraph-toolchain by apache.

the class FileReader method init.

@Override
public void init(LoadContext context, InputStruct struct) throws InitException {
    this.progress(context, struct);
    List<Readable> readableList;
    try {
        readableList = this.scanReadables();
        // Sort readable files by name
        readableList.sort(Comparator.comparing(Readable::name));
    } catch (IOException e) {
        throw new InitException("Failed to scan readable files for '%s'", e, this.source);
    }
    this.readables = readableList.iterator();
    this.fetcher = this.createLineFetcher();
    this.fetcher.readHeaderIfNeeded(readableList);
}
Also used : InitException(com.baidu.hugegraph.loader.exception.InitException) Readable(com.baidu.hugegraph.loader.reader.Readable) IOException(java.io.IOException)

Example 2 with InitException

use of com.baidu.hugegraph.loader.exception.InitException in project incubator-hugegraph-toolchain by apache.

the class HugeGraphLoader method loadStructs.

private void loadStructs(List<InputStruct> structs) {
    // Load input structs one by one
    for (InputStruct struct : structs) {
        if (this.context.stopped()) {
            break;
        }
        if (struct.skip()) {
            continue;
        }
        // Create and init InputReader, fetch next batch lines
        try (InputReader reader = InputReader.create(struct.input())) {
            // Init reader
            reader.init(this.context, struct);
            // Load data from current input mapping
            this.loadStruct(struct, reader);
        } catch (InitException e) {
            throw new LoadException("Failed to init input reader", e);
        }
    }
}
Also used : InputReader(com.baidu.hugegraph.loader.reader.InputReader) InputStruct(com.baidu.hugegraph.loader.mapping.InputStruct) InitException(com.baidu.hugegraph.loader.exception.InitException) LoadException(com.baidu.hugegraph.loader.exception.LoadException)

Example 3 with InitException

use of com.baidu.hugegraph.loader.exception.InitException in project incubator-hugegraph-toolchain by apache.

the class JDBCReader method init.

@Override
public void init(LoadContext context, InputStruct struct) throws InitException {
    this.progress(context, struct);
    if (!this.source.existsCustomSQL()) {
        try {
            this.source.header(this.fetcher.readHeader());
            this.fetcher.readPrimaryKey();
        } catch (SQLException e) {
            throw new InitException("Failed to fetch table structure info", e);
        }
    }
}
Also used : SQLException(java.sql.SQLException) InitException(com.baidu.hugegraph.loader.exception.InitException)

Aggregations

InitException (com.baidu.hugegraph.loader.exception.InitException)3 LoadException (com.baidu.hugegraph.loader.exception.LoadException)1 InputStruct (com.baidu.hugegraph.loader.mapping.InputStruct)1 InputReader (com.baidu.hugegraph.loader.reader.InputReader)1 Readable (com.baidu.hugegraph.loader.reader.Readable)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1