Skip to content

Commit e058e68

Browse files
committed
fixup: review comments
1 parent 2b2a035 commit e058e68

File tree

36 files changed

+314
-225
lines changed

36 files changed

+314
-225
lines changed

core/trino-server/src/main/provisio/trino.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@
157157
</artifact>
158158
</artifactSet>
159159

160+
<artifactSet to="plugin/lance">
161+
<artifact id="${project.groupId}:trino-lance:zip:${project.version}">
162+
<unpack />
163+
</artifact>
164+
</artifactSet>
165+
160166
<artifactSet to="plugin/loki">
161167
<artifact id="${project.groupId}:trino-loki:zip:${project.version}">
162168
<unpack />

lib/trino-lance-file/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<description>Trino - Lance file format</description>
1414

1515
<properties>
16+
<air.compiler.fail-warnings>true</air.compiler.fail-warnings>
1617
<air.test.jvm.additional-arguments>${air.test.jvm.additional-arguments.default}
1718
--add-opens=java.base/java.nio=ALL-UNNAMED
1819
--sun-misc-unsafe-memory-access=allow</air.test.jvm.additional-arguments>
@@ -47,6 +48,7 @@
4748
<dependency>
4849
<groupId>io.github.luohao</groupId>
4950
<artifactId>fastlanes-java</artifactId>
51+
<version>1</version>
5052
</dependency>
5153

5254
<dependency>

lib/trino-lance-file/src/main/java/io/trino/lance/file/LanceReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public LanceReader(LanceDataSource dataSource,
124124
entry -> metadata.get(entry.getValue())));
125125

126126
this.columnReaders = fields.stream()
127-
.filter(field -> columnIds.contains(field.getId()))
127+
.filter(field -> columnIds.contains(field.id()))
128128
.map(field ->
129129
ColumnReader.createColumnReader(
130130
dataSource,
@@ -149,7 +149,7 @@ public static List<Field> toFields(List<build.buf.gen.lance.file.Field> fieldsPr
149149
}
150150
List<Field> fields = new ArrayList<>();
151151
for (Map.Entry<Integer, Field> entry : fieldMap.entrySet()) {
152-
int parentId = fieldMap.get(entry.getKey()).getParentId();
152+
int parentId = fieldMap.get(entry.getKey()).parentId();
153153
Field field = entry.getValue();
154154
if (parentId == -1) {
155155
fields.add(field);
@@ -299,7 +299,7 @@ public Block getBlock(int channel)
299299

300300
Block block = blocks[channel];
301301
if (block == null) {
302-
block = columnReaders[channel].read().getBlock();
302+
block = columnReaders[channel].read().block();
303303
block = selectedPositions.apply(block);
304304
}
305305
blocks[channel] = block;

lib/trino-lance-file/src/main/java/io/trino/lance/file/v2/metadata/AllNullLayout.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@
1313
*/
1414
package io.trino.lance.file.v2.metadata;
1515

16-
import java.util.List;
16+
import com.google.common.collect.ImmutableList;
1717

18-
import static java.util.Objects.requireNonNull;
18+
import java.util.List;
1919

20-
public final class AllNullLayout
20+
public record AllNullLayout(List<RepDefLayer> layers)
2121
implements PageLayout
2222
{
23-
public final List<RepDefLayer> layers;
24-
2523
public AllNullLayout(List<RepDefLayer> layers)
2624
{
27-
this.layers = requireNonNull(layers, "layers is null");
25+
this.layers = ImmutableList.copyOf(layers);
2826
}
2927

3028
public static AllNullLayout fromProto(build.buf.gen.lance.encodings21.AllNullLayout proto)

lib/trino-lance-file/src/main/java/io/trino/lance/file/v2/metadata/ColumnMetadata.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,14 @@
2323

2424
import static com.google.common.base.Preconditions.checkArgument;
2525
import static com.google.common.collect.ImmutableList.toImmutableList;
26-
import static java.util.Objects.requireNonNull;
2726

28-
public class ColumnMetadata
27+
public record ColumnMetadata(int index, List<PageMetadata> pages, List<DiskRange> bufferOffsets)
2928
{
30-
private final int index;
31-
private final List<PageMetadata> pages;
32-
private final List<DiskRange> bufferOffsets;
33-
3429
public ColumnMetadata(int index, List<PageMetadata> pages, List<DiskRange> bufferOffsets)
3530
{
3631
this.index = index;
37-
this.pages = requireNonNull(pages, "pages is null");
38-
this.bufferOffsets = requireNonNull(bufferOffsets, "bufferOffsets is null");
32+
this.pages = ImmutableList.copyOf(pages);
33+
this.bufferOffsets = ImmutableList.copyOf(bufferOffsets);
3934
}
4035

4136
public static ColumnMetadata from(int columnIndex, Slice data)
@@ -88,19 +83,4 @@ private static PageLayout getPageLayout(build.buf.gen.lance.file.v2.ColumnMetada
8883
default -> throw new UnsupportedOperationException("Invalid encoding: " + encoding);
8984
};
9085
}
91-
92-
public int getIndex()
93-
{
94-
return index;
95-
}
96-
97-
public List<PageMetadata> getPages()
98-
{
99-
return pages;
100-
}
101-
102-
public List<DiskRange> getBufferOffsets()
103-
{
104-
return bufferOffsets;
105-
}
10686
}

lib/trino-lance-file/src/main/java/io/trino/lance/file/v2/metadata/Field.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,8 @@
3939
import static io.trino.spi.type.VarcharType.VARCHAR;
4040
import static java.util.Objects.requireNonNull;
4141

42-
public class Field
42+
public record Field(String name, int id, int parentId, String logicalType, Map<String, String> metadata, boolean nullable, List<Field> children)
4343
{
44-
private final String name;
45-
private final int id;
46-
private final int parentId;
47-
private final String logicalType;
48-
private final Map<String, String> metadata;
49-
private final boolean nullable;
50-
private final List<Field> children;
51-
5244
@JsonCreator
5345
public Field(
5446
@JsonProperty("name") String name,
@@ -89,44 +81,51 @@ public void addChild(Field child)
8981
this.children.add(child);
9082
}
9183

84+
@Override
9285
@JsonProperty
93-
public int getId()
86+
public int id()
9487
{
9588
return id;
9689
}
9790

91+
@Override
9892
@JsonProperty
99-
public String getName()
93+
public String name()
10094
{
10195
return name;
10296
}
10397

98+
@Override
10499
@JsonProperty
105-
public int getParentId()
100+
public int parentId()
106101
{
107102
return parentId;
108103
}
109104

105+
@Override
110106
@JsonProperty
111-
public String getLogicalType()
107+
public String logicalType()
112108
{
113109
return logicalType;
114110
}
115111

112+
@Override
116113
@JsonProperty
117-
public Map<String, String> getMetadata()
114+
public Map<String, String> metadata()
118115
{
119116
return metadata;
120117
}
121118

119+
@Override
122120
@JsonProperty
123-
public boolean isNullable()
121+
public boolean nullable()
124122
{
125123
return nullable;
126124
}
127125

126+
@Override
128127
@JsonProperty
129-
public List<Field> getChildren()
128+
public List<Field> children()
130129
{
131130
return children;
132131
}

lib/trino-lance-file/src/main/java/io/trino/lance/file/v2/metadata/FullZipLayout.java

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,10 @@
1717

1818
import static java.util.Objects.requireNonNull;
1919

20-
public final class FullZipLayout
20+
public record FullZipLayout(int numRepBits, int numDeflBits, io.trino.lance.file.v2.metadata.FullZipLayout.Block block, int numItems, int numVisibleItems,
21+
List<RepDefLayer> repDefLayers)
2122
implements PageLayout
2223
{
23-
private final int numRepBits;
24-
private final int numDeflBits;
25-
private final Block block;
26-
private final int numItems;
27-
private final int numVisibleItems;
28-
private final List<RepDefLayer> repDefLayers;
29-
3024
public FullZipLayout(int numRepBits,
3125
int numDeflBits,
3226
Block block,
@@ -58,36 +52,6 @@ public static FullZipLayout fromProto(build.buf.gen.lance.encodings21.FullZipLay
5852
RepDefLayer.fromProtoList(proto.getLayersList()));
5953
}
6054

61-
public int getNumRepBits()
62-
{
63-
return numRepBits;
64-
}
65-
66-
public int getNumDeflBits()
67-
{
68-
return numDeflBits;
69-
}
70-
71-
public Block getBlock()
72-
{
73-
return block;
74-
}
75-
76-
public int getNumItems()
77-
{
78-
return numItems;
79-
}
80-
81-
public int getNumVisibleItems()
82-
{
83-
return numVisibleItems;
84-
}
85-
86-
public List<RepDefLayer> getRepDefLayers()
87-
{
88-
return repDefLayers;
89-
}
90-
9155
public sealed interface Block
9256
permits
9357
Block.FixedWidthBlock,

lib/trino-lance-file/src/main/java/io/trino/lance/file/v2/metadata/TypeUtil.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public T primitive(Field primitive)
4747

4848
public static <T> T visit(Field field, FieldVisitor<T> visitor)
4949
{
50-
return switch (LogicalType.from(field.getLogicalType())) {
50+
return switch (LogicalType.from(field.logicalType())) {
5151
case LogicalType.Int8Type _,
5252
LogicalType.Int16Type _,
5353
LogicalType.Int32Type _,
@@ -58,15 +58,15 @@ public static <T> T visit(Field field, FieldVisitor<T> visitor)
5858
LogicalType.BinaryType _,
5959
LogicalType.DateType _ -> visitor.primitive(field);
6060
case LogicalType.StructType _ -> {
61-
List<T> results = new ArrayList<>(field.getChildren().size());
62-
for (Field child : field.getChildren()) {
61+
List<T> results = new ArrayList<>(field.children().size());
62+
for (Field child : field.children()) {
6363
results.add(visit(child, visitor));
6464
}
6565
yield visitor.struct(field, results);
6666
}
6767
case LogicalType.ListType _ -> {
68-
verify(field.getChildren().size() == 1);
69-
T result = visit(field.getChildren().get(0), visitor);
68+
verify(field.children().size() == 1);
69+
T result = visit(field.children().get(0), visitor);
7070
yield visitor.list(field, result);
7171
}
7272
case LogicalType.FixedSizeListType _ -> throw new UnsupportedOperationException("FIXED LIST TYPES not yet supported");
@@ -87,7 +87,7 @@ public static class FieldIdToColumnIndexVisitor
8787
@Override
8888
public Map<Integer, Integer> primitive(Field primitive)
8989
{
90-
return ImmutableMap.of(primitive.getId(), current++);
90+
return ImmutableMap.of(primitive.id(), current++);
9191
}
9292

9393
@Override

lib/trino-lance-file/src/main/java/io/trino/lance/file/v2/reader/ColumnReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static ColumnReader createColumnReader(LanceDataSource dataSource,
3030
List<Range> readRanges,
3131
AggregatedMemoryContext memoryContext)
3232
{
33-
return switch (LogicalType.from(field.getLogicalType())) {
33+
return switch (LogicalType.from(field.logicalType())) {
3434
case LogicalType.Int8Type _,
3535
LogicalType.Int16Type _,
3636
LogicalType.Int32Type _,
@@ -39,10 +39,10 @@ static ColumnReader createColumnReader(LanceDataSource dataSource,
3939
LogicalType.DoubleType _,
4040
LogicalType.StringType _,
4141
LogicalType.BinaryType _,
42-
LogicalType.DateType _ -> new PrimitiveColumnReader(dataSource, field, columnMetadata.get(field.getId()), readRanges, memoryContext);
42+
LogicalType.DateType _ -> new PrimitiveColumnReader(dataSource, field, columnMetadata.get(field.id()), readRanges, memoryContext);
4343
case LogicalType.ListType _ -> new ListColumnReader(dataSource, field, columnMetadata, readRanges, memoryContext);
4444
case LogicalType.StructType _ -> new StructColumnReader(dataSource, field, columnMetadata, readRanges, memoryContext);
45-
default -> throw new RuntimeException("Unsupported logical type: " + field.getLogicalType());
45+
default -> throw new RuntimeException("Unsupported logical type: " + field.logicalType());
4646
};
4747
}
4848

lib/trino-lance-file/src/main/java/io/trino/lance/file/v2/reader/DecodedPage.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,11 @@
1717

1818
import static java.util.Objects.requireNonNull;
1919

20-
public class DecodedPage
20+
public record DecodedPage(Block block, RepetitionDefinitionUnraveler unraveler)
2121
{
22-
private final Block block;
23-
private final RepetitionDefinitionUnraveler unraveler;
24-
2522
public DecodedPage(Block block, RepetitionDefinitionUnraveler unraveler)
2623
{
2724
this.block = requireNonNull(block, "block is null");
2825
this.unraveler = requireNonNull(unraveler, "unraveler is null");
2926
}
30-
31-
public Block getBlock()
32-
{
33-
return block;
34-
}
35-
36-
public RepetitionDefinitionUnraveler getUnraveler()
37-
{
38-
return unraveler;
39-
}
4027
}

0 commit comments

Comments
 (0)