|
36 | 36 | import static com.facebook.presto.plugin.prometheus.PrometheusRecordCursor.getBlockFromMap;
|
37 | 37 | import static com.facebook.presto.plugin.prometheus.PrometheusRecordCursor.getMapFromBlock;
|
38 | 38 | import static com.facebook.presto.plugin.prometheus.TestPrometheusTable.TYPE_MANAGER;
|
| 39 | +import static com.google.common.collect.ImmutableMap.toImmutableMap; |
39 | 40 | import static java.time.Instant.ofEpochMilli;
|
40 | 41 | import static org.testng.Assert.assertEquals;
|
41 | 42 | import static org.testng.Assert.assertFalse;
|
@@ -64,27 +65,28 @@ public void testCursorSimple()
|
64 | 65 | List<PrometheusStandardizedRow> actual = new ArrayList<>();
|
65 | 66 | while (cursor.advanceNextPosition()) {
|
66 | 67 | actual.add(new PrometheusStandardizedRow(
|
67 |
| - (Block) cursor.getObject(0), |
| 68 | + getMapFromBlock(varcharMapType, (Block) cursor.getObject(0)).entrySet().stream() |
| 69 | + .collect(toImmutableMap(entry -> (String) entry.getKey(), entry -> (String) entry.getValue())), |
68 | 70 | ((Instant) cursor.getObject(1)),
|
69 | 71 | cursor.getDouble(2)));
|
70 | 72 | assertFalse(cursor.isNull(0));
|
71 | 73 | assertFalse(cursor.isNull(1));
|
72 | 74 | assertFalse(cursor.isNull(2));
|
73 | 75 | }
|
74 | 76 | List<PrometheusStandardizedRow> expected = ImmutableList.<PrometheusStandardizedRow>builder()
|
75 |
| - .add(new PrometheusStandardizedRow(getBlockFromMap(varcharMapType, |
76 |
| - ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")), ofEpochMilli(1565962969044L), 1.0)) |
77 |
| - .add(new PrometheusStandardizedRow(getBlockFromMap(varcharMapType, |
78 |
| - ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")), ofEpochMilli(1565962984045L), 1.0)) |
79 |
| - .add(new PrometheusStandardizedRow(getBlockFromMap(varcharMapType, |
80 |
| - ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")), ofEpochMilli(1565962999044L), 1.0)) |
81 |
| - .add(new PrometheusStandardizedRow(getBlockFromMap(varcharMapType, |
82 |
| - ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")), ofEpochMilli(1565963014044L), 1.0)) |
| 77 | + .add(new PrometheusStandardizedRow( |
| 78 | + ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus"), ofEpochMilli(1565962969044L), 1.0)) |
| 79 | + .add(new PrometheusStandardizedRow( |
| 80 | + ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus"), ofEpochMilli(1565962984045L), 1.0)) |
| 81 | + .add(new PrometheusStandardizedRow( |
| 82 | + ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus"), ofEpochMilli(1565962999044L), 1.0)) |
| 83 | + .add(new PrometheusStandardizedRow( |
| 84 | + ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus"), ofEpochMilli(1565963014044L), 1.0)) |
83 | 85 | .build();
|
84 | 86 | List<PairLike<PrometheusStandardizedRow, PrometheusStandardizedRow>> pairs = Streams.zip(actual.stream(), expected.stream(), PairLike::new)
|
85 | 87 | .collect(Collectors.toList());
|
86 | 88 | pairs.forEach(pair -> {
|
87 |
| - assertEquals(getMapFromBlock(varcharMapType, pair.getFirst().getLabels()), getMapFromBlock(varcharMapType, pair.getSecond().getLabels())); |
| 89 | + assertEquals(getMapFromBlock(varcharMapType, getBlockFromMap(varcharMapType, pair.getFirst().getLabels())), getMapFromBlock(varcharMapType, getBlockFromMap(varcharMapType, pair.getSecond().getLabels()))); |
88 | 90 | assertEquals(pair.getFirst().getTimestamp(), pair.getSecond().getTimestamp());
|
89 | 91 | assertEquals(pair.getFirst().getValue(), pair.getSecond().getValue());
|
90 | 92 | });
|
|
0 commit comments