当前位置: 首页>>代码示例>>Java>>正文


Java ColumnConfig类代码示例

本文整理汇总了Java中org.embulk.spi.ColumnConfig的典型用法代码示例。如果您正苦于以下问题:Java ColumnConfig类的具体用法?Java ColumnConfig怎么用?Java ColumnConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ColumnConfig类属于org.embulk.spi包,在下文中一共展示了ColumnConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getColumnOptions

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
HashMap<Column, Map<String, Integer>> getColumnOptions(PluginTask task)
{
    SchemaConfig schemaConfig = task.getSchema();
    Schema schema = schemaConfig.toSchema();
    HashMap<Column, Map<String, Integer>> lengthMap = new HashMap<>();
    for (Column column : schema.getColumns()) {
        HashMap<String, Integer> miniMap = new HashMap<>();
        ColumnConfig c = schemaConfig.getColumn(column.getIndex());
        miniMap.put("length", c.getOption().get(Integer.class, "length", 0));
        miniMap.put("null_rate", c.getOption().get(Integer.class, "null_rate", 0));
        miniMap.put("max_value", c.getOption().get(Integer.class, "max_value", null));
        miniMap.put("min_value", c.getOption().get(Integer.class, "min_value", null));
        lengthMap.put(column, miniMap);
    }
    return lengthMap;
}
 
开发者ID:yuokada,项目名称:embulk-input-randomj,代码行数:17,代码来源:RandomjInputPlugin.java

示例2: KafkaInputColumns

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
public KafkaInputColumns(KafkaInputPlugin.PluginTask task) {

        List<String> columns = task.getColumns();

        // Validate column name
        if(columns.size() <= 0) {
            throw new IllegalArgumentException("columns property should have one or more elements.");
        }
        for(String column : columns) {
            if(column == null) {
                throw new IllegalArgumentException("column name should not be null.");
            }
            if(!ArrayUtils.contains(columnList, column.toLowerCase())) {
                throw new IllegalArgumentException("column: \"" + column + "\" does not use in columns property.");
            }
        }

        columnHandler = new ColumnBase[columns.size()];
        List<ColumnConfig> columnConfigs = new LinkedList<>();
        for(int i = 0; i < columnHandler.length; i++) {
            columnHandler[i] = getHandler(columns.get(i), task);
            columnConfigs.add(columnHandler[i].getColumnConfig());
        }

        this.schema = new SchemaConfig(columnConfigs).toSchema();
    }
 
开发者ID:sasakitoa,项目名称:embulk-input-kafka,代码行数:27,代码来源:KafkaInputColumns.java

示例3: transaction

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
@Override
public void transaction(ConfigSource configSource, Control control)
{
    PluginTask task = configSource.loadConfig(PluginTask.class);

    if (! task.getColumnOptions().isEmpty()) {
        log.warn("embulk-parser-jsonl: \"column_options\" option is deprecated, specify type directly to \"columns\" option with typecast: true (default: true).");
    }

    SchemaConfig schemaConfig = getSchemaConfig(task);
    ImmutableList.Builder<Column> columns = ImmutableList.builder();
    for (int i = 0; i < schemaConfig.getColumnCount(); i++) {
        ColumnConfig columnConfig = schemaConfig.getColumn(i);
        Type type = getType(task, columnConfig);
        columns.add(new Column(i, columnConfig.getName(), type));
    }
    control.run(task.dump(), new Schema(columns.build()));
}
 
开发者ID:shun0102,项目名称:embulk-parser-jsonl,代码行数:19,代码来源:JsonlParserPlugin.java

示例4: initializeExpandedColumns

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
private List<ExpandedColumn> initializeExpandedColumns(PluginTask task,
                                                       Schema outputSchema)
{
    ImmutableList.Builder<ExpandedColumn> expandedJsonColumnsBuilder = ImmutableList.builder();
    for (Column outputColumn : outputSchema.getColumns()) {
        for (ColumnConfig expandedColumnConfig : task.getExpandedColumns()) {
            if (outputColumn.getName().equals(expandedColumnConfig.getName())) {

                TimestampParser timestampParser = null;
                if (Types.TIMESTAMP.equals(expandedColumnConfig.getType())) {
                    timestampParser = createTimestampParser(task, expandedColumnConfig);
                }

                ExpandedColumn expandedColumn = new ExpandedColumn(outputColumn.getName(),
                                                                   outputColumn,
                                                                   task.getRoot() + outputColumn.getName(),
                                                                   Optional.fromNullable(timestampParser));
                expandedJsonColumnsBuilder.add(expandedColumn);
            }
        }
    }
    return expandedJsonColumnsBuilder.build();
}
 
开发者ID:civitaspo,项目名称:embulk-filter-expand_json,代码行数:24,代码来源:FilteredPageOutput.java

示例5: initializeColumnBean

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
private void initializeColumnBean(PluginTask task, Schema schema) {
	List<ColumnConfig> list = task.getColumns().getColumns();

	Map<String, ColumnOptionTask> map = new HashMap<>();
	List<SheetCommonOptionTask> slist = getSheetOption();
	for (int i = slist.size() - 1; i >= 0; i--) {
		SheetCommonOptionTask s = slist.get(i);
		if (s instanceof SheetOptionTask) {
			Optional<Map<String, ColumnOptionTask>> option = ((SheetOptionTask) s).getColumns();
			if (option.isPresent()) {
				map.putAll(option.get());
			}
		}
	}

	for (Column column : schema.getColumns()) {
		String name = column.getName();
		ColumnConfig c = list.get(column.getIndex());
		ColumnOptionTask t = c.getOption().loadConfig(ColumnOptionTask.class);
		PoiExcelColumnBean bean = new PoiExcelColumnBean(this, column, t, map.get(name));
		columnBeanList.add(bean);
	}

	new PoiExcelColumnIndex().initializeColumnIndex(task, columnBeanList);
}
 
开发者ID:hishidama,项目名称:embulk-parser-poi_excel,代码行数:26,代码来源:PoiExcelSheetBean.java

示例6: build

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
public HashMap<String, HashMap<String, String>> build()
        throws IOException
{
    HashMap<String, HashMap<String, String>> table = Maps.newHashMap();

    for (HashMap<String, String> rawRecord: loadFile()) {

        HashMap<String, String> record = Maps.newHashMap();

        for (ColumnConfig column: columns) {
            String columnKey = columnPrefix + column.getName();
            String value = rawRecord.get(column.getName());

            record.put(columnKey, value);
        }

        String rowKey = rawRecord.get(rowKeyName);
        table.put(rowKey, record);
    }

    return table;
}
 
开发者ID:civitaspo,项目名称:embulk-filter-join_file,代码行数:23,代码来源:TableBuilder.java

示例7: buildOutputSchema

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
private Schema buildOutputSchema(Schema inputSchema, List<ColumnConfig> columns, String joinedColumnPrefix)
{
    ImmutableList.Builder<Column> builder = ImmutableList.builder();

    int i = 0; // columns index
    for (Column inputColumn: inputSchema.getColumns()) {
        Column outputColumn = new Column(i++, inputColumn.getName(), inputColumn.getType());
        builder.add(outputColumn);
    }
    for (ColumnConfig columnConfig: columns) {
        String columnName = joinedColumnPrefix + columnConfig.getName();
        builder.add(new Column(i++, columnName, columnConfig.getType()));
    }

    return new Schema(builder.build());
}
 
开发者ID:civitaspo,项目名称:embulk-filter-join_file,代码行数:17,代码来源:JoinFileFilterPlugin.java

示例8: buildTimestampParserMap

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
private HashMap<String, TimestampParser> buildTimestampParserMap(ScriptingContainer jruby, List<ColumnConfig> columns, String joinedColumnPrefix, String timeZone)
{
    final HashMap<String, TimestampParser> timestampParserMap = Maps.newHashMap();
    for (ColumnConfig columnConfig: columns) {
        if (Types.TIMESTAMP.equals(columnConfig.getType())) {
            String format = columnConfig.getOption().get(String.class, "format");
            DateTimeZone timezone = DateTimeZone.forID(timeZone);
            TimestampParser parser = new TimestampParser(jruby, format, timezone);

            String columnName = joinedColumnPrefix + columnConfig.getName();

            timestampParserMap.put(columnName, parser);
        }
    }

    return timestampParserMap;
}
 
开发者ID:civitaspo,项目名称:embulk-filter-join_file,代码行数:18,代码来源:JoinFileFilterPlugin.java

示例9: createJsonPathMap

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
private Map<Column, String> createJsonPathMap(PluginTask task, Schema schema)
{
    ImmutableMap.Builder<Column, String> builder = ImmutableMap.builder();
    for (int i = 0; i < schema.size(); i++) {
        ColumnConfig config = getSchemaConfig(task).getColumn(i);
        JsonpathColumnOption option = config.getOption().loadConfig(JsonpathColumnOption.class);
        if (option.getPath().isPresent()) {
            builder.put(schema.getColumn(i), option.getPath().get());
        }
    }
    return builder.build();
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:13,代码来源:JsonpathParserPlugin.java

示例10: validateExpandedColumns

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
private void validateExpandedColumns(List<ColumnConfig> expandedColumns)
{
    List<String> columnList = new ArrayList<>();
    for (ColumnConfig columnConfig: expandedColumns) {
        String columnName = columnConfig.getName();
        if (columnList.contains(columnName)) {
            throw new ConfigException(String.format("Column config for '%s' is duplicated at 'expanded_columns' option", columnName));
        }
        columnList.add(columnName);
    }
}
 
开发者ID:civitaspo,项目名称:embulk-filter-expand_json,代码行数:12,代码来源:ExpandJsonFilterPlugin.java

示例11: create

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
public static List<DateParser> create(GrokParserPlugin.PluginTask task) {
    switch (task.getTimestampParser().toLowerCase()) {
        case "ruby":
            TimestampParser[] ps = Timestamps.newTimestampColumnParsers(task, task.getColumns());
            return Arrays.stream(ps)
                    .map(parser -> (DateParser) (text) -> parser.parse(text))
                    .collect(Collectors.toList());
        case "epoch":
            return task.getColumns().getColumns().stream()
                    .map(x -> (DateParser) (text) -> Timestamp.ofEpochMilli(Long.parseLong(text)))
                    .collect(Collectors.toList());
        case "sdf":
        case "simpledateformat":
        default:
            SimpleDateFormat[] parsers = new SimpleDateFormat[task.getColumns().getColumnCount()];
            int i = 0;
            for (ColumnConfig column : task.getColumns().getColumns()) {
                if (column.getType() instanceof TimestampType) {
                    TimestampColumnOption option = column.getOption().loadConfig(TimestampColumnOption.class);
                    String format = convertToJavaDateFormat(option.getFormat().or("yyyy-MM-dd HH:MM:ss.SSS z"));
                    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.ENGLISH);
                    sdf.setTimeZone(option.getTimeZone().or(DateTimeZone.UTC).toTimeZone());
                    parsers[i] = sdf;
                }
                i++;
            }
            return Arrays.stream(parsers).map(parser ->
                    (DateParser) (String date) -> {
                        try {
                            return Timestamp.ofEpochMilli(parser.parse(date).getTime());
                        } catch (ParseException e) {
                            throw new GrokRecordValidateException(e);
                        }
                    }).collect(Collectors.toList());
    }
}
 
开发者ID:arielnetworks,项目名称:embulk-parser-grok,代码行数:37,代码来源:TimestampParserFactory.java

示例12: TableBuilder

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
public TableBuilder(String filePath, String fileFormat, List<ColumnConfig> columns, String rowKeyName, String columnPrefix)
{
    this.filePath = filePath;
    this.fileFormat = fileFormat;
    this.columns = columns;
    this.rowKeyName = rowKeyName;
    this.columnPrefix = columnPrefix;
}
 
开发者ID:civitaspo,项目名称:embulk-filter-join_file,代码行数:9,代码来源:TableBuilder.java

示例13: transaction

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
@Override
public void transaction(ConfigSource config, ParserPlugin.Control control)
{
    PluginTask task = config.loadConfig(PluginTask.class);
    ArrayList<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    final String columnName = task.getColumnName();

    columns.add(new ColumnConfig(columnName, STRING ,config));

    Schema schema = new SchemaConfig(columns).toSchema();
    control.run(task.dump(), schema);
}
 
开发者ID:sonots,项目名称:embulk-parser-none,代码行数:13,代码来源:NoneParserPlugin.java

示例14: getColumnConfig

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
@Override
public ColumnConfig getColumnConfig() {
    return new ColumnConfig("offset", this.type, "%d");
}
 
开发者ID:sasakitoa,项目名称:embulk-input-kafka,代码行数:5,代码来源:ColumnOffset.java

示例15: getColumnConfig

import org.embulk.spi.ColumnConfig; //导入依赖的package包/类
@Override
public ColumnConfig getColumnConfig() {
    return new ColumnConfig("timestamp", this.type, "%d");
}
 
开发者ID:sasakitoa,项目名称:embulk-input-kafka,代码行数:5,代码来源:ColumnTimestamp.java


注:本文中的org.embulk.spi.ColumnConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。