auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private PageSinkCommitStrategy getPageSinkCommitStrategy() { START if (pageSinkCommitRequired) { END return TASK_COMMIT; } if (stageExecutionDescriptor.isRecoverableGroupedExecution()) { return LIFESPAN_COMMIT; } return NO_COMMIT; } Should we first check whether `isRecoverableGroupedExecution` is `true` and return `LIFESPAN_COMMIT` first? I feel like `isRecoverableGroupedExecution` is a stronger predicate than `pageSinkCommitRequired`. What do you think?

Target:
private PageSinkCommitStrategy getPageSinkCommitStrategy() { if (stageExecutionDescriptor.isRecoverableGroupedExecution()) { return LIFESPAN_COMMIT; } if (pageSinkCommitRequired) { return TASK_COMMIT; } return NO_COMMIT; }
Source:
public void start() { if (!enabled || started.getAndSet(true)) { START log.info("ShardOrganizationManager return"); END return; } startDiscovery(); } Do we really need this?

Target:
public void start() { if (!enabled || started.getAndSet(true)) { return; } startDiscovery(); }
Source:
public static Block stPoints(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { Geometry geometry = deserialize(input); START validateType("ST_Points", geometry, VALID_TYPES_FOR_ST_POINTS); END if (geometry.isEmpty()) { return null; } int pointCount = geometry.getNumPoints(); BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, pointCount); buildPointsBlock(geometry, blockBuilder); return blockBuilder.build(); } Since this is all current geometries, and the method would work for any additional geometry that JTS supports, we can remove this (and the associated bit in lines 150-152.

Target:
public static Block stPoints(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { Geometry geometry = deserialize(input); if (geometry.isEmpty()) { return null; } BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, geometry.getNumPoints()); buildPointsBlock(geometry, blockBuilder); return blockBuilder.build(); }
Source:
private boolean evaluateDeterministicFilterFunctionsWithConstantInputs(List<FilterFunction> filterFunctions) { for (FilterFunction function : filterFunctions) { START if (function.isDeterministic() && hasInputs(function) && allConstantInputs(function)) { END if (!evaluateDeterministicFilterFunctionWithConstantInputs(function)) { return false; } } } return true; } ```java if (function.isDeterministic() && hasInputs(function) && allConstantInputs(function) && !evaluateDeterministicFilterFunctionWithConstantInputs(function)) { return false; }

Target:
private boolean evaluateDeterministicFilterFunctionsWithConstantInputs(List<FilterFunction> filterFunctions) { for (FilterFunction function : filterFunctions) { if (function.isDeterministic() && hasInputs(function) && allConstantInputs(function) && !evaluateDeterministicFilterFunctionWithConstantInputs(function)) { return false; } } return true; }
Source:
private static boolean isSTDistance(RowExpression expression, FunctionManager functionManager) { START if (expression instanceof CallExpression) { END return functionManager.getFunctionMetadata(((CallExpression) expression).getFunctionHandle()).getName().equals(ST_DISTANCE); } return false; } return (expression instanceof CallExpression) && functionManager.getFunctionMetadata(...

Target:
private static boolean isSTDistance(RowExpression expression, FunctionManager functionManager) { return expression instanceof CallExpression && functionManager.getFunctionMetadata(((CallExpression) expression).getFunctionHandle()).getName().equals(ST_DISTANCE); }
Source:
START private Map<String, Type> buildBigIntTypeProviderMap(String... variables) END { ImmutableMap.Builder<String, Type> builder = ImmutableMap.builder(); Arrays.stream(variables).forEach(variable -> builder.put(variable, BIGINT)); return builder.build(); } static

Target:
private static Map<String, Type> buildBigIntTypeProviderMap(String... variables) { ImmutableMap.Builder<String, Type> builder = ImmutableMap.builder(); Arrays.stream(variables).forEach(variable -> builder.put(variable, BIGINT)); return builder.build(); }
Source:
public boolean testDouble(double value) { if (Double.isNaN(value)) { return nanAllowed; } for (TupleDomainFilter filter : filters) { START if ((nanAllowed && Double.isNaN(value)) || filter.testDouble(value)) { END return true; } } return false; } @bhhari - `nanAllowed && Double.isNaN(value)` filter is redundant; NaN has been checked already - ditto testFloat

Target:
public boolean testDouble(double value) { if (Double.isNaN(value)) { return nanAllowed; } for (TupleDomainFilter filter : filters) { if (filter.testDouble(value)) { return true; } } return false; }
Source:
private static boolean findColumnName(String tableName, String columnName, Connection connection) throws SQLException { Statement statement = connection.createStatement(); ResultSet results = statement.executeQuery("SELECT * FROM " + tableName + " LIMIT 0"); ResultSetMetaData metadata = results.getMetaData(); int columnCount = metadata.getColumnCount(); START for (int i = 1; i <= columnCount; i++) { END if (columnName.equalsIgnoreCase(metadata.getColumnName(i))) { return true; } } return false; } i = 0; i < columnCount

Target:
private static boolean findColumnName(String tableName, String columnName, Connection connection) throws SQLException { Statement statement = connection.createStatement(); ResultSet results = statement.executeQuery("SELECT * FROM " + tableName + " LIMIT 0"); ResultSetMetaData metadata = results.getMetaData(); int columnCount = metadata.getColumnCount(); for (int i = 0; i < columnCount; i++) { if (columnName.equalsIgnoreCase(metadata.getColumnName(i + 1))) { return true; } } return false; }
Source:
public void testBackoffTimeCapped() { START VerificationContext verificationContext = new VerificationContext(); END RetryDriver retryDriver = new RetryDriver<>( new RetryConfig() .setMaxAttempts(5) .setMinBackoffDelay(new Duration(10, MILLISECONDS)) .setMaxBackoffDelay(new Duration(100, MILLISECONDS)) .setScaleFactor(1000), QueryException::isRetryable, QueryException.class, verificationContext::addException); retryDriver.run("test", new MockOperation(5, RETRYABLE_EXCEPTION)); } @caithagoras I understand `@Test(singleThreaded = true)` change, but why is this change?

Target:
public void testBackoffTimeCapped() { RetryDriver retryDriver = new RetryDriver<>( new RetryConfig() .setMaxAttempts(5) .setMinBackoffDelay(new Duration(10, MILLISECONDS)) .setMaxBackoffDelay(new Duration(100, MILLISECONDS)) .setScaleFactor(1000), QueryException::isRetryable, QueryException.class, verificationContext::addException); retryDriver.run("test", new MockOperation(5, RETRYABLE_EXCEPTION)); }
Source:
private static void alterTable(Runnable alterTableFunction) { try { alterTableFunction.run(); } catch (Exception e) { START log.info("Alter table failed: %s", e); END } } `log.warn(e, "Alter table failed");`

Target:
private static void alterTable(Runnable alterTableFunction) { try { alterTableFunction.run(); } catch (Exception e) { log.warn("Alter table failed: %s", e.getMessage()); } }
Source:
public void testTableTablesWithoutUpgrading() { // without perform upgrading operation would cause metadata incorrect long tableId = dao.insertTable("schema1", "table1", true, false, null, 0, false); START assertNotNull(tableId); END } No need to create `tableId` and assign/assert on it. The code will never reach this point.

Target:
public void testTableTablesWithoutUpgrading() { // without perform upgrading operation would cause metadata incorrect dao.insertTable("schema1", "table1", true, false, null, 0, false); }
Source:
START public Optional<BitSet> getRowsDeleted() END { // Just load once if (!loaded && tableSupportsDeltaDelete && deltaShardUuid.isPresent()) { rowsDeleted = orcStorageManager.getRowsFromUuid(fileSystem, deltaShardUuid); loaded = true; } return rowsDeleted; } private

Target:
private Optional<BitSet> getRowsDeleted() { // Just load once if (!loaded && tableSupportsDeltaDelete && deltaShardUuid.isPresent()) { rowsDeleted = orcStorageManager.getRowsFromUuid(fileSystem, deltaShardUuid); loaded = true; } return rowsDeleted; }
Source:
private <T> void assertBlockPositions(Block block, Supplier<BlockBuilder> newBlockBuilder, T[] expectedValues) { START try { END assertEquals(block.getPositionCount(), expectedValues.length); } catch (Exception e) { e.printStackTrace(); } for (int position = 0; position < block.getPositionCount(); position++) { assertBlockPosition(block, newBlockBuilder, position, expectedValues[position], expectedValues.getClass().getComponentType()); } } I don't understand this change. Would you explain?

Target:
private <T> void assertBlockPositions(Block block, Supplier<BlockBuilder> newBlockBuilder, T[] expectedValues) { assertEquals(block.getPositionCount(), expectedValues.length); for (int position = 0; position < block.getPositionCount(); position++) { assertBlockPosition(block, newBlockBuilder, position, expectedValues[position], expectedValues.getClass().getComponentType()); } }
Source:
START public synchronized boolean isFinished() END { StageExecutionState rootStageState = rootStage.getStageExecution().getState(); return rootStageState.isDone() && !rootStageState.isFailure(); } Defensive synchronized methods everywhere? 😄

Target:
public boolean isFinished() { StageExecutionState rootStageState = rootStage.getStageExecution().getState(); return rootStageState.isDone() && !rootStageState.isFailure(); }
Source:
public KafkaProducer<Long, Object> createProducer() { Properties properties = new Properties(); properties.setProperty(BOOTSTRAP_SERVERS_CONFIG, getConnectString()); properties.setProperty(VALUE_SERIALIZER_CLASS_CONFIG, JsonEncoder.class.getName()); properties.setProperty(KEY_SERIALIZER_CLASS_CONFIG, LongSerializer.class.getName()); START properties.setProperty(PARTITIONER_CLASS_CONFIG, DefaultPartitioner.class.getName()); END properties.setProperty(ACKS_CONFIG, "1"); return new KafkaProducer<>(properties); } Default partitioner is default. Need to specify?

Target:
public KafkaProducer<Long, Object> createProducer() { Properties properties = new Properties(); properties.setProperty(BOOTSTRAP_SERVERS_CONFIG, getConnectString()); properties.setProperty(VALUE_SERIALIZER_CLASS_CONFIG, JsonEncoder.class.getName()); properties.setProperty(KEY_SERIALIZER_CLASS_CONFIG, LongSerializer.class.getName()); properties.setProperty(ACKS_CONFIG, "1"); return new KafkaProducer<>(properties); }
Source:
public Object readBlocksWithoutJni(BenchmarkData data) throws Throwable { OrcBatchRecordReader recordReader = data.createRecordReader(false); START List<Block> blocks = new ArrayList<>(); END while (recordReader.nextBatch() > 0) { Block block = recordReader.readBlock(data.type, 0); blocks.add(block); } return blocks; } Use ImmutableList.builder

Target:
public Object readBlocksWithoutJni(BenchmarkData data) throws Throwable { OrcBatchRecordReader recordReader = data.createRecordReader(false); ImmutableList.Builder<Block> blocks = new ImmutableList.Builder<>(); while (recordReader.nextBatch() > 0) { Block block = recordReader.readBlock(0); blocks.add(block); } return blocks.build(); }
Source:
START protected final List<?> createValues() END { switch (withNulls) { case ALL: return NULL_VALUES; case PARTIAL: return IntStream.range(0, ROWS).mapToObj(i -> i % 2 == 0 ? createValue() : null).collect(toList()); default: return IntStream.range(0, ROWS).mapToObj(i -> createValue()).collect(toList()); } } nit: we don't usually use `final` on method. (Also, as a side note: we don't use `final` for tmp variables)

Target:
protected List<?> createValues() { switch (withNulls) { case ALL: return NULL_VALUES; case PARTIAL: return IntStream.range(0, ROWS).mapToObj(i -> i % 2 == 0 ? createValue() : null).collect(toList()); default: return IntStream.range(0, ROWS).mapToObj(i -> createValue()).collect(toList()); } }
Source:
START static String getAlphaNumericString(int length) END { String alphaNumericString = "USINDIA"; StringBuilder stringBuilder = new StringBuilder(length); for (int index = 0; index < length; index++) { int arrayIndex = (int) (alphaNumericString.length() * Math.random()); stringBuilder.append(alphaNumericString.charAt(arrayIndex)); } return stringBuilder.toString(); } private

Target:
private static String getAlphaNumericString(int length) { String alphaNumericString = "USINDIA"; StringBuilder stringBuilder = new StringBuilder(length); for (int index = 0; index < length; index++) { int arrayIndex = (int) (alphaNumericString.length() * Math.random()); stringBuilder.append(alphaNumericString.charAt(arrayIndex)); } return stringBuilder.toString(); }
Source:
public void testIsDistinctFrom() { START long[] arr1 = {112L, 0L}; // DECIMAL '1.12' END long[] arr2 = {185L, 0L}; // DECIMAL '1.85' Block left = new Int128ArrayBlock(1, Optional.empty(), arr1); Block right = new Int128ArrayBlock(1, Optional.empty(), arr2); assertFalse(DecimalInequalityOperators.distinctBlockPositionLongLong(left, 0, left, 0)); assertTrue(DecimalInequalityOperators.distinctBlockPositionLongLong(left, 0, right, 0)); } - don't use a1, a2, etc. variables names; here, I'd just inline arr1 and arr2 - static import distinctBlockPositionLongLong ``` @Test public void testIsDistinctFrom() { Block left = new Int128ArrayBlock(1, Optional.empty(), new long[] {112L, 0L}); Block right = new Int128ArrayBlock(1, Optional.empty(), new long[] {185L, 0L}); assertFalse(distinctBlockPositionLongLong(left, 0, left, 0)); assertTrue(distinctBlockPositionLongLong(left, 0, right, 0)); } ```

Target:
public void testIsDistinctFrom() { Block left = new Int128ArrayBlock(1, Optional.empty(), new long[]{112L, 0L}); Block right = new Int128ArrayBlock(1, Optional.empty(), new long[]{185L, 0L}); assertFalse(distinctBlockPositionLongLong(left, 0, left, 0)); assertTrue(distinctBlockPositionLongLong(left, 0, right, 0)); }
Source:
public BenchmarkSuite get() { BenchmarkSuite benchmarkSuite; ImmutableList.Builder<BenchmarkQuery> benchmarkQueries = ImmutableList.builder(); try (Handle handle = jdbi.open()) { BenchmarkSuiteDao benchmarkDao = handle.attach(BenchmarkSuiteDao.class); BenchmarkSuiteInfo benchmarkSuiteInfo = benchmarkDao.getBenchmarkSuiteInfo(suitesTableName, suite); START benchmarkQueries.addAll(benchmarkDao.getBenchmarkQueries(queriesTableName, benchmarkSuiteInfo.getQuerySet())); END benchmarkSuite = new BenchmarkSuite(benchmarkSuiteInfo, benchmarkQueries.build()); } return benchmarkSuite; } `benchmarkDao.getBenchmarkQueries` returns a list. Why do you need to create an empty list and then the elements?

Target:
public BenchmarkSuite get() { BenchmarkSuite benchmarkSuite; try (Handle handle = jdbi.open()) { BenchmarkSuiteDao benchmarkDao = handle.attach(BenchmarkSuiteDao.class); BenchmarkSuiteInfo benchmarkSuiteInfo = benchmarkDao.getBenchmarkSuiteInfo(suitesTableName, suite); benchmarkSuite = new BenchmarkSuite(benchmarkSuiteInfo, benchmarkDao.getBenchmarkQueries(queriesTableName, benchmarkSuiteInfo.getQuerySet())); } return benchmarkSuite; }
Source:
public void testDefault() { assertRecordedDefaults(recordDefaults(BenchmarkSuiteConfig.class) START .setDatabase(null) .setSuitesTableName("benchmark_suites") .setQueriesTableName("benchmark_queries") .setSuite(null)); END } Keep them in the order of the definition in `BenchmarkSuiteConfig `

Target:
public void testDefault() { assertRecordedDefaults(recordDefaults(BenchmarkSuiteConfig.class) .setSuite(null) .setSuitesTableName("benchmark_suites") .setQueriesTableName("benchmark_queries")); }
Source:
public void setup() throws Exception { mySqlServer = setupMySql(); jdbi = getJdbi(mySqlServer); handle = jdbi.open(); config = new BenchmarkSuiteConfig() START .setSuitesTableName(BENCHMARK_SUITES_TABLE) .setQueriesTableName(BENCHMARK_QUERIES_TABLE); END } You can just use the default config.

Target:
public void setup() throws Exception { mySqlServer = setupMySql(); jdbi = getJdbi(mySqlServer); handle = jdbi.open(); }
Source:
private void transitionToFinished() { cleanupQueryQuietly(); queryStateTimer.endQuery(); START session.getSessionLogger().log(() -> "Query state machine finished"); END queryState.setIf(FINISHED, currentState -> !currentState.isDone()); } nit: remove

Target:
private void transitionToFinished() { cleanupQueryQuietly(); queryStateTimer.endQuery(); queryState.setIf(FINISHED, currentState -> !currentState.isDone()); }
Source:
private synchronized void startSplit(PrioritizedSplitRunner split) { allSplits.add(split); START split.getTaskHandle().getSessionLogger().log(() -> "offering split " + split); END waitingSplits.offer(split); } nit: remove

Target:
private synchronized void startSplit(PrioritizedSplitRunner split) { allSplits.add(split); waitingSplits.offer(split); }
Source:
public void start() { try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) { // to start we just need to trigger an update scheduleUpdate(); taskStatusFetcher.start(); taskInfoFetcher.start(); START session.getSessionLogger().log(() -> String.format("started task %s", taskId)); END } } nit: remove

Target:
public void start() { try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) { // to start we just need to trigger an update scheduleUpdate(); taskStatusFetcher.start(); taskInfoFetcher.start(); } }
Source:
public ColumnChunk readNext() { ColumnChunk columnChunk = null; try { seek(); if (field.isRequired()) { columnChunk = readWithoutNull(); } else { columnChunk = readWithNull(); } } START catch (IOException ex) { END throw new PrestoException(PARQUET_IO_READ_ERROR, "Error reading Parquet column " + columnDescriptor, ex); } readOffset = 0; nextBatchSize = 0; return columnChunk; } s/ex/exception/g

Target:
public ColumnChunk readNext() { ColumnChunk columnChunk = null; try { seek(); if (field.isRequired()) { columnChunk = readWithoutNull(); } else { columnChunk = readWithNull(); } } catch (IOException exception) { throw new PrestoException(PARQUET_IO_READ_ERROR, "Error reading Parquet column " + columnDescriptor, exception); } readOffset = 0; nextBatchSize = 0; return columnChunk; }
Source:
private void assertQuery(String query, byte[] checksum) { byte[] expected = (byte[]) computeActual(query).getOnlyValue(); for (int i = 0; i < expected.length; i++) { System.err.print(expected[i] + ", "); START } END assertEquals(computeActual(query).getOnlyValue(), checksum); } Remove before merging

Target:
private void assertQuery(String query, byte[] checksum) { assertEquals(computeActual(query).getOnlyValue(), checksum); }
Source:
public LongInputStreamV1(OrcInputStream input, boolean signed) { this.input = input; this.signed = signed; START lastReadInputCheckpoint = input.getCheckpoint(); END } `lastReadInputCheckpoint` is never used anymore. Could you remove?

Target:
public LongInputStreamV1(OrcInputStream input, boolean signed) { this.input = input; this.signed = signed; }
Source:
public InternalResourceGroup getRoot() { START synchronized (root) { END return root; } } `root` would not change and I can't think why its access needs to be serialized with other methods so why does this need to be synchronized?

Target:
public InternalResourceGroup getRoot() { return root; }
Source:
private List<QueryStateInfo> getAllAggregatedRunningQueriesInfo() { synchronized (root) { InternalResourceGroup resourceGroup = this; START List<QueryStateInfo> result = new ArrayList<>(resourceGroup.getAggregatedRunningQueriesInfo()); END while (resourceGroup.getPrev().isPresent()) { resourceGroup = resourceGroup.getPrev().get(); result.addAll(resourceGroup.getAggregatedRunningQueriesInfo()); } return ImmutableList.copyOf(result); } } ```suggestion ImmutableList.Builder<QueryStateInfo> result = ImmutableList.builder().addAll(resourceGroup.getAggregatedRunningQueriesInfo()); ```

Target:
private List<QueryStateInfo> getAllAggregatedRunningQueriesInfo() { synchronized (root) { InternalResourceGroup resourceGroup = this; ImmutableList.Builder<QueryStateInfo> result = ImmutableList.builder(); result.addAll(resourceGroup.getAggregatedRunningQueriesInfo()); while (resourceGroup.getPrev().isPresent()) { resourceGroup = resourceGroup.getPrev().get(); result.addAll(resourceGroup.getAggregatedRunningQueriesInfo()); } return result.build(); } }
Source:
public TestFixedHistogramJacknifeAggregation() { START super(DifferentialEntropyStateStrategy.FIXED_HISTOGRAM_JACKNIFE_METHOD_NAME); END } nit: static import

Target:
public TestFixedHistogramJacknifeAggregation() { super(FIXED_HISTOGRAM_JACKNIFE_METHOD_NAME); }
Source:
public Double getExpectedValue(int start, int length) { START assertTrue(length < MAX_SAMPLES); END double[] samples = new double[2 * length]; for (int i = 0; i < length; i++) { samples[i] = (double) (start + i); samples[i + length] = (double) (start + i); } return calculateFromSamplesUsingVasicek(samples); } move this change to the previous commit

Target:
public Double getExpectedValue(int start, int length) { assertTrue(2 * length < MAX_SAMPLES); double[] samples = new double[2 * length]; for (int i = 0; i < length; i++) { samples[i] = (double) (start + i); samples[i + length] = (double) (start + i); } return calculateFromSamplesUsingVasicek(samples); }
Source:
START public Set<Class<?>> getFunctionTranslators() END { return ImmutableSet.of(OperatorTranslators.class); } private

Target:
private Set<Class<?>> getFunctionTranslators() { return ImmutableSet.of(OperatorTranslators.class); }
Source:
private static <T extends PlanNode> Optional<T> findSinglePlanNode(StreamingSubPlan plan, Class<T> clazz) { List<PlanNode> allMatches = findPlanNodes(plan, clazz); switch (allMatches.size()) { case 0: return Optional.empty(); case 1: START return Optional.of((T) getOnlyElement(allMatches)); END default: throw new IllegalStateException(format("Multiple matches found for class %s", clazz)); } } You can avoid the unchecked cast: * `List<PlanNode> allMatches` -> `List<T> allMatches` * In `findPlanNodes`: `<T extends PlanNode> List<PlanNode>` -> `<T extends PlanNode> List<T>`, `.findAll())` -> `.<T>findAll())`

Target:
private static <T extends PlanNode> Optional<T> findSinglePlanNode(StreamingSubPlan plan, Class<T> clazz) { List<T> allMatches = findPlanNodes(plan, clazz); switch (allMatches.size()) { case 0: return Optional.empty(); case 1: return Optional.of(getOnlyElement(allMatches)); default: throw new IllegalArgumentException(format("Multiple matches found for class %s", clazz)); } }
Source:
START public WriterTarget getTarget() END { return target; } Add `@JsonIgnore`

Target:
public Optional<WriterTarget> getTarget() { return target; }
Source:
private int getValidPercentile(String fraction) { try { double p = Double.parseDouble(fraction); if (p < 0 || p > 1) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Percentile must be between 0 and 1"); } double percent = p * 100.0; if (percent == Math.floor(percent)) { return (int) percent; } } catch (NumberFormatException ne) { // Skip } return -1; START } END just call this `percent`

Target:
private int getValidPercentile(String fraction) { try { double percent = Double.parseDouble(fraction); if (percent < 0 || percent > 1) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Percentile must be between 0 and 1"); } percent = percent * 100.0; if (percent == Math.floor(percent)) { return (int) percent; } } catch (NumberFormatException ne) { // Skip } return -1; }
Source:
public PinotQueryGeneratorContext visitTopN(TopNNode node, PinotQueryGeneratorContext context) { context = node.getSource().accept(this, context); requireNonNull(context, "context is null"); checkSupported(preferBrokerQueries, "Cannot push topn in segment mode"); checkSupported(node.getStep().equals(TopNNode.Step.SINGLE), "Can only push single logical topn in"); return context.withTopN(PushdownUtils.getOrderingScheme(node), node.getCount()).withOutputColumns(node.getOutputVariables()); START } END Map<...>

Target:
public PinotQueryGeneratorContext visitTopN(TopNNode node, PinotQueryGeneratorContext context) { context = node.getSource().accept(this, context); requireNonNull(context, "context is null"); checkSupported(preferBrokerQueries, "Cannot push topn in segment mode"); checkSupported(node.getStep().equals(TopNNode.Step.SINGLE), "Can only push single logical topn in"); return context.withTopN(getOrderingScheme(node), node.getCount()).withOutputColumns(node.getOutputVariables()); }
Source:
START public String sendHttpGetToController(String path) END { return doHttpActionWithHeaders( Request.builder().prepareGet().setUri(URI.create(String.format("http://%s/%s", getControllerUrl(), path))), Optional.empty(), Optional.ofNullable(pinotConfig.getControllerRestService())); } private

Target:
private String sendHttpGetToController(String path) { return doHttpActionWithHeaders( Request.builder().prepareGet().setUri(URI.create(String.format("http://%s/%s", getControllerUrl(), path))), Optional.empty(), Optional.ofNullable(pinotConfig.getControllerRestService())); }
Source:
public IdentityHashMap<TableScanNode, Void> visitTableScan(TableScanNode node, Void context) { START IdentityHashMap<TableScanNode, Void> ret = new IdentityHashMap<>(); END ret.put(node, null); return ret; } `Map<TableScanNode, Void> result = new IdentityHashMap<>();`

Target:
public Map<TableScanNode, Void> visitTableScan(TableScanNode node, Void context) { Map<TableScanNode, Void> ret = new IdentityHashMap<>(); ret.put(node, null); return ret; }
Source:
public TranslatedExpression<T> translate(FunctionMetadata functionMetadata, RowExpression original) { START return translate(functionMetadata, original, emptyList()); END } ImmutableList.of()

Target:
public TranslatedExpression<T> translate(FunctionMetadata functionMetadata, RowExpression original) throws Throwable { return translate(functionMetadata, original, ImmutableList.of()); }
Source:
public TestRowExpressionTranslator() { this.functionManager = METADATA.getFunctionManager(); this.functionResolution = new FunctionResolution(functionManager); this.determinismEvaluator = new RowExpressionDeterminismEvaluator(functionManager); this.sqlToRowExpressionTranslator = new TestingRowExpressionTranslator(METADATA); START } END Can you also cover: 1) Function that does not have a rule, so we cannot translate? 2) Function has same name but different signature (for example input types are different)? 3) Function that is hidden, probably `not`. 4) Simple operators such as: +, -, > .

Target:
public TestRowExpressionTranslator() { this.functionManager = METADATA.getFunctionManager(); this.sqlToRowExpressionTranslator = new TestingRowExpressionTranslator(METADATA); }
Source:
START public static TypeSignature removeTypeParameters(TypeSignature typeSignature) END { return new TypeSignature(typeSignature.getBase()); } private

Target:
private static TypeSignature removeTypeParameters(TypeSignature typeSignature) { return new TypeSignature(typeSignature.getBase()); }
Source:
public static <T> TranslatedExpression<T> untranslated(RowExpression originalExpression) { START return new TranslatedExpression<>(Optional.empty(), originalExpression, emptyList()); END } ImmutableList.of()

Target:
public static <T> TranslatedExpression<T> untranslated(RowExpression originalExpression) { return new TranslatedExpression<>(Optional.empty(), originalExpression, ImmutableList.of()); }
Source:
public void checkCanSetCatalogSessionProperty(ConnectorTransactionHandle transaction, ConnectorIdentity identity, String propertyName) { START if (false && !isAdmin(transaction, identity)) { END denySetCatalogSessionProperty(connectorId, propertyName); } } Is this change intentional? As this means the method is not doing anything no matter what the input is.

Target:
public void checkCanSetCatalogSessionProperty(ConnectorTransactionHandle transaction, ConnectorIdentity identity, String propertyName) { if (!isAdmin(transaction, identity)) { denySetCatalogSessionProperty(connectorId, propertyName); } }
Source:
START Type getTypeForBlock(PinotColumnHandle pinotColumnHandle) END { if (pinotColumnHandle.getColumnType().equals(INTEGER)) { return BIGINT; } else { return pinotColumnHandle.getColumnType(); } } private static

Target:
private static Type getTypeForBlock(PinotColumnHandle pinotColumnHandle) { if (pinotColumnHandle.getColumnType().equals(INTEGER)) { return BIGINT; } return pinotColumnHandle.getColumnType(); }
Source:
private int getEstimatedColumnSizeInBytes(DataSchema.ColumnDataType dataType) { if (dataType.isNumber()) { switch (dataType) { case LONG: return Long.BYTES; case FLOAT: return Float.BYTES; case DOUBLE: return Double.BYTES; case INT: default: return Integer.BYTES; } } START else { END return pinotConfig.getEstimatedSizeInBytesForNonNumericColumn(); } } `else` is redundant

Target:
private int getEstimatedColumnSizeInBytes(DataSchema.ColumnDataType dataType) { if (dataType.isNumber()) { switch (dataType) { case LONG: return Long.BYTES; case FLOAT: return Float.BYTES; case DOUBLE: return Double.BYTES; case INT: default: return Integer.BYTES; } } return pinotConfig.getEstimatedSizeInBytesForNonNumericColumn(); }
Source:
START static int getHashTableSize(int positionCount){ END return HashCommon.arraySize(positionCount, 0.75f); } nit: private?

Target:
private static int getHashTableSize(int positionCount) { return HashCommon.arraySize(positionCount, 0.75f); }
Source:
START static long getEstimatedAdditionalSize(int positionCount){ END int hashSize = getHashTableSize(positionCount); long predictedKeySize = sizeOfIntArray(hashSize); long predictedPositionToHashesSize = sizeOfByteArray(positionCount); long predictedPositionLinksSize = sizeOfIntArray(positionCount); return predictedKeySize + predictedPositionToHashesSize + predictedPositionLinksSize; } nit: public

Target:
public static long getEstimatedAdditionalSize(int positionCount) { int hashSize = getHashTableSize(positionCount); long predictedKeySize = sizeOfIntArray(hashSize); long predictedPositionToHashesSize = sizeOfByteArray(positionCount); long predictedPositionLinksSize = sizeOfIntArray(positionCount); return predictedKeySize + predictedPositionToHashesSize + predictedPositionLinksSize; }
Source:
private void skip(int items) throws IOException { if (presentStream != null) { int dataToSkip = presentStream.countBitsSet(items); if (inDictionaryStream != null) { inDictionaryStream.skip(dataToSkip); } START if (dataStream != null) { END dataStream.skip(dataToSkip); } } else { if (inDictionaryStream != null) { inDictionaryStream.skip(items); } dataStream.skip(items); } } dataStream here can't be null, can it?

Target:
private void skip(int items) throws IOException { if (presentStream != null) { int dataToSkip = presentStream.countBitsSet(items); if (inDictionaryStream != null) { inDictionaryStream.skip(dataToSkip); } dataStream.skip(dataToSkip); } else { if (inDictionaryStream != null) { inDictionaryStream.skip(items); } dataStream.skip(items); } }
Source:
START protected BlockLease newLease(Block block) END { valuesInUse = true; return ClosingBlockLease.newLease(block, () -> valuesInUse = false); } make it private

Target:
private BlockLease newLease(Block block) { valuesInUse = true; return ClosingBlockLease.newLease(block, () -> valuesInUse = false); }
Source:
Block makeBlock(int positionCount, boolean includeNulls, boolean[] nulls, long[] values) { START Block block = new Int128ArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), values); END return block; } nit: inline `block` variable

Target:
protected Block makeBlock(int positionCount, boolean includeNulls, boolean[] nulls, long[] values) { return new Int128ArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), values); }
Source:
public void testBytes() { // Single tinyint column assertQueryUsingH2Cte("SELECT ship_day FROM lineitem_ex"); assertQueryUsingH2Cte("SELECT ship_day FROM lineitem_ex WHERE ship_day < 15"); assertQueryUsingH2Cte("SELECT count(*) FROM lineitem_ex WHERE ship_day > 15"); assertQueryUsingH2Cte("SELECT count(*) FROM lineitem_ex WHERE ship_day is null"); // Two tinyint columns assertQueryUsingH2Cte("SELECT ship_day, ship_month FROM lineitem_ex"); assertQueryUsingH2Cte("SELECT ship_day, ship_month FROM lineitem_ex WHERE ship_month = 1"); assertQueryUsingH2Cte("SELECT ship_day, ship_month FROM lineitem_ex WHERE ship_day = 1 AND ship_month = 1"); assertQueryUsingH2Cte("SELECT COUNT(*) FROM lineitem_ex WHERE ship_month is null"); assertQueryUsingH2Cte("SELECT COUNT(*) FROM lineitem_ex WHERE ship_day is not null AND ship_month = 1"); assertQueryUsingH2Cte("SELECT ship_day, ship_month FROM lineitem_ex WHERE ship_day > 15 AND ship_month < 5 AND (ship_day + ship_month) < 20"); assertQueryUsingH2Cte("SELECT count(*) FROM lineitem_ex WHERE ship_day_month[2] = 12"); START assertQueryUsingH2Cte("SELECT ship_day_month_nulls FROM lineitem_ex WHERE ship_day_month_nulls[1] is NOT NULL AND ship_day_month[1] > 3"); END } I expect this query to fail because ship_day_month_nulls column doesn't exist

Target:
public void testBytes() { // Single tinyint column assertQueryUsingH2Cte("SELECT ship_day FROM lineitem_ex"); assertQueryUsingH2Cte("SELECT ship_day FROM lineitem_ex WHERE ship_day < 15"); assertQueryUsingH2Cte("SELECT count(*) FROM lineitem_ex WHERE ship_day > 15"); assertQueryUsingH2Cte("SELECT count(*) FROM lineitem_ex WHERE ship_day is null"); // Two tinyint columns assertQueryUsingH2Cte("SELECT ship_day, ship_month FROM lineitem_ex"); assertQueryUsingH2Cte("SELECT ship_day, ship_month FROM lineitem_ex WHERE ship_month = 1"); assertQueryUsingH2Cte("SELECT ship_day, ship_month FROM lineitem_ex WHERE ship_day = 1 AND ship_month = 1"); assertQueryUsingH2Cte("SELECT COUNT(*) FROM lineitem_ex WHERE ship_month is null"); assertQueryUsingH2Cte("SELECT COUNT(*) FROM lineitem_ex WHERE ship_day is not null AND ship_month = 1"); assertQueryUsingH2Cte("SELECT ship_day, ship_month FROM lineitem_ex WHERE ship_day > 15 AND ship_month < 5 AND (ship_day + ship_month) < 20"); assertQueryUsingH2Cte("SELECT count(*) FROM lineitem_ex WHERE ship_day_month[2] = 12"); }
Source:
private long createTable(String name) { START return dbi.onDemand(MetadataDao.class).insertTable("test", name, false, true, null, 0, false); END } Why do we change the `organized` argument from `false` to `true`?

Target:
private long createTable(String name) { return dbi.onDemand(MetadataDao.class).insertTable("test", name, false, false, null, 0, false); }
Source:
public void start() { START log.info("ShardOrganizationManager start, enabled: %s, started: %s", enabled, started); END if (!enabled || started.getAndSet(true)) { log.info("ShardOrganizationManager return"); return; } startDiscovery(); } I don't think we need this log. Same for the next one.

Target:
public void start() { if (!enabled || started.getAndSet(true)) { return; } startDiscovery(); }
Source:
public void testTriggerBucketBalancer() { START assertUpdate("CREATE TABLE test_bucket_balancer (c1 bigint, c2 bigint)"); END assertUpdate("INSERT INTO test_bucket_balancer VALUES (1, 1), (1, 2), (1, 3), (1, 4), (11, 1), (11, 2)", 6); assertUpdate("CALL system.trigger_bucket_balancer()"); assertUpdate("DROP TABLE test_bucket_balancer"); } I think we don't need to create a table for this test. Just call the procedure and see if it fails.

Target:
public void testTriggerBucketBalancer() { assertUpdate("CALL system.trigger_bucket_balancer()"); }
Source:
public void testCreateTableWithUnsupportedType() { assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS)); try { ConnectorTableMetadata raptorMetadata = START buildTable(ImmutableMap.of(), tableMetadataBuilder(DEFAULT_TEST_ORDERS) END .column("orderkey", BIGINT) .column("rowtype", RowType.withDefaultFieldNames(ImmutableList.of(BIGINT)))); metadata.createTable(SESSION, raptorMetadata, false); fail(); } catch (PrestoException e) { assertEquals(e.getErrorCode(), NOT_SUPPORTED.toErrorCode()); } } Let's put this together with the previous line ```java ConnectorTableMetadata raptorMetadata = buildTable(ImmutableMap.of(), tableMetadataBuilder(DEFAULT_TEST_ORDERS) ...

Target:
public void testCreateTableWithUnsupportedType() { assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS)); ConnectorTableMetadata raptorMetadata = buildTable(ImmutableMap.of(), tableMetadataBuilder(DEFAULT_TEST_ORDERS) .column("orderkey", BIGINT) .column("rowtype", RowType.withDefaultFieldNames(ImmutableList.of(BIGINT)))); try { metadata.createTable(SESSION, raptorMetadata, false); fail(); } catch (PrestoException e) { assertEquals(e.getErrorCode(), NOT_SUPPORTED.toErrorCode()); } }
Source:
public void setup() { for (int i = 0; i < POSITIONS_PER_PAGE; i++) { longValues[i] = random.nextLong(); ids[i] = random.nextInt(POSITIONS_PER_PAGE / 10); positions[i] = i; START if (i % 7 == 0) { END nulls[i] = true; } } } nit: what about ```java nulls[i] = i % 7 == 0 ``` ?

Target:
public void setup() { for (int i = 0; i < POSITIONS_PER_PAGE; i++) { longValues[i] = random.nextLong(); ids[i] = random.nextInt(POSITIONS_PER_PAGE / 10); positions[i] = i; nulls[i] = i % 7 == 0; } }
Source:
synchronized Map<QueryId, Map<String, Long>> getTaggedMemoryAllocations() { return taggedMemoryAllocations.keySet().stream() START .collect(toImmutableMap(identity(), queryId -> getTaggedMemoryAllocations(queryId))); END } `this:: getTaggedMemoryAllocations`

Target:
synchronized Map<QueryId, Map<String, Long>> getTaggedMemoryAllocations() { return taggedMemoryAllocations.keySet().stream() .collect(toImmutableMap(identity(), this::getTaggedMemoryAllocations)); }
Source:
public PlanNode visitSemiJoin(SemiJoinNode node, RewriteContext<RowExpression> context) { RowExpression inheritedPredicate = context.get(); START if (!extractConjuncts(inheritedPredicate).contains(new SymbolReference(node.getSemiJoinOutput().getName()))) { END return visitNonFilteringSemiJoin(node, context); } return visitFilteringSemiJoin(node, context); } SymbolReference is an issue

Target:
public PlanNode visitSemiJoin(SemiJoinNode node, RewriteContext<RowExpression> context) { RowExpression inheritedPredicate = context.get(); if (!extractConjuncts(inheritedPredicate).contains(node.getSemiJoinOutput())) { return visitNonFilteringSemiJoin(node, context); } return visitFilteringSemiJoin(node, context); }
Source:
public void readFully(long position, byte[] buffer) START throws IOException END { } `throws IOException` is not needed. Same for other `readFully`s

Target:
public void readFully(long position, byte[] buffer) { }
Source:
START public int getHeight() END { return levelOffsets.length; } this method is not used

Target:
int getHeight() { return levelOffsets.length; }
Source:
public static Expression rewrite(Expression expression, Session session, Metadata metadata, SqlParser sqlParser, SymbolAllocator symbolAllocator) { requireNonNull(metadata, "metadata is null"); START requireNonNull(sqlParser, "sqlParser is null"); END if (expression instanceof SymbolReference) { return expression; } return new AnalyzedExpressionRewriter(session, metadata, sqlParser, symbolAllocator.getTypes()).rewriteWith(Visitor::new, expression); } If `apply` is added, the `testCorrelatedExistsSubqueries` will fail. It seems like `ExpressionAnalyzer` are having trouble analyze subquery ( For example, `EXISTIS ( SELECT ...)`). This has been a long standing issue though. The current solution is do the `Desugar` again after correlated subqueries are replaced with plan nodes. This is an issue might worth dig into, but likely outside the scope of this PR.

Target:
public static Expression rewrite(Expression expression, Session session, Metadata metadata, SqlParser sqlParser, SymbolAllocator symbolAllocator) { requireNonNull(metadata, "metadata is null"); requireNonNull(sqlParser, "sqlParser is null"); return new AnalyzedExpressionRewriter(session, metadata, sqlParser, symbolAllocator.getTypes()).rewriteWith(Visitor::new, expression); }
Source:
START protected UnweightedReservoirSampleStateStrategy(UnweightedReservoirSampleStateStrategy other) END { reservoir = other.reservoir.clone(); } make this private

Target:
private UnweightedReservoirSampleStateStrategy(UnweightedReservoirSampleStateStrategy other) { reservoir = other.reservoir.clone(); }
Source:
public static void output(@AggregationState DifferentialEntropyState state, BlockBuilder out) { DifferentialEntropyStateStrategy strategy = state.getStrategy(); START double result = strategy == null ? Double.NaN : strategy.calculateEntropy(); END DOUBLE.writeDouble(out, result); } I'd inline result variable: `DOUBLE.writeDouble(out, strategy == null ? Double.NaN : strategy.calculateEntropy());`

Target:
public static void output(@AggregationState DifferentialEntropyState state, BlockBuilder out) { DifferentialEntropyStateStrategy strategy = state.getStrategy(); DOUBLE.writeDouble(out, strategy == null ? Double.NaN : strategy.calculateEntropy()); }
Source:
public void setStrategy(DifferentialEntropyStateStrategy strategy) { START requireNonNull(strategy, "strategy is null"); END this.strategy = strategy; } nit: combine with assignment `this.strategy = requireNonNull(strategy, "strategy is null");`

Target:
public void setStrategy(DifferentialEntropyStateStrategy strategy) { this.strategy = requireNonNull(strategy, "strategy is null"); }
Source:
public Operator createOperator(DriverContext driverContext) { OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, PartitionedOutputOperator.class.getSimpleName()); return new PartitionedOutputOperator( operatorContext, sourceTypes, pagePreprocessor, partitionFunction, partitionChannels, partitionConstants, replicatesAnyRow, nullChannel, outputBuffer, serdeFactory, maxMemory, START SystemSessionProperties.isOptimizedRepartitioningEnabled(operatorContext.getSession())); END } static import

Target:
public Operator createOperator(DriverContext driverContext) { OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, PartitionedOutputOperator.class.getSimpleName()); return new PartitionedOutputOperator( operatorContext, sourceTypes, pagePreprocessor, partitionFunction, partitionChannels, partitionConstants, replicatesAnyRow, nullChannel, outputBuffer, serdeFactory, maxMemory); }
Source:
public void addInput(Page page) { requireNonNull(page, "page is null"); if (page.getPositionCount() == 0) { return; } page = pagePreprocessor.apply(page); if (useOptmizedPartitionedOutputOperator) { START partitionFunction.ariaPartitionPage(page); END } else { partitionFunction.partitionPage(page); } operatorContext.recordOutput(page.getSizeInBytes(), page.getPositionCount()); // We use getSizeInBytes() here instead of getRetainedSizeInBytes() for an approximation of // the amount of memory used by the pageBuilders, because calculating the retained // size can be expensive especially for complex types. long partitionsSizeInBytes = partitionFunction.getSizeInBytes(); // We also add partitionsInitialRetainedSize as an approximation of the object overhead of the partitions. systemMemoryContext.setBytes(partitionsSizeInBytes + partitionsInitialRetainedSize); } - don't use `aria` in the code - partitionPageOptimized ?

Target:
public void addInput(Page page) { requireNonNull(page, "page is null"); if (page.getPositionCount() == 0) { return; } page = pagePreprocessor.apply(page); partitionFunction.partitionPage(page); operatorContext.recordOutput(page.getSizeInBytes(), page.getPositionCount()); // We use getSizeInBytes() here instead of getRetainedSizeInBytes() for an approximation of // the amount of memory used by the pageBuilders, because calculating the retained // size can be expensive especially for complex types. long partitionsSizeInBytes = partitionFunction.getSizeInBytes(); // We also add partitionsInitialRetainedSize as an approximation of the object overhead of the partitions. systemMemoryContext.setBytes(partitionsSizeInBytes + partitionsInitialRetainedSize); }
Source:
private static void setupLogging() { Logging logging = Logging.initialize(); logging.setLevel("org.apache.parquet.hadoop", WARN); logging.setLevel("parquet.hadoop", WARN); START logging.setLevel("org.glassfish.jersey.internal.inject.Providers", ERROR); END logging.setLevel("com.facebook.presto.server.PluginManager", WARN); logging.setLevel("io.airlift.bootstrap.LifeCycleManager", WARN); logging.setLevel("com.facebook.presto.security.AccessControlManager", WARN); logging.setLevel("org.eclipse.jetty.server.handler.ContextHandler", WARN); logging.setLevel("org.eclipse.jetty.server.AbstractConnector", WARN); } perhaps, arrange these lines in alphabetical order: ``` logging.setLevel("com.facebook.presto.security.AccessControlManager", WARN); logging.setLevel("com.facebook.presto.server.PluginManager", WARN); logging.setLevel("io.airlift.bootstrap.LifeCycleManager", WARN); logging.setLevel("org.apache.parquet.hadoop", WARN); logging.setLevel("org.eclipse.jetty.server.handler.ContextHandler", WARN); logging.setLevel("org.eclipse.jetty.server.AbstractConnector", WARN); logging.setLevel("org.glassfish.jersey.internal.inject.Providers", ERROR); logging.setLevel("parquet.hadoop", WARN); logging.setLevel("parquet.hadoop", WARN); ```

Target:
private static void setupLogging() { Logging logging = Logging.initialize(); logging.setLevel("com.facebook.presto.security.AccessControlManager", WARN); logging.setLevel("com.facebook.presto.server.PluginManager", WARN); logging.setLevel("io.airlift.bootstrap.LifeCycleManager", WARN); logging.setLevel("org.apache.parquet.hadoop", WARN); logging.setLevel("org.eclipse.jetty.server.handler.ContextHandler", WARN); logging.setLevel("org.eclipse.jetty.server.AbstractConnector", WARN); logging.setLevel("org.glassfish.jersey.internal.inject.Providers", ERROR); logging.setLevel("parquet.hadoop", WARN); }
Source:
public void partitionPage(Page page) { populatePositionsForEachPartition(page); int channelCount = page.getChannelCount(); for (int i = 0; i < channelCount; i++) { START decodedBlocks[i] = decodeBlock(flattener, page.getBlock(i)); END } for (int i = 0; i < partitionData.length; i++) { partitionData[i].appendRows(decodedBlocks, fixedWidthRowSize, variableWidthChannels, outputBuffer); } } channelCount -> decodedBlocks.length for consistency with the next loop

Target:
public void partitionPage(Page page) { populatePositionsForEachPartition(page); for (int i = 0; i < decodedBlocks.length; i++) { decodedBlocks[i] = decodeBlock(flattener, page.getBlock(i)); } for (int i = 0; i < partitionData.length; i++) { partitionData[i].appendRows(decodedBlocks, fixedWidthRowSize, variableWidthChannels, outputBuffer); } }
Source:
public void close() { try (Closer closer = Closer.create()) { START closer.register(() -> directReader.close()); END closer.register(() -> dictionaryReader.close()); } catch (IOException e) { throw new UncheckedIOException(e); } } nit ```java closer.register(directReader::close); closer.register(dictionaryReader::close);

Target:
public void close() { try (Closer closer = Closer.create()) { closer.register(directReader::close); closer.register(dictionaryReader::close); } catch (IOException e) { throw new UncheckedIOException(e); } }
Source:
public void startStripe(InputStreamSources dictionaryStreamSources, List<ColumnEncoding> encoding) throws IOException { ColumnEncoding.ColumnEncodingKind kind = encoding.get(streamDescriptor.getStreamId()) .getColumnEncoding(streamDescriptor.getSequence()) .getColumnEncodingKind(); START if (kind == DIRECT || kind == DIRECT_V2 || kind == DWRF_DIRECT) { END currentReader = directReader; } else if (kind == DICTIONARY) { currentReader = dictionaryReader; } else { throw new IllegalArgumentException("Unsupported encoding " + kind); } currentReader.startStripe(dictionaryStreamSources, encoding); } I think this would be better expressed as a switch statement

Target:
public void startStripe(InputStreamSources dictionaryStreamSources, List<ColumnEncoding> encoding) throws IOException { ColumnEncoding.ColumnEncodingKind kind = encoding.get(streamDescriptor.getStreamId()) .getColumnEncoding(streamDescriptor.getSequence()) .getColumnEncodingKind(); switch (kind) { case DIRECT: case DIRECT_V2: case DWRF_DIRECT: currentReader = directReader; break; case DICTIONARY: currentReader = dictionaryReader; break; default: throw new IllegalArgumentException("Unsupported encoding " + kind); } currentReader.startStripe(dictionaryStreamSources, encoding); }
Source:
private MergeQuantileDigestFunction() { START super(NAME, QDIGEST, StatisticalDigestStateFactory.createQuantileDigestFactory()); END } nits: static import

Target:
private MergeQuantileDigestFunction() { super(NAME, QDIGEST, createQuantileDigestFactory(), false); }
Source:
private MergeTDigestFunction() { START super(NAME, TDIGEST, StatisticalDigestStateFactory.createTDigestFactory()); END } nits: static import

Target:
private MergeTDigestFunction() { super(NAME, TDIGEST, createTDigestFactory(), true); }