Search in sources :

Example 6 with InputStruct

use of com.baidu.hugegraph.loader.mapping.InputStruct in project hugegraph-computer by hugegraph.

the class LoaderFileInputSplitFetcher method fetchVertexInputSplits.

@Override
public List<InputSplit> fetchVertexInputSplits() {
    List<InputSplit> splits = new ArrayList<>();
    for (InputStruct vertexInputStruct : this.vertexInputStructs) {
        FileSource source = (FileSource) vertexInputStruct.input();
        List<String> paths = this.scanPaths(source);
        if (CollectionUtils.isNotEmpty(paths)) {
            for (String path : paths) {
                FileInputSplit split = new FileInputSplit(ElemType.VERTEX, vertexInputStruct, path);
                splits.add(split);
            }
        }
    }
    return splits;
}
Also used : InputStruct(com.baidu.hugegraph.loader.mapping.InputStruct) FileSource(com.baidu.hugegraph.loader.source.file.FileSource) ArrayList(java.util.ArrayList) InputSplit(com.baidu.hugegraph.computer.core.input.InputSplit)

Example 7 with InputStruct

use of com.baidu.hugegraph.loader.mapping.InputStruct in project hugegraph-computer by hugegraph.

the class FileElementFetcher method createReader.

private InputReader createReader(FileInputSplit split) {
    InputStruct struct = split.struct();
    FileSource source = (FileSource) struct.input();
    source.path(split.path());
    FileReader reader = (FileReader) InputReader.create(struct.input());
    reader.init(this.context, struct);
    return reader;
}
Also used : InputStruct(com.baidu.hugegraph.loader.mapping.InputStruct) FileSource(com.baidu.hugegraph.loader.source.file.FileSource) FileReader(com.baidu.hugegraph.loader.reader.file.FileReader)

Example 8 with InputStruct

use of com.baidu.hugegraph.loader.mapping.InputStruct in project incubator-hugegraph-toolchain by apache.

the class LoadTaskService method buildLoadMapping.

private LoadMapping buildLoadMapping(GraphConnection connection, FileMapping fileMapping) {
    FileSource source = this.buildFileSource(fileMapping);
    List<com.baidu.hugegraph.loader.mapping.VertexMapping> vMappings;
    vMappings = this.buildVertexMappings(connection, fileMapping);
    List<com.baidu.hugegraph.loader.mapping.EdgeMapping> eMappings;
    eMappings = this.buildEdgeMappings(connection, fileMapping);
    InputStruct inputStruct = new InputStruct(vMappings, eMappings);
    inputStruct.id("1");
    inputStruct.input(source);
    return new LoadMapping(ImmutableList.of(inputStruct));
}
Also used : VertexMapping(com.baidu.hugegraph.entity.load.VertexMapping) InputStruct(com.baidu.hugegraph.loader.mapping.InputStruct) FileSource(com.baidu.hugegraph.loader.source.file.FileSource) EdgeMapping(com.baidu.hugegraph.entity.load.EdgeMapping) LoadMapping(com.baidu.hugegraph.loader.mapping.LoadMapping)

Example 9 with InputStruct

use of com.baidu.hugegraph.loader.mapping.InputStruct 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)

Aggregations

InputStruct (com.baidu.hugegraph.loader.mapping.InputStruct)9 FileSource (com.baidu.hugegraph.loader.source.file.FileSource)5 FileInputSplit (com.baidu.hugegraph.computer.core.input.loader.FileInputSplit)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 InputSplit (com.baidu.hugegraph.computer.core.input.InputSplit)2 LoadMapping (com.baidu.hugegraph.loader.mapping.LoadMapping)2 EdgeMapping (com.baidu.hugegraph.entity.load.EdgeMapping)1 VertexMapping (com.baidu.hugegraph.entity.load.VertexMapping)1 InitException (com.baidu.hugegraph.loader.exception.InitException)1 LoadException (com.baidu.hugegraph.loader.exception.LoadException)1 ElementMapping (com.baidu.hugegraph.loader.mapping.ElementMapping)1 InputReader (com.baidu.hugegraph.loader.reader.InputReader)1 FileReader (com.baidu.hugegraph.loader.reader.file.FileReader)1 InputSource (com.baidu.hugegraph.loader.source.InputSource)1 SourceType (com.baidu.hugegraph.loader.source.SourceType)1 ElementStructV1 (com.baidu.hugegraph.loader.struct.ElementStructV1)1 GraphStructV1 (com.baidu.hugegraph.loader.struct.GraphStructV1)1