-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About the failure of the query method-----query(@Nonnull String var1, @Nonnull Class<M> var2) #598
Comments
I thought that the databases were all of type String, so I modified the accepted type, but it still didn't seem to be available package com.cabin.empty.influxDB;
import com.influxdb.annotations.Column;
import com.influxdb.annotations.Measurement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.Instant;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Measurement(name = "Stat")
public class Stat {
@Column
private String intr;
@Column
private String ctxt;
@Column
private String btime;
@Column
private String processes;
@Column
private String procs_running;
@Column
private String procs_blocked;
@Column
private String softirq;
@Column(timestamp = true)
Instant time;
} |
I can only read multiple times, and then copy each time, public List<CPUStatVo> getOneSecondCpu(String bucket,String[] measurement) {
Instant stop = DateUtil.getNowInstant();
Instant start = stop.minus(Duration.ofSeconds(1));
List<CPUStatVo> cpuStatVos = new ArrayList<>();
for (int i = 0; i < measurement.length; i++) {
InfluxBO bo = new InfluxBO();
Flux statFlux = Flux.from(bucket)
.range(start, stop)
.filter(Restrictions.and(
Restrictions.measurement().equal(measurement[i])));
bo.setFlux(statFlux);
List<FluxTable> query = influxDBTemplate.query(QueryType.Flux,bo);
CPUStatVo cpuStatVo = new CPUStatVo();
for (FluxTable fluxTable : query) {
List<FluxRecord> records = fluxTable.getRecords();
for (FluxRecord fluxRecord : records) {
Object key = fluxRecord.getValueByKey("_field");
Object value = fluxRecord.getValueByKey("_value");
if(key==null){
continue;
}
cpuStatVo.setProperty((String) key, value);
System.out.println(fluxRecord.getTime() + ": " + fluxRecord.getValueByKey("_value"));
}
}
cpuStatVos.add(cpuStatVo);
}
return cpuStatVos;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue:
There is a problem with the data when using this method-----client.getQueryApi().query(statFlux.toString(), Stat.class);
However, when using this method, the data is obtained normally-----client.getQueryApi().query(statFlux.toString());
This indicates that the database is working correctly, but there may be problems converting the data.
The following is the relevant information.
The dependency:
The model:
The code:
The result:
The information:
The text was updated successfully, but these errors were encountered: