eric-maynard commented on code in PR #1378:
URL: https://github.com/apache/polaris/pull/1378#discussion_r2049418207
##########
service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java:
##########
@@ -1184,16 +1200,55 @@ public ViewBuilder withLocation(String newLocation) {
}
}
- private class BasePolarisTableOperations extends
BaseMetastoreTableOperations {
+ public class BasePolarisTableOperations extends BaseMetastoreTableOperations
{
private final TableIdentifier tableIdentifier;
private final String fullTableName;
+ private final boolean updateMetadataOnCommit;
private FileIO tableFileIO;
- BasePolarisTableOperations(FileIO defaultFileIO, TableIdentifier
tableIdentifier) {
+ // TODO remove the following if the Iceberg library allows us to do this
without reflection
+ // For more details see:
+ // https://github.com/apache/polaris/pull/1378
+ private static final Unsafe unsafe;
+ private static final Field tableMetadataField;
+ private static final long changesFieldOffset;
+ private static final Field currentMetadataLocationField;
+ private static final Field currentMetadataField;
+
+ static {
+ try {
+ tableMetadataField =
TableMetadata.class.getDeclaredField("metadataFileLocation");
+ tableMetadataField.setAccessible(true);
+
+ Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
+ unsafeField.setAccessible(true);
+ unsafe = (Unsafe) unsafeField.get(null);
+ Field changesField = TableMetadata.class.getDeclaredField("changes");
+ changesField.setAccessible(true);
+ changesFieldOffset = unsafe.objectFieldOffset(changesField);
+
+ currentMetadataLocationField =
+
BaseMetastoreTableOperations.class.getDeclaredField("currentMetadataLocation");
+ currentMetadataLocationField.setAccessible(true);
+
+ currentMetadataField =
+
BaseMetastoreTableOperations.class.getDeclaredField("currentMetadata");
+ currentMetadataField.setAccessible(true);
+ } catch (IllegalAccessException | NoSuchFieldException e) {
+ LOGGER.error(
+ "Encountered an unexpected error while attempting to access
private fields in TableMetadata",
Review Comment:
Now that it's moved to a static block, I don't think we can actually check
the BehaviorChangeConfiguration anymore. @dimas-b should we move this back?
--
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]