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


Java Type类代码示例

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


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

示例1: configure

import org.embulk.spi.type.Type; //导入依赖的package包/类
private void configure(PluginTask task, Schema inputSchema)
{
    List<ColumnConfig> columns = task.getColumns();

    if (columns.size() < 2) {
        throw new ConfigException("\"columns\" should be specified 2~ columns.");
    }

    // throw if column type is not supported
    for (ColumnConfig columnConfig : columns) {
        String name = columnConfig.getName();
        Type type = inputSchema.lookupColumn(name).getType();

        if (type instanceof JsonType) {
            throw new ConfigException(String.format("casting to json is not available: \"%s\"", name));
        }
        if (type instanceof TimestampType) {
            throw new ConfigException(String.format("casting to timestamp is not available: \"%s\"", name));
        }
    }
}
 
开发者ID:toru-takahashi,项目名称:embulk-filter-concat,代码行数:22,代码来源:ConcatFilterPlugin.java

示例2: buildOutputSchema

import org.embulk.spi.type.Type; //导入依赖的package包/类
static Schema buildOutputSchema(PluginTask task, Schema inputSchema)
{
    Type jsonColumnType = jsonColumnType(task);
    String jsonColumnName = task.getJsonColumn().getName();

    Schema.Builder builder = Schema.builder();
    int found = 0;

    for (Column inputColumns : inputSchema.getColumns()) {
        if (jsonColumnName.equals(inputColumns.getName())) {
            builder.add(inputColumns.getName(), jsonColumnType);
            found = 1;
        }
        else {
            builder.add(inputColumns.getName(), inputColumns.getType());
        }
    }
    if (found == 0) {
        builder.add(jsonColumnName, jsonColumnType);
    }

    return builder.build();
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-filter-build_json,代码行数:24,代码来源:BuildJsonFilterPlugin.java

示例3: fromBoolean

import org.embulk.spi.type.Type; //导入依赖的package包/类
public Value fromBoolean(Type outputType, BooleanValue value)
{
    if (outputType instanceof BooleanType) {
        return value;
    }
    else if (outputType instanceof LongType) {
        return ValueFactory.newInteger(BooleanCast.asLong(value.getBoolean()));
    }
    else if (outputType instanceof DoubleType) {
        return ValueFactory.newFloat(BooleanCast.asDouble(value.getBoolean()));
    }
    else if (outputType instanceof StringType) {
        return ValueFactory.newString(BooleanCast.asString(value.getBoolean()));
    }
    else if (outputType instanceof JsonType) {
        return BooleanCast.asJson(value.getBoolean());
    }
    else {
        assert (false);
        return null;
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:23,代码来源:JsonCaster.java

示例4: fromLong

import org.embulk.spi.type.Type; //导入依赖的package包/类
public Value fromLong(Type outputType, IntegerValue value)
{
    if (outputType instanceof BooleanType) {
        return ValueFactory.newBoolean(LongCast.asBoolean(value.asLong()));
    }
    else if (outputType instanceof LongType) {
        return value;
    }
    else if (outputType instanceof DoubleType) {
        return ValueFactory.newFloat(LongCast.asDouble(value.asLong()));
    }
    else if (outputType instanceof StringType) {
        return ValueFactory.newString(LongCast.asString(value.asLong()));
    }
    else if (outputType instanceof JsonType) {
        return LongCast.asJson(value.asLong());
    }
    else {
        assert false;
        return null;
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:23,代码来源:JsonCaster.java

示例5: fromDouble

import org.embulk.spi.type.Type; //导入依赖的package包/类
public Value fromDouble(Type outputType, FloatValue value)
{
    if (outputType instanceof BooleanType) {
        return ValueFactory.newBoolean(DoubleCast.asBoolean(value.toDouble()));
    }
    else if (outputType instanceof LongType) {
        return ValueFactory.newInteger(DoubleCast.asLong(value.toDouble()));
    }
    else if (outputType instanceof DoubleType) {
        return value;
    }
    else if (outputType instanceof StringType) {
        return ValueFactory.newString(DoubleCast.asString(value.toDouble()));
    }
    else if (outputType instanceof JsonType) {
        return DoubleCast.asJson(value.toDouble());
    }
    else {
        assert (false);
        return null;
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:23,代码来源:JsonCaster.java

示例6: fromString

import org.embulk.spi.type.Type; //导入依赖的package包/类
public Value fromString(Type outputType, StringValue value)
{
    if (outputType instanceof BooleanType) {
        return ValueFactory.newBoolean(StringCast.asBoolean(value.asString()));
    }
    else if (outputType instanceof LongType) {
        return ValueFactory.newInteger(StringCast.asLong(value.asString()));
    }
    else if (outputType instanceof DoubleType) {
        return ValueFactory.newFloat(StringCast.asDouble(value.asString()));
    }
    else if (outputType instanceof StringType) {
        return value;
    }
    else if (outputType instanceof JsonType) {
        return StringCast.asJson(value.asString());
    }
    else {
        assert false;
        return null;
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:23,代码来源:JsonCaster.java

示例7: fromJson

import org.embulk.spi.type.Type; //导入依赖的package包/类
public Value fromJson(Type outputType, Value value)
{
    if (outputType instanceof BooleanType) {
        return ValueFactory.newBoolean(JsonCast.asBoolean(value));
    }
    else if (outputType instanceof LongType) {
        return ValueFactory.newInteger(JsonCast.asLong(value));
    }
    else if (outputType instanceof DoubleType) {
        return ValueFactory.newFloat(JsonCast.asDouble(value));
    }
    else if (outputType instanceof StringType) {
        return ValueFactory.newString(JsonCast.asString(value));
    }
    else if (outputType instanceof JsonType) {
        return value;
    }
    else {
        assert false;
        return null;
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:23,代码来源:JsonCaster.java

示例8: setFromBoolean

import org.embulk.spi.type.Type; //导入依赖的package包/类
public void setFromBoolean(Column outputColumn, boolean value)
{
    Type outputType = outputColumn.getType();
    if (outputType instanceof BooleanType) {
        pageBuilder.setBoolean(outputColumn, BooleanCast.asBoolean(value));
    }
    else if (outputType instanceof LongType) {
        pageBuilder.setLong(outputColumn, BooleanCast.asLong(value));
    }
    else if (outputType instanceof DoubleType) {
        pageBuilder.setDouble(outputColumn, BooleanCast.asDouble(value));
    }
    else if (outputType instanceof StringType) {
        pageBuilder.setString(outputColumn, BooleanCast.asString(value));
    }
    else if (outputType instanceof TimestampType) {
        pageBuilder.setTimestamp(outputColumn, BooleanCast.asTimestamp(value));
    }
    else if (outputType instanceof JsonType) {
        pageBuilder.setJson(outputColumn, BooleanCast.asJson(value));
    }
    else {
        assert (false);
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:26,代码来源:ColumnCaster.java

示例9: buildOuputSchema

import org.embulk.spi.type.Type; //导入依赖的package包/类
private Schema buildOuputSchema(final PluginTask task, final Schema inputSchema)
{
    List<ColumnConfig> columnConfigs = task.getColumns();
    ImmutableList.Builder<Column> builder = ImmutableList.builder();
    int i = 0;
    for (Column inputColumn : inputSchema.getColumns()) {
        String name = inputColumn.getName();
        Type   type = inputColumn.getType();
        ColumnConfig columnConfig = getColumnConfig(name, columnConfigs);
        if (columnConfig != null) {
            type = columnConfig.getType();
        }
        Column outputColumn = new Column(i++, name, type);
        builder.add(outputColumn);
    }
    return new Schema(builder.build());
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:18,代码来源:TypecastFilterPlugin.java

示例10: transaction

import org.embulk.spi.type.Type; //导入依赖的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

示例11: jsonColumnType

import org.embulk.spi.type.Type; //导入依赖的package包/类
static Type jsonColumnType(PluginTask task)
{
    Type columnType = task.getJsonColumn().getType().or(DEFAULT_COLUMN_TYPE);

    if (columnType != Types.JSON && columnType != Types.STRING) {
        throw new SchemaConfigException("columnType must be json or string");
    }
    return columnType;
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-filter-build_json,代码行数:10,代码来源:BuildJsonFilterPlugin.java

示例12: visitReferenceValue

import org.embulk.spi.type.Type; //导入依赖的package包/类
@Override
public Value visitReferenceValue(JSONParser.ReferenceValueContext ctx)
{
    JSONParser.ReferenceContext ref = ctx.reference();
    String key = ref.ID().getText();
    Column column = inputSchema.lookupColumn(key);
    Value value;
    Type column_type = column.getType();

    if (pageReader.isNull(column)){
        value =  ValueFactory.newNil();
    }
    else if (column_type == Types.BOOLEAN) {
        value = ValueFactory.newBoolean(pageReader.getBoolean(column));
    }
    else if (column_type == Types.DOUBLE) {
        value = ValueFactory.newFloat(pageReader.getDouble(column));
    }
    else if (column_type == Types.STRING) {
        value = ValueFactory.newString(pageReader.getString(column));
    }
    else if (column_type == Types.LONG) {
        value = ValueFactory.newInteger(pageReader.getLong(column));
    }
    else if (column_type == Types.JSON) {
        value = pageReader.getJson(column);
    }
    else {
        // Unsupported type;
        value = ValueFactory.newNil();
    }

    return value;
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-filter-build_json,代码行数:35,代码来源:BuildJsonParseTreeVisitor.java

示例13: buildJsonPathTypeMap

import org.embulk.spi.type.Type; //导入依赖的package包/类
private void buildJsonPathTypeMap()
{
    // json path => Type
    for (ColumnConfig columnConfig : task.getColumns()) {
        String name = columnConfig.getName();
        if (! PathCompiler.isProbablyJsonPath(name)) {
            continue;
        }
        Path compiledPath = PathCompiler.compile(name);
        Type type = columnConfig.getType();
        this.jsonPathTypeMap.put(compiledPath.toString(), type);
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:14,代码来源:JsonVisitor.java

示例14: buildToTimestampUnitMap

import org.embulk.spi.type.Type; //导入依赖的package包/类
private void buildToTimestampUnitMap()
{
    // columnName or jsonPath => TimestampUnit
    for (ColumnConfig columnConfig : task.getColumns()) {
        Type type = columnConfig.getType();
        if (type instanceof LongType || type instanceof DoubleType) {
            TimestampUnit unit = getToTimestampUnit(columnConfig, task);
            this.toTimestampUnitMap.put(columnConfig.getName(), unit);
        }
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-timestamp_format,代码行数:12,代码来源:ColumnCaster.java

示例15: getDefault

import org.embulk.spi.type.Type; //导入依赖的package包/类
static Value getDefault(PluginTask task, String name, Type type, ColumnConfig columnConfig)
{
    Object defaultValue = ColumnVisitorImpl.getDefault(task, name, type, columnConfig);
    if (defaultValue == null) {
        return ValueFactory.newNil();
    }
    if (type instanceof BooleanType) {
        return ValueFactory.newBoolean((Boolean) defaultValue);
    }
    else if (type instanceof LongType) {
        return ValueFactory.newInteger((Long) defaultValue);
    }
    else if (type instanceof DoubleType) {
        return ValueFactory.newFloat((Double) defaultValue);
    }
    else if (type instanceof StringType) {
        return ValueFactory.newString((String) defaultValue.toString());
    }
    else if (type instanceof JsonType) {
        return (Value) defaultValue;
    }
    else if (type instanceof TimestampType) {
        throw new ConfigException("type: timestamp is not available in json path");
    }
    else {
        throw new ConfigException(String.format("type: '%s' is not supported", type));
    }
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:29,代码来源:JsonVisitor.java


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