influxdata / influxdata/influxdb-client-java

About the failure of the query method-----query(@Nonnull String var1, @Nonnull Class<M> var2)

オープン
#598 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
477
フォーク
129
PR マージ指標
30日以内にマージされた PR はありません

説明

__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:__
```xml
3.1.0
17
UTF-8

com.influxdb
influxdb-client-java
6.9.0


com.influxdb
flux-dsl
6.9.0

```
__The model:__
```java

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")//influxDB注解
public class Stat {
@Column
private String intr;
@Column
private long ctxt;
@Column
private long btime;
@Column
private long processes;
@Column
private long procs_running;
@Column
private String procs_blocked;
@Column
private long softirq;
@Column(timestamp = true)
Instant time;
}

```
__The code:__
```java
import com.cabin.empty.influxDB.Stat;
import com.cabin.influxDB.util.InfluxDBTemplate;
import com.cabin.utils.dateUtil.DateUtil;
import com.influxdb.client.InfluxDBClient;
import com.influxdb.query.FluxTable;
import com.influxdb.query.dsl.Flux;
import com.influxdb.query.dsl.functions.restriction.Restrictions;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.Duration;
import java.time.Instant;
import java.util.List;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
public class InfluxDBTest {
@Resource(name = "influxByToken")
private InfluxDBClient client;
@Resource(name = "InfluxDBTemplate")
private InfluxDBTemplate template;

@Test
void testAPI() {
String bucket = "bucket";
String measurement = "Stat";
Instant stop = DateUtil.getNowInstant();
Instant start = stop.minus(Duration.ofSeconds(1));

Flux statFlux = Flux.from(bucket)
.range(start, stop)
.filter(Restrictions.and(
Restrictions.measurement().equal(measurement)));

List queryList = client.getQueryApi().query(statFlux.toString(), Stat.class);
queryList.forEach(l -> {
System.out.println(l.toString());
});

List query = client.getQueryApi().query(statFlux.toString());
query.forEach(l -> {
l.getRecords()
.forEach(r -> System.out.println(r.getTime() + ": " + r.getValueByKey("_value")));
});
}

}

```
__The result:__
```
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
Stat(intr=null, ctxt=0, btime=0, processes=0, procs_running=0, procs_blocked=null, softirq=0, time=2023-07-04T06:36:23.005Z)
Stat(intr=null, ctxt=0, btime=0, processes=0, procs_running=0, procs_blocked=null, softirq=0, time=2023-07-04T06:36:23.005Z)
Stat(intr=null, ctxt=0, btime=0, processes=0, procs_running=0, procs_blocked=null, softirq=0, time=2023-07-04T06:36:23.005Z)
Stat(intr=null, ctxt=0, btime=0, processes=0, procs_running=0, procs_blocked=null, softirq=0, time=2023-07-04T06:36:23.005Z)
Stat(intr=null, ctxt=0, btime=0, processes=0, procs_running=0, procs_blocked=null, softirq=0, time=2023-07-04T06:36:23.005Z)
Stat(intr=null, ctxt=0, btime=0, processes=0, procs_running=0, procs_blocked=null, softirq=0, time=2023-07-04T06:36:23.005Z)
2023-07-04T06:36:23.005Z: 1685014131
2023-07-04T06:36:23.005Z: 15002073429
2023-07-04T06:36:23.005Z: 6140525
2023-07-04T06:36:23.005Z: 0
2023-07-04T06:36:23.005Z: 7
2023-07-04T06:36:23.005Z: 0
```
__The information:__
![image](https://github.com/influxdata/influxdb-client-java/assets/74083801/774f1419-70a1-42ec-9476-26a631eac3d4)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

QueryApi.query(String, Class) から始め、提供されている Stat モデルと Flux クエリを使用してマッピング結果を再現しながら、その動作を query(String) と比較します。クラスベースのクエリが、raw FluxTable レコードに示されているフィールド値を設定済みの状態で返せば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, spring-boot
領域
databases
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。