gaborkaszab commented on code in PR #16952:
URL: https://github.com/apache/iceberg/pull/16952#discussion_r3470181383
##########
core/src/main/java/org/apache/iceberg/TrackedFileStruct.java:
##########
@@ -274,106 +274,59 @@ protected <T> T internalGet(int pos, Class<T> javaClass)
{
}
private Object getByPos(int pos) {
- switch (pos) {
- case 0:
- return tracking;
- case 1:
- return contentType != null ? contentType.id() : null;
- case 2:
- return writerFormatVersion;
- case 3:
- return location;
- case 4:
- return fileFormat != null ? fileFormat.toString() : null;
- case 5:
- return recordCount;
- case 6:
- return fileSizeInBytes;
- case 7:
- return specId;
- case 8:
- return partitionData;
- case 9:
- return contentStats;
- case 10:
- return sortOrderId;
- case 11:
- return deletionVector;
- case 12:
- return manifestInfo;
- case 13:
- return keyMetadata();
- case 14:
- return splitOffsets();
- case 15:
- return equalityIds();
- default:
- throw new UnsupportedOperationException("Unknown field ordinal: " +
pos);
- }
+ return switch (pos) {
+ case 0 -> tracking;
+ case 1 -> contentType != null ? contentType.id() : null;
+ case 2 -> formatVersion;
+ case 3 -> location;
+ case 4 -> fileFormat != null ? fileFormat.toString() : null;
+ case 5 -> recordCount;
+ case 6 -> fileSizeInBytes;
+ case 7 -> specId;
+ case 8 -> partitionData;
+ case 9 -> contentStats;
+ case 10 -> sortOrderId;
+ case 11 -> deletionVector;
+ case 12 -> manifestInfo;
+ case 13 -> keyMetadata();
+ case 14 -> splitOffsets();
+ case 15 -> equalityIds();
+ default -> throw new UnsupportedOperationException("Unknown field
ordinal: " + pos);
+ };
}
@Override
protected <T> void internalSet(int pos, T value) {
switch (pos) {
- case 0:
- this.tracking = (Tracking) value;
- break;
- case 1:
- this.contentType = FileContent.fromId((Integer) value);
- break;
- case 2:
- this.writerFormatVersion = (int) value;
- break;
- case 3:
- // always coerce to String for Serializable
- this.location = value.toString();
- break;
- case 4:
- this.fileFormat = FileFormat.fromString(value.toString());
- break;
- case 5:
- this.recordCount = (long) value;
- break;
- case 6:
- this.fileSizeInBytes = (long) value;
- break;
- case 7:
- this.specId = (Integer) value;
- break;
- case 8:
- this.partitionData = (PartitionData) value;
- break;
- case 9:
- this.contentStats = (ContentStats) value;
- break;
- case 10:
- this.sortOrderId = (Integer) value;
- break;
- case 11:
- this.deletionVector = (DeletionVector) value;
- break;
- case 12:
- this.manifestInfo = (ManifestInfo) value;
- break;
- case 13:
- this.keyMetadata = ByteBuffers.toByteArray((ByteBuffer) value);
- break;
- case 14:
- this.splitOffsets = ArrayUtil.toLongArray((List<Long>) value);
- break;
- case 15:
- this.equalityIds = ArrayUtil.toIntArray((List<Integer>) value);
- break;
- default:
+ case 0 -> this.tracking = (Tracking) value;
Review Comment:
The PR was straightforward enough that I went for changing this to the new
format. I recall the agreement was that we can do this one by one when having
changes around such switches.
--
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]