Skip to content

Commit ccd4767

Browse files
committed
test: replace duplicated countRows(reader) helper with layout().rowCount()
Both ParquetImporterTest and ParquetImportIntegrationTest reimplemented the same helper — a full scan decoding every chunk just to sum rowCount(). VortexReader.layout().rowCount() already answers this directly from the footer metadata, no scan needed (CsvExporter already uses it this way for progress tracking).
1 parent 41b7cc3 commit ccd4767

2 files changed

Lines changed: 4 additions & 21 deletions

File tree

integration/src/test/java/io/github/dfa1/vortex/integration/ParquetImportIntegrationTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ class ParquetImportIntegrationTest {
3838

3939
private static final int EXPECTED_ROWS = 100;
4040

41-
private static long countRows(VortexReader reader) {
42-
var total = new java.util.concurrent.atomic.AtomicLong();
43-
try (ScanIterator iter = reader.scan(ScanOptions.all())) {
44-
iter.forEachRemaining(c -> total.addAndGet(c.rowCount()));
45-
}
46-
return total.get();
47-
}
48-
4941
private static long countParquetRows(Path path) throws Exception {
5042
long total = 0;
5143
try (ParquetFileReader parquet = ParquetFileReader.open(InputFile.of(path));
@@ -106,7 +98,7 @@ void rowCountAndColumnNamesMatch(@TempDir Path tmp) throws Exception {
10698
DType.Struct schema = (DType.Struct) reader.dtype();
10799
assertThat(schema.fieldNames().stream().map(io.github.dfa1.vortex.core.model.ColumnName::value).toList()).containsExactlyElementsOf(parquetColumns);
108100

109-
long vortexRows = countRows(reader);
101+
long vortexRows = reader.layout().rowCount();
110102
assertThat(vortexRows).isEqualTo(EXPECTED_ROWS);
111103
}
112104
}
@@ -210,7 +202,7 @@ void parquetAndVortexRowCountsAreEqual(@TempDir Path tmp) throws Exception {
210202
long parquetRows = countParquetRows(parquetFile);
211203
long vortexRows;
212204
try (VortexReader reader = VortexReader.open(vortexFile)) {
213-
vortexRows = countRows(reader);
205+
vortexRows = reader.layout().rowCount();
214206
}
215207
assertThat(vortexRows).isEqualTo(parquetRows);
216208
}

parquet/src/test/java/io/github/dfa1/vortex/parquet/ParquetImporterTest.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import java.nio.file.Path;
2525
import java.util.List;
26-
import java.util.concurrent.atomic.AtomicLong;
2726

2827
import static org.assertj.core.api.Assertions.assertThat;
2928
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -198,7 +197,7 @@ void importsFixture_schemaAndRowCount(@TempDir Path tmp) throws Exception {
198197
assertThat(reader.dtype()).isInstanceOf(DType.Struct.class);
199198
DType.Struct schema = (DType.Struct) reader.dtype();
200199
assertThat(schema.fieldNames()).contains(ColumnName.of("c_customer_sk"), ColumnName.of("c_first_name"));
201-
assertThat(countRows(reader)).isEqualTo(100L);
200+
assertThat(reader.layout().rowCount()).isEqualTo(100L);
202201
}
203202
}
204203

@@ -244,7 +243,7 @@ void projection_importsOnlyRequestedColumns(@TempDir Path tmp) throws Exception
244243
try (VortexReader reader = VortexReader.open(vortex)) {
245244
DType.Struct schema = (DType.Struct) reader.dtype();
246245
assertThat(schema.fieldNames()).containsExactly(ColumnName.of("c_customer_sk"));
247-
assertThat(countRows(reader)).isEqualTo(100L);
246+
assertThat(reader.layout().rowCount()).isEqualTo(100L);
248247
}
249248
}
250249

@@ -290,12 +289,4 @@ private static Path fixture() throws Exception {
290289
return Path.of(ParquetImporterTest.class
291290
.getResource("/fixtures/delta_encoding_optional_column.parquet").toURI());
292291
}
293-
294-
private static long countRows(VortexReader reader) {
295-
AtomicLong total = new AtomicLong();
296-
try (ScanIterator iter = reader.scan(ScanOptions.all())) {
297-
iter.forEachRemaining(c -> total.addAndGet(c.rowCount()));
298-
}
299-
return total.get();
300-
}
301292
}

0 commit comments

Comments
 (0)