【发布时间】:2017-12-06 11:57:10
【问题描述】:
我正在尝试使用 influxdb-java API 将 oracle 数据插入到 influxdb。
我想编写一个通用代码,根据我的 SQL 查询输出字段将数据插入到 influx 中。
目前我正在使用 switch 并根据我从查询中获得的属性数量制作多个案例。 参考代码:
switch (columnLength) {
case 1:
sotPoint = Point.measurement(measurementName)
.time(System.currentTimeMillis(),TimeUnit.MILLISECONDS)
.tag("source", "SOT")
.tag(attributes[0],rsObj.getString(attributes[0]))
.addField("recordcount", 1)
.build();
break;
case 2:
sotPoint = Point.measurement(measurementName)
.time(System.currentTimeMillis(),TimeUnit.MILLISECONDS)
.tag("source", "SOT")
.tag(attributes[0],rsObj.getString(attributes[0]))
.tag(attributes[1],rsObj.getString(attributes[1]))
.addField("recordcount", 1)
.build();
break;
default: System.out.println("Invalid column length");
}
有没有办法单独动态创建标签字段,并在创建点时只在该点添加这些字段?
我使用的是influxdb-java API 2.2版本
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
<version>2.2</version>
</dependency>
【问题讨论】: