auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>void rankIndexSearchApply(AbstractPlanNode plan) { if ( ! (plan instanceof IndexScanPlanNode) ) { return; } IndexScanPlanNode indexscan = (IndexScanPlanNode)plan; if (indexscan.getPredicate() != null || indexscan.getEndExpression() != null || indexscan.getSkipNullPredicate() != null || indexscan.getInitialExpression() != null) { return; } if (indexscan.getInlinePlanNodes().isEmpty()) { return; } <START> <END> LimitPlanNode limit = (LimitPlanNode) indexscan.getInlinePlanNodes().get(PlanNodeType.LIMIT); if (limit == null || !limit.hasOffset()) { return; } Index index = indexscan.getCatalogIndex(); if (! index.getCountable()) { return; } if (! indexscan.getSearchKeyExpressions().isEmpty()) { return; } indexscan.setOffsetRank(true); }</code><technical_language>other kinds of plan nodes inlined index scan prohibit this optimization? aggregation</technical_language>

Target:
void rankIndexSearchApply(AbstractPlanNode plan) { if ( ! (plan instanceof IndexScanPlanNode) ) { return; } IndexScanPlanNode indexscan = (IndexScanPlanNode)plan; if (indexscan.getPredicate() != null || indexscan.getEndExpression() != null || indexscan.getSkipNullPredicate() != null || indexscan.getInitialExpression() != null) { return; } if (indexscan.getInlinePlanNodes().isEmpty()) { return; } LimitPlanNode limit = (LimitPlanNode) indexscan.getInlinePlanNodes().get(PlanNodeType.LIMIT); if (limit == null || !limit.hasOffset()) { return; } if (AggregatePlanNode.getInlineAggregationNode(indexscan) != null) { return; } Index index = indexscan.getCatalogIndex(); if (! index.getCountable()) { return; } if (! indexscan.getSearchKeyExpressions().isEmpty()) { return; } indexscan.setOffsetRank(true); }
Source:
<code>protected void updateDetailsAvailability() { super.updateDetailsAvailability(); NetworkView network = getSelectedItem(); if (network == null || !network.isExternal()) { externalSubnetListModel.setIsAvailable(false); } else { AsyncDataProvider.getInstance().getProviderById( <START> new AsyncQuery<>(provider -> externalSubnetListModel.setIsAvailable(!provider.getIsUnmanaged())), <END> network.getProvidedBy().getProviderId()); } }</code><technical_language>afraid of a NPE in case provider removed async answer returned. Please add a null check explain do a NPE happen here:)</technical_language>

Target:
protected void updateDetailsAvailability() { super.updateDetailsAvailability(); NetworkView network = getSelectedItem(); if (network == null || !network.isExternal()) { externalSubnetListModel.setIsAvailable(false); } else { AsyncDataProvider.getInstance().getProviderById( new AsyncQuery<>(provider -> { boolean available = provider != null ? !provider.getIsUnmanaged() : false; externalSubnetListModel.setIsAvailable(available); }), network.getProvidedBy().getProviderId()); } }
Source:
<code><START> public BaseProfitBricksRequestBinder(String paramName) { <END> this.paramName = checkNotNull(paramName, "Initialize 'paramName' in constructor"); }</code><technical_language>This created Guice injector. constructor protected</technical_language>

Target:
protected BaseProfitBricksRequestBinder(String paramName) { this.paramName = checkNotNull(paramName, "Initialize 'paramName' in constructor"); }
Source:
<code>private PointSensitivityBuilder calculateRateSensitivity() { <START> PointSensitivityBuilder combinedPointSensitivity = PointSensitivityBuilder.none(); <END> double factor = pastCompositionFactor() * valuationCompositionFactor() / accrualFactorTotal; ObjectDoublePair<PointSensitivityBuilder> compositionFactorAndSensitivityNonCutoff = compositionFactorAndSensitivityNonCutoff(); ObjectDoublePair<PointSensitivityBuilder> compositionFactorAndSensitivityCutoff = compositionFactorAndSensitivityCutoff(); combinedPointSensitivity = combinedPointSensitivity.combinedWith(compositionFactorAndSensitivityNonCutoff .getFirst().multipliedBy(compositionFactorAndSensitivityCutoff.getSecond())); combinedPointSensitivity = combinedPointSensitivity.combinedWith(compositionFactorAndSensitivityCutoff .getFirst().multipliedBy(compositionFactorAndSensitivityNonCutoff.getSecond())); combinedPointSensitivity = combinedPointSensitivity.multipliedBy(factor); return combinedPointSensitivity; }</code><technical_language>empty builder is required</technical_language>

Target:
private PointSensitivityBuilder calculateRateSensitivity() { double factor = pastCompositionFactor() * valuationCompositionFactor() / accrualFactorTotal; ObjectDoublePair<PointSensitivityBuilder> compositionFactorAndSensitivityNonCutoff = compositionFactorAndSensitivityNonCutoff(); ObjectDoublePair<PointSensitivityBuilder> compositionFactorAndSensitivityCutoff = compositionFactorAndSensitivityCutoff(); PointSensitivityBuilder combinedPointSensitivity = compositionFactorAndSensitivityNonCutoff.getFirst(). multipliedBy(compositionFactorAndSensitivityCutoff.getSecond() * factor); combinedPointSensitivity = combinedPointSensitivity.combinedWith(compositionFactorAndSensitivityCutoff .getFirst().multipliedBy(compositionFactorAndSensitivityNonCutoff.getSecond() * factor)); return combinedPointSensitivity; }
Source:
<code>public void repairHand(User user) throws Exception { <START> final ItemStack item = user.getBase().getInventory().getItemInMainHand(); <END> if (item == null || item.getType().isBlock() || item.getDurability() == 0) { throw new Exception(tl("repairInvalidType")); } if (!item.getEnchantments().isEmpty() && !ess.getSettings().getRepairEnchanted() && !user.isAuthorized("essentials.repair.enchanted")) { throw new Exception(tl("repairEnchanted")); } final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH); final Trade charge = getCharge(item.getType()); charge.isAffordableFor(user); repairItem(item); charge.charge(user); user.getBase().updateInventory(); user.sendMessage(tl("repair", itemName.replace('_', ' '))); }</code><technical_language>hand added in 1.9 this break versions (such popular 1.8.8). Do want add a version check for this? breaking <1.9 support completely</technical_language>

Target:
public void repairHand(User user) throws Exception { final ItemStack item = user.getItemInHand(); if (item == null || item.getType().isBlock() || item.getDurability() == 0) { throw new Exception(tl("repairInvalidType")); } if (!item.getEnchantments().isEmpty() && !ess.getSettings().getRepairEnchanted() && !user.isAuthorized("essentials.repair.enchanted")) { throw new Exception(tl("repairEnchanted")); } final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH); final Trade charge = getCharge(item.getType()); charge.isAffordableFor(user); repairItem(item); charge.charge(user); user.getBase().updateInventory(); user.sendMessage(tl("repair", itemName.replace('_', ' '))); }
Source:
<code>public void showImages(List<PostImage> images, int position, Loadable loadable) { MultiImageView.Mode newMode; <START> if(this.images.size() < 1) { <END> newMode = MultiImageView.Mode.LOWRES; } else { newMode = callback.getImageMode(getCurrentPostImage()); } this.images.addAll(images); this.selectedPosition = position; this.loadable = loadable; this.progress = new ArrayList<>(this.images.size()); for (int i = 0; i < this.images.size(); i++) { this.progress.add(i, -1f); } callback.setPagerItems(this.images, selectedPosition); callback.setImageMode(this.images.get(selectedPosition), newMode); }</code><technical_language>list.isEmpty() instead of .size() < 1</technical_language>

Target:
public void showImages(List<PostImage> images, int position, Loadable loadable) { MultiImageView.Mode newMode; if(this.images.isEmpty()) { newMode = MultiImageView.Mode.LOWRES; } else { newMode = callback.getImageMode(getCurrentPostImage()); } this.images.addAll(images); this.selectedPosition = position; this.loadable = loadable; progress = new ArrayList<>(this.images.size()); for (int i = 0; i < this.images.size(); i++) { progress.add(i, -1f); } callback.setPagerItems(this.images, selectedPosition); callback.setImageMode(this.images.get(selectedPosition), newMode); }
Source:
<code><START> @Test public void shouldOpenCompareEditorInWorksaceModel() throws Exception { <END> resetRepository(PROJ1); createTag(PROJ1, "compare2"); changeFilesInProject(); showDialog(PROJ1, "Team", "Synchronize..."); bot.shell("Synchronize repository: " + REPO1 + File.separator + ".git") .activate(); bot.comboBox(2) .setSelection(UIText.SynchronizeWithAction_tagsName); bot.comboBox(3).setSelection("compare2"); bot.button(IDialogConstants.OK_LABEL).click(); SWTBotView syncView = bot.viewByTitle("Synchronize"); syncView.toolbarDropDownButton("Show File System Resources").click() .menuItem("Workspace").click(); SWTBotTree syncViewTree = syncView.bot().tree(); syncViewTree.getAllItems()[0].collapse().doubleClick(); syncViewTree.getAllItems()[0].getNode(FOLDER).getNode(FILE1) .doubleClick(); SWTBot compare = bot.editorByTitle(FILE1).bot(); assertNotNull(compare); }</code><technical_language>typo in method name s/InWorksaceModel/InWorkspaceModel/</technical_language>

Target:
@Test public void shouldOpenCompareEditorInWorksaceModel() throws Exception { resetRepository(PROJ1); createTag(PROJ1, "compare2"); changeFilesInProject(); showDialog(PROJ1, "Team", "Synchronize..."); bot.shell("Synchronize repository: " + REPO1 + File.separator + ".git") .activate(); bot.comboBox(2) .setSelection(UIText.SynchronizeWithAction_tagsName); bot.comboBox(3).setSelection("compare2"); bot.button(IDialogConstants.OK_LABEL).click(); SWTBotView syncView = bot.viewByTitle("Synchronize"); syncView.toolbarDropDownButton("Show File System Resources").click() .menuItem("Workspace").click(); SWTBotTree syncViewTree = syncView.bot().tree(); syncViewTree.getAllItems()[0].expand().getItems()[0].expand() .getItems()[0].doubleClick(); SWTBot compare = bot.editorByTitle(FILE1).bot(); assertNotNull(compare); }
Source:
<code>protected void setupInternals() throws IOException { if (getObjectDirectory() == null) { <START> if (getGitCommonDir() != null) <END> setObjectDirectory( safeFS().resolve(getGitCommonDir(), OBJECTS)); else if (getGitDir() != null) setObjectDirectory(safeFS().resolve(getGitDir(), OBJECTS)); } }</code><technical_language>style nit: missing braces</technical_language>

Target:
protected void setupInternals() throws IOException { if (getObjectDirectory() == null) { if (getGitCommonDir() != null) { setObjectDirectory( safeFS().resolve(getGitCommonDir(), OBJECTS)); } else if (getGitDir() != null) { setObjectDirectory(safeFS().resolve(getGitDir(), OBJECTS)); } } }
Source:
<code>public static HostController create(final File jbossHomeDir, final ModuleLoader moduleLoader, final Properties systemProps, final Map<String, String> systemEnv, final String[] cmdargs) { assert jbossHomeDir != null : "jbossHomeDir is null"; assert moduleLoader != null : "moduleLoader is null"; assert systemProps != null : "systemProps is null"; assert systemEnv != null : "systemEnv is null"; <START> assert cmdargs != null : "cmdargs is null"; <END> setupCleanDirectories(jbossHomeDir, systemProps); return new HostControllerImpl(jbossHomeDir, cmdargs, systemProps, systemEnv, moduleLoader); }</code><technical_language>methods public generally consumers of API. if assertions work if user enables assertions. this, EmbeddedStandaloneFactory, internally ManagedProcessFactory this matter</technical_language>

Target:
public static HostController create(final File jbossHomeDir, final ModuleLoader moduleLoader, final Properties systemProps, final Map<String, String> systemEnv, final String[] cmdargs) { if (jbossHomeDir == null) throw EmbeddedLogger.ROOT_LOGGER.nullVar("jbossHomeDir"); if (moduleLoader == null) throw EmbeddedLogger.ROOT_LOGGER.nullVar("moduleLoader"); if (systemProps == null) throw EmbeddedLogger.ROOT_LOGGER.nullVar("systemProps"); if (systemEnv == null) throw EmbeddedLogger.ROOT_LOGGER.nullVar("systemEnv"); if (cmdargs == null) throw EmbeddedLogger.ROOT_LOGGER.nullVar("cmdargs"); setupCleanDirectories(jbossHomeDir, systemProps); return new HostControllerImpl(jbossHomeDir, cmdargs, systemProps, systemEnv, moduleLoader); }
Source:
<code>public void testFlatten() { Properties prop1 = new Properties(); prop1.put("key1", "value1"); Properties prop2 = new Properties(prop1); prop2.put("key2", "value2"); Properties prop3 = new Properties(prop2); prop3.put("key3", "value3"); Properties flattened = flatten(prop3); <START> Assert.assertEquals(flattened.get("key1"), prop3.getProperty("key1")); Assert.assertEquals(flattened.get("key2"), prop3.getProperty("key2")); Assert.assertEquals(flattened.get("key3"), prop3.getProperty("key3")); Assert.assertNotEquals(flattened.get("key1"), prop3.get("key1")); Assert.assertNotEquals(flattened.get("key2"), prop3.get("key2")); Assert.assertEquals(flattened.get("key3"), prop3.get("key3")); <END> Assert.assertEquals(flattened.get("key1"), "value1"); Assert.assertEquals(flattened.get("key2"), "value2"); Assert.assertEquals(flattened.get("key3"), "value3"); }</code><technical_language>remove assertions 3</technical_language>

Target:
public void testFlatten() { Properties prop1 = new Properties(); prop1.put("key1", "value1"); Properties prop2 = new Properties(prop1); prop2.put("key2", "value2"); Properties prop3 = new Properties(prop2); prop3.put("key3", "value3"); Properties flattened = flatten(prop3); Assert.assertEquals(flattened.get("key1"), "value1"); Assert.assertEquals(flattened.get("key2"), "value2"); Assert.assertEquals(flattened.get("key3"), "value3"); }
Source:
<code>public void setStartDate(Date startDate) { <START> this.startDate = endDate != null ? (Date) startDate.clone() : null; <END> }</code><technical_language>check [this](<LINK_0>, deep copy instead of clone in setters</technical_language>

Target:
public void setStartDate(Date startDate) { this.startDate = startDate != null ? new Date(startDate.getTime()) : null; }
Source:
<code>public void shutdown() { LOGGER.entering(); running = false; proxyLogger.fine("Interrupting NodeRecycleThread."); <START> interrupt(); <END> LOGGER.exiting(); }</code><technical_language>setting running false interrupting thread here. sufficient</technical_language>

Target:
public void shutdown() { LOGGER.entering(); running = false; proxyLogger.fine("Shutting down NodeRecycleThread for node " + nodeId); interrupt(); LOGGER.exiting(); }
Source:
<code><START> public List<StudentProfile> getStudentProfileEntities() { <END> Query q = getPm().newQuery(StudentProfile.class); return (List<StudentProfile>) q.execute(); }</code><technical_language>If this method in getAllStudentProfiles, private. Also, consider inline method in getAllStudentProfiles lines here</technical_language>

Target:
private List<StudentProfile> getStudentProfileEntities() { Query q = getPm().newQuery(StudentProfile.class); return (List<StudentProfile>) q.execute(); }
Source:
<code>private boolean checkSumsHolder(DiscreteNaiveBayesSumsHolder holder1, DiscreteNaiveBayesSumsHolder holder2) { if (holder1 == null || holder2 == null) { return false; } <START> Optional<long[][]> optinalFirst = holder1.valuesInBucketPerLbl.values().stream().findFirst(); <END> Optional<long[][]> optinalSecond = holder2.valuesInBucketPerLbl.values().stream().findFirst(); if (optinalFirst.isPresent()) { if (optinalSecond.isPresent()) { return optinalFirst.get().length == optinalSecond.get().length; } else { return false; } } else { return !optinalSecond.isPresent(); } }</code><technical_language>"optional"</technical_language>

Target:
private boolean checkSumsHolder(DiscreteNaiveBayesSumsHolder holder1, DiscreteNaiveBayesSumsHolder holder2) { if (holder1 == null || holder2 == null) { return false; } Optional<long[][]> optionalFirst = holder1.valuesInBucketPerLbl.values().stream().findFirst(); Optional<long[][]> optionalSecond = holder2.valuesInBucketPerLbl.values().stream().findFirst(); if (optionalFirst.isPresent()) { if (optionalSecond.isPresent()) { return optionalFirst.get().length == optionalSecond.get().length; } else { return false; } } else { return !optionalSecond.isPresent(); } }
Source:
<code>protected FSDataOutputStream openStreamInAppendMode(Path filepath) { FSDataOutputStream fsOutput = null; try { fsOutput = fs.append(filepath); } catch (IOException e) { <START> if (e.getMessage().contains("Not supported")) { <END> fsOutput = openStreamForNonAppendFS(filepath); } } return fsOutput; }</code><technical_language>is output of e.getMessage() in this case? e.getMessage().equals instead of contains</technical_language>

Target:
protected FSDataOutputStream openStreamInAppendMode(Path filepath) { FSDataOutputStream fsOutput = null; try { fsOutput = fs.append(filepath); } catch (IOException e) { if (e.getMessage().equals("Not supported")) { fsOutput = openStreamForNonAppendFS(filepath); } } return fsOutput; }
Source:
<code><START> private List<JBPMProcessModel> findModels(final Path path, final Predicate<Definitions> filter) { <END> Path rootPath = moduleService.resolveModule(path).getRootPath(); return VFSScanner.scan(ioService, Paths.convert(rootPath), ResourceType.getResourceType("BPMN2").getAllExtensions(), this::toDefinitions, filter) .stream() .filter(Objects::nonNull) .map(VFSScanner.ScanResult::getResource) .map(definitions -> parseToModel(definitions, path)) .collect(Collectors.toList()); }</code><technical_language>This method return Stream instead of List, method getModelForProcess need create a stream again</technical_language>

Target:
private Stream<JBPMProcessModel> findModels(final Path path, final Predicate<Definitions> filter) { Path rootPath = moduleService.resolveModule(path).getRootPath(); return VFSScanner.scan(ioService, Paths.convert(rootPath), ResourceType.getResourceType("BPMN2").getAllExtensions(), this::toDefinitions, filter) .stream() .filter(Objects::nonNull) .map(VFSScanner.ScanResult::getResource) .map(definitions -> parseToModel(definitions, path)); }
Source:
<code>protected FirebaseRecyclerAdapter<Chat, ChatHolder> getAdapter() { return new FirebaseRecyclerAdapter<Chat, ChatHolder>( <START> new FirebaseIndexArray<>( <END> mChatIndicesRef.limitToLast(50), mChatRef, new ClassSnapshotParser<>(Chat.class)), R.layout.message, ChatHolder.class, this) { @Override public void populateViewHolder(ChatHolder holder, Chat chat, int position) { holder.bind(chat); } @Override public void onDataChanged() { mEmptyListMessage.setVisibility(getItemCount() == 0 ? View.VISIBLE : View.GONE); } }; }</code><technical_language>do need create IndexArray manually now</technical_language>

Target:
protected FirebaseRecyclerAdapter<Chat, ChatHolder> getAdapter() { return new FirebaseIndexRecyclerAdapter<Chat, ChatHolder>( Chat.class, R.layout.message, ChatHolder.class, mChatIndicesRef.limitToLast(50), mChatRef, this) { @Override public void populateViewHolder(ChatHolder holder, Chat chat, int position) { holder.bind(chat); } @Override public void onDataChanged() { mEmptyListMessage.setVisibility(getItemCount() == 0 ? View.VISIBLE : View.GONE); } }; }
Source:
<code>public ConfigRenderOptions setComments(boolean value) { if (value == comments) return this; else <START> return new ConfigRenderOptions(originComments, value, formatted, json, new DefaultComparator()); <END> }</code><technical_language>setters copying existing comparator I believe. (otherwise setting other comparator reset comparator.) Meaning change new DefaultComparator() comparator for set* methods</technical_language>

Target:
public ConfigRenderOptions setComments(boolean value) { if (value == comments) return this; else return new ConfigRenderOptions(originComments, value, formatted, json, comparator); }
Source:
<code>private static JobInfo waitFor(final long jobId, AlluxioConfiguration alluxioConf) throws InterruptedException { try (final JobMasterClient client = JobMasterClient.Factory.create(JobMasterClientContext .newBuilder(ClientContext.create(alluxioConf)).build())) { JobInfo resultInfo = CommonUtils.waitForResult("Job to finish", ()-> { try { return client.getJobStatus(jobId); } catch (Exception e) { LOG.warn("Failed to get status for job (jobId={})", jobId, e); return null; } }, (jobInfo) -> { if (jobInfo != null) { switch (jobInfo.getStatus()) { case FAILED: case CANCELED: case COMPLETED: return true; case RUNNING: case CREATED: return false; default: throw new IllegalStateException("Unrecognized job status: " + jobInfo.getStatus()); } } return true; }, WaitForOptions.defaults().setInterval(1000)); if (resultInfo != null) { <START> resultInfo = client.getJobStatusDetailed(resultInfo.getId()); <END> } return resultInfo; } catch (IOException e) { LOG.warn("Failed to close job master client: {}", e.toString()); return null; } catch (TimeoutException e) { throw new IllegalStateException(e); } }</code><technical_language>If resultInfo is null this point return null. add @Nullable this method</technical_language>

Target:
private static JobInfo waitFor(final long jobId, AlluxioConfiguration alluxioConf) throws InterruptedException { try (final JobMasterClient client = JobMasterClient.Factory.create(JobMasterClientContext .newBuilder(ClientContext.create(alluxioConf)).build())) { return CommonUtils.waitForResult("Job to finish", ()-> { try { return client.getJobStatus(jobId); } catch (Exception e) { LOG.warn("Failed to get status for job (jobId={})", jobId, e); return null; } }, (jobInfo) -> { if (jobInfo != null) { switch (jobInfo.getStatus()) { case FAILED: case CANCELED: case COMPLETED: return true; case RUNNING: case CREATED: return false; default: throw new IllegalStateException("Unrecognized job status: " + jobInfo.getStatus()); } } return true; }, WaitForOptions.defaults().setInterval(1000)); } catch (IOException e) { LOG.warn("Failed to close job master client: {}", e.toString()); return null; } catch (TimeoutException e) { throw new IllegalStateException(e); } }
Source:
<code>public void testBroadcastCorrelatedSubqueryAvoidsRemoteExchangeBeforeAggregation() { Session broadcastJoin = Session.builder(this.getQueryRunner().getDefaultSession()) .setSystemProperty(DISTRIBUTED_JOIN, Boolean.toString(false)) .setSystemProperty(FORCE_SINGLE_NODE_OUTPUT, Boolean.toString(false)) .build(); PlanMatchPattern joinBuildSideWithRemoteExchange = anyTree( node(JoinNode.class, anyTree( node(TableScanNode.class)), anyTree( exchange(REMOTE, ExchangeNode.Type.REPLICATE, anyTree( node(TableScanNode.class)))))); Consumer<Plan> validateSingleRemoteExchange = plan -> assertEquals( countOfMatchingNodes( plan, node -> node instanceof ExchangeNode && ((ExchangeNode) node).getScope() == REMOTE), 1); <START> Consumer<Plan> validateSingleAggregation = plan -> assertEquals( <END> countOfMatchingNodes( plan, node -> node instanceof AggregationNode && ((AggregationNode) node).getGroupingKeys().contains(new Symbol("unique"))), 1); assertPlanWithSession( "SELECT (SELECT count(*) FROM region r2 WHERE r2.regionkey > r1.regionkey) FROM region r1", broadcastJoin, false, joinBuildSideWithRemoteExchange, validateSingleRemoteExchange.andThen(validateSingleAggregation)); assertPlanWithSession( "SELECT count(count) " + "FROM (SELECT o1.orderkey orderkey, (SELECT count(*) FROM orders o2 WHERE o2.orderkey > o1.orderkey) count FROM orders o1) " + "GROUP BY orderkey", broadcastJoin, false, joinBuildSideWithRemoteExchange, validateSingleRemoteExchange.andThen(validateSingleAggregation)); }</code><technical_language>rename validateSingleStreamingAggregation</technical_language>

Target:
public void testBroadcastCorrelatedSubqueryAvoidsRemoteExchangeBeforeAggregation() { Session broadcastJoin = Session.builder(this.getQueryRunner().getDefaultSession()) .setSystemProperty(DISTRIBUTED_JOIN, Boolean.toString(false)) .setSystemProperty(FORCE_SINGLE_NODE_OUTPUT, Boolean.toString(false)) .build(); PlanMatchPattern joinBuildSideWithRemoteExchange = anyTree( node(JoinNode.class, anyTree( node(TableScanNode.class)), anyTree( exchange(REMOTE, ExchangeNode.Type.REPLICATE, anyTree( node(TableScanNode.class)))))); Consumer<Plan> validateSingleRemoteExchange = plan -> assertEquals( countOfMatchingNodes( plan, node -> node instanceof ExchangeNode && ((ExchangeNode) node).getScope() == REMOTE), 1); Consumer<Plan> validateSingleStreamingAggregation = plan -> assertEquals( countOfMatchingNodes( plan, node -> node instanceof AggregationNode && ((AggregationNode) node).getGroupingKeys().contains(new Symbol("unique")) && ((AggregationNode) node).isStreamable()), 1); assertPlanWithSession( "SELECT (SELECT count(*) FROM region r2 WHERE r2.regionkey > r1.regionkey) FROM region r1", broadcastJoin, false, joinBuildSideWithRemoteExchange, validateSingleRemoteExchange.andThen(validateSingleStreamingAggregation)); assertPlanWithSession( "SELECT count(count) " + "FROM (SELECT o1.orderkey orderkey, (SELECT count(*) FROM orders o2 WHERE o2.orderkey > o1.orderkey) count FROM orders o1) " + "GROUP BY orderkey", broadcastJoin, false, joinBuildSideWithRemoteExchange, validateSingleRemoteExchange.andThen(validateSingleStreamingAggregation)); }
Source:
<code>public void editBuffersPerSlice() throws Exception { final int value = 10; <START> ModelNodeResult modelNodeResult = operations.readAttribute(BUFFER_POOL_ADDRESS, BUFFERS_PER_SLICE); <END> modelNodeResult.assertSuccess(); try { new ConfigChecker.Builder(client, BUFFER_POOL_ADDRESS) .configFragment(page.getConfigFragment()) .editAndSave(ConfigChecker.InputType.TEXT, BUFFERS_PER_SLICE, String.valueOf(value)) .verifyFormSaved() .verifyAttribute(BUFFERS_PER_SLICE, value); } finally { operations.writeAttribute(BUFFER_POOL_ADDRESS, BUFFERS_PER_SLICE, modelNodeResult.value()); } }</code><technical_language>Please rename originalBuffersPerSliceResult originalResult</technical_language>

Target:
public void editBuffersPerSlice() throws Exception { final int value = 10; final ModelNodeResult originalNodeResult = operations.readAttribute(BUFFER_POOL_ADDRESS, BUFFERS_PER_SLICE); originalNodeResult.assertSuccess(); try { new ConfigChecker.Builder(client, BUFFER_POOL_ADDRESS) .configFragment(page.getConfigFragment()) .editAndSave(ConfigChecker.InputType.TEXT, BUFFERS_PER_SLICE, String.valueOf(value)) .verifyFormSaved() .verifyAttribute(BUFFERS_PER_SLICE, value); } finally { operations.writeAttribute(BUFFER_POOL_ADDRESS, BUFFERS_PER_SLICE, originalNodeResult.value()); } }
Source:
<code>private Entity buildMandateConnectorRequestPayload(MandateConnectorRequest requestPayload) { JsonStringBuilder jsonStringBuilder = new JsonStringBuilder() .add(MandateConnectorRequest.RETURN_URL_FIELD_NAME, requestPayload.getReturnUrl()) <START> .add(MandateConnectorRequest.AGREEMENT_TYPE_FIELD_NAME, requestPayload.getAgreementType().toString()); <END> if (isNotBlank(requestPayload.getServiceReference())) { jsonStringBuilder.add(MandateConnectorRequest.SERVICE_REFERENCE_FIELD_NAME, requestPayload.getServiceReference()); } return json(jsonStringBuilder.build()); }</code><technical_language>toString() needed AgreementType enum automatically serialise a string</technical_language>

Target:
private Entity buildMandateConnectorRequestPayload(MandateConnectorRequest requestPayload) { JsonStringBuilder jsonStringBuilder = new JsonStringBuilder() .add(MandateConnectorRequest.RETURN_URL_FIELD_NAME, requestPayload.getReturnUrl()) .add(MandateConnectorRequest.AGREEMENT_TYPE_FIELD_NAME, requestPayload.getAgreementType()); if (isNotBlank(requestPayload.getServiceReference())) { jsonStringBuilder.add(MandateConnectorRequest.SERVICE_REFERENCE_FIELD_NAME, requestPayload.getServiceReference()); } return json(jsonStringBuilder.build()); }
Source:
<code>void initialiseLockManager() { lockManager.init( new LockTarget( currentPath, parent.getView().asWidget(), placeRequest, new LockTarget.TitleProvider() { @Override public String getTitle() { return currentPath.getFileName() + " - " + resourceType.getDescription(); } }, new Runnable() { @Override public void run() { } <START> } ), <END> parent ); }</code><technical_language>parameters LockTarget constructor lambda expressions this statement shorter</technical_language>

Target:
void initialiseLockManager() { lockManager.init( new LockTarget( currentPath, parent.getView().asWidget(), placeRequest, () -> currentPath.getFileName() + " - " + resourceType.getDescription(), () -> { } ), parent ); }
Source:
<code><START> public void setUp() throws MalformedURLException { <END> base = new URL("http://localhost:" + port); }</code><technical_language>Generally, a good idea throws Exception a more specific in signature of test methods</technical_language>

Target:
public void setUp() throws Exception { base = new URL("http://localhost:" + port); }
Source:
<code>public SearchResults search(String searchText) throws IOException { SearchResults results = new SearchResults(searchText); try { StringBuilder sb = new StringBuilder(); String encodedSearch = URLEncoder.encode(searchText, "UTF-8"); <START> String request = "<LINK_0>" + Runtime.getInstance().getLocaleTag() + "&q=" + encodedSearch + "&aqs=chrome..69i57.5547j0j7&sourceid=chrome&ie=UTF-8"; <END> Document doc = Jsoup.connect(request).userAgent(USER_AGENT).get(); if (saveSearchToFile) { FileOutputStream fos = new FileOutputStream(getDataDir() + fs + encodedSearch + ".html"); fos.write(doc.toString().getBytes()); fos.close(); } for (Element header : doc.select("h2")) { String title = header.text(); if (title.equals("Description")) { Element parent = header.parent(); Elements spans = parent.select("span"); for (Element span : spans) { log.info("description - ", span.text()); String text = null; if (lowerCase != null && lowerCase) { text = span.text().toLowerCase(); } else if (lowerCase != null && !lowerCase) { text = span.text().toUpperCase(); } for (String filter : excludeTextFilter) { text = text.replace(filter.toLowerCase(), ""); } sb.append(text); results.text.add(text); } } } invoke("publishText", sb.toString()); results.images = imageSearch(searchText); invoke("publishResults", results); } catch (Exception e) { results.errorText = e.getMessage(); error(e); } return results; }</code><technical_language>This locale of google search service.. runtime</technical_language>

Target:
public SearchResults search(String searchText) throws IOException { SearchResults results = new SearchResults(searchText); try { StringBuilder sb = new StringBuilder(); String encodedSearch = URLEncoder.encode(searchText, "UTF-8"); String request = "<LINK_0>" + locale.getTag() + "&q=" + encodedSearch + "&aqs=chrome..69i57.5547j0j7&sourceid=chrome&ie=UTF-8"; Document doc = Jsoup.connect(request).userAgent(USER_AGENT).get(); if (saveSearchToFile) { FileOutputStream fos = new FileOutputStream(getDataDir() + fs + encodedSearch + ".html"); fos.write(doc.toString().getBytes()); fos.close(); } for (Element header : doc.select("h2")) { String title = header.text(); if (title.equals("Description")) { Element parent = header.parent(); Elements spans = parent.select("span"); for (Element span : spans) { log.info("description - ", span.text()); String text = null; if (lowerCase != null && lowerCase) { text = span.text().toLowerCase(); } else if (lowerCase != null && !lowerCase) { text = span.text().toUpperCase(); } for (String filter : excludeTextFilter) { text = text.replace(filter.toLowerCase(), ""); } sb.append(text); results.text.add(text); } } } invoke("publishText", sb.toString()); results.images = imageSearch(searchText); invoke("publishResults", results); } catch (Exception e) { results.errorText = e.getMessage(); error(e); } return results; }
Source:
<code>protected void run(Registration registration, String executionCourseId) throws FenixServiceException { ServiceMonitoring.logService(this.getClass(), registration, executionCourseId); if (registration == null) { throw new FenixServiceException("error.registration.not.exist"); } ExecutionCourse executionCourse = readExecutionCourse(executionCourseId); for (Registration registration2 : registration.getStudent().getAllRegistrations()) { <START> if (!registration.getExternalId().equals(registration2.getExternalId()) && registration2.attends(executionCourse)) { <END> throw new FenixServiceException("error.registration.executionCourse.alreadyAttends"); } } registration.addAttendsTo(executionCourse); }</code><technical_language>fenix-framework guarantees instance of a domain object is unique virtual machine. need exists compare objects external id. compare objects instead. resulting code is easier read more efficient</technical_language>

Target:
protected void run(Registration registration, String executionCourseId) throws FenixServiceException { ServiceMonitoring.logService(this.getClass(), registration, executionCourseId); if (registration == null) { throw new FenixServiceException("error.registration.not.exist"); } ExecutionCourse executionCourse = readExecutionCourse(executionCourseId); if (registration.getStudent().getRegistrationStream().filter(r -> !r.equals(registration)).anyMatch(r -> r.attends(executionCourse))) { throw new FenixServiceException("error.registration.executionCourse.alreadyAttends"); } registration.addAttendsTo(executionCourse); }
Source:
<code>private void parseDelete(final ReceiveCommand cmd) { RefControl ctl = projectControl.controlForRef(cmd.getRefName()); <START> String refName = ctl.getRefName(); <END> if (refName.startsWith("refs/changes/")) { errors.put(Error.DELETE_CHANGES, refName); reject(cmd, "cannot delete changes"); } else if (ctl.canDelete()) { batch.addCommand(cmd); } else { if (GitRepositoryManager.REF_CONFIG.equals(refName)) { reject(cmd, "cannot delete project configuration"); } else { errors.put(Error.DELETE, ctl.getRefName()); reject(cmd, "cannot delete references"); } } }</code><technical_language>rest of this method ctl.getRefName() inline needs it. I proposed remove this variable ctl.getRefName() match style in rest of this method</technical_language>

Target:
private void parseDelete(final ReceiveCommand cmd) { RefControl ctl = projectControl.controlForRef(cmd.getRefName()); if (ctl.getRefName().startsWith("refs/changes/")) { errors.put(Error.DELETE_CHANGES, ctl.getRefName()); reject(cmd, "cannot delete changes"); } else if (ctl.canDelete()) { batch.addCommand(cmd); } else { if (GitRepositoryManager.REF_CONFIG.equals(ctl.getRefName())) { reject(cmd, "cannot delete project configuration"); } else { errors.put(Error.DELETE, ctl.getRefName()); reject(cmd, "cannot delete references"); } } }
Source:
<code>public Image(Device device, String[] filenames) { super(device); if (filenames == null || filenames.length == 0) SWT.error(SWT.ERROR_NULL_ARGUMENT); dpiFilename = filenames; int imageSelectorIndex = device.getImageSelector (); if (imageSelectorIndex > 0 && !DPIUtil.fileExists (filenames [imageSelectorIndex])) { imageSelectorIndex = 0; } initNative (filenames [imageSelectorIndex]); <START> if (this.handle == 0) init(new ImageData (filenames [imageSelectorIndex])); <END> init(); }</code><technical_language>store ImageData in data[]</technical_language>

Target:
public Image(Device device, String[] filenames) { super(device); if (filenames == null || filenames.length == 0) SWT.error(SWT.ERROR_NULL_ARGUMENT); imageRepFileNames = filenames; int imageSelectorIndex = getImageSelector (); if (imageSelectorIndex > 0 && !DPIUtil.fileExists (filenames [imageSelectorIndex])) { imageSelectorIndex = 0; } initNative (filenames [imageSelectorIndex]); data [imageSelectorIndex] = new ImageData (filenames [imageSelectorIndex]); if (this.handle == 0) init(data [imageSelectorIndex]); init(); }
Source:
<code>public void testGetOrComputeIfAbsentRemovesFault() throws CacheAccessException { final OnHeapStore<String, String> store = newStore(); <START> final CountDownLatch latch1 = new CountDownLatch(1); <END> final CountDownLatch latch2 = new CountDownLatch(1); final CountDownLatch latch3 = new CountDownLatch(1); Thread thread = new Thread(new Runnable() { @Override public void run() { try { try { latch3.await(); } catch (InterruptedException e) { e.printStackTrace(); } store.remove("1"); store.getOrComputeIfAbsent("1", new Function<String, ValueHolder<String>>() { @Override public ValueHolder<String> apply(final String s) { latch2.countDown(); try { latch1.await(); } catch (InterruptedException e) { e.printStackTrace(); } return null; } }); } catch (CacheAccessException e) { e.printStackTrace(); } } }); thread.start(); store.getOrComputeIfAbsent("1", new Function<String, ValueHolder<String>>() { @Override public ValueHolder<String> apply(final String s) { try { latch3.countDown(); latch2.await(); } catch (InterruptedException e) { e.printStackTrace(); } return null; } }); latch1.countDown(); }</code><technical_language>Please name giving</technical_language>

Target:
public void testGetOrComputeIfAbsentRemovesFault() throws CacheAccessException { final OnHeapStore<String, String> store = newStore(); final CountDownLatch testCompletionLatch = new CountDownLatch(1); final CountDownLatch threadFaultCompletionLatch = new CountDownLatch(1); final CountDownLatch mainFaultCreationLatch = new CountDownLatch(1); Thread thread = new Thread(new Runnable() { @Override public void run() { try { try { mainFaultCreationLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); } store.remove("1"); store.getOrComputeIfAbsent("1", new Function<String, ValueHolder<String>>() { @Override public ValueHolder<String> apply(final String s) { threadFaultCompletionLatch.countDown(); try { testCompletionLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); } return null; } }); } catch (CacheAccessException e) { e.printStackTrace(); } } }); thread.start(); store.getOrComputeIfAbsent("1", new Function<String, ValueHolder<String>>() { @Override public ValueHolder<String> apply(final String s) { try { mainFaultCreationLatch.countDown(); threadFaultCompletionLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); } return null; } }); testCompletionLatch.countDown(); }
Source:
<code>public HttpServiceResponse handle(HttpServiceRequest request) throws Exception { HttpServiceResponse response = new HttpServiceResponse(); if (HttpServer.Method.GET == request.getMethod()) { ZooKeeper zk = ZooKeeperClient.newBuilder() .connectString(conf.getZkServers()) .sessionTimeoutMs(conf.getZkTimeout()) .build(); BookieSocketAddress bookieId = null; try { bookieId = AuditorElector.getCurrentAuditor(conf, zk); if (bookieId == null) { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("No auditor elected"); return response; } } catch (Exception e) { <START> e.printStackTrace(); <END> response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Exception when get." + e.getMessage()); return response; } response.setCode(HttpServer.StatusCode.OK); response.setBody("Auditor: " + bookieId.getSocketAddress().getAddress().getCanonicalHostName() + "/" + bookieId.getSocketAddress().getAddress().getHostAddress() + ":" + bookieId.getSocketAddress().getPort()); LOG.debug("response body:" + response.getBody()); return response; } else { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Not found method. Should be GET method"); return response; } }</code><technical_language>remove</technical_language>

Target:
public HttpServiceResponse handle(HttpServiceRequest request) throws Exception { HttpServiceResponse response = new HttpServiceResponse(); if (HttpServer.Method.GET == request.getMethod()) { BookieSocketAddress bookieId = null; try { bookieId = AuditorElector.getCurrentAuditor(conf, zk); if (bookieId == null) { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("No auditor elected"); return response; } } catch (Exception e) { LOG.error("Meet Exception: ", e); response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Exception when get." + e.getMessage()); return response; } response.setCode(HttpServer.StatusCode.OK); response.setBody("Auditor: " + bookieId.getSocketAddress().getAddress().getCanonicalHostName() + "/" + bookieId.getSocketAddress().getAddress().getHostAddress() + ":" + bookieId.getSocketAddress().getPort()); LOG.debug("response body:" + response.getBody()); return response; } else { response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("Not found method. Should be GET method"); return response; } }
Source:
<code>public ActionResult execute() { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); List<InstructorAttributes> instructorsOfCourse = logic.getInstructorsForCourse(courseId); InstructorsData data; String intentStr = getRequestParamValue(Const.ParamsNames.INTENT); if (intentStr == null) { instructorsOfCourse = instructorsOfCourse.stream() .filter(InstructorAttributes::isDisplayedToStudents) .collect(Collectors.toList()); data = new InstructorsData(instructorsOfCourse); data.getInstructors().forEach(i -> { i.setGoogleId(null); i.setJoinState(null); i.setIsDisplayedToStudents(null); i.setRole(null); }); } else if (intentStr.equals(Intent.FULL_DETAIL.toString())) { <START> if (userInfo.isAdmin || logic.getInstructorForGoogleId(courseId, userInfo.getId()).getRole().equals( Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER)) { <END> data = new InstructorsData(); for (InstructorAttributes instructor : instructorsOfCourse) { InstructorData instructorData = new InstructorData(instructor); instructorData.setGoogleId(instructor.googleId); data.getInstructors().add(instructorData); } } else { data = new InstructorsData(instructorsOfCourse); } } else { throw new InvalidHttpParameterException("unknown intent"); } return new JsonResult(data); }</code><technical_language>add userInfo != null first</technical_language>

Target:
public ActionResult execute() { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); List<InstructorAttributes> instructorsOfCourse = logic.getInstructorsForCourse(courseId); InstructorsData data; String intentStr = getRequestParamValue(Const.ParamsNames.INTENT); if (intentStr == null) { instructorsOfCourse = instructorsOfCourse.stream() .filter(InstructorAttributes::isDisplayedToStudents) .collect(Collectors.toList()); data = new InstructorsData(instructorsOfCourse); data.getInstructors().forEach(i -> { i.setGoogleId(null); i.setJoinState(null); i.setIsDisplayedToStudents(null); i.setRole(null); }); } else if (intentStr.equals(Intent.FULL_DETAIL.toString())) { if (userInfo.isAdmin || logic.getInstructorForGoogleId(courseId, userInfo.getId()).getPrivileges() .isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR)) { data = new InstructorsData(); for (InstructorAttributes instructor : instructorsOfCourse) { InstructorData instructorData = new InstructorData(instructor); instructorData.setGoogleId(instructor.googleId); data.getInstructors().add(instructorData); } } else { data = new InstructorsData(instructorsOfCourse); } } else { throw new InvalidHttpParameterException("unknown intent"); } return new JsonResult(data); }
Source:
<code>public void addCookie(Cookie cookie) { <START> this.cookies.add(new ZestCookie(cookie.getDomain(), cookie.getName(), cookie.getValue(), <END> cookie.getPath(), cookie.getExpiryDate(), cookie.getSecure())); }</code><technical_language>call method addCookie(String domain,....) instead</technical_language>

Target:
public void addCookie(Cookie cookie) { addCookie(cookie.getDomain(), cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getExpiryDate(), cookie.getSecure()); }
Source:
<code>public void onReceiveResult(int resultCode, Bundle resultData) { long progress; if (resultCode == Constants.UPDATE_DOWNLOAD_PROGRESS) { progress = resultData.getLong(ProgressResponseBody.TAG_PROGRESS); updateProgressDialog(progress); } else if (resultCode == Constants.UPDATE_DOWNLOAD_SUCCESS) { progress = resultData.getLong(ProgressResponseBody.TAG_PROGRESS); updateProgressDialog(progress); <START> ToastUtil.showSuccess(WebViewActivity.this, "Download successful"); <END> } else { dismissProgressDialog(); ToastUtil.showError(WebViewActivity.this, "Download failed"); } }</code><technical_language>is a hardcoded string "Download successful". do that, please a correctly provide strings visible UI</technical_language>

Target:
public void onReceiveResult(int resultCode, Bundle resultData) { long progress; switch (resultCode) { case UPDATE_DOWNLOAD_PROGRESS: progress = resultData.getLong(ProgressResponseBody.TAG_PROGRESS); updateProgressDialog(progress); break; case UPDATE_DOWNLOAD_SUCCESS: progress = resultData.getLong(ProgressResponseBody.TAG_PROGRESS); updateProgressDialog(progress); ToastUtil.showSuccess(this, R.string.status_download_finished); break; default: dismissProgressDialog(); ToastUtil.showError(this, R.string.download_failed); } }
Source:
<code>public void onViewStateRestored(Bundle savedInstanceState) { if (savedInstanceState != null) { layoutManagerSavedState = savedInstanceState.getParcelable(LAYOUT_MANAGER_STATE); <START> prevLeftAction = savedInstanceState.getString("prevLeftAction", ""); <END> prevRightAction = savedInstanceState.getString("prevRightAction", ""); } super.onViewStateRestored(savedInstanceState); }</code><technical_language>Do need this here? I onResume() is called activity is restored. settings reloaded. I remove logic onViewStateRestored() onSaveInstanceState() right? I missing here</technical_language>

Target:
public void onViewStateRestored(Bundle savedInstanceState) { if (savedInstanceState != null) layoutManagerSavedState = savedInstanceState.getParcelable(LAYOUT_MANAGER_STATE); super.onViewStateRestored(savedInstanceState); }
Source:
<code>private static String asHtml(String text) { if (qualifiesAsHtml(text)) { if (qualifiesAsSymbolReplacement(text)) { int contentOffset = text.indexOf('['); String assignment = text.substring(0, contentOffset); String content = text.substring(contentOffset); return HtmlUtil.escapeHTML(assignment) + content; } return text; } <START> if(containsHtml(text) && qualifiesAsConvertedList(text)) { <END> return text; } return HtmlUtil.escapeHTML(text); }</code><technical_language>suggestion if (containsHtml(text) && qualifiesAsConvertedList(text)) {</technical_language>

Target:
private static String asHtml(String text) { if (qualifiesAsHtml(text)) { if (qualifiesAsSymbolReplacement(text)) { int contentOffset = text.indexOf('['); String assignment = text.substring(0, contentOffset); String content = text.substring(contentOffset); return HtmlUtil.escapeHTML(assignment) + content; } return text; } if (containsHtmlTable(text) && qualifiesAsConvertedList(text)) { return text; } return HtmlUtil.escapeHTML(text); }
Source:
<code>private static String getSettingValue( String tag, String defaultValue ) { final PluginSettings settings = PluginEnvironment.env().getPluginSettings(); <START> String value = settings.getTagValue( tag ).get( 0 ); <END> if ( value == null ) { value = defaultValue; } return value; }</code><technical_language>I get IndexOutOfBoundException here. want check lke this: List<String> values = settings.getTagValue(tag); return values.isEmpty() ? defaultValue : values.get(0);</technical_language>

Target:
private static String getSettingValue( String tag, String defaultValue ) { final PluginSettings settings = PluginEnvironment.env().getPluginSettings(); List<String> values = settings.getTagValue( tag ); return values.isEmpty() ? defaultValue : values.get( 0 ); }