auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void doChangeAbandonedHook(final Change change, final Account account, final String reason) { final ChangeAbandonedEvent event = new ChangeAbandonedEvent(); event.project = change.getProject().get(); event.branch = change.getDest().getShortName(); event.change = change.getKey().get(); event.author = getAuthorAttribute(account); event.reason = reason; <START> for (ChangeListenerHolder holder : listeners.values()) { <END> if (isVisibleTo(change, holder.user)) { holder.listener.onChangeEvent(event); } } final List<String> args = new ArrayList<String>(); args.add(changeAbandonedHook.getAbsolutePath()); args.add("--change"); args.add(event.change); args.add("--project"); args.add(event.project); args.add("--branch"); args.add(event.branch); args.add("--abandoner"); args.add(getDisplayName(account)); args.add("--reason"); args.add(reason == null ? "" : reason); runHook(getRepo(change), args); }</code><technical_language>This loop pulled a utility method: private void fireChangeEvent(ChangeEvent event) { ... } duplicating logic for type of event</technical_language>

Target:
public void doChangeAbandonedHook(final Change change, final Account account, final String reason) { final ChangeAbandonedEvent event = new ChangeAbandonedEvent(); event.project = change.getProject().get(); event.branch = change.getDest().getShortName(); event.change = change.getKey().get(); event.author = getAuthorAttribute(account); event.reason = reason; fireEvent(change, event); final List<String> args = new ArrayList<String>(); args.add(changeAbandonedHook.getAbsolutePath()); args.add("--change"); args.add(event.change); args.add("--project"); args.add(event.project); args.add("--branch"); args.add(event.branch); args.add("--abandoner"); args.add(getDisplayName(account)); args.add("--reason"); args.add(reason == null ? "" : reason); runHook(getRepo(change), args); }
Source:
<code>private void createSupplementaryDirectory() { IFolder supplFolder = getTraceSupplementaryFolder(getResourceName()); if (!supplFolder.exists()) { try { supplFolder.create(true, true, new NullProgressMonitor()); } catch (CoreException e) { <START> Activator.getDefault().logError("Error creating resource supplementary file " + supplFolder, e); END> } } try { fResource.setPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, supplFolder.getLocationURI().getPath()); } catch (CoreException e) { Activator.getDefault().logError("Error setting persistant property " + TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, e); } }</code><technical_language>externalize</technical_language>

Target:
private void createSupplementaryDirectory() { IFolder supplFolder = getTraceSupplementaryFolder(getResourceName()); if (!supplFolder.exists()) { try { supplFolder.create(true, true, new NullProgressMonitor()); } catch (CoreException e) { Activator.getDefault().logError(Messages.TmfCommonProjectElement_ErrorCreateSuppRes + supplFolder, e); } } try { fResource.setPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, supplFolder.getLocationURI().getPath()); } catch (CoreException e) { Activator.getDefault().logError(Messages.TmfCommonProjectElement_ErrorSettingProperty + TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, e); } }
Source:
<code><START> public boolean hasMatchingUniqueConstraint(final Item item, final String propertyName, final String propertyValue) { <END> final Class<? extends Item> itemClass = item.getClass(); final String tableName = getItemTableName(itemClass); final Map<String, ItemId> uniqueConstraintsForProperty = uniqueConstraints.get(newUniqueConstraintKey( tableName, propertyName)); final ItemId itemId = getItemId(item); for (final Entry<String, ItemId> entry : uniqueConstraintsForProperty.entrySet()) { if (entry.getValue().equals(itemId)) { return entry.getKey().equals(propertyValue.toUpperCase()); } } return false; }</code><technical_language>Is this method in unit tests? If so, is move unit test source code tree</technical_language>

Target:
boolean hasMatchingUniqueConstraint(final Item item, final String propertyName, final String propertyValue) { final Class<? extends Item> itemClass = item.getClass(); final String tableName = getItemTableName(itemClass); final Map<String, ItemId> uniqueConstraintsForProperty = uniqueConstraints.get(newUniqueConstraintKey( tableName, propertyName)); final ItemId itemId = getItemId(item); for (final Entry<String, ItemId> entry : uniqueConstraintsForProperty.entrySet()) { if (entry.getValue().equals(itemId)) { return entry.getKey().equals(propertyValue.toUpperCase()); } } return false; }
Source:
<code>protected TokenManager getLexerForSource(SourceCode sourceCode) { <START> return new VfTokenManager(new CharSequenceReader(sourceCode.getCodeBuffer())); <END> }</code><technical_language>need skip BOM preserve behavior..</technical_language>

Target:
protected TokenManager getLexerForSource(SourceCode sourceCode) { return new VfTokenManager(IOUtil.skipBOM(new CharSequenceReader(sourceCode.getCodeBuffer()))); }
Source:
<code>public static ServerWebExchangeMatcher anyExchange() { return exchange -> ServerWebExchangeMatcher.MatchResult.match(); <START> } <END></code><technical_language>right issue ^</technical_language>

Target:
public static ServerWebExchangeMatcher anyExchange() { return new ServerWebExchangeMatcher() { @Override public Mono<MatchResult> matches(ServerWebExchange exchange) { return ServerWebExchangeMatcher.MatchResult.match(); } }; }
Source:
<code>private Map<Site, Pattern> getFromConfig(Site site) { List<Map<String, String>> patternMaps = (List<Map<String, String>>) site.getTheme() .getConfigMap("journalDoiRegex").get("regexList"); String journalKey = site.getJournalKey(); for (Map<String, String> patternMap : patternMaps) { String journalKeyFromConfig = patternMap.values().iterator().next(); if (journalKey.equals(journalKeyFromConfig)) { putIntoCache(site, Pattern.compile(patternMap.get("pattern"))); return getFromCache(site); } <START> } <END> return null; }</code><technical_language>I problems here. discuss refactoring</technical_language>

Target:
private ImmutableList<DoiJournalRegex> getFromConfig(Site site) { List<Map<String, String>> patternMaps = (List<Map<String, String>>) site.getTheme() .getConfigMap("journalDoiRegex").get("regexList"); List<DoiJournalRegex> regices = patternMaps.stream().map(regexMap -> { String journalKey = regexMap.get("journalKey"); String pattern = regexMap.get("pattern"); return new DoiJournalRegex(journalKey, Pattern.compile(pattern)); }).collect(Collectors.toList()); return ImmutableList.copyOf(regices); }
Source:
<code>public void testDisableRule() { SonarLintGlobalSettings settings = new SonarLintGlobalSettings(); settings.disableRule(RULE); <START> assertThat(settings.isRuleActive(RULE)).isEqualTo(false); <END> }</code><technical_language>s/isEqualTo(false)/isFalse</technical_language>

Target:
public void testDisableRule() { SonarLintGlobalSettings settings = new SonarLintGlobalSettings(); settings.disableRule(RULE); assertThat(settings.isRuleExplicitlyDisabled(RULE)).isTrue(); }
Source:
<code>public CommandExecutorQueueProvider(@GerritServerConfig final Config config, final WorkQueue queues) { final int cores = Runtime.getRuntime().availableProcessors(); poolSize = config.getInt("sshd", "threads", 3 * cores / 2); int interactiveThreads = config.getInt("sshd", "interactive", (int) (0.75f * poolSize)); <START> int batchThreads = poolSize - interactiveThreads; <END> interactiveExecutor = queues.createQueue(interactiveThreads, "SSH-Worker"); batchExecutor = queues.createQueue(batchThreads, "SSH-Batch-Worker"); setThreadFactory(interactiveExecutor); setThreadFactory(batchExecutor); }</code><technical_language>If poolSize = 1, batchThreads = 0 starve batch threads. I instead say: int batchThreads = Math.min(1, poolSize - interactiveThreads) But... I invert this. admin set number of batch threads, allow rest of pool interactive threads. I a lot easier batch concurrency level needs be. E.g. X build machines, set batchThreads = X. I if some smarts this. if sshd.batchThreads is set sshd.threads isn't, sshd.batchThreads is > sshd.threads default? automatically increase sshd.threads match? Yes, probably</technical_language>

Target:
public CommandExecutorQueueProvider(@GerritServerConfig final Config config, final WorkQueue queues) { final int cores = Runtime.getRuntime().availableProcessors(); poolSize = config.getInt("sshd", "threads", 3 * cores / 2); batchThreads = config.getInt("sshd", "batchThreads", 0); if (batchThreads > poolSize) { poolSize += batchThreads; } int interactiveThreads = Math.max(1, poolSize - batchThreads); interactiveExecutor = queues.createQueue(interactiveThreads, "SSH-Interactive-Worker"); if (batchThreads != 0) { batchExecutor = queues.createQueue(batchThreads, "SSH-Batch-Worker"); setThreadFactory(batchExecutor); } else { batchExecutor = interactiveExecutor; } setThreadFactory(interactiveExecutor); }
Source:
<code>public void applyConfig(Configuration config, boolean reindex, boolean interactive) { setConfiguration(config, interactive); LOGGER.log(Level.INFO, "Configuration updated: {0}", configuration.getSourceRoot()); if (reindex) { refreshSearcherManagerMap(); maybeRefreshIndexSearchers(); refreshDateForLastIndexRun(); } if (isAuthorizationWatchdog() && config.getPluginDirectory() != null) { startWatchDogService(new File(config.getPluginDirectory())); } else { stopWatchDogService(); } getAuthorizationFramework().setPluginDirectory(config.getPluginDirectory()); getAuthorizationFramework().setStack(config.getPluginStack()); getAuthorizationFramework().reload(); messagesContainer.setMessageLimit(config.getMessageLimit()); <START> SuggesterServiceImpl.getInstance().refresh(configuration); <END> }</code><technical_language>is this approach of design (interface - implementaion) implementation class occur in code for constructing. a factory, factory method more suggester service a part of RuntimeEnvironment? point is concrete implementation is hidden end user. If done, leave this</technical_language>

Target:
public void applyConfig(Configuration config, boolean reindex, boolean interactive) { setConfiguration(config, interactive); LOGGER.log(Level.INFO, "Configuration updated: {0}", configuration.getSourceRoot()); if (reindex) { refreshSearcherManagerMap(); maybeRefreshIndexSearchers(); refreshDateForLastIndexRun(); } if (isAuthorizationWatchdog() && config.getPluginDirectory() != null) { startWatchDogService(new File(config.getPluginDirectory())); } else { stopWatchDogService(); } getAuthorizationFramework().setPluginDirectory(config.getPluginDirectory()); getAuthorizationFramework().setStack(config.getPluginStack()); getAuthorizationFramework().reload(); messagesContainer.setMessageLimit(config.getMessageLimit()); }
Source:
<code>public static ParameterizedTypeName get( ClassName rawType, Iterable<? extends TypeName> typeArguments) { ArrayList<TypeName> typeArgumentsList = new ArrayList<>(); for (TypeName typeArgument : typeArguments) { typeArgumentsList.add(typeArgument); } <START> return get(rawType, typeArgumentsList.toArray(new TypeName[0])); <END> }</code><technical_language>calling toArray instead of calling constructor directly</technical_language>

Target:
public static ParameterizedTypeName get( ClassName rawType, Iterable<? extends TypeName> typeArguments) { ArrayList<TypeName> typeArgumentsList = new ArrayList<>(); for (TypeName typeArgument : typeArguments) { typeArgumentsList.add(typeArgument); } return new ParameterizedTypeName(null, rawType, typeArgumentsList); }
Source:
<code>public void initWithNiwsConfig(IClientConfig clientConfig) { super.initWithNiwsConfig(clientConfig); <START> serverWeightTaskTimerInterval = Integer.parseInt( <END> String.valueOf(clientConfig.getProperty(WEIGHT_TASK_TIMER_INTERVAL_CONFIG_KEY, DEFAULT_TIMER_INTERVAL))); }</code><technical_language>above, this written java serverWeightTaskTimerInterval = clientConfig.get(WEIGHT_TASK_TIMER_INTERVAL_CONFIG_KEY, DEFAULT_TIMER_INTERVAL);</technical_language>

Target:
public void initWithNiwsConfig(IClientConfig clientConfig) { super.initWithNiwsConfig(clientConfig); serverWeightTaskTimerInterval = clientConfig.get(WEIGHT_TASK_TIMER_INTERVAL_CONFIG_KEY, DEFAULT_TIMER_INTERVAL); }
Source:
<code>public Void visitJoin(JoinNode node, Integer indent) { List<Expression> joinExpressions = new ArrayList<>(); for (JoinNode.EquiJoinClause clause : node.getCriteria()) { joinExpressions.add(clause.toExpression()); } node.getFilter().ifPresent(expression -> joinExpressions.add(expression)); if (node.isSpatialJoin()) { print(indent, "- SpatialJoin[%s] => [%s]", Joiner.on(" AND ").join(joinExpressions), formatOutputs(node.getOutputSymbols())); } else if (node.isCrossJoin()) { print(indent, "- CrossJoin[%s] => [%s]", <START> Joiner.on(" AND ").join(joinExpressions), <END> formatOutputs(node.getOutputSymbols())); } else { print(indent, "- %s[%s]%s => [%s]", node.getType().getJoinLabel(), Joiner.on(" AND ").join(joinExpressions), formatHash(node.getLeftHashSymbol(), node.getRightHashSymbol()), formatOutputs(node.getOutputSymbols())); } node.getDistributionType().ifPresent(distributionType -> print(indent + 2, "Distribution: %s", distributionType)); node.getSortExpressionContext().ifPresent(context -> print(indent + 2, "SortExpression[%s]", context.getSortExpression())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); node.getLeft().accept(this, indent + 1); node.getRight().accept(this, indent + 1); return null; }</code><technical_language>join expressions? (if not, add a checkState doesn't)</technical_language>

Target:
public Void visitJoin(JoinNode node, Integer indent) { List<Expression> joinExpressions = new ArrayList<>(); for (JoinNode.EquiJoinClause clause : node.getCriteria()) { joinExpressions.add(clause.toExpression()); } node.getFilter().ifPresent(expression -> joinExpressions.add(expression)); if (node.isSpatialJoin()) { print(indent, "- SpatialJoin[%s] => [%s]", Joiner.on(" AND ").join(joinExpressions), formatOutputs(node.getOutputSymbols())); } else if (node.isCrossJoin()) { checkState(joinExpressions.isEmpty()); print(indent, "- CrossJoin => [%s]", formatOutputs(node.getOutputSymbols())); } else { print(indent, "- %s[%s]%s => [%s]", node.getType().getJoinLabel(), Joiner.on(" AND ").join(joinExpressions), formatHash(node.getLeftHashSymbol(), node.getRightHashSymbol()), formatOutputs(node.getOutputSymbols())); } node.getDistributionType().ifPresent(distributionType -> print(indent + 2, "Distribution: %s", distributionType)); node.getSortExpressionContext().ifPresent(context -> print(indent + 2, "SortExpression[%s]", context.getSortExpression())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); node.getLeft().accept(this, indent + 1); node.getRight().accept(this, indent + 1); return null; }
Source:
<code>public Cipher(String key) { if (!isValidKey(key)) { <START> throw new IllegalArgumentException("Bad key"); <END> } this.key = key; }</code><technical_language>I I prefer "Invalid key" exception message</technical_language>

Target:
public Cipher(String key) { if (!isValidKey(key)) { throw new IllegalArgumentException("Invalid key"); } this.key = key; }
Source:
<code>private int handleExceptions(Exception e, String url, String method) { if (logEnabled) { <START> System.out.println(new StringBuilder(method).append(" Request: ").append(url).append(" | ") <END> .append(e.getClass().getName()).append(" occured | Error message: ") .append(e.getMessage()).toString()); } if (e instanceof ClientProtocolException) { return 400; } return 500; }</code><technical_language>System.out in a places System.err messages stderr. I a examples of this in other bindings</technical_language>

Target:
private int handleExceptions(Exception e, String url, String method) { if (logEnabled) { System.err.println(new StringBuilder(method).append(" Request: ").append(url).append(" | ") .append(e.getClass().getName()).append(" occured | Error message: ") .append(e.getMessage()).toString()); } if (e instanceof ClientProtocolException) { return 400; } return 500; }
Source:
<code>public static Task<OsDetails> getOsDetails(final SshMachineLocation sshLocation) { return Tasks.<OsDetails>builder() .name("Get OsDetails for " + sshLocation) .body(new Callable<OsDetails>() { @Override public OsDetails call() throws Exception { BufferedReader reader = new BufferedReader(Streams.reader( new ResourceUtils(this).getResourceFromUrl("classpath://brooklyn/entity/software/os-details.sh"))); List<String> script = CharStreams.readLines(reader); reader.close(); String output = DynamicTasks.queue(SshEffectorTasks.ssh(script) .machine(sshLocation) .requiringZeroAndReturningStdout()) .get(); String[] details = output.split("\\r?\\n"); if (details.length != 3) LOG.warn("Unexpected length ({}) of os details for {}: {}", new Object[]{details.length, sshLocation, output}); String name = find(details, "name:").or("unknown"); String version = find(details, "version:").or("unknown"); String architecture = find(details, "architecture:").or("unknown"); OsDetails osDetails = new BasicOsDetails(name, architecture, version); if (LOG.isDebugEnabled()) LOG.debug("OsDetails for {}: {}", sshLocation, osDetails); return osDetails; } private Optional<String> find(String[] inputs, String field) { for (String input : inputs) { if (input.startsWith(field)) { <START> return Optional.of(input.substring(field.length())); <END> } } return Optional.absent(); } }) .build(); }</code><technical_language>Do want do a .trim(), include if non-empty? non-empty</technical_language>

Target:
public static Task<OsDetails> getOsDetails(final SshMachineLocation sshLocation) { return Tasks.<OsDetails>builder() .name("Get OsDetails for " + sshLocation) .body(new Callable<OsDetails>() { @Override public OsDetails call() throws Exception { BufferedReader reader = new BufferedReader(Streams.reader( new ResourceUtils(this).getResourceFromUrl("classpath://brooklyn/entity/software/os-details.sh"))); List<String> script = CharStreams.readLines(reader); reader.close(); String output = DynamicTasks.queue(SshEffectorTasks.ssh(script) .machine(sshLocation) .requiringZeroAndReturningStdout()) .get(); String[] details = output.split("\\r?\\n"); if (details.length != 3) LOG.warn("Unexpected length ({}) of os details for {}: {}", new Object[]{details.length, sshLocation, output}); String name = find(details, "name:").or("unknown"); String version = find(details, "version:").or("unknown"); String architecture = find(details, "architecture:").or("unknown"); OsDetails osDetails = new BasicOsDetails(name, architecture, version); if (LOG.isDebugEnabled()) LOG.debug("OsDetails for {}: {}", sshLocation, osDetails); return osDetails; } private Optional<String> find(String[] inputs, String field) { for (String input : inputs) { if (input.startsWith(field)) { String value = input.substring(field.length()).trim(); return (!value.isEmpty()) ? Optional.of(input.substring(field.length())) : Optional.<String>absent(); } } return Optional.absent(); } }) .build(); }
Source:
<code>public boolean loadFromConfig( File configFile ) { String namespace = DataStorePluginOptions.getStoreNamespace(storeName); return loadFromConfig( ConfigOptions.loadProperties( configFile, "^" + namespace), namespace, <START> null); <END> }</code><technical_language>is this intentional</technical_language>

Target:
public boolean loadFromConfig( File configFile ) { String namespace = DataStorePluginOptions.getStoreNamespace(storeName); return loadFromConfig( ConfigOptions.loadProperties( configFile, "^" + namespace), namespace, configFile); }
Source:
<code>public void setBccVisibility(boolean visible) { boolean bccAlreadyVisible = isBccVisible(); bccWrapper.setVisibility(visible ? View.VISIBLE : View.GONE); <START> if(visible && !bccAlreadyVisible){ <END> List<Recipient> bccRecipients = getBccRecipients(); bccView.clear(); bccView.addRecipients(bccRecipients.toArray(new Recipient[0])); } bccDivider.setVisibility(visible ? View.VISIBLE : View.GONE); }</code><technical_language>This removes recipients re-adds them, fixing symptom cause. Do underlying problem? Also, this is more logic MvpView class</technical_language>

Target:
public void setBccVisibility(boolean visible) { bccWrapper.setVisibility(visible ? View.VISIBLE : View.GONE); bccDivider.setVisibility(visible ? View.VISIBLE : View.GONE); }
Source:
<code>protected List<DeploymentContent> generateDeploymentContent(TestClass testClass) { final List<DeploymentContent> deploymentContents = new ArrayList<DeploymentContent>(); final ServiceLoader<AutomaticDeployment> deploymentSpis = automaticDeploymentLocator.find(); final Iterator<AutomaticDeployment> deploymentSpiIterator = deploymentSpis.iterator(); <START> while (deploymentSpiIterator.hasNext()) { <END> final DeploymentContent deploymentContent = deploymentSpiIterator.next().generateDeploymentScenario(testClass); if (deploymentContent != null) { deploymentContents.add(deploymentContent); } } return deploymentContents; }</code><technical_language>"replace foreach" (IDEA do for ya :))</technical_language>

Target:
protected List<DeploymentConfiguration> generateDeploymentContent(TestClass testClass) { final List<DeploymentConfiguration> deploymentConfigurations = new ArrayList<DeploymentConfiguration>(); final ServiceLoader<AutomaticDeployment> deploymentSpis = automaticDeploymentLocator.find(); for (AutomaticDeployment deploymentSpi : deploymentSpis) { final DeploymentConfiguration deploymentConfiguration = deploymentSpi.generateDeploymentScenario(testClass); if (deploymentConfiguration != null) { deploymentConfigurations.add(deploymentConfiguration); } } return deploymentConfigurations; }
Source:
<code>public String explain(String impliedTableName) { ExpressionType type = getExpressionType(); if (type == ExpressionType.OPERATOR_IS_NULL) { return "(" + m_left.explain(impliedTableName) + " IS NULL)"; } if (type == ExpressionType.OPERATOR_NOT) { return "(NOT " + m_left.explain(impliedTableName) + ")"; } if (type == ExpressionType.OPERATOR_CAST) { return "(CAST (" + m_left.explain(impliedTableName) + " AS " + m_valueType.toSQLString() + "))"; } if (type == ExpressionType.OPERATOR_EXISTS) { return "(EXISTS " + m_left.explain(impliedTableName) + ")"; } if (type == ExpressionType.OPERATOR_CASE_WHEN) { return "(CASE WHEN " + m_left.explain(impliedTableName) + " THEN " + m_right.m_left.explain(impliedTableName) + " ELSE " + m_right.m_right.explain(impliedTableName) + " END)"; } <START> if (type == ExpressionType.OPERATOR_UNARY_MINUS) { <END> return "(-" + m_left.explain(impliedTableName) + ")"; } return "(" + m_left.explain(impliedTableName) + " " + type.symbol() + " " + m_right.explain(impliedTableName) + ")"; }</code><technical_language>@kaikaizi some refactoring this class in [ENG-14621] CREATE TABLE Calcite!. (if else -> switch) is calcite branch I bring master this moment. <LINK_0></technical_language>

Target:
public String explain(String impliedTableName) { final String explainLeftTableName = m_left.explain(impliedTableName); switch(getExpressionType()) { case OPERATOR_IS_NULL: return String.format("(%s IS NULL)", explainLeftTableName); case OPERATOR_NOT: return String.format("(NOT %s)", explainLeftTableName); case OPERATOR_CAST: return String.format("(CAST (%s AS %s))", explainLeftTableName, m_valueType.toSQLString()); case OPERATOR_EXISTS: return String.format("(EXISTS %s)", explainLeftTableName); case OPERATOR_CASE_WHEN: return String.format("(CASE WHEN %s THEN %s ELSE %s END)", explainLeftTableName, m_right.m_left.explain(impliedTableName), m_right.m_right.explain(impliedTableName)); case OPERATOR_UNARY_MINUS: return String.format("(-%s)", explainLeftTableName); default: return String.format("(%s %s %s)", explainLeftTableName, getExpressionType().symbol(), m_right.explain(impliedTableName)); } }
Source:
<code>public static <T extends MinecraftLens> ReusableLens<T> getLens(Class<T> lensType, InventoryAdapter<IInventory, ItemStack> adapter, Function<SlotCollection, T> lens, Supplier<SlotCollection> slots) <START> { <END> Map<Integer, ReusableLens> reusableLens = reusableLenses.computeIfAbsent(lensType, k -> new HashMap<>()); return reusableLens.computeIfAbsent(adapter.getInventory().getSize(), k -> new ReusableLens(slots.get(), lens)); }</code><technical_language>this belongs previous line</technical_language>

Target:
public static <T extends Lens<IInventory, ItemStack>> ReusableLens<T> getLens(Class<T> lensType, InventoryAdapter<IInventory, ItemStack> adapter, Function<SlotCollection, T> lens, Supplier<SlotCollection> slots) { Map<Class<? extends Lens<IInventory, ItemStack>>, Int2ObjectMap<ReusableLens>> adapterLenses = reusableLenses.computeIfAbsent(adapter.getClass(), k -> new HashMap<>()); Int2ObjectMap<ReusableLens> lenses = adapterLenses.computeIfAbsent(lensType, k -> new Int2ObjectOpenHashMap<>()); return lenses.computeIfAbsent(adapter.getInventory().getSize(), k -> new ReusableLens(slots.get(), lens, adapter.getClass())); }
Source:
<code>public void typeAmountOfColumns(int columns) { tablePropertiesInputs.get(1).clear(); tablePropertiesInputs.get(1).sendKeys(Integer.toString(columns)); <START> PageObjectLogging.log("typeAmountOfColumns", "amount of columns was typed", true, driver); <END> }</code><technical_language>"amount of columns typed: " + columns</technical_language>

Target:
public void typeAmountOfColumns(int columns) { tablePropertiesInputs.get(1).clear(); tablePropertiesInputs.get(1).sendKeys(Integer.toString(columns)); PageObjectLogging.log( "typeAmountOfColumns", "amount of columns was typed: " + columns, true ); }
Source:
<code>public void start() throws InterruptedException { this.bossGroup = new NioEventLoopGroup(); final InetSocketAddress address = this.host != null ? SocketUtils.socketAddress(this.host, this.port) : new InetSocketAddress(this.port); this.socketFuture = new Bootstrap() .group(this.bossGroup) .channel(NioDatagramChannel.class) <START> .option(ChannelOption.SO_REUSEADDR, true) <END> .handler(new ChannelInitializer<DatagramChannel>() { @Override protected void initChannel(final DatagramChannel ch) throws Exception { ch.pipeline() .addLast(new PacketDecoder()) .addLast(new PacketHandler(Listener.this.dispatcher)) .addLast(new ChannelInboundHandlerAdapter() { @Override public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { LOG.warn("Invalid packet: {}", cause.getMessage()); LOG.debug("", cause); } }); } }) .bind(address) .sync(); }</code><technical_language>setup listener options org.opennms.netmgt.telemetry.listeners.udp.UdpListener? (We update org.opennms.netmgt.telemetry.listeners.flow.AbstractUdpListener well.)</technical_language>

Target:
public void start() throws InterruptedException { this.bossGroup = new NioEventLoopGroup(); final InetSocketAddress address = this.host != null ? SocketUtils.socketAddress(this.host, this.port) : new InetSocketAddress(this.port); this.socketFuture = new Bootstrap() .group(this.bossGroup) .channel(NioDatagramChannel.class) .option(ChannelOption.SO_REUSEADDR, true) .option(ChannelOption.SO_RCVBUF, Integer.MAX_VALUE) .option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(this.maxPacketSize)) .handler(new ChannelInitializer<DatagramChannel>() { @Override protected void initChannel(final DatagramChannel ch) throws Exception { ch.pipeline() .addLast(new PacketDecoder()) .addLast(new PacketHandler(Listener.this.dispatcher)) .addLast(new ChannelInboundHandlerAdapter() { @Override public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { LOG.warn("Invalid packet: {}", cause.getMessage()); LOG.debug("", cause); } }); } }) .bind(address) .sync(); }
Source:
<code>private <T> CompletableFuture<T> executeCommandAndCommitIfNeededAsync(InvocationContext ctx, VisitableCommand command) { final boolean txInjected = isTxInjected(ctx); CompletableFuture<T> cf; final Transaction implicitTransaction; try { cf = (CompletableFuture<T>) invoker.invokeAsync(ctx, command); if (txInjected) { <START> implicitTransaction = transactionManager.suspend(); <END> assert implicitTransaction != null; } else { implicitTransaction = null; } } catch (SystemException e) { throw new CacheException("Cannot suspend implicit transaction", e); } catch (Throwable e) { if (txInjected) tryRollback(); throw e; } if (txInjected) { return cf.handle((result, throwable) -> { if (throwable != null) { try { implicitTransaction.rollback(); } catch (SystemException e) { log.trace("Could not rollback", e); throwable.addSuppressed(e); } throw CompletableFutures.asCompletionException(throwable); } try { implicitTransaction.commit(); } catch (Exception e) { log.couldNotCompleteInjectedTransaction(e); throw CompletableFutures.asCompletionException(e); } return result; }); } else { return cf; } }</code><technical_language>interceptors try access TM transaction thread-local, invocation context. safe suspend TM transaction calling invokeAsync</technical_language>

Target:
private <T> CompletableFuture<T> executeCommandAndCommitIfNeededAsync(InvocationContext ctx, VisitableCommand command) { final boolean txInjected = isTxInjected(ctx); CompletableFuture<T> cf; final Transaction implicitTransaction; try { if (txInjected) { implicitTransaction = transactionManager.suspend(); assert implicitTransaction != null; } else { implicitTransaction = null; } cf = (CompletableFuture<T>) invoker.invokeAsync(ctx, command); } catch (SystemException e) { throw new CacheException("Cannot suspend implicit transaction", e); } catch (Throwable e) { if (txInjected) tryRollback(); throw e; } if (txInjected) { return cf.handle((result, throwable) -> { if (throwable != null) { try { implicitTransaction.rollback(); } catch (SystemException e) { log.trace("Could not rollback", e); throwable.addSuppressed(e); } throw CompletableFutures.asCompletionException(throwable); } try { implicitTransaction.commit(); } catch (Exception e) { log.couldNotCompleteInjectedTransaction(e); throw CompletableFutures.asCompletionException(e); } return result; }); } else { return cf; } }
Source:
<code>private long generateCidaFromFilepaths(String[] fileNames) { final int n = fileNames.length; long pidls = new long [n]; try { CIDA cida = new CIDA(); cida.cidl = n; int cidaSize = CIDA.sizeof + 4 * n; cida.aoffset = cidaSize; int[] pidlOffsets = new int[n]; int[] pidlSizes = new int[n]; int pidlSizeSum = 2; for (int i = 0; i < n; i++) { TCHAR szfileName = new TCHAR(0, fileNames[i], true); long ppv = new long [1]; int hr = COM.PathToPIDL(szfileName.chars, ppv); if (hr != OS.S_OK) { <START> DND.error(DND.ERROR_INVALID_DATA); <END> } pidls[i] = ppv[0]; pidlSizes[i] = OS.ILGetSize(pidls[i]); pidlSizeSum += pidlSizes[i]; if (i == 0) { pidlOffsets[0] = cidaSize + 2; } else { pidlOffsets[i] = pidlOffsets[i - 1] + pidlSizes[i - 1]; } } long newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, cidaSize + pidlSizeSum); if (newPtr != 0) { OS.MoveMemory(newPtr, cida, CIDA.sizeof); OS.MoveMemory(newPtr + CIDA.sizeof, pidlOffsets, 4 * cida.cidl); for (int i = 0; i < n; i++) { OS.MoveMemory(newPtr + pidlOffsets[i], pidls[i], pidlSizes[i]); } } return newPtr; } finally { for (int i = 0; i < n; i++) { if (pidls[i] != 0) { OS.CoTaskMemFree(pidls[i]); } } } }</code><technical_language>I generic SWT.ERROR_NO_HANDLES is more appropriate. simply return zero data query fail E_FAIL. error is abnormal, converting Java exception useful</technical_language>

Target:
private long generateCidaFromFilepaths(String[] fileNames) { final int n = fileNames.length; long pidls = new long [n]; try { CIDA cida = new CIDA(); cida.cidl = n; int cidaSize = CIDA.sizeof + 4 * n; cida.aoffset = cidaSize; int[] pidlOffsets = new int[n]; int[] pidlSizes = new int[n]; int pidlSizeSum = 2; for (int i = 0; i < n; i++) { TCHAR szfileName = new TCHAR(0, fileNames[i], true); long ppv = new long [1]; int hr = COM.PathToPIDL(szfileName.chars, ppv); if (hr != OS.S_OK) { return 0; } pidls[i] = ppv[0]; pidlSizes[i] = OS.ILGetSize(pidls[i]); pidlSizeSum += pidlSizes[i]; if (i == 0) { pidlOffsets[0] = cidaSize + 2; } else { pidlOffsets[i] = pidlOffsets[i - 1] + pidlSizes[i - 1]; } } long newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, cidaSize + pidlSizeSum); if (newPtr != 0) { OS.MoveMemory(newPtr, cida, CIDA.sizeof); OS.MoveMemory(newPtr + CIDA.sizeof, pidlOffsets, 4 * cida.cidl); for (int i = 0; i < n; i++) { OS.MoveMemory(newPtr + pidlOffsets[i], pidls[i], pidlSizes[i]); } } return newPtr; } finally { for (int i = 0; i < n; i++) { if (pidls[i] != 0) { OS.CoTaskMemFree(pidls[i]); } } } }
Source:
<code>public void onTestRunEnd(DataRecord runData, Result result) { File destination = FULL_REPORT_DESTINATION.toFile(); File directory = destination.getParentFile(); <START> Log.e(LOG_TAG, String.format("Exists? : %b", destination.exists())); <END> if (destination.exists()) { throw new IllegalStateException( String.format("Report destination already written to: %s", FULL_REPORT_DESTINATION)); } else if (!directory.exists() && !directory.mkdirs()) { throw new RuntimeException( String.format("Could not create incident destination folder: %s.", directory.toString())); } String fullReportCmd = String.format(REDIRECT_INCIDENT_REPORT_CMD, "EXPLICIT"); Log.v(LOG_TAG, String.format("Collecting full incident report: %s.", fullReportCmd)); InstrumentationRegistry.getInstrumentation().getUiAutomation() .adoptShellPermissionIdentity(); byte[] output = executeCommandBlocking(fullReportCmd); InstrumentationRegistry.getInstrumentation().getUiAutomation() .dropShellPermissionIdentity(); if (output == null) { throw new RuntimeException("Failed to run the incident report command."); } if (output.length == 0) { throw new RuntimeException("The incident report command returned no data."); } else { try { Files.write(destination.toPath(), output, StandardOpenOption.CREATE_NEW); } catch (IOException e) { throw new RuntimeException("Unable to write incident report.", e); } if (!destination.exists()) { throw new RuntimeException("Unable to find the full incident report available."); } runData.addFileMetric(FULL_REPORT_KEY, destination); } }</code><technical_language>nit: do need this</technical_language>

Target:
public void onTestRunEnd(DataRecord runData, Result result) { if (!REPORT_DIRECTORY.toFile().exists()) { throw new IllegalStateException(String.format( "Report destination folder does not exist: %s", REPORT_DIRECTORY.toString())); } String fullReportCmd = String.format(REDIRECT_INCIDENT_REPORT_CMD, "EXPLICIT"); Log.v(LOG_TAG, String.format("Collecting full incident report: %s.", fullReportCmd)); InstrumentationRegistry.getInstrumentation().getUiAutomation() .adoptShellPermissionIdentity(); byte[] output = executeCommandBlocking(fullReportCmd); InstrumentationRegistry.getInstrumentation().getUiAutomation() .dropShellPermissionIdentity(); if (output == null) { throw new RuntimeException("Failed to run the incident report command."); } if (output.length == 0) { throw new RuntimeException("The incident report command returned no data."); } else { try { Files.write(FINAL_REPORT_PATH, output, StandardOpenOption.CREATE_NEW); } catch (IOException e) { throw new RuntimeException("Unable to write full incident report.", e); } File destination = FINAL_REPORT_PATH.toFile(); if (!destination.exists()) { throw new RuntimeException("Unable to find the full incident report available."); } runData.addFileMetric(FINAL_REPORT_KEY, destination); } }
Source:
<code>public static Definitions wbFromDMN(final org.kie.dmn.model.api.Definitions dmn) { if (dmn == null) { return null; } Id id = new Id(dmn.getId()); Name name = new Name(dmn.getName()); String namespace = dmn.getNamespace(); Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); Definitions result = new Definitions(); result.setId(id); result.setName(name); result.setNamespace(namespace); result.setDescription(description); result.getNsContext().putAll(dmn.getNsContext()); <START> result.getNsContext().put(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix(), <END> DMNModelInstrumentedBase.Namespace.DEFAULT.getUri()); for (org.kie.dmn.model.api.ItemDefinition itemDef : dmn.getItemDefinition()) { ItemDefinition itemDefConverted = ItemDefinitionPropertyConverter.wbFromDMN(itemDef); if (itemDefConverted != null) { itemDefConverted.setParent(result); } result.getItemDefinition().add(itemDefConverted); } for (org.kie.dmn.model.api.Import i : dmn.getImport()) { Import importConverted = ImportConverter.nodeFromDMN(i); if (importConverted != null) { importConverted.setParent(result); } result.getImport().add(importConverted); } return result; }</code><technical_language>I this is OK for DMN->workbench (as, if importing a file lacks default name space need add one). check is default name space defined - this overwrite it</technical_language>

Target:
public static Definitions wbFromDMN(final org.kie.dmn.model.api.Definitions dmn) { if (dmn == null) { return null; } Id id = new Id(dmn.getId()); Name name = new Name(dmn.getName()); String namespace = dmn.getNamespace(); Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); Definitions result = new Definitions(); result.setId(id); result.setName(name); result.setNamespace(namespace); result.getNsContext().put(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix(), namespace); result.setDescription(description); for (Entry<String, String> kv : dmn.getNsContext().entrySet()) { String mappedURI = kv.getValue(); switch (mappedURI) { case org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase.URI_DMN: mappedURI = org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_DMN; break; case org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase.URI_FEEL: mappedURI = org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_FEEL; break; case org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase.URI_KIE: mappedURI = org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_KIE; break; } result.getNsContext().put(kv.getKey(), mappedURI); } for (org.kie.dmn.model.api.ItemDefinition itemDef : dmn.getItemDefinition()) { ItemDefinition itemDefConverted = ItemDefinitionPropertyConverter.wbFromDMN(itemDef); if (itemDefConverted != null) { itemDefConverted.setParent(result); } result.getItemDefinition().add(itemDefConverted); } for (org.kie.dmn.model.api.Import i : dmn.getImport()) { Import importConverted = ImportConverter.wbFromDMN(i); if (importConverted != null) { importConverted.setParent(result); } result.getImport().add(importConverted); } return result; }
Source:
<code>private StoreKey getKeyAt(ByteBuffer mmap, int index) throws StoreException { StoreKey storeKey = null; try { mmap.position(firstKeyRelativeOffset + index * persistedEntrySize); storeKey = factory.getStoreKey(new DataInputStream(new ByteBufferInputStream(mmap))); } catch (Throwable t) { if (t.getClass() == InternalError.class && t.getMessage().equals(StoreException.INTERNAL_ERROR_STR)) { throw new StoreException("Internal error occurred due to unsafe memory access", t, StoreErrorCodes.IOError); } else if (t.getClass() == IOException.class && t.getMessage().equals(StoreException.IO_ERROR_STR)) { <START> throw new StoreException("IO error while trying to get store key", t, StoreErrorCodes.IOError); <END> } else { throw new StoreException("Unknown error while trying to get store key ", t, StoreErrorCodes.Unknown_Error); } } return storeKey; }</code><technical_language>of exceptions StoreErrorCodes.IOError counted BlobStore</technical_language>

Target:
private StoreKey getKeyAt(ByteBuffer mmap, int index) throws StoreException { StoreKey storeKey = null; try { mmap.position(firstKeyRelativeOffset + index * persistedEntrySize); storeKey = factory.getStoreKey(new DataInputStream(new ByteBufferInputStream(mmap))); } catch (InternalError e) { throw e.getMessage().equals(StoreException.INTERNAL_ERROR_STR) ? new StoreException( "Internal error occurred due to unsafe memory access", e, StoreErrorCodes.IOError) : new StoreException("Unknown internal error while trying to get store key", e, StoreErrorCodes.Unknown_Error); } catch (IOException e) { throw e.getMessage().equals(StoreException.IO_ERROR_STR) ? new StoreException( "IO error while trying to get store key", e, StoreErrorCodes.IOError) : new StoreException("Unknown IO error while trying to get store key", e, StoreErrorCodes.Unknown_Error); } catch (Throwable t) { throw new StoreException("Unknown error while trying to get store key ", t, StoreErrorCodes.Unknown_Error); } return storeKey; }
Source:
<code>public synchronized int onStartCommand(Intent intent, int flags, int startId) { Logger.d(TAG, "BeginQuestionnaireService started"); super.onStartCommand(intent, flags, startId); <START> if (statusManager.areParametersUpdated()) { <END> notifyQuestionnaire(); } stopSelf(); return START_REDELIVER_INTENT; }</code><technical_language>check questionnaires left answer</technical_language>

Target:
public synchronized int onStartCommand(Intent intent, int flags, int startId) { Logger.d(TAG, "BeginQuestionnaireService started"); super.onStartCommand(intent, flags, startId); if (statusManager.areParametersUpdated() && !statusManager.areBeginQuestionnairesCompleted()) { notifyQuestionnaire(); } stopSelf(); return START_REDELIVER_INTENT; }
Source:
<code>public void init(BibEntry entry) { cancelSearch(); <START> entryKey.set(entry.getCiteKeyOptional().orElse(null)); <END> if (entryKey.get() == null) { searchError.set(Localization.lang("Selected entry does not have an associated BibTeX key.")); status.set(Status.ERROR); return; } startSearch(); }</code><technical_language>Please orElse(null). point of optionals is remove null values (and prevent NPEs). Here, I propose code: java Optional<String> citeKey = entry.getCiteKeyOptional(); if (citeKey.isPresent()) { startSearch(citeKey.get()); } else { searchError.set(Localization.lang("Selected entry BibTeX key.")); status.set(Status.ERROR); }</technical_language>

Target:
public void init(BibEntry entry) { cancelSearch(); Optional<String> citeKey = entry.getCiteKeyOptional(); if (citeKey.isPresent()) { startSearch(citeKey.get()); } else { searchError.set(Localization.lang("Selected entry does not have an associated BibTeX key.")); status.set(Status.ERROR); } }
Source:
<code>public static String reconcilePath(String originalPath ) { int len = originalPath.length(); int len1 = len - 1; int j = 0; boolean noSepBefore = true; char[] ein = new char[len]; char[] aus = new char[len + 1]; originalPath.getChars(0, len, ein, 0); char separatorChar = File.separatorChar; if (UNCPathConverter.isUNC(originalPath)) { <START> Assert.isTrue(len >= 2, "Unknown UNC path format"); END> Assert.isTrue(ein[0] == ein[1], "Unknown UNC path format"); Assert.isTrue(ein[0] == BSLASH || ein[0] == SLASH, "Unknown UNC path format"); separatorChar = ein[0]; aus[j++] = separatorChar; } for (int i= 0; i < len; i++) { char c = ein[i]; switch (c) { case QUOTE: noSepBefore = true; break; case SLASH: case BSLASH: if (noSepBefore) { noSepBefore = false; aus[j++] = separatorChar; } break; case DOT: if (noSepBefore && j > 0) { aus[j++] = c; } else { if (i < len1) { c = ein[i + 1]; if (c == SLASH || c == BSLASH) { i++; noSepBefore = false; } else { i++; noSepBefore = true; aus[j++] = DOT; aus[j++] = c; } } } break; default: noSepBefore = true; aus[j++] = c; } } return new String(aus, 0, j); }</code><technical_language>Asserting stricter conditions guaranteed UNCPathConverter.isUNC sense is dangerous. If stricter conditions needed, checks in UNCPathConverter.isUNC changed guarantee them</technical_language>

Target:
public static String reconcilePath(String originalPath ) { int len = originalPath.length(); int len1 = len - 1; int j = 0; boolean noSepBefore = true; char[] ein = new char[len]; char[] aus = new char[len + 1]; originalPath.getChars(0, len, ein, 0); char separatorChar = File.separatorChar; if (UNCPathConverter.isUNC(originalPath)) { separatorChar = ein[0]; aus[j++] = separatorChar; } for (int i= 0; i < len; i++) { char c = ein[i]; switch (c) { case QUOTE: noSepBefore = true; break; case SLASH: case BSLASH: if (noSepBefore) { noSepBefore = false; aus[j++] = separatorChar; } break; case DOT: if (noSepBefore && j > 0) { aus[j++] = c; } else { if (i < len1) { c = ein[i + 1]; if (c == SLASH || c == BSLASH) { i++; noSepBefore = false; } else { i++; noSepBefore = true; aus[j++] = DOT; aus[j++] = c; } } } break; default: noSepBefore = true; aus[j++] = c; } } return new String(aus, 0, j); }
Source:
<code>public List<PoolQuantity> getDryRun(Consumer consumer, String serviceLevelOverride) { List<PoolQuantity> result = new ArrayList<PoolQuantity>(); try { Owner owner = consumer.getOwner(); if (consumer.isDev()) { if (config.getBoolean(ConfigProperties.STANDALONE) || !poolCurator.hasActiveEntitlementPools(consumer.getOwner(), null)) { throw new ForbiddenException(i18n.tr( "Development units may only be used on hosted servers" + " and with orgs that have active subscriptions.")); } String sku = consumer.getFact("dev_sku"); Pool devPool = poolCurator.findDevPool(consumer); if (devPool != null) { poolManager.deletePool(devPool); } devPool = poolManager.createPool(assembleDevPool(consumer, sku)); result.add(new PoolQuantity(devPool, 1)); } else { result = poolManager.getBestPools( consumer, null, null, owner, serviceLevelOverride, null); } log.debug("Created Pool Quantity list: " + result); } catch (EntitlementRefusedException e) { if (log.isDebugEnabled()) { <START> log.debug("consumer dry-run " + consumer.getUuid() + ": errors:"); <END> for (Entry<String, ValidationResult> entry : e.getResults().entrySet()) { log.debug("errors for pool id: " + entry.getKey()); for (ValidationError error : entry.getValue().getErrors()) { log.debug(error.getResourceKey()); } } } } return result; }</code><technical_language>{} placeholders line 413</technical_language>

Target:
public List<PoolQuantity> getDryRun(Consumer consumer, String serviceLevelOverride) { List<PoolQuantity> result = new ArrayList<PoolQuantity>(); try { Owner owner = consumer.getOwner(); if (consumer.isDev()) { if (config.getBoolean(ConfigProperties.STANDALONE) || !poolCurator.hasActiveEntitlementPools(consumer.getOwner(), null)) { throw new ForbiddenException(i18n.tr( "Development units may only be used on hosted servers" + " and with orgs that have active subscriptions.")); } String sku = consumer.getFact("dev_sku"); Pool devPool = poolCurator.findDevPool(consumer); if (devPool != null) { poolManager.deletePool(devPool); } devPool = poolManager.createPool(assembleDevPool(consumer, sku)); result.add(new PoolQuantity(devPool, 1)); } else { result = poolManager.getBestPools( consumer, null, null, owner, serviceLevelOverride, null); } log.debug("Created Pool Quantity list: " + result); } catch (EntitlementRefusedException e) { if (log.isDebugEnabled()) { log.debug("consumer dry-run errors:", consumer.getUuid()); for (Entry<String, ValidationResult> entry : e.getResults().entrySet()) { log.debug("errors for pool id: {}", entry.getKey()); for (ValidationError error : entry.getValue().getErrors()) { log.debug(error.getResourceKey()); } } } } return result; }
Source:
<code><START> private double[] sumOverFirstDimension(final double[][][] data) { <END> final double result = new double[data.length]; for (int i = 0; i < data.length; i++) { result[i] = 0; for (int j = 0; j < data[0].length; j++) { for (int k = 0; k < data[0][0].length; k++) { result[i] += data[i][j][k]; } } } return result; }</code><technical_language>This method sums dimension</technical_language>

Target:
static double[][] sumOverFirstDimension(final double[][][] data) { final double [][] result = new double[data[0].length][data[0][0].length]; for (int j = 0; j < data[0].length; j++) { for (int k = 0; k < data[0][0].length; k++) { result[j][k] = 0; for (int i = 0; i < data.length; i++) { result[j][k] += data[i][j][k]; } } } return result; }