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


Java Column类代码示例

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


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

示例1: process

import org.apache.storm.jdbc.common.Column; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
   protected void process(Tuple tuple) {
       try {
           List<Column> columns = jdbcMapper.getColumns(tuple);
           List<List<Column>> columnLists = new ArrayList<List<Column>>();
           columnLists.add(columns);
           if(!StringUtils.isBlank(tableName)) {
               this.jdbcClient.insert(this.tableName, columnLists);
           } else {
               this.jdbcClient.executeInsertQuery(this.insertQuery, columnLists);
           }
           this.collector.ack(tuple);
       } catch (Exception e) {
           this.collector.reportError(e);
           this.collector.fail(tuple);
       }
   }
 
开发者ID:neur0nus,项目名称:storm-clickhouse,代码行数:19,代码来源:ClickhouseInsertBolt.java

示例2: buildBolt

import org.apache.storm.jdbc.common.Column; //导入依赖的package包/类
@Bean("wordCountToMySQLBolt")
    public JdbcInsertBolt buildBolt() {

        super.setId("wordCountToMySQLBolt");

        Map hikariConfigMap = Maps.newHashMap();
        hikariConfigMap.put("dataSourceClassName", mySQLProps.getDataSourceClassName());
        hikariConfigMap.put("dataSource.url", mySQLProps.getDataSourceUrl());
        hikariConfigMap.put("dataSource.user", mySQLProps.getDataSourceUser());
        hikariConfigMap.put("dataSource.password", mySQLProps.getDataSourcePassword());
        ConnectionProvider connectionProvider = new HikariCPConnectionProvider(hikariConfigMap);

        List<Column> columnSchema = Lists.newArrayList(
                new Column("targetDate", Types.DATE),
                new Column("word", java.sql.Types.VARCHAR),
                new Column("count", Types.BIGINT),
                new Column("count_0", Types.BIGINT)
        );
//        JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(tableName, connectionProvider);
        JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(columnSchema);
        JdbcInsertBolt insertBolt = new JdbcInsertBolt(connectionProvider, simpleJdbcMapper)
                .withInsertQuery(insertQuery)
                .withQueryTimeoutSecs(queryTimeoutSecs);
        return insertBolt;
    }
 
开发者ID:Paleozoic,项目名称:storm_spring_boot_demo,代码行数:26,代码来源:WordCountToMySQLBoltBuilder.java

示例3: getColumns

import org.apache.storm.jdbc.common.Column; //导入依赖的package包/类
@Override
public List<Column> getColumns(ITuple tuple) {
    StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    List<Column> res = new ArrayList<>();
    if (fieldsToColumns.isEmpty()) {
        initFieldsToColumns();
    }
    for(String field: fields) {
        Column<?> column = getColumn(field);
        String columnName = column.getColumnName();
        Integer columnSqlType = column.getSqlType();
        Object value = Util.getJavaType(columnSqlType).cast(event.get(field));
        res.add(new Column<>(columnName, value, columnSqlType));
    }
    return res;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:17,代码来源:StreamlineJdbcMapper.java

示例4: initializeColumns

import org.apache.storm.jdbc.common.Column; //导入依赖的package包/类
public void initializeColumns(Map<String, String> columnsTypeMap) {
	if (columnsTypeMap==null||columnsTypeMap.isEmpty()) throw new IllegalArgumentException("Columns and types map not specified");
	this.schemaColumns.clear();
	for (Entry<String, String> e:columnsTypeMap.entrySet()) {
		String colName = e.getKey();
		String colType = e.getValue();
		this.schemaColumns.add(new Column(colName, parseSlqType(colType)));
	}
}
 
开发者ID:neur0nus,项目名称:storm-clickhouse,代码行数:10,代码来源:JsonJdbcMapper.java

示例5: initFieldsToColumns

import org.apache.storm.jdbc.common.Column; //导入依赖的package包/类
private void initFieldsToColumns() {
    connectionProvider.prepare();
    JdbcClient client = new JdbcClient(connectionProvider, 30);
    for (Column<?> column: client.getColumnSchema(tableName)) {
        fieldsToColumns.put(column.getColumnName().toUpperCase(), column);
    }
    LOG.info("fieldsToColumns {}", fieldsToColumns);
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:9,代码来源:StreamlineJdbcMapper.java

示例6: getColumn

import org.apache.storm.jdbc.common.Column; //导入依赖的package包/类
private Column<?> getColumn(String fieldName) {
    Column<?> column = fieldsToColumns.get(fieldName.toUpperCase());
    if (column != null) {
        return column;
    }
    throw new IllegalArgumentException("Could not find database column: " + fieldName);
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:8,代码来源:StreamlineJdbcMapper.java

示例7: getColumns

import org.apache.storm.jdbc.common.Column; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<Column> getColumns(ITuple input) {
	try {
		String jsonString = input.getString(0);
		JsonObject jsonObject = parser.parse(jsonString).getAsJsonObject();
        List<Column> columns = new ArrayList<Column>();
        for(Column column : schemaColumns) {
            String columnName = column.getColumnName();
			JsonElement elem = jsonObject.get(columnName);
			if (elem==null) continue;
            Integer columnSqlType = column.getSqlType();
            switch (columnSqlType) {
			case Types.VARCHAR:
                String strValue = elem.getAsString();
                columns.add(new Column(columnName, strValue, columnSqlType));
				break;
			case Types.FLOAT:
                Float floatValue = elem.getAsFloat();
                columns.add(new Column(columnName, floatValue, columnSqlType));
				break;
			case Types.DOUBLE:
                Double doubleValue = elem.getAsDouble();
                columns.add(new Column(columnName, doubleValue, columnSqlType));
				break;
			case Types.DATE:
                Date dateValue = new Date(FMT_DATE.parseDateTime(elem.getAsString()).toDate().getTime());
                columns.add(new Column(columnName, dateValue, columnSqlType));
				break;
			case Types.TIMESTAMP:
                Timestamp timeValue = new Timestamp(elem.getAsLong());
                columns.add(new Column(columnName, timeValue, columnSqlType));
				break;
			case Types.SMALLINT:
                Short shortValue = elem.getAsShort();
                columns.add(new Column(columnName, shortValue, columnSqlType));
				break;
			case Types.INTEGER:
                Integer intValue = elem.getAsInt();
                columns.add(new Column(columnName, intValue, columnSqlType));
				break;
			case Types.BIGINT:
                Long longValue = elem.getAsLong();
                columns.add(new Column(columnName, longValue, columnSqlType));
				break;
			default:
                throw new RuntimeException("Unsupported java type in tuple " + Util.getJavaType(columnSqlType));
			}
        }
        return columns;
	} catch(Exception err) {
		throw new RuntimeException("JSON parsing error", err);
	}
}
 
开发者ID:neur0nus,项目名称:storm-clickhouse,代码行数:55,代码来源:JsonJdbcMapper.java


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