Skip to content

Commit c8ddfb1

Browse files
committed
Address the review comments
1 parent ab7e7a2 commit c8ddfb1

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetWriteSupport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
*/
3333
public class GeoParquetWriteSupport extends WriteSupport<GeoParquetGroup> {
3434

35-
private RecordConsumer recordConsumer;
35+
private Configuration configuration;
3636
private final MessageType schema;
3737
private final GeoParquetMetadata metadata;
38+
private RecordConsumer recordConsumer;
3839
private final ObjectMapper objectMapper = new ObjectMapper();
3940

4041
/**

baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetWriter.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,48 @@ private Builder(Path file) {
4848
super(file);
4949
}
5050

51+
/**
52+
* Replace the message type with the specified one.
53+
*
54+
* @param type the message type
55+
* @return the builder
56+
*/
5157
public GeoParquetWriter.Builder withType(MessageType type) {
5258
this.type = type;
5359
return this;
5460
}
5561

62+
/**
63+
* Replace the metadata with the specified one.
64+
*
65+
* @param metadata the metadata
66+
* @return the builder
67+
*/
5668
public GeoParquetWriter.Builder withGeoParquetMetadata(GeoParquetMetadata metadata) {
5769
this.metadata = metadata;
5870
return this;
5971
}
6072

73+
/**
74+
* {@inheritDoc}
75+
*/
6176
@Override
6277
protected WriteSupport<GeoParquetGroup> getWriteSupport(Configuration conf) {
78+
// We don't need access to the hadoop configuration for now
6379
return getWriteSupport((ParquetConfiguration) null);
6480
}
6581

82+
/**
83+
* {@inheritDoc}
84+
*/
6685
@Override
6786
protected WriteSupport<GeoParquetGroup> getWriteSupport(ParquetConfiguration conf) {
6887
return new GeoParquetWriteSupport(type, metadata);
6988
}
7089

90+
/**
91+
* {@inheritDoc}
92+
*/
7193
@Override
7294
protected GeoParquetWriter.Builder self() {
7395
return this;

baremaps-geoparquet/src/test/java/org/apache/baremaps/geoparquet/GeoParquetWriterTest.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.IOException;
2424
import java.util.HashMap;
25+
import java.util.Iterator;
2526
import java.util.List;
2627
import java.util.Map;
2728
import org.apache.baremaps.geoparquet.GeoParquetMetadata.Column;
@@ -121,30 +122,33 @@ void testWriteAndReadGeoParquet() throws IOException {
121122

122123
@Test
123124
@Tag("integration")
124-
void copy() throws IOException {
125+
void copyGeoParquetData() throws IOException {
125126
Path geoParquet = new Path(TestFiles.GEOPARQUET.toUri());
126127

127128
Configuration conf = new Configuration();
128129
Path outputPath = new Path("target/test-output/geoparquet-copy.parquet");
129130

130131
try {
132+
// Write the GeoParquet file
131133
GeoParquetReader reader = new GeoParquetReader(geoParquet, null, conf);
132134
GeoParquetWriter.Builder builder = GeoParquetWriter.builder(outputPath);
133135
ParquetWriter<GeoParquetGroup> writer = builder.withType(reader.getParquetSchema())
134136
.withGeoParquetMetadata(reader.getGeoParquetMetadata()).build();
135-
reader.read().forEach(group -> {
136-
System.out.println(group);
137-
try {
138-
writer.write(group);
139-
} catch (IOException e) {
140-
e.printStackTrace();
141-
}
142-
});
143-
} catch (IOException e) {
144-
e.printStackTrace();
137+
Iterator<GeoParquetGroup> iterator = reader.read().iterator();
138+
while (iterator.hasNext()) {
139+
writer.write(iterator.next());
140+
}
141+
writer.close();
142+
143+
// Read the copied file
144+
GeoParquetReader copiedReader = new GeoParquetReader(outputPath, null, conf);
145+
assertEquals(5, copiedReader.read().count());
145146
} finally {
146147
outputPath.getFileSystem(conf).delete(outputPath, false);
147148
}
149+
150+
151+
148152
}
149153

150154
}

0 commit comments

Comments
 (0)