From edcd84043f08f7e3757b873a1a6df758a0dba1f0 Mon Sep 17 00:00:00 2001 From: Shixuan Fan Date: Fri, 22 Feb 2019 15:21:04 -0800 Subject: [PATCH] Extract partitionUpdates deserialization logic --- .../com/facebook/presto/hive/HiveMetadata.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java b/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java index 94238e41b72f..56f5fff51852 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java @@ -1075,10 +1075,7 @@ public Optional finishCreateTable(ConnectorSession sess { HiveOutputTableHandle handle = (HiveOutputTableHandle) tableHandle; - List partitionUpdates = fragments.stream() - .map(Slice::getBytes) - .map(partitionUpdateCodec::fromJson) - .collect(toList()); + List partitionUpdates = getPartitionUpdates(fragments); WriteInfo writeInfo = locationService.getQueryWriteInfo(handle.getLocationHandle()); Table table = buildTableObject( @@ -1297,10 +1294,7 @@ public Optional finishInsert(ConnectorSession session, { HiveInsertTableHandle handle = (HiveInsertTableHandle) insertHandle; - List partitionUpdates = fragments.stream() - .map(Slice::getBytes) - .map(partitionUpdateCodec::fromJson) - .collect(toList()); + List partitionUpdates = getPartitionUpdates(fragments); HiveStorageFormat tableStorageFormat = handle.getTableStorageFormat(); partitionUpdates = PartitionUpdate.mergePartitionUpdates(partitionUpdates); @@ -2044,6 +2038,14 @@ private static boolean hasAdminRole(Set roles) return roles.stream().anyMatch(principal -> principal.getName().equalsIgnoreCase(ADMIN_ROLE_NAME)); } + private List getPartitionUpdates(Collection fragments) + { + return fragments.stream() + .map(Slice::getBytes) + .map(partitionUpdateCodec::fromJson) + .collect(toList()); + } + private void verifyJvmTimeZone() { if (!allowCorruptWritesForTesting && !timeZone.equals(DateTimeZone.getDefault())) {