All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zhao.algorithmMagic.io.InputHDFSBuilder Maven / Gradle / Ivy

There is a newer version: 1.42
Show newest version
package zhao.algorithmMagic.io;

import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import zhao.algorithmMagic.operands.table.Cell;
import zhao.algorithmMagic.operands.table.FinalCell;
import zhao.algorithmMagic.operands.table.SingletonCell;
import zhao.algorithmMagic.utils.ASClass;

import java.util.HashMap;

/**
 * HDFS数据输入组件建造者对象,在该对象中能够为HDFS的数据输入组件进行构建。
 * 

* HDFS data input component object, which can obtain file data from the HDFS platform. * * @author 赵凌宇 * 2023/4/6 9:18 */ public class InputHDFSBuilder extends HashMap> implements InputBuilder { /** * HDFS文件系统对象 */ public final static String FILE_SYSTEM = "FS"; /** * 数据加载分隔符 */ public final static String SEP = "sep"; /** * 数据输入路径 */ public final static String IN_PATH = "inPath"; /** * 数据输入字符集 */ public final static String CHAR_SET = "cs"; /** * 数据输入主键 */ public final static String PK = "pk"; /** * 数据字符名称 */ public final static String FIELD = "field"; /** * 读取的矩阵行数量,在读取矩阵的时候会使用该参数,默认读取全部行。 */ public final static String ROW_COUNT = "RC"; /** * 添加数据输入描述,不同的组件有不同的配置属性,具体可以参阅实现类。 *

* Add data input descriptions, and different components have different configuration properties. Please refer to the implementation class for details. * * @param key 属性名称 *

* Attribute Name. * @param value 属性数值 *

* Attribute Value. * @return 链式调用,继续构建 *

* Chain call, continue building. */ @Override public InputBuilder addInputArg(String key, Cell value) { this.put(key, value); return this; } /** * 将所需的对象构建出来并获取到对应的输入设备对象。 * * @return 输入设备对象。 */ @Override public InputComponent create() { return new InputHDFS( (FileSystem) this.get(FILE_SYSTEM).getValue(), new Path(this.get(IN_PATH).toString()), ASClass., Cell>transform(this.getOrDefault(SEP, new FinalCell<>(','))).getValue(), this.getOrDefault(CHAR_SET, new FinalCell<>("utf-8")).toString(), ASClass., Cell>transform(this.get(FIELD)), this.getOrDefault(PK, new FinalCell<>(0)).getIntValue(), this.getOrDefault(ROW_COUNT, SingletonCell.$(-1)).getIntValue() ); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy