rdblue commented on code in PR #17159:
URL: https://github.com/apache/iceberg/pull/17159#discussion_r3599057093
##########
core/src/test/java/org/apache/iceberg/TestTrackedFileStruct.java:
##########
@@ -211,6 +217,103 @@ void copy() {
assertThat(copy.recordCount()).isEqualTo(50L);
assertThat(copy.fileSizeInBytes()).isEqualTo(512L);
assertThat(copy.specId()).isEqualTo(1);
+ assertThat(copy.contentStats()).isSameAs(CONTENT_STATS_COPY);
+ assertThat(copy.sortOrderId()).isEqualTo(5);
+ assertThat(copy.deletionVector()).isSameAs(DELETION_VECTOR_COPY);
+ assertThat(copy.manifestInfo()).isSameAs(MANIFEST_INFO_COPY);
+ assertThat(copy.keyMetadata()).isEqualTo(ByteBuffer.wrap(new byte[] {1, 2,
3}));
+ assertThat(copy.splitOffsets()).containsExactly(100L, 200L);
+ assertThat(copy.equalityIds()).containsExactly(1, 2, 3);
+ assertThat(copy.partition()).isSameAs(PARTITION_COPY);
+
+ // mutable fields are deep-copied, not shared with the original
+ assertThat(copy.keyMetadata()).isNotSameAs(file.keyMetadata());
+ }
+
+ @Test
+ void copyWithStats() {
+ ContentStats stats = Mockito.mock(ContentStats.class);
+ ContentStats statsCopy = Mockito.mock(ContentStats.class);
+ Mockito.when(stats.copy(ImmutableSet.of(1))).thenReturn(statsCopy);
+
+ TrackedFileStruct file =
+ new TrackedFileStruct(
+ TRACKING,
+ FileContent.DATA,
+ FORMAT_VERSION_V4,
+ "s3://bucket/data/00000-0-file.parquet",
+ FileFormat.PARQUET,
+ PARTITION,
+ 50L,
+ 512L,
+ 1,
+ stats,
+ 5,
+ DELETION_VECTOR,
+ MANIFEST_INFO,
+ ByteBuffer.wrap(new byte[] {1, 2, 3}),
+ ImmutableList.of(100L, 200L),
+ ImmutableList.of(1, 2, 3));
+
+ TrackedFile copy = file.copyWithStats(ImmutableSet.of(1));
+
+ assertThat(copy).isInstanceOf(TrackedFileStruct.class);
+ assertThat(copy.tracking()).isSameAs(TRACKING_COPY);
+ assertThat(copy.contentType()).isEqualTo(FileContent.DATA);
+ assertThat(copy.formatVersion()).isEqualTo(FORMAT_VERSION_V4);
+
assertThat(copy.location()).isEqualTo("s3://bucket/data/00000-0-file.parquet");
+ assertThat(copy.fileFormat()).isEqualTo(FileFormat.PARQUET);
+ assertThat(copy.recordCount()).isEqualTo(50L);
+ assertThat(copy.fileSizeInBytes()).isEqualTo(512L);
+ assertThat(copy.specId()).isEqualTo(1);
+ assertThat(copy.contentStats()).isSameAs(statsCopy);
+ assertThat(copy.sortOrderId()).isEqualTo(5);
+ assertThat(copy.deletionVector()).isSameAs(DELETION_VECTOR_COPY);
+ assertThat(copy.manifestInfo()).isSameAs(MANIFEST_INFO_COPY);
+ assertThat(copy.keyMetadata()).isEqualTo(ByteBuffer.wrap(new byte[] {1, 2,
3}));
+ assertThat(copy.splitOffsets()).containsExactly(100L, 200L);
+ assertThat(copy.equalityIds()).containsExactly(1, 2, 3);
+ assertThat(copy.partition()).isSameAs(PARTITION_COPY);
+
+ // mutable fields are deep-copied, not shared with the original
+ assertThat(copy.keyMetadata()).isNotSameAs(file.keyMetadata());
+ }
+
+ @Test
+ void copyWithoutStats() {
Review Comment:
Good catch.
Fixed. I thought that `withStats` was being set but it turns out the
interface has a default that passes `ImmutableSet.of()` instead. I removed the
unnecessary boolean and updated this test to verify that no methods are called
on `stats`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]