in amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/amoro/hive/io/writer/AdaptHiveGenericTaskWriterBuilder.java [182:262]
private GenericBaseTaskWriter buildBaseWriter(LocationKind locationKind) {
writeBasePreconditions();
FileFormat fileFormat =
FileFormat.valueOf(
(table
.properties()
.getOrDefault(
TableProperties.BASE_FILE_FORMAT, TableProperties.BASE_FILE_FORMAT_DEFAULT)
.toUpperCase(Locale.ENGLISH)));
long fileSizeBytes;
if (this.targetFileSize == null) {
fileSizeBytes =
PropertyUtil.propertyAsLong(
table.properties(),
TableProperties.WRITE_TARGET_FILE_SIZE_BYTES,
TableProperties.WRITE_TARGET_FILE_SIZE_BYTES_DEFAULT);
} else {
fileSizeBytes = this.targetFileSize;
}
long mask =
PropertyUtil.propertyAsLong(
table.properties(),
TableProperties.BASE_FILE_INDEX_HASH_BUCKET,
TableProperties.BASE_FILE_INDEX_HASH_BUCKET_DEFAULT)
- 1;
String baseLocation;
EncryptionManager encryptionManager;
Schema schema;
PrimaryKeySpec primaryKeySpec = null;
if (table.isKeyedTable()) {
KeyedTable keyedTable = table.asKeyedTable();
baseLocation = keyedTable.baseLocation();
encryptionManager = keyedTable.baseTable().encryption();
schema = keyedTable.baseTable().schema();
primaryKeySpec = keyedTable.primaryKeySpec();
} else {
UnkeyedTable table = this.table.asUnkeyedTable();
baseLocation = table.location();
encryptionManager = table.encryption();
schema = table.schema();
}
OutputFileFactory outputFileFactory =
locationKind == HiveLocationKind.INSTANT
? new AdaptHiveOutputFileFactory(
((SupportHive) table).hiveLocation(),
table.spec(),
fileFormat,
table.io(),
encryptionManager,
partitionId,
taskId,
transactionId,
customHiveSubdirectory,
hiveConsistentWrite)
: new CommonOutputFileFactory(
baseLocation,
table.spec(),
fileFormat,
table.io(),
encryptionManager,
partitionId,
taskId,
transactionId);
FileAppenderFactory<Record> appenderFactory =
TableTypeUtil.isHive(table)
? new AdaptHiveGenericAppenderFactory(schema, table.spec())
: new GenericAppenderFactory(schema, table.spec());
return new GenericBaseTaskWriter(
fileFormat,
appenderFactory,
outputFileFactory,
table.io(),
fileSizeBytes,
mask,
schema,
table.spec(),
primaryKeySpec,
orderedWriter);
}