Source:
<code>public List<List<Object>> execute() { PlanFragment rootFragment = prestoSparkPlan.getPlan().getFragment(); RemoteSourceNode remoteSource = getOnlyElement(rootFragment.getRemoteSourceNodes()); PrestoSparkTaskDescriptor taskDescriptor = new PrestoSparkTaskDescriptor( session.toSessionRepresentation(), session.getIdentity().getExtraCredentials(), rootFragment, ImmutableList.of(), prestoSparkPlan.getTableWriteInfo()); SerializedPrestoSparkTaskDescriptor serializedTaskDescriptor = new SerializedPrestoSparkTaskDescriptor(sparkTaskDescriptorJsonCodec.toJsonBytes(taskDescriptor)); List<Tuple2<Integer, PrestoSparkRow>> resultRdd; try { List<Tuple2<Integer, PrestoSparkRow>> sparkDriverInput = rdd.collect(); resultRdd = ImmutableList.copyOf(prestoSparkTaskExecutorFactoryProvider.get().create( 0, 0, serializedTaskDescriptor, new PrestoSparkTaskInputs(ImmutableMap.of(remoteSource.getId().toString(), sparkDriverInput.iterator())), taskStatsCollector)); commit(); } catch (RuntimeException executionFailure) { try { rollback(); } catch (RuntimeException rollbackFailure) { if (executionFailure != rollbackFailure) { executionFailure.addSuppressed(rollbackFailure); } } queryCompletedEvent(Optional.of(executionFailure)); throw executionFailure; } queryCompletedEvent(Optional.empty()); ConnectorSession connectorSession = session.toConnectorSession(); List<Type> types = rootFragment.getTypes(); ImmutableList.Builder<List<Object>> result = ImmutableList.builder(); for (Tuple2<Integer, PrestoSparkRow> tuple : resultRdd) { PrestoSparkRow row = tuple._2; SliceInput sliceInput = new BasicSliceInput(Slices.wrappedBuffer(row.getBytes(), 0, row.getLength())); ImmutableList.Builder<Object> columns = ImmutableList.builder(); for (Type type : types) { BlockBuilder blockBuilder = type.createBlockBuilder(null, 1); <START> blockBuilder.deserializePosition(sliceInput); <END> columns.add(type.getObjectValue(connectorSession, blockBuilder, 0)); } result.add(columns.build()); } return result.build(); }</code><technical_language>considered adding overload getObjectValue takes in a sliceInput, avoid create block builder cell</technical_language>

Target:
public List<List<Object>> execute() { PlanFragment rootFragment = prestoSparkPlan.getPlan().getFragment(); RemoteSourceNode remoteSource = getOnlyElement(rootFragment.getRemoteSourceNodes()); PrestoSparkTaskDescriptor taskDescriptor = new PrestoSparkTaskDescriptor( session.toSessionRepresentation(), session.getIdentity().getExtraCredentials(), rootFragment, ImmutableList.of(), prestoSparkPlan.getTableWriteInfo()); SerializedPrestoSparkTaskDescriptor serializedTaskDescriptor = new SerializedPrestoSparkTaskDescriptor(sparkTaskDescriptorJsonCodec.toJsonBytes(taskDescriptor)); List<Tuple2<Integer, PrestoSparkRow>> resultRdd; try { List<Tuple2<Integer, PrestoSparkRow>> sparkDriverInput = rdd.collect(); resultRdd = ImmutableList.copyOf(prestoSparkTaskExecutorFactoryProvider.get().create( 0, 0, serializedTaskDescriptor, new PrestoSparkTaskInputs(ImmutableMap.of(remoteSource.getId().toString(), sparkDriverInput.iterator())), taskStatsCollector)); commit(); } catch (RuntimeException executionFailure) { try { rollback(); } catch (RuntimeException rollbackFailure) { if (executionFailure != rollbackFailure) { executionFailure.addSuppressed(rollbackFailure); } } queryCompletedEvent(Optional.of(executionFailure)); throw executionFailure; } queryCompletedEvent(Optional.empty()); ConnectorSession connectorSession = session.toConnectorSession(); List<Type> types = rootFragment.getTypes(); ImmutableList.Builder<List<Object>> result = ImmutableList.builder(); for (Tuple2<Integer, PrestoSparkRow> tuple : resultRdd) { PrestoSparkRow row = tuple._2; SliceInput sliceInput = new BasicSliceInput(Slices.wrappedBuffer(row.getBytes(), 0, row.getLength())); ImmutableList.Builder<Object> columns = ImmutableList.builder(); for (Type type : types) { BlockBuilder blockBuilder = type.createBlockBuilder(null, 1); blockBuilder.readPositionFrom(sliceInput); columns.add(type.getObjectValue(connectorSession, blockBuilder, 0)); } result.add(columns.build()); } return result.build(); }