Skip to content

Commit f87f114

Browse files
feat: add test for getMapFromVectorSchemaRoot function
1 parent 1b5601c commit f87f114

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/test/java/com/influxdb/v3/client/internal/VectorSchemaRootConverterTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public void testConverterWithMetaType() {
214214
Assertions.assertThat(diskFree.getClass()).isEqualTo(Long.class);
215215

216216
Double temperature = (Double) pointValues.getField("temperature");
217-
Assertions.assertThat(temperature).isEqualTo(100.8766f);
217+
Assertions.assertThat(temperature).isEqualTo(100.8766);
218218
Assertions.assertThat(temperature.getClass()).isEqualTo(Double.class);
219219

220220
String name = (String) pointValues.getField("name");
@@ -227,6 +227,21 @@ public void testConverterWithMetaType() {
227227
}
228228
}
229229

230+
@Test
231+
void testGetMapFromVectorSchemaRoot() {
232+
try (VectorSchemaRoot root = VectorSchemaRootUtils.generateVectorSchemaRoot()) {
233+
Map<String, Object> map = VectorSchemaRootConverter.INSTANCE.getMapFromVectorSchemaRoot(root, 0);
234+
235+
Assertions.assertThat(map).hasSize(7);
236+
Assertions.assertThat(map.get("measurement")).isEqualTo("host");
237+
Assertions.assertThat(map.get("mem_total")).isEqualTo(2048L);
238+
Assertions.assertThat(map.get("temperature")).isEqualTo(100.8766);
239+
Assertions.assertThat(map.get("isActive")).isEqualTo(true);
240+
Assertions.assertThat(map.get("name")).isEqualTo("intel");
241+
Assertions.assertThat(map.get("time")).isEqualTo(BigInteger.valueOf(123_456L * 1_000_000));
242+
}
243+
}
244+
230245
@Test
231246
void timestampWithoutMetadataAndFieldWithoutMetadata() {
232247
FieldType timeType = new FieldType(true, new ArrowType.Time(TimeUnit.MILLISECOND, 32), null);

src/test/java/com/influxdb/v3/client/internal/VectorSchemaRootUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static VectorSchemaRoot generateVectorSchemaRoot() {
118118

119119
Float8Vector floatVector = (Float8Vector) root.getVector("temperature");
120120
floatVector.allocateNew();
121-
floatVector.set(0, 100.8766f);
121+
floatVector.set(0, 100.8766);
122122

123123
VarCharVector stringVector = (VarCharVector) root.getVector("name");
124124
stringVector.allocateNew();

0 commit comments

Comments
 (0)