Search in sources :

Example 6 with FileSource

use of com.baidu.hugegraph.loader.source.file.FileSource in project hugegraph-computer by hugegraph.

the class LoaderFileInputSplitFetcher method fetchEdgeInputSplits.

@Override
public List<InputSplit> fetchEdgeInputSplits() {
    List<InputSplit> splits = new ArrayList<>();
    for (InputStruct edgeInputStruct : this.edgeInputStructs) {
        FileSource source = (FileSource) edgeInputStruct.input();
        List<String> paths = this.scanPaths(source);
        if (CollectionUtils.isNotEmpty(paths)) {
            for (String path : paths) {
                FileInputSplit split = new FileInputSplit(ElemType.EDGE, edgeInputStruct, 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 FileSource

use of com.baidu.hugegraph.loader.source.file.FileSource 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 8 with FileSource

use of com.baidu.hugegraph.loader.source.file.FileSource 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 9 with FileSource

use of com.baidu.hugegraph.loader.source.file.FileSource 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)

Aggregations

FileSource (com.baidu.hugegraph.loader.source.file.FileSource)9 InputStruct (com.baidu.hugegraph.loader.mapping.InputStruct)5 ArrayList (java.util.ArrayList)4 InputSplit (com.baidu.hugegraph.computer.core.input.InputSplit)2 LoadMapping (com.baidu.hugegraph.loader.mapping.LoadMapping)2 HugeClient (com.baidu.hugegraph.driver.HugeClient)1 EdgeMapping (com.baidu.hugegraph.entity.load.EdgeMapping)1 FileSetting (com.baidu.hugegraph.entity.load.FileSetting)1 ListFormat (com.baidu.hugegraph.entity.load.ListFormat)1 VertexMapping (com.baidu.hugegraph.entity.load.VertexMapping)1 PropertyKeyEntity (com.baidu.hugegraph.entity.schema.PropertyKeyEntity)1 ExternalException (com.baidu.hugegraph.exception.ExternalException)1 LoadException (com.baidu.hugegraph.loader.exception.LoadException)1 ElementMapping (com.baidu.hugegraph.loader.mapping.ElementMapping)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 ListFormat (com.baidu.hugegraph.loader.source.file.ListFormat)1 ElementStructV1 (com.baidu.hugegraph.loader.struct.ElementStructV1)1 GraphStructV1 (com.baidu.hugegraph.loader.struct.GraphStructV1)1