• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Column类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TagOptionSingleton类代码示例发布时间:2022-05-15
下一篇:
Java ProcessConsole类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap