auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static void main(String[] args) { Queue data = Data.data(); System.out.println("Data received"); Filter stage1 = new Stage1(); Filter stage2 = new Stage2(); Process stage3 = new Stage3(); <START> Print stage4 = new Stage4(); <END> buffer1 = new LinkedList(); buffer2 = new LinkedList(); buffer3 = new LinkedList(); buffer4 = new LinkedList(); System.out.println("Buffers initialised"); int time = 1; while (!(data.isEmpty())) { System.out.println("\nTime " + time + " : "); String newData = (String) data.remove(); buffer1.add(newData); if (!buffer4.isEmpty()) { stage4.printData(); } if (!buffer3.isEmpty()) { stage3.process(); System.out.println("Data processed through 3rd stage"); } if (!buffer2.isEmpty()) { stage2.removeChar(); System.out.println("Data filtered through 2nd stage"); } if (!buffer1.isEmpty()) { stage1.removeChar(); System.out.println("Data filtered through 1st stage"); } time++; } while (!buffer4.isEmpty()) { System.out.println("\nTime " + time + " : "); stage4.printData(); if (!buffer3.isEmpty()) { stage3.process(); System.out.println("Data processed through 3rd stage"); } if (!buffer2.isEmpty()) { stage2.removeChar(); System.out.println("Data filtered through 2nd stage"); } if (!buffer1.isEmpty()) { stage1.removeChar(); System.out.println("Data filtered through 1st stage"); } time++; } }</code><technical_language>Stages linked together, a queue graph? a builder method class create pipeline</technical_language>

Target:
public static void main(String[] args) throws InterruptedException { Pipeline pipeline = new Pipeline(); pipeline.start(); }
Source:
<code><START> public Simulation createSimulation(Path context, String dmnFilePath) throws Exception { <END> final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); SimulationDescriptor simulationDescriptor = toReturn.getSimulationDescriptor(); ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex.class); AtomicInteger id = new AtomicInteger(1); final Collection<FactModelTree> visibleFactTrees = factModelTuple.getVisibleFacts().values(); final Map<String, FactModelTree> hiddenValues = factModelTuple.getHiddenFacts(); visibleFactTrees.stream().sorted((a, b) -> { Type aType = a.getType(); Type bType = b.getType(); return aType.equals(bType) ? 0 : (Type.INPUT.equals(aType) ? -1 : 1); }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, scenarioWithIndex.getIndex(), id, convert(factModelTree.getType()), simulationDescriptor, scenarioWithIndex.getScesimData()); addFactMapping(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); addEmptyColumnsIfNeeded(toReturn, scenarioWithIndex); return toReturn; }</code><technical_language>I initializeNameAndNamespace needs added in createSettings. I correct</technical_language>

Target:
public Simulation createSimulation(Path context, String dmnFilePath) throws Exception { final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor(); ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex.class); AtomicInteger id = new AtomicInteger(1); final Collection<FactModelTree> visibleFactTrees = factModelTuple.getVisibleFacts().values(); final Map<String, FactModelTree> hiddenValues = factModelTuple.getHiddenFacts(); visibleFactTrees.stream().sorted((a, b) -> { Type aType = a.getType(); Type bType = b.getType(); return aType.equals(bType) ? 0 : (Type.INPUT.equals(aType) ? -1 : 1); }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, scenarioWithIndex.getIndex(), id, convert(factModelTree.getType()), simulationDescriptor, scenarioWithIndex.getScesimData()); addFactMapping(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); addEmptyColumnsIfNeeded(toReturn, scenarioWithIndex); return toReturn; }
Source:
<code>public byte[] serialize(Object object) { RuntimeException ex = null; ISerializationListener listener = listener(); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream((int)this.bufferSize.bytes()); FSTObjectOutput out = fastSerialConfig.getObjectOutput(buffer); if (listener != null) { out.setListener(new ListenerAdapter(listener)); listener.begin(object); } out.writeObject(object); out.flush(); out.setListener(null); buffer.close(); return buffer.toByteArray(); } catch (RuntimeException e) { <START> throw new Fast2WicketSerialException("serialize", e); <END> } catch (IOException e) { throw new Fast2WicketSerialException("serialize", e); } finally { if (listener != null) { listener.end(object, ex); } } }</code><technical_language>"serialize" is a bit short :)</technical_language>

Target:
public byte[] serialize(Object object) { Exception exception = null; try { FSTObjectOutput out = fastSerializationConfig.getObjectOutput(); if (listener != null) { out.setListener(new ListenerAdapter(listener)); listener.begin(object); } out.writeObject(object); out.setListener(null); return out.getCopyOfWrittenBuffer(); } catch (Exception e) { exception = e; throw new Fast2WicketSerialException(String.format( "Unable to serialize the object %1$s", object), e); } finally { if (listener != null) { listener.end(object, exception); } } }
Source:
<code>public void checkNotHosted(Tool tool) { if (tool.getMode() == ToolMode.HOSTED) { <START> throw new WebApplicationException("Cannot modify hosted entries this way", HttpStatus.SC_BAD_REQUEST); <END> } }</code><technical_language>difference CustomWebApplicationException WebApplicationException</technical_language>

Target:
public void checkNotHosted(Tool tool) { if (tool.getMode() == ToolMode.HOSTED) { throw new CustomWebApplicationException("Cannot modify hosted entries this way", HttpStatus.SC_BAD_REQUEST); } }
Source:
<code>private <T extends DataWriteCommand & ParamsCommand> CompletableFuture<Void> visitWriteCommand(InvocationContext ctx, T command) throws Throwable { Object retval = ctx.forkInvocationSync(command); if (!isStoreEnabled(command) || ctx.isInTxScope() || !command.isSuccessful()) return ctx.shortCircuit(retval); if (!isProperWriter(ctx, command, command.getKey())) return ctx.shortCircuit(retval); Param<PersistenceMode> persistMode = command.getParams().get(PersistenceMode.ID); switch (persistMode.get()) { case PERSIST: Object key = command.getKey(); CacheEntry entry = ctx.lookupEntry(key); if (entry != null) { if (entry.isRemoved()) { boolean resp = persistenceManager.deleteFromAllStores(key, BOTH); if (trace) getLog().tracef("Removed entry under key %s and got response %s from CacheStore", key, resp); <START> } else if (entry.isChanged()) { <END> storeEntry(ctx, key, command); } } case SKIP: log.trace("Skipping cache store since persistence mode parameter is SKIP"); } return ctx.shortCircuit(retval); }</code><technical_language>deleted break mistake</technical_language>

Target:
private <T extends DataWriteCommand & ParamsCommand> CompletableFuture<Void> visitWriteCommand(InvocationContext ctx, T command) throws Throwable { Object retval = ctx.forkInvocationSync(command); if (!isStoreEnabled(command) || ctx.isInTxScope() || !command.isSuccessful()) return ctx.shortCircuit(retval); if (!isProperWriter(ctx, command, command.getKey())) return ctx.shortCircuit(retval); Param<PersistenceMode> persistMode = command.getParams().get(PersistenceMode.ID); switch (persistMode.get()) { case PERSIST: Object key = command.getKey(); CacheEntry entry = ctx.lookupEntry(key); if (entry != null) { if (entry.isRemoved()) { boolean resp = persistenceManager.deleteFromAllStores(key, BOTH); if (trace) getLog().tracef("Removed entry under key %s and got response %s from CacheStore", key, resp); } else if (entry.isChanged()) { storeEntry(ctx, key, command); } break; } case SKIP: log.trace("Skipping cache store since persistence mode parameter is SKIP"); } return ctx.shortCircuit(retval); }
Source:
<code>public void testHelpTopic() { <START> String dir = System.getProperty("user.dir"); <END> IPath wsRoot = new Path(dir); IPath testRoot = wsRoot.append("javadoc_root"); IPreferenceStore ps = JavaDocPlugin.getDefault().getPreferenceStore(); ps.setValue(PreferenceConstants.JAVADOCS_DIRECTORY, testRoot.toOSString()); JavaDocToc toc = new JavaDocToc(); ITopic[] topics = toc.getTopics(); assertTrue(topics.length > 0); assertTrue(topics.length == 1); ITopic topicJnr = topics[0]; assertTrue(topicJnr.getLabel().startsWith("jnr-unixsocket")); ITopic[] subtopicsJnr = topicJnr.getSubtopics(); assertTrue(subtopicsJnr.length == 0); IUAElement[] elementsJnr = topicJnr.getChildren(); assertTrue(elementsJnr.length == 0); String hrefApache = topicJnr.getHref(); assertEquals(hrefApache, "org.eclipse.linuxtools.javadocs/jnr-unixsocket/index.html"); assertTrue(topicJnr.isEnabled(null)); }</code><technical_language>This ideal of path plugin I guess work. a in DataManipulatorTest testPerfStatDataOpenHandler() example</technical_language>

Target:
public void testHelpTopic() throws IOException { String testDocLoc = "/javadoc_root"; String dir = FileLocator.toFileURL( this.getClass().getResource(testDocLoc)).getPath(); IPath wsRoot = new Path(dir); IPreferenceStore ps = JavaDocPlugin.getDefault().getPreferenceStore(); ps.setValue(PreferenceConstants.JAVADOCS_DIRECTORY, wsRoot.toOSString()); JavaDocToc toc = new JavaDocToc(); ITopic[] topics = toc.getTopics(); assertTrue(topics.length > 0); assertTrue(topics.length == 1); ITopic topicJnr = topics[0]; assertTrue(topicJnr.getLabel().startsWith("jnr-unixsocket")); ITopic[] subtopicsJnr = topicJnr.getSubtopics(); assertTrue(subtopicsJnr.length == 0); IUAElement[] elementsJnr = topicJnr.getChildren(); assertTrue(elementsJnr.length == 0); String hrefApache = topicJnr.getHref(); assertEquals(hrefApache, "org.eclipse.linuxtools.javadocs/jnr-unixsocket/index.html"); assertTrue(topicJnr.isEnabled(null)); }
Source:
<code>public void givenThread_WhenExchangedMessage_thenCorrect() throws InterruptedException, ExecutionException { Exchanger<String> exchanger = new Exchanger<>(); Runnable runner = () -> { try { String message = exchanger.exchange("from runner"); assertEquals("to runner", message); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } }; CompletableFuture<Void> result = CompletableFuture.runAsync(runner); String msg = exchanger.exchange("to runner"); assertEquals("from runner", msg); <START> CompletableFuture.allOf(result).get(); <END> }</code><technical_language>do result.join()</technical_language>

Target:
public void givenThread_WhenExchangedMessage_thenCorrect() throws InterruptedException, ExecutionException { Exchanger<String> exchanger = new Exchanger<>(); Runnable runner = () -> { try { String message = exchanger.exchange("from runner"); assertEquals("to runner", message); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } }; CompletableFuture<Void> result = CompletableFuture.runAsync(runner); String msg = exchanger.exchange("to runner"); assertEquals("from runner", msg); result.join(); }
Source:
<code><START> public static SortedMap<String, Charset> requiredCharsets() { <END> return Collections.unmodifiableSortedMap(REQUIRED_CHARSETS); }</code><technical_language>sorted map? TreeMap is sorted already?</technical_language>

Target:
public static SortedMap<String, Charset> requiredCharsets() { return REQUIRED_CHARSETS; }
Source:
<code>private void showInfoPopup(View view) { if (!isAdded() || view == null) return; if (mInfoPopupWindow == null) { mInfoPopupWindow = new PopupWindow(getActivity()); mInfoPopupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); mInfoPopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); mInfoPopupWindow.setBackgroundDrawable(new ColorDrawable(0)); mInfoPopupWindow.setOutsideTouchable(true); mInfoPopupWindow.setFocusable(true); <START> LayoutInflater inflater = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); <END> View popupView = inflater.inflate(R.layout.popup_info, null); mInfoPopupWindow.setContentView(popupView); } updateInfoPopup(); mInfoPopupWindow.showAsDropDown(view); }</code><technical_language>cleaner do this: LayoutInflater.from(getActivity())</technical_language>

Target:
private void showInfoPopup(View view) { if (!isAdded() || view == null) return; if (mInfoPopupWindow == null) { mInfoPopupWindow = new PopupWindow(getActivity()); mInfoPopupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); mInfoPopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); mInfoPopupWindow.setBackgroundDrawable(new ColorDrawable(0)); mInfoPopupWindow.setOutsideTouchable(true); mInfoPopupWindow.setFocusable(true); LayoutInflater inflater = LayoutInflater.from(getActivity()); View popupView = inflater.inflate(R.layout.popup_info, null); mInfoPopupWindow.setContentView(popupView); } updateInfoPopup(); mInfoPopupWindow.showAsDropDown(view); }
Source:
<code><START> public void testDoesNotFire() <END> { tester.assertThat(new RemoveDistinctFromSemiJoin()) .on(p -> { Symbol sourceKey = p.symbol("custkey", BigintType.BIGINT); Symbol filteringSourceKey = p.symbol("custkey_1", BigintType.BIGINT); Symbol outputKey = p.symbol("orderkey", BigintType.BIGINT); return p.semiJoin( p.tableScan("orders", ImmutableMap.of("custkey", "custkey")), p.project(Assignments.of(filteringSourceKey, expression("x")), p.aggregation(ab -> ab.step(AggregationNode.Step.SINGLE) .groupingSets(ImmutableList.of(ImmutableList.of(filteringSourceKey))) .addAggregation(p.symbol("max", BigintType.BIGINT), expression("max(custkey_1)"), ImmutableList.of(BIGINT)) .source(p.tableScan("customer", ImmutableMap.of("custkey_1", "custkey"))) .build()) ), sourceKey, filteringSourceKey, outputKey ); }).doesNotFire(); }</code><technical_language>Please put some information fire test name</technical_language>

Target:
public void testDoesNotFire() { tester.assertThat(new RemoveDistinctFromSemiJoin()) .on(p -> { Symbol sourceKey = p.symbol("custkey", BigintType.BIGINT); Symbol filteringSourceKey = p.symbol("custkey_1", BigintType.BIGINT); Symbol outputKey = p.symbol("orderkey", BigintType.BIGINT); return p.semiJoin( p.tableScan( new TableHandle( new ConnectorId("local"), new TpchTableHandle("local", "orders", TINY_SCALE_FACTOR)), ImmutableList.of(sourceKey), ImmutableMap.of(sourceKey, new TpchColumnHandle("custkey", BIGINT))), p.project(Assignments.of(filteringSourceKey, expression("x")), p.aggregation(ab -> ab.step(AggregationNode.Step.SINGLE) .groupingSets(ImmutableList.of(ImmutableList.of(filteringSourceKey))) .addAggregation(p.symbol("max", BigintType.BIGINT), expression("max(custkey_1)"), ImmutableList.of(BIGINT)) .source(p.tableScan( new TableHandle( new ConnectorId("local"), new TpchTableHandle("local", "customer", TINY_SCALE_FACTOR)), ImmutableList.of(filteringSourceKey), ImmutableMap.of(filteringSourceKey, new TpchColumnHandle("custkey", BIGINT))) ) .build()) ), sourceKey, filteringSourceKey, outputKey ); }).doesNotFire(); }
Source:
<code>private Collection<Problem> parseContestProblems(XmlNode problemsNode, String rootDirectory) throws AppException { if (problemsNode == null) { <START> throw new AppException("Invalid XmlNode."); <END> } Collection<Problem> contestProblems = new ArrayList<>(); for (XmlNode node : problemsNode.getChildList()) { Problem problem = parseContestProblem(rootDirectory + "/" + node.getInnerText().trim()); contestProblems.add(problem); } return contestProblems; }</code><technical_language>AppExceptionUtil.assertNotNull</technical_language>

Target:
private ArrayList<ProblemDTO> parseContestProblems(XmlNode problemsNode, String rootDirectory) throws AppException { AppExceptionUtil.assertNotNull(problemsNode); ArrayList<ProblemDTO> contestProblems = new ArrayList<>(); for (XmlNode node : problemsNode.getChildList()) { String problemDirectory = rootDirectory + "/" + node.getInnerText().trim(); ProblemDTO problem = parseContestProblem(problemDirectory); problemDataDirectories.add(problemDirectory.replaceFirst(settings.SETTING_UPLOAD_FOLDER, "")); contestProblems.add(problem); } return contestProblems; }
Source:
<code>private ShadowDocument.Update createShadowDOMUpdate() { verifyThreadAccess(); if (mDocumentProvider.getRootElement() != mShadowDOM.getRootElement()) { throw new IllegalStateException(); } ArrayListAccumulator<Object> childrenAccumulator = acquireChildrenAccumulator(); ShadowDocument.UpdateBuilder updateBuilder = mShadowDOM.beginUpdate(); <START> Queue<Object> queue = new ArrayDeque<>(); <END> queue.add(mDocumentProvider.getRootElement()); while (!queue.isEmpty()) { final Object element = queue.remove(); NodeDescriptor descriptor = mDocumentProvider.getNodeDescriptor(element); mObjectIdMapper.putObject(element); descriptor.getChildren(element, childrenAccumulator); updateBuilder.setElementChildren(element, childrenAccumulator); for (int i = 0, N = childrenAccumulator.size(); i < N; ++i) { queue.add(childrenAccumulator.get(i)); } childrenAccumulator.clear(); } releaseChildrenAccumulator(childrenAccumulator); return updateBuilder.build(); }</code><technical_language>I add a // TODO: cache this too, resolve this done this PR</technical_language>

Target:
private ShadowDocument.Update createShadowDOMUpdate() { verifyThreadAccess(); if (mDocumentProvider.getRootElement() != mShadowDocument.getRootElement()) { throw new IllegalStateException(); } ArrayListAccumulator<Object> childrenAccumulator = acquireChildrenAccumulator(); ShadowDocument.UpdateBuilder updateBuilder = mShadowDocument.beginUpdate(); mCachedUpdateQueue.add(mDocumentProvider.getRootElement()); while (!mCachedUpdateQueue.isEmpty()) { final Object element = mCachedUpdateQueue.remove(); NodeDescriptor descriptor = mDocumentProvider.getNodeDescriptor(element); mObjectIdMapper.putObject(element); descriptor.getChildren(element, childrenAccumulator); updateBuilder.setElementChildren(element, childrenAccumulator); for (int i = 0, N = childrenAccumulator.size(); i < N; ++i) { mCachedUpdateQueue.add(childrenAccumulator.get(i)); } childrenAccumulator.clear(); } releaseChildrenAccumulator(childrenAccumulator); return updateBuilder.build(); }
Source:
<code>public GetHealthStatusResponse dequeueGetHealthResponse( final String correlationUid ) throws OsgpException { <START> LOGGER.debug( "dequeueGetHealthRequest called with correlation uid {}", correlationUid ); <END> return (GetHealthStatusResponse) processResponse( correlationUid ); }</code><technical_language>dequeueGetHealthRequest</technical_language>

Target:
public GetHealthStatusResponse dequeueGetHealthResponse(final String correlationUid) throws OsgpException { LOGGER.debug("dequeueGetHealthResponse called with correlation uid {}", correlationUid); return (GetHealthStatusResponse) processResponse(correlationUid); }
Source:
<code>private void placeBlock(ItemStack item, Block facedBlock, Dispenser dispenser) { BlockPlacerPlaceEvent e = new BlockPlacerPlaceEvent(dispenser.getBlock(), item, facedBlock); Bukkit.getPluginManager().callEvent(e); <START> if(!dispenser.getInventory().getViewers().isEmpty()){ <END> e.setCancelled(true); } if (!e.isCancelled()) { facedBlock.setType(item.getType()); if (item.hasItemMeta()) { ItemMeta meta = item.getItemMeta(); if (meta.hasDisplayName()) { BlockStateSnapshotResult blockState = PaperLib.getBlockState(facedBlock, false); if ((blockState.getState() instanceof Nameable)) { Nameable nameable = ((Nameable) blockState.getState()); nameable.setCustomName(meta.getDisplayName()); if (blockState.isSnapshot()) { blockState.getState().update(true, false); } } } } facedBlock.getWorld().playEffect(facedBlock.getLocation(), Effect.STEP_SOUND, item.getType()); if (dispenser.getInventory().containsAtLeast(item, 2)) { dispenser.getInventory().removeItem(new CustomItem(item, 1)); } else { SlimefunPlugin.runSync(() -> dispenser.getInventory().removeItem(item), 2L); } } }</code><technical_language>Formatting, please adhere code style guidelines, a space if curly bracket {</technical_language>

Target:
private void placeBlock(ItemStack item, Block facedBlock, Dispenser dispenser) { BlockPlacerPlaceEvent e = new BlockPlacerPlaceEvent(dispenser.getBlock(), item, facedBlock); Bukkit.getPluginManager().callEvent(e); if (!e.isCancelled()) { facedBlock.setType(item.getType()); if (item.hasItemMeta()) { ItemMeta meta = item.getItemMeta(); if (meta.hasDisplayName()) { BlockStateSnapshotResult blockState = PaperLib.getBlockState(facedBlock, false); if ((blockState.getState() instanceof Nameable)) { Nameable nameable = ((Nameable) blockState.getState()); nameable.setCustomName(meta.getDisplayName()); if (blockState.isSnapshot()) { blockState.getState().update(true, false); } } } } facedBlock.getWorld().playEffect(facedBlock.getLocation(), Effect.STEP_SOUND, item.getType()); if (dispenser.getInventory().containsAtLeast(item, 2)) { dispenser.getInventory().removeItem(new CustomItem(item, 1)); } else { SlimefunPlugin.runSync(() -> dispenser.getInventory().removeItem(item), 2L); } } }
Source:
<code>private static String buildComment(AllergyIntolerance allergyIntolerance) { if (CollectionUtils.isNotEmpty(allergyIntolerance.getNote())) { return allergyIntolerance.getNoteFirstRep().getText(); } <START> return null; <END> }</code><technical_language>do in line</technical_language>

Target:
private static String buildComment(AllergyIntolerance allergyIntolerance) { return (CollectionUtils.isNotEmpty(allergyIntolerance.getNote())) ? allergyIntolerance.getNoteFirstRep().getText() : null; }