Skip to content

Commit ef281c3

Browse files
committed
Temporary test
1 parent 51b5d84 commit ef281c3

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

core/trino-spi/pom.xml

+9
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@
274274
<annotation>@com.fasterxml.jackson.annotation.JsonValue</annotation>
275275
<justification>On-the-wire representation shouldn't rely on the Jackson format</justification>
276276
</item>
277+
<item>
278+
<ignore>true</ignore>
279+
<code>java.method.visibilityIncreased</code>
280+
<old>method long[] io.trino.spi.block.LongArrayBlock::getRawValues()</old>
281+
<new>method long[] io.trino.spi.block.LongArrayBlock::getRawValues()</new>
282+
<oldVisibility>package</oldVisibility>
283+
<newVisibility>public</newVisibility>
284+
<justification>Just a test</justification>
285+
</item>
277286
</differences>
278287
</revapi.differences>
279288
</analysisConfiguration>

core/trino-spi/src/main/java/io/trino/spi/block/LongArrayBlock.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ int getRawValuesOffset()
235235
return arrayOffset;
236236
}
237237

238-
long[] getRawValues()
238+
public long[] getRawValues()
239239
{
240240
return values;
241241
}

testing/trino-tests/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
<scope>runtime</scope>
8686
</dependency>
8787

88+
<dependency>
89+
<groupId>io.airlift</groupId>
90+
<artifactId>slice</artifactId>
91+
<scope>runtime</scope>
92+
</dependency>
93+
8894
<dependency>
8995
<groupId>io.airlift</groupId>
9096
<artifactId>units</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package io.trino.tests.tpch;
15+
16+
import com.google.common.collect.ImmutableList;
17+
import io.airlift.slice.Slice;
18+
import io.airlift.slice.Slices;
19+
import io.airlift.units.DataSize;
20+
import io.trino.plugin.tpch.DecimalTypeMapping;
21+
import io.trino.plugin.tpch.TpchTables;
22+
import io.trino.spi.Page;
23+
import io.trino.spi.block.IntArrayBlock;
24+
import io.trino.spi.block.LongArrayBlock;
25+
import io.trino.spi.block.vstream.IntStreamVByte;
26+
import io.trino.spi.block.vstream.LongStreamVByte;
27+
28+
import java.util.List;
29+
30+
import static io.airlift.slice.SizeOf.SIZE_OF_INT;
31+
32+
public class TestTpchDataSize
33+
{
34+
private TestTpchDataSize() {}
35+
36+
public static void main(String[] args)
37+
{
38+
List<Page> pages = ImmutableList.copyOf(TpchTables.getTablePages("lineitem", 3, DecimalTypeMapping.DECIMAL));
39+
40+
int totalSize = 0;
41+
int encodedTotalSize = 0;
42+
43+
for (Page page : pages) {
44+
for (int i = 0; i < page.getChannelCount(); i++) {
45+
if (page.getBlock(i) instanceof LongArrayBlock longArrayBlock) {
46+
totalSize += longArrayBlock.getRawValues().length * SIZE_OF_INT;
47+
//System.out.println("block[" + i + "] size is " + longArrayBlock.getRawValues().length * SIZE_OF_INT);
48+
Slice buffer = Slices.allocate(LongStreamVByte.maxEncodedSize(longArrayBlock.getRawValues().length));
49+
50+
//System.out.println("Buffer size is " + buffer.length() + " for positions " + longArrayBlock.getRawValues().length);
51+
52+
int size = LongStreamVByte.writeLongs(buffer.getOutput(), longArrayBlock.getRawValues());
53+
//System.out.println("block[" + i + "] encoded size is " + size + " " + (size * 100.0f / (longArrayBlock.getRawValues().length * SIZE_OF_INT)) + "%");
54+
encodedTotalSize += size;
55+
}
56+
57+
if (page.getBlock(i) instanceof IntArrayBlock intArrayBlock) {
58+
totalSize += intArrayBlock.getRawValues().length * SIZE_OF_INT;
59+
//System.out.println("block[" + i + "] size is " + intArrayBlock.getRawValues().length * SIZE_OF_INT);
60+
Slice buffer = Slices.allocate(LongStreamVByte.maxEncodedSize(intArrayBlock.getRawValues().length));
61+
int size = IntStreamVByte.writeInts(buffer.getOutput(), intArrayBlock.getRawValues());
62+
//System.out.println("block[" + i + "] encoded size is " + size + " " + (size * 100.0f / (intArrayBlock.getRawValues().length * SIZE_OF_INT)) + "%");
63+
encodedTotalSize += size;
64+
}
65+
}
66+
}
67+
68+
System.out.println("Total size is " + DataSize.succinctBytes(totalSize));
69+
System.out.println("Total encoded size is " + DataSize.succinctBytes(encodedTotalSize));
70+
System.out.println("Total encoded size is " + (encodedTotalSize * 100.0f / totalSize) + "%");
71+
}
72+
}

0 commit comments

Comments
 (0)