|
7 | 7 |
|
8 | 8 | public class Query extends DriverBenchmark { |
9 | 9 | @Benchmark |
10 | | - public void selectDateTime32Rows(Blackhole blackhole, DriverState state) throws Throwable { |
| 10 | + public void selectArrayOfInts(Blackhole blackhole, DriverState state) throws Throwable { |
11 | 11 | int num = state.getRandomNumber(); |
12 | 12 | int rows = state.getSampleSize() + num; |
| 13 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getArray(i))); |
13 | 14 | try (Statement stmt = executeQuery(state, |
14 | | - "select toDateTime32(1613826920 + number) as d from system.numbers limit ?", rows)) { |
| 15 | + "select range(100, number % 600) as v from numbers(?)", rows)) { |
15 | 16 | ResultSet rs = stmt.getResultSet(); |
16 | 17 | while (rs.next()) { |
17 | | - blackhole.consume(rs.getTimestamp(1)); |
| 18 | + func.consume(blackhole, rs, 1); |
18 | 19 | } |
19 | 20 | } |
20 | 21 | } |
21 | 22 |
|
22 | 23 | @Benchmark |
23 | | - public void selectDateTime64Rows(Blackhole blackhole, DriverState state) throws Throwable { |
| 24 | + public void selectMapOfInts(Blackhole blackhole, DriverState state) throws Throwable { |
24 | 25 | int num = state.getRandomNumber(); |
25 | 26 | int rows = state.getSampleSize() + num; |
| 27 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getObject(i))); |
26 | 28 | try (Statement stmt = executeQuery(state, |
27 | | - "select toDateTime64(1613826920 + number / 1000000000, 9) as d from system.numbers limit ?", rows)) { |
| 29 | + "select cast((arrayMap(x->x+1000, range(1, number % 100)), arrayMap(x->x+10000, range(1, number %100))) as Map(Int32, Int32)) as v from numbers(?)", |
| 30 | + rows)) { |
28 | 31 | ResultSet rs = stmt.getResultSet(); |
29 | 32 | while (rs.next()) { |
30 | | - blackhole.consume(rs.getTimestamp(1)); |
| 33 | + func.consume(blackhole, rs, 1); |
31 | 34 | } |
32 | 35 | } |
33 | 36 | } |
34 | 37 |
|
35 | 38 | @Benchmark |
36 | | - public void selectDateTime64ObjectRows(Blackhole blackhole, DriverState state) throws Throwable { |
| 39 | + public void selectTupleOfInts(Blackhole blackhole, DriverState state) throws Throwable { |
37 | 40 | int num = state.getRandomNumber(); |
38 | 41 | int rows = state.getSampleSize() + num; |
| 42 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getArray(i))); |
39 | 43 | try (Statement stmt = executeQuery(state, |
40 | | - "select toDateTime64(1613826920 + number / 1000000000, 9) as d from system.numbers limit ?", rows)) { |
| 44 | + "select tuple(range(100, number % 600)) as v from numbers(?)", rows)) { |
41 | 45 | ResultSet rs = stmt.getResultSet(); |
42 | 46 | while (rs.next()) { |
43 | | - blackhole.consume(rs.getObject(1)); |
| 47 | + func.consume(blackhole, rs, 1); |
44 | 48 | } |
45 | 49 | } |
46 | 50 | } |
47 | 51 |
|
48 | 52 | @Benchmark |
49 | | - public void selectInt32Rows(Blackhole blackhole, DriverState state) throws Throwable { |
| 53 | + public void selectDateTime32(Blackhole blackhole, DriverState state) throws Throwable { |
50 | 54 | int num = state.getRandomNumber(); |
51 | 55 | int rows = state.getSampleSize() + num; |
52 | | - try (Statement stmt = executeQuery(state, "select toInt32(number) from system.numbers limit ?", rows)) { |
| 56 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getTimestamp(i))); |
| 57 | + try (Statement stmt = executeQuery(state, |
| 58 | + "select toDateTime32(1613826920 + number) as v from numbers(?)", rows)) { |
| 59 | + ResultSet rs = stmt.getResultSet(); |
| 60 | + while (rs.next()) { |
| 61 | + func.consume(blackhole, rs, 1); |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + @Benchmark |
| 67 | + public void selectDateTime64(Blackhole blackhole, DriverState state) throws Throwable { |
| 68 | + int num = state.getRandomNumber(); |
| 69 | + int rows = state.getSampleSize() + num; |
| 70 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getTimestamp(i))); |
| 71 | + try (Statement stmt = executeQuery(state, |
| 72 | + "select toDateTime64(1613826920 + number / 1000000000, 9) as v from numbers(?)", rows)) { |
| 73 | + ResultSet rs = stmt.getResultSet(); |
| 74 | + while (rs.next()) { |
| 75 | + func.consume(blackhole, rs, 1); |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + @Benchmark |
| 81 | + public void selectInt8(Blackhole blackhole, DriverState state) throws Throwable { |
| 82 | + int num = state.getRandomNumber(); |
| 83 | + int rows = state.getSampleSize() + num; |
| 84 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getByte(i))); |
| 85 | + try (Statement stmt = executeQuery(state, "select toInt8(number % 256) as v from numbers(?)", rows)) { |
| 86 | + ResultSet rs = stmt.getResultSet(); |
| 87 | + while (rs.next()) { |
| 88 | + func.consume(blackhole, rs, 1); |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + @Benchmark |
| 94 | + public void selectUInt8(Blackhole blackhole, DriverState state) throws Throwable { |
| 95 | + int num = state.getRandomNumber(); |
| 96 | + int rows = state.getSampleSize() + num; |
| 97 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getShort(i))); |
| 98 | + try (Statement stmt = executeQuery(state, "select toUInt8(number % 256) as v from numbers(?)", rows)) { |
| 99 | + ResultSet rs = stmt.getResultSet(); |
| 100 | + while (rs.next()) { |
| 101 | + func.consume(blackhole, rs, 1); |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + @Benchmark |
| 107 | + public void selectInt32(Blackhole blackhole, DriverState state) throws Throwable { |
| 108 | + int num = state.getRandomNumber(); |
| 109 | + int rows = state.getSampleSize() + num; |
| 110 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getInt(i))); |
| 111 | + try (Statement stmt = executeQuery(state, "select toInt32(number) as v from numbers(?)", rows)) { |
| 112 | + ResultSet rs = stmt.getResultSet(); |
| 113 | + while (rs.next()) { |
| 114 | + func.consume(blackhole, rs, 1); |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + @Benchmark |
| 120 | + public void selectString(Blackhole blackhole, DriverState state) throws Throwable { |
| 121 | + int num = state.getRandomNumber(); |
| 122 | + int rows = state.getSampleSize() + num; |
| 123 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getString(i))); |
| 124 | + try (Statement stmt = executeQuery(state, "select toString(number/3) as v from numbers(?)", rows)) { |
53 | 125 | ResultSet rs = stmt.getResultSet(); |
54 | 126 | while (rs.next()) { |
55 | | - blackhole.consume(rs.getInt(1)); |
| 127 | + func.consume(blackhole, rs, 1); |
56 | 128 | } |
57 | 129 | } |
58 | 130 | } |
59 | 131 |
|
60 | 132 | @Benchmark |
61 | | - public void selectStringRows(Blackhole blackhole, DriverState state) throws Throwable { |
| 133 | + public void selectUInt64(Blackhole blackhole, DriverState state) throws Throwable { |
62 | 134 | int num = state.getRandomNumber(); |
63 | 135 | int rows = state.getSampleSize() + num; |
64 | | - try (Statement stmt = executeQuery(state, "select toString(number) as s from system.numbers limit ?", rows)) { |
| 136 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getLong(i))); |
| 137 | + try (Statement stmt = executeQuery(state, "select number as v from numbers(?)", rows)) { |
65 | 138 | ResultSet rs = stmt.getResultSet(); |
66 | 139 | while (rs.next()) { |
67 | | - blackhole.consume(rs.getString(1)); |
| 140 | + func.consume(blackhole, rs, 1); |
68 | 141 | } |
69 | 142 | } |
70 | 143 | } |
71 | 144 |
|
72 | 145 | @Benchmark |
73 | | - public void selectUInt64Rows(Blackhole blackhole, DriverState state) throws Throwable { |
| 146 | + public void selectDecimal64(Blackhole blackhole, DriverState state) throws Throwable { |
74 | 147 | int num = state.getRandomNumber(); |
75 | 148 | int rows = state.getSampleSize() + num; |
76 | | - try (Statement stmt = executeQuery(state, "select * from system.numbers limit ?", rows)) { |
| 149 | + ConsumeValueFunction func = state.getConsumeFunction((b, r, i) -> b.consume(r.getBigDecimal(i))); |
| 150 | + try (Statement stmt = executeQuery(state, "select toDecimal64(number + number / 10000, 4) as v from numbers(?)", |
| 151 | + rows)) { |
77 | 152 | ResultSet rs = stmt.getResultSet(); |
78 | 153 | while (rs.next()) { |
79 | | - blackhole.consume(rs.getLong(1)); |
| 154 | + func.consume(blackhole, rs, 1); |
80 | 155 | } |
81 | 156 | } |
82 | 157 | } |
|
0 commit comments