auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void testRegExp(final String regexp, final String[] expected) throws IOException { final String[] allNames = {"5newline5.txt", "Level2.fofn", "example.bam", "ipsum.txt.bgz", "ipsum.txt.bgzipped_with_gzextension.gz", "slurptest.txt", "Level1.fofn", "empty.txt", "ipsum.txt", "ipsum.txt.bgz.wrongextension", "ipsum.txt.gz", "words_longs.txt"}; final Path regExpDir = Files.createTempDirectory("regExpDir"); regExpDir.toFile().deleteOnExit(); final List<String> listExpected = Arrays.asList(expected); final List<File> expectedFiles = new ArrayList<File>(); for (String name : allNames) { final Path file = regExpDir.resolve(name); file.toFile().createNewFile(); if (listExpected.contains(name)) { expectedFiles.add(file.toFile()); } file.toFile().deleteOnExit(); } final File[] result = IOUtil.getFilesMatchingRegexp(regExpDir.toFile(), regexp); Assert.assertEqualsNoOrder(result, expectedFiles.toArray()); }

Target:
public void testRegExp(final String regexp, final String[] expected) throws IOException { final String[] allNames = {"5newline5.txt", "Level2.fofn", "example.bam", "ipsum.txt.bgz", "ipsum.txt.bgzipped_with_gzextension.gz", "slurptest.txt", "Level1.fofn", "empty.txt", "ipsum.txt", "ipsum.txt.bgz.wrongextension", "ipsum.txt.gz"}; final Path regExpDir = Files.createTempDirectory("regExpDir"); regExpDir.toFile().deleteOnExit(); final List<String> listExpected = Arrays.asList(expected); final List<File> expectedFiles = new ArrayList<File>(); for (String name : allNames) { final Path file = regExpDir.resolve(name); file.toFile().deleteOnExit(); file.toFile().createNewFile(); if (listExpected.contains(name)) { expectedFiles.add(file.toFile()); } } final File[] result = IOUtil.getFilesMatchingRegexp(regExpDir.toFile(), regexp); Assert.assertEqualsNoOrder(result, expectedFiles.toArray()); }
Source:
private List<StorageQuotaValidationParameter> getStorageQuotaListParameters() { List<StorageQuotaValidationParameter> list = new ArrayList<StorageQuotaValidationParameter>(); for (Disk disk : getParameters().getVm().getDiskMap().values()) { if(disk instanceof DiskImage){ DiskImage diskImage = (DiskImage)disk; list.add(new StorageQuotaValidationParameter(diskImage.getQuotaId(), imageToDestinationDomainMap.get(diskImage.getId()), diskImage.getSizeInGigabytes())); } } return list; }

Target:
private List<StorageQuotaValidationParameter> getStorageQuotaListParameters() { List<StorageQuotaValidationParameter> list = new ArrayList<StorageQuotaValidationParameter>(); for (Disk disk : getVm().getDiskMap().values()) { if(disk instanceof DiskImage){ DiskImage diskImage = (DiskImage)disk; list.add(new StorageQuotaValidationParameter(diskImage.getQuotaId(), imageToDestinationDomainMap.get(diskImage.getId()), diskImage.getSizeInGigabytes())); } } return list; }
Source:
public void testClone() { final CookieClient oldClient = new CookieClient(); oldClient.setName(TYPE); final SimpleTestUsernameProfileCreator profileCreator = new SimpleTestUsernameProfileCreator(); oldClient.setProfileCreator(profileCreator); final TokenAuthenticator authN = new SimpleTestTokenAuthenticator(); oldClient.setAuthenticator(authN); final CookieClient client = (CookieClient) oldClient.clone(); assertEquals(oldClient.getName(), client.getName()); assertEquals(oldClient.getProfileCreator(), client.getProfileCreator()); assertEquals(oldClient.getAuthenticator(), client.getAuthenticator()); }

Target:
public void testClone() { final CookieClient oldClient = new CookieClient(); oldClient.setName(TYPE); final AuthenticatorProfileCreator profileCreator = new AuthenticatorProfileCreator(); oldClient.setProfileCreator(profileCreator); final TokenAuthenticator authN = new SimpleTestTokenAuthenticator(); oldClient.setAuthenticator(authN); final CookieClient client = (CookieClient) oldClient.clone(); assertEquals(oldClient.getName(), client.getName()); assertEquals(oldClient.getProfileCreator(), client.getProfileCreator()); assertEquals(oldClient.getAuthenticator(), client.getAuthenticator()); }
Source:
public static ReaderRelatedPostList fromJsonPosts(@NonNull JSONArray jsonPosts) { ReaderRelatedPostList posts = new ReaderRelatedPostList(); for (int i = 0; i < jsonPosts.length(); i++) { posts.add(ReaderRelatedPost.fromJson(jsonPosts.optJSONObject(i))); } return posts; }

Target:
public static ReaderRelatedPostList fromJsonPosts(@NonNull JSONArray jsonPosts) { ReaderRelatedPostList posts = new ReaderRelatedPostList(); for (int i = 0; i < jsonPosts.length(); i++) { JSONObject jsonRelatedPost = jsonPosts.optJSONObject(i); if (jsonRelatedPost != null) { ReaderRelatedPost relatedPost = ReaderRelatedPost.fromJson(jsonRelatedPost); if (relatedPost != null) { posts.add(relatedPost); } } } return posts; }
Source:
public ResponseEntity<?> delete(@RequestBody List<Long> printerIds) throws IOException { for (long id : printerIds) { Printer printer = printerService.get(id); if (printer != null) { printerService.remove(printer); } } return new ResponseEntity<>(HttpStatus.OK); }

Target:
public void delete(@RequestBody List<Long> printerIds) throws IOException { for (long id : printerIds) { Printer printer = printerService.get(id); if (printer != null) { printerService.remove(printer); } } }
Source:
public MethodOutcome updatePatient(@ResourceParam Patient patient, @IdParam IdDt theId) { MethodOutcome retVal = new MethodOutcome(); OperationOutcome outcome = new OperationOutcome(); try { patient = patientResource.updatePatient(patient, theId.getIdPart()); } catch (Exception e) { outcome.addIssue() .setDetails( "No Patient is associated with the given UUID to update. Please" + " make sure you have set at lease one prefered identifier, non-deleted name, Gender and Birthdate to create a new " + "Patient with the given UUID. The actual error message was" + e.getMessage()); retVal.setOperationOutcome(outcome); return retVal; } outcome.addIssue().setDetails("Patient is successfully updated"); retVal.setOperationOutcome(outcome); return retVal; }

Target:
public MethodOutcome updatePatient(@ResourceParam Patient patient, @IdParam IdDt theId) { MethodOutcome retVal = new MethodOutcome(); OperationOutcome outcome = new OperationOutcome(); patient = patientResource.updatePatient(patient, theId.getIdPart()); outcome.addIssue().setDetails("Patient is successfully updated"); retVal.setOperationOutcome(outcome); return retVal; }
Source:
public ServiceMetricEvent.Builder makeMetricBuilder(GroupByQuery query) { int numMinutes = 0; for (Interval interval : query.getIntervals()) { numMinutes += Minutes.minutesIn(interval).getMinutes(); } return new ServiceMetricEvent.Builder() .setUser2(query.getDataSource()) .setUser3(String.format("%,d dims", query.getDimensions().size())) .setUser4("groupBy") .setUser5(Joiner.on(",").join(query.getIntervals())) .setUser6(String.valueOf(query.hasFilters())) .setUser7(String.format("%,d aggs", query.getAggregatorSpecs().size())) .setUser9(Minutes.minutes(numMinutes).toString()) .setUser10(QueryHelper.getQueryId(query)); }

Target:
public ServiceMetricEvent.Builder makeMetricBuilder(GroupByQuery query) { int numMinutes = 0; for (Interval interval : query.getIntervals()) { numMinutes += Minutes.minutesIn(interval).getMinutes(); } return new ServiceMetricEvent.Builder() .setUser2(query.getDataSource()) .setUser3(String.format("%,d dims", query.getDimensions().size())) .setUser4("groupBy") .setUser5(Joiner.on(",").join(query.getIntervals())) .setUser6(String.valueOf(query.hasFilters())) .setUser7(String.format("%,d aggs", query.getAggregatorSpecs().size())) .setUser9(Minutes.minutes(numMinutes).toString()) .setUser10(query.getId()); }
Source:
protected void onInit() { if (this.getSessionAcknowledgeMode()!= null) { Integer acknowledgeMode = JmsAdapterParserUtils.parseAcknowledgeMode(this.getSessionAcknowledgeMode()); if (acknowledgeMode != null) { if (JmsAdapterParserUtils.SESSION_TRANSACTED == acknowledgeMode) { jmsTemplate.setSessionTransacted(true); } } else { jmsTemplate.setSessionAcknowledgeMode(acknowledgeMode); } } }

Target:
protected void onInit() { if (this.getSessionAcknowledgeMode() != null) { Integer acknowledgeMode = JmsAdapterUtils.parseAcknowledgeMode(this.getSessionAcknowledgeMode()); if (acknowledgeMode != null) { if (JmsAdapterUtils.SESSION_TRANSACTED == acknowledgeMode) { this.jmsTemplate.setSessionTransacted(true); } else { this.jmsTemplate.setSessionAcknowledgeMode(acknowledgeMode); } } } }
Source:
public List<String> executeLastN(SearchParameterMap theSearchParameterMap, FhirContext theFhirContext, Integer theMaxResultsToFetch) { String OBSERVATION_IDENTIFIER_FIELD_NAME = "identifier"; String[] topHitsInclude = {OBSERVATION_IDENTIFIER_FIELD_NAME}; return buildAndExecuteSearch(theSearchParameterMap, theFhirContext, topHitsInclude, ObservationJson::getIdentifier, theMaxResultsToFetch); }

Target:
public List<String> executeLastN(SearchParameterMap theSearchParameterMap, FhirContext theFhirContext, Integer theMaxResultsToFetch) { String[] topHitsInclude = {OBSERVATION_IDENTIFIER_FIELD_NAME}; return buildAndExecuteSearch(theSearchParameterMap, theFhirContext, topHitsInclude, ObservationJson::getIdentifier, theMaxResultsToFetch); }
Source:
public EventAddedEvent(org.sleuthkit.datamodel.TimelineManager.EventAddedEvent event) { super(Case.Events.EVENT_ADDED.name(), null, event.getAddedEvent().getEventID()); addedEvent = event.getAddedEvent(); addedEventID = addedEvent.getEventID(); }

Target:
public EventAddedEvent(org.sleuthkit.datamodel.TimelineManager.EventAddedEvent event) { super(Case.Events.EVENT_ADDED.name(), null, event.getAddedEvent().getEventID()); addedEvent = event.getAddedEvent(); }
Source:
private void maybeWriteToChannel() { if (firstChunk.isComplete() && readCalled) { while (operationException.get() == null && chunkIndexToBuf.containsKey(indexOfNextChunkToWriteOut)) { ByteBuf byteBuf = chunkIndexToBuf.remove(indexOfNextChunkToWriteOut); if (byteBuf != null) { asyncWritableChannel.write(byteBuf.nioBuffer(), chunkAsyncWriteCallback); chunkIndexToBufWaitingForRelease.put(indexOfNextChunkToWriteOut, byteBuf); indexOfNextChunkToWriteOut++; } } if (operationException.get() != null || numChunksWrittenOut.get() == numChunksTotal) { completeRead(); } } }

Target:
private void maybeWriteToChannel() { if (firstChunk.isComplete() && readCalled) { while (operationException.get() == null && chunkIndexToBuf.containsKey(indexOfNextChunkToWriteOut)) { ByteBuf byteBuf = chunkIndexToBuf.remove(indexOfNextChunkToWriteOut); if (byteBuf != null) { chunkIndexToBufWaitingForRelease.put(indexOfNextChunkToWriteOut, byteBuf); asyncWritableChannel.write(byteBuf.nioBuffer(), chunkAsyncWriteCallback); indexOfNextChunkToWriteOut++; } } if (operationException.get() != null || numChunksWrittenOut.get() == numChunksTotal) { completeRead(); } } }
Source:
public void close() { synchronized (lock) { final State oldState = state; state = State.DONE; try { if (yielder != null) { Yielder<Object[]> theYielder = this.yielder; this.yielder = null; Runnable closer = () -> { try { theYielder.close(); } catch (Throwable t) { throw Throwables.propagate(t); } }; Future future = yielderOpenCloseExecutor.submit(closer); future.get(); } } catch (Throwable t) { if (oldState != State.DONE) { try { onClose.run(); } catch (Throwable t1) { t.addSuppressed(t1); } } throw Throwables.propagate(t); } if (oldState != State.DONE) { try { onClose.run(); } catch (Throwable t) { throw Throwables.propagate(t); } } } }

Target:
public void close() { synchronized (lock) { final State oldState = state; state = State.DONE; try { if (yielder != null) { Yielder<Object[]> theYielder = this.yielder; this.yielder = null; yielderOpenCloseExecutor.submit( () -> { theYielder.close(); return null; } ).get(); yielderOpenCloseExecutor.shutdownNow(); } } catch (Throwable t) { if (oldState != State.DONE) { try { onClose.run(); } catch (Throwable t1) { t.addSuppressed(t1); } } throw Throwables.propagate(t); } if (oldState != State.DONE) { try { onClose.run(); } catch (Throwable t) { throw Throwables.propagate(t); } } } }
Source:
private void showLocationPickerOrPopupMenu(@NonNull final View view) { if (!mPost.hasLocation()) { showLocationPicker(); return; } if (!isAdded()) { return; } PopupMenu popupMenu = new PopupMenu(getActivity(), view); popupMenu.inflate(R.menu.post_settings_location_popup); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { if (menuItem.getItemId() == R.id.menu_change_location) { showLocationPicker(); } else if (menuItem.getItemId() == R.id.menu_remove_location) { setLocation(null); } return true; } }); try { Field fieldPopup = popupMenu.getClass().getDeclaredField("mPopup"); fieldPopup.setAccessible(true); Object menuPopupHelper = fieldPopup.get(popupMenu); MenuPopupHelper popupHelper = (MenuPopupHelper) fieldPopup.get(popupMenu); Class<?> classPopupHelper = Class.forName(popupHelper.getClass().getName()); Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class); setForceIcons.invoke(menuPopupHelper, true); } catch (Exception e) { } popupMenu.show(); }

Target:
private void showLocationPickerOrPopupMenu(@NonNull final View view) { if (!isAdded()) { return; } if (!mPost.hasLocation()) { showLocationPicker(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), view); popupMenu.inflate(R.menu.post_settings_location_popup); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { if (menuItem.getItemId() == R.id.menu_change_location) { showLocationPicker(); } else if (menuItem.getItemId() == R.id.menu_remove_location) { setLocation(null); } return true; } }); try { Field fieldPopup = popupMenu.getClass().getDeclaredField("mPopup"); fieldPopup.setAccessible(true); Object menuPopupHelper = fieldPopup.get(popupMenu); MenuPopupHelper popupHelper = (MenuPopupHelper) fieldPopup.get(popupMenu); Class<?> classPopupHelper = Class.forName(popupHelper.getClass().getName()); Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class); setForceIcons.invoke(menuPopupHelper, true); } catch (Exception e) { } popupMenu.show(); }
Source:
public void initialize(Context context) { context.registerSyntaxNodeConsumer(Tree.Kind.FILE_INPUT, ctx -> previousToken = null); context.registerSyntaxNodeConsumer(Tree.Kind.TOKEN, ctx -> { Token token = (Token) ctx.syntaxNode(); if (token.isGeneratedCode()) { return; } if (previousToken != null && previousToken.line() != token.line()) { String[] lines = previousToken.value().split("\r?\n|\r", -1); int length = previousToken.column(); for (String line : lines) { length += line.length(); if (length > maximumLineLength) { String message = MessageFormat.format("The line contains {0,number,integer} characters which is greater than {1,number,integer} authorized.", length, maximumLineLength); ctx.addLineIssue(message, previousToken.line()); } length = 0; } } previousToken = token; }); }

Target:
public void initialize(Context context) { context.registerSyntaxNodeConsumer(Tree.Kind.FILE_INPUT, ctx -> previousToken = null); context.registerSyntaxNodeConsumer(Tree.Kind.TOKEN, ctx -> { Token token = (Token) ctx.syntaxNode(); if (token.type().equals(PythonTokenType.NEWLINE)) { return; } if (previousToken != null && previousToken.line() != token.line()) { String[] lines = previousToken.value().split("\r?\n|\r", -1); int length = previousToken.column(); for (String line : lines) { length += line.length(); if (length > maximumLineLength) { String message = MessageFormat.format("The line contains {0,number,integer} characters which is greater than {1,number,integer} authorized.", length, maximumLineLength); ctx.addLineIssue(message, previousToken.line()); } length = 0; } } previousToken = token; }); }
Source:
protected void onResumeFragments() { super.onResumeFragments(); if (shouldFinish()) { setResult(RESULT_OK); this.finish(); return; } if (CommCareApplication._().isConsumerApp()) { uiController.setUsername("t1"); uiController.setPasswordOrPin("123"); localLoginOrPullAndLogin(false); } else { tryAutoLogin(); } }

Target:
protected void onResumeFragments() { super.onResumeFragments(); if (shouldFinish()) { setResult(RESULT_OK); this.finish(); return; } if (CommCareApplication._().isConsumerApp()) { uiController.setUsername(BuildConfig.CONSUMER_APP_USERNAME); uiController.setPasswordOrPin(BuildConfig.CONSUMER_APP_PASSWORD); localLoginOrPullAndLogin(false); } else { tryAutoLogin(); } }
Source:
public Class getRealClass() { return clazz; }

Target:
public Class<?> getRealClass() { return clazz; }
Source:
public void addTwitterExtensions(Activity activity, Twitter twitter, Interaction interaction) { Retweet retweet = twitter.getRetweet(); Map<String, Object> extensions = ensureExtensions(activity); List<String> hashTags = Lists.newLinkedList(); List<Object> hts = Lists.newLinkedList(); if(twitter.getHashtags() != null) { hts = twitter.getHashtags(); } else if (retweet != null) { hts = retweet.getHashtags(); } if(hts != null) { for(Object ht : twitter.getHashtags()) { if(ht instanceof String) { hashTags.add((String) ht); } else { LOGGER.warn("Hashtag was not instance of String : {}", ht.getClass().getName()); } } } extensions.put("hashtags", hashTags); if(retweet != null) { Map<String, Object> rebroadcasts = Maps.newHashMap(); rebroadcasts.put("perspectival", true); rebroadcasts.put("count", retweet.getCount()); extensions.put("rebroadcasts", rebroadcasts); } if(interaction.getAdditionalProperties() != null) { ArrayList<String> mentions = (ArrayList<String>) interaction.getAdditionalProperties().get("mentions"); ArrayList<Long> mentionIds = (ArrayList<Long>) interaction.getAdditionalProperties().get("mention_ids"); ArrayList<UserMentions> userMentions = new ArrayList<UserMentions>(); if(mentions != null && mentionIds != null && (mentionIds.size() == mentions.size()) && !mentions.isEmpty() && !mentionIds.isEmpty()) { for(int x = 0; x < mentions.size(); x ++) { UserMentions mention = new UserMentions(); mention.setIdStr("id:twitter:" + mentionIds.get(x)); mention.setId(mentionIds.get(x)); mention.setName(mentions.get(x)); mention.setScreenName(mentions.get(x)); userMentions.add(mention); } extensions.put("user_mentions", userMentions); } } extensions.put("keywords", interaction.getContent()); }

Target:
public void addTwitterExtensions(Activity activity, Twitter twitter, Interaction interaction) { Retweet retweet = twitter.getRetweet(); Map<String, Object> extensions = ensureExtensions(activity); List<String> hashTags = Lists.newLinkedList(); List<Object> hts = Lists.newLinkedList(); if(twitter.getHashtags() != null) { hts = twitter.getHashtags(); } else if (retweet != null) { hts = retweet.getHashtags(); } if(hts != null) { for(Object ht : twitter.getHashtags()) { if(ht instanceof String) { hashTags.add((String) ht); } else { LOGGER.warn("Hashtag was not instance of String : {}", ht.getClass().getName()); } } } extensions.put("hashtags", hashTags); if(retweet != null) { Map<String, Object> rebroadcasts = Maps.newHashMap(); rebroadcasts.put("perspectival", true); rebroadcasts.put("count", retweet.getCount()); extensions.put("rebroadcasts", rebroadcasts); } if(interaction.getAdditionalProperties() != null) { Object mentionsObject = interaction.getAdditionalProperties().get("mentions"); if(mentionsObject != null ) { if(mentionsObject instanceof List) { List mentions = (List) mentionsObject; List<Map<String, Object>> userMentions = Lists.newLinkedList(); for(Object mention : mentions) { Map<String, Object> actor = Maps.newHashMap(); actor.put("displayName", mention); userMentions.add(actor); } extensions.put("user_mentions", userMentions); } } } extensions.put("keywords", interaction.getContent()); }
Source:
public static Long ifPositive(Long time) { if (time==null || time<=0) return null; return time; }

Target:
private static Long ifPositive(Long time) { if (time==null || time<=0) return null; return time; }
Source:
private int calculateDrawingRadius(final MapProjectionImpl projection) { final float[] distanceArray = new float[1]; final Geopoint itemCoord = items.get(0).getCoord().getCoords(); Location.distanceBetween(itemCoord.getLatitude(), itemCoord.getLongitude(), itemCoord.getLatitude(), itemCoord.getLongitude() + 1, distanceArray); final float longitudeLineDistance = distanceArray[0]; final GeoPointImpl itemGeo = mapItemFactory.getGeoPointBase(itemCoord); final Geopoint leftCoords = new Geopoint(itemCoord.getLatitude(), itemCoord.getLongitude() - 160.9344f / longitudeLineDistance); final GeoPointImpl leftGeo = mapItemFactory.getGeoPointBase(leftCoords); final Point center = new Point(); projection.toPixels(itemGeo, center); final Point left = new Point(); projection.toPixels(leftGeo, left); return center.x - left.x; }

Target:
private int calculateDrawingRadius(final MapProjectionImpl projection) { final float[] distanceArray = new float[1]; final Geopoint itemCoord = items.get(0).getCoord().getCoords(); Location.distanceBetween(itemCoord.getLatitude(), itemCoord.getLongitude(), itemCoord.getLatitude(), itemCoord.getLongitude() + 1, distanceArray); final float longitudeLineDistance = distanceArray[0]; final GeoPointImpl itemGeo = mapItemFactory.getGeoPointBase(itemCoord); final Geopoint leftCoords = new Geopoint(itemCoord.getLatitude(), itemCoord.getLongitude() - 528.0 * IConversion.FEET_TO_KILOMETER * 1000.0 / longitudeLineDistance); final GeoPointImpl leftGeo = mapItemFactory.getGeoPointBase(leftCoords); final Point center = new Point(); projection.toPixels(itemGeo, center); final Point left = new Point(); projection.toPixels(leftGeo, left); return center.x - left.x; }
Source:
public void regenerateChunk(Actor actor, World world, LocalSession session, EditSession editSession, @Selection Region region) throws WorldEditException { Mask mask = session.getMask(); boolean success; try { session.setMask(null); success = world.regenerate(region, editSession); } finally { session.setMask(mask); } if (success) { actor.print("Region regenerated."); } else { actor.print("Unable to regenerate chunks."); } }

Target:
public void regenerateChunk(Actor actor, World world, LocalSession session, EditSession editSession, @Selection Region region) throws WorldEditException { Mask mask = session.getMask(); boolean success; try { session.setMask(null); success = world.regenerate(region, editSession); } finally { session.setMask(mask); } if (success) { actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated")); } else { actor.printError(TranslatableComponent.of("worldedit.regen.failed")); } }
Source:
public Poll clickNthAnswer(int number) { wait.forElementClickable(answersList.get(number)); answersList.get(number).click(); return this; }

Target:
public Poll clickNthAnswer(int number) { try { wait.forElementClickable(answersList.get(number)); answersList.get(number).click(); } catch (Exception e) { PageObjectLogging.log("Could not click nth answer", e, false); } return this; }
Source:
public DerivativeDataSourceMetadata( @JsonProperty("baseDataSource") String baseDataSource, @JsonProperty("dimensions") Set<String> dimensions, @JsonProperty("metrics") Set<String> metrics ) { Preconditions.checkNotNull(baseDataSource, "baseDataSource cannot be null. This is not a valid DerivativeDataSourceMetadata."); Preconditions.checkNotNull(dimensions, "dimensions cannot be null. This is not a valid DerivativeDataSourceMetadata."); Preconditions.checkNotNull(metrics, "metrics cannot be null. This is not a valid DerivativeDataSourceMetadata."); this.baseDataSource = baseDataSource; this.dimensions = dimensions; this.metrics = metrics; }

Target:
public DerivativeDataSourceMetadata( @JsonProperty("baseDataSource") String baseDataSource, @JsonProperty("dimensions") Set<String> dimensions, @JsonProperty("metrics") Set<String> metrics ) { this.baseDataSource = Preconditions.checkNotNull(baseDataSource, "baseDataSource cannot be null. This is not a valid DerivativeDataSourceMetadata."); this.dimensions = Preconditions.checkNotNull(dimensions, "dimensions cannot be null. This is not a valid DerivativeDataSourceMetadata."); this.metrics = Preconditions.checkNotNull(metrics, "metrics cannot be null. This is not a valid DerivativeDataSourceMetadata."); }
Source:
@Override public Response addFromVmSnapshot(Template template) { validateIconParameters(template); validateSnapshotExistence(template.getVm()); Guid snapshotId = getSnapshotId(template.getVm().getSnapshots()); org.ovirt.engine.core.common.businessentities.VM vmConfiguration = getVmConfiguration(snapshotId); Guid clusterId = null; if (namedCluster(template)) { clusterId = getClusterId(template); } if (template.getVersion() != null) { validateParameters(template.getVersion(), "baseTemplate"); } VmStatic originalVm = vmConfiguration.getStaticData(); VmStatic staticVm = getMapper(Template.class, VmStatic.class).map(template, originalVm); if (namedCluster(template)) { staticVm.setClusterId(clusterId); } AddVmTemplateFromSnapshotParameters params = new AddVmTemplateFromSnapshotParameters( staticVm, template.getName(), template.getDescription(), snapshotId); return addTemplate(template, originalVm, vmConfiguration.getDiskMap().keySet(), params, ActionType.AddVmTemplateFromSnapshot); }

Target:
public Response addFromVmSnapshot(Template template) { validateIconParameters(template); validateSnapshotExistence(template.getVm()); Guid snapshotId = getSnapshotId(template.getVm().getSnapshots()); org.ovirt.engine.core.common.businessentities.VM vmConfiguration = getVmConfiguration(snapshotId); Guid clusterId = null; if (namedCluster(template)) { clusterId = getClusterId(template); } if (template.getVersion() != null) { validateParameters(template.getVersion(), "baseTemplate"); } VmStatic originalVm = vmConfiguration.getStaticData(); VmStatic staticVm = getMapper(Template.class, VmStatic.class).map(template, originalVm); if (namedCluster(template)) { staticVm.setClusterId(clusterId); } AddVmTemplateFromSnapshotParameters params = new AddVmTemplateFromSnapshotParameters( staticVm, template.getName(), template.getDescription(), snapshotId); return addTemplate(template, originalVm, vmConfiguration.getDiskMap().keySet(), params, ActionType.AddVmTemplateFromSnapshot); }
Source:
public void init(Map<String, Serializable> args) throws Exception { if (args.containsKey("ftpHostname")) { ftpHostname = args.get("ftpHostname").toString(); } if (args.containsKey("ftpPort")) { ftpPort = Integer.parseInt(args.get("ftpPort").toString()); } if (args.containsKey("ftpExtractArchive")) { ftpExtractArchive = Boolean.parseBoolean(args.get("ftpExtractArchive").toString()); } if (args.containsKey(FTP_LOCAL_FILE_PATH) && args.get(FTP_LOCAL_FILE_PATH).toString() != null) { ftpLocalFilePath = args.get(FTP_LOCAL_FILE_PATH).toString(); } if (args.containsKey("ftpRemoteFilePath")) { ftpRemoteFilePath = args.get("ftpRemoteFilePath").toString(); } if (args.containsKey("ftpMode")) { ftpMode = args.get("ftpMode").toString(); } ftpUsername = getThirdPartyCredential("FTP_USERNAME"); ftpPassword = getThirdPartyCredential("FTP_PASSWORD"); if (ftpUsername == null || ftpPassword == null) { throw new IllegalArgumentException("You first need to add your ftp username and password (FTP_USERNAME, FTP_PASSWORD) to the third party credentials"); } }

Target:
public void init(Map<String, Serializable> args) throws Exception { if (args.containsKey("ftpHostname")) { ftpHostname = args.get("ftpHostname").toString(); } if (args.containsKey("ftpPort")) { ftpPort = Integer.parseInt(args.get("ftpPort").toString()); } if (args.containsKey("ftpMode")) { ftpMode = args.get("ftpMode").toString(); } if (args.containsKey("ftpExtractArchive")) { ftpExtractArchive = Boolean.parseBoolean(args.get("ftpExtractArchive").toString()); } if (args.containsKey(FTP_LOCAL_RELATIVE_PATH) && !args.get(FTP_LOCAL_RELATIVE_PATH).toString().isEmpty()) { ftpLocalRelativePath = args.get(FTP_LOCAL_RELATIVE_PATH).toString(); } else { if (ftpMode.equals("PUT")) { throw new IllegalArgumentException("You have to specify the local relative path. Empty value is not allowed."); } ftpLocalRelativePath = getLocalSpace(); } if (args.containsKey("ftpRemoteRelativePath")) { ftpRemoteRelativePath = args.get("ftpRemoteRelativePath").toString(); } ftpUsername = getThirdPartyCredential("FTP_USERNAME"); ftpPassword = getThirdPartyCredential("FTP_PASSWORD"); if (ftpUsername == null || ftpPassword == null) { throw new IllegalArgumentException("You first need to add your ftp username and password (FTP_USERNAME, FTP_PASSWORD) to the third party credentials"); } }
Source:
void setUpHomeMenuIcon() { drawerIconDot.setVisibility(AccountUtil.isLoggedIn() && Prefs.showActionFeedIndicator() && ReleaseUtil.isPreBetaRelease() && Prefs.getTotalUserDescriptionsEdited() >= ACTION_DESCRIPTION_EDIT_UNLOCK_THRESHOLD ? VISIBLE : GONE); }

Target:
void setUpHomeMenuIcon() { drawerIconDot.setVisibility(AccountUtil.isLoggedIn() && Prefs.showActionFeedIndicator() && ReleaseUtil.isPreBetaRelease() ? VISIBLE : GONE); }
Source:
private List<String> getOutputFolder() throws ValueStorageException { String outputDir; try { outputDir = extensionService.getOutputDir(wsPath); } catch (Exception e) { throw new ValueStorageException( format("Failed to get '%s'. Cause: '%s'", OUTPUT_FOLDER, e.getMessage())); } return outputDir.startsWith(wsPath) ? singletonList(outputDir.substring(wsPath.length() + 1)) : singletonList(outputDir); }

Target:
private List<String> getOutputFolder() throws ValueStorageException { String outputDir; try { outputDir = extensionService.getOutputDir(wsPath); } catch (Exception e) { throw new ValueStorageException( format("Failed to get '%s'. ", OUTPUT_FOLDER), e.getCause()); } return outputDir.startsWith(wsPath) ? singletonList(outputDir.substring(wsPath.length() + 1)) : singletonList(outputDir); }
Source:
public void testSearch(String searchTerm) throws DAOException { HomePage homePage = new HomePage(driver); User admin = DBUtility.getAdmin(); UserInfoPage userInfoPage = homePage.logIn(admin.getLogin(), admin.getPassword()); AdministrationPage administrationPage = userInfoPage.clickAdministrationTab(); for (SearchFilters filters : SearchFilters.values()) { for (SearchConditions conditions : SearchConditions.values()) { if (filters == ALL_COLUMNS) { continue; } else { administrationPage.setFilters(filters.getFilterName()) .setCondition(conditions) .fillSearchField(searchTerm) .clickSearchButton(); usersListFromView = administrationPage.getTableFromView(); administrationPage.clearSearchField(); usersListFromDB = DBUtility.getUserDao().getAllUsers(); filteredListFromDB = getFilteredList(usersListFromDB, filters, conditions, searchTerm); Comparator<User> userComparator = Comparator.comparing(User::getLogin); Comparator<UserFromView> userFromViewComparator = Comparator.comparing(UserFromView::getLogin); filteredListFromDB.sort(userComparator); usersListFromView.sort(userFromViewComparator); loggingSoftAssert.assertTrue(areListsEqual(usersListFromView, filteredListFromDB), filters + " " + conditions + " " + searchTerm); loggingSoftAssert.assertAll(); } } } administrationPage.clickLogOutButton(); }

Target:
public void testSearch(String searchTerm) throws DAOException { HomePage homePage = new HomePage(driver); User admin = DBUtility.getAdmin(); UserInfoPage userInfoPage = homePage.logIn(admin.getLogin(), admin.getPassword()); AdministrationPage administrationPage = userInfoPage.clickAdministrationTab(); for (SearchFilters filter : SearchFilters.values()) { for (SearchConditions conditions : SearchConditions.values()) { if (filter == ALL_COLUMNS) { continue; } else { administrationPage.setFilters(filter) .setCondition(conditions) .fillSearchField(searchTerm) .clickSearchButton(); usersListFromView = administrationPage.getTableFromView(); administrationPage.clearSearchField(); usersListFromDB = DBUtility.getUserDao().getAllUsers(); filteredListFromDB = getFilteredList(usersListFromDB, filter, conditions, searchTerm); filteredListFromDB.sort(Comparator.comparing(User::getLogin)); usersListFromView.sort(Comparator.comparing(UserFromView::getLogin)); loggingSoftAssert.assertTrue(areListsEqual(usersListFromView, filteredListFromDB), filter + " " + conditions + " " + searchTerm); loggingSoftAssert.assertAll(); } } } administrationPage.clickLogOutButton(); }
Source:
public void testUnionAllCorrectTuples() throws DbException { TupleBatchBuffer[] randomTuples = new TupleBatchBuffer[2]; randomTuples[0] = generateRandomTuples(123, false); randomTuples[1] = generateRandomTuples(42, false); TupleSource[] children = new TupleSource[2]; children[0] = new TupleSource(randomTuples[0]); children[1] = new TupleSource(randomTuples[1]); UnionAll union = new UnionAll(children); union.open(null); TupleBatch tb; HashSet<Long> idCollector = new HashSet<Long>(); while (!union.eos()) { tb = union.nextReady(); if (tb != null) { for (int i = 0; i < tb.numTuples(); i++) { idCollector.add(tb.getLong(0, i)); } } } union.close(); for (TupleBatchBuffer randomTuple : randomTuples) { for (TupleBatch tuples : randomTuple.getAll()) { for (int j = 0; j < tuples.numTuples(); j++) { assert idCollector.contains(tuples.getLong(0, j)); } } } }

Target:
public void testUnionAllCorrectTuples() throws DbException { TupleBatchBuffer[] randomTuples = new TupleBatchBuffer[2]; randomTuples[0] = generateRandomTuples(123, false); randomTuples[1] = generateRandomTuples(42, false); TupleSource[] children = new TupleSource[2]; children[0] = new TupleSource(randomTuples[0]); children[1] = new TupleSource(randomTuples[1]); UnionAll union = new UnionAll(children); union.open(null); TupleBatch tb; Multiset<Long> actualCounts = HashMultiset.create(); while (!union.eos()) { tb = union.nextReady(); if (tb != null) { for (int i = 0; i < tb.numTuples(); i++) { long index = tb.getLong(0, i); actualCounts.add(index); } } } union.close(); Multiset<Long> expectedCounts = HashMultiset.create(); for (TupleBatchBuffer randomTuple : randomTuples) { for (TupleBatch tuples : randomTuple.getAll()) { for (int j = 0; j < tuples.numTuples(); j++) { Long index = tuples.getLong(0, j); expectedCounts.add(index); } } } for (Multiset.Entry<Long> expectedEntry : expectedCounts.entrySet()) { assertEquals(expectedEntry.getCount(), actualCounts.count(expectedEntry.getElement())); } }
Source:
private int checkMissingStates() { int numMatchingEvals = 0; for (MissingState missingState : missingStates) { MissingConditionEval eval = new MissingConditionEval(missingState.getCondition(), missingState.getPreviousTime(), System.currentTimeMillis()); if (eval.isMatch()) { rules.removeFact(missingState); missingState.setPreviousTime(System.currentTimeMillis()); missingState.setTime(System.currentTimeMillis()); rules.addFact(missingState); rules.addFact(eval); numMatchingEvals++; } } return numMatchingEvals; }

Target:
private int checkMissingStates() { int numMatchingEvals = 0; for (MissingState missingState : missingStates) { long now = System.currentTimeMillis(); if (missingState.getCondition().match(missingState.getPreviousTime(), now)) { MissingConditionEval eval = new MissingConditionEval(missingState.getCondition(), missingState.getPreviousTime(), now); rules.removeFact(missingState); missingState.setPreviousTime(System.currentTimeMillis()); missingState.setTime(System.currentTimeMillis()); rules.addFact(missingState); rules.addFact(eval); numMatchingEvals++; } } return numMatchingEvals; }
Source:
public Coordinate[] getFinPointsWithTab() { final Coordinate[] finPoints = getFinPoints(); final Coordinate[] tabPoints = getTabPoints(); Coordinate[] combinedPoints = Arrays.copyOf(finPoints, finPoints.length + tabPoints.length); combinedPoints[finPoints.length + 3] = tabPoints[0]; combinedPoints[finPoints.length + 2] = tabPoints[1]; combinedPoints[finPoints.length + 1] = tabPoints[2]; combinedPoints[finPoints.length + 0] = tabPoints[3]; return combinedPoints; }

Target:
public Coordinate[] getFinPointsWithTab() { return combineCurves(getFinPoints(), getTabPoints()); }
Source:
private static long fillNextLeafNode(HistoryTreeStub ht, long leafNodeStart) { int prevCount = ht.getNodeCount(); int prevDepth = ht.getDepth(); HTNode node = ht.getLatestLeaf(); int intervalSize = new HTInterval(10, 20, 1, STRING_VALUE).getIntervalSize(); int nodeFreeSpace = node.getNodeFreeSpace(); int nbIntervals = nodeFreeSpace / intervalSize; long ret = fillValues(ht, STRING_VALUE, nbIntervals, leafNodeStart); assertEquals(prevCount, ht.getNodeCount()); assertEquals(prevDepth, ht.getDepth()); return ret; }

Target:
private static long fillNextLeafNode(HistoryTreeStub ht, long leafNodeStart) { int prevCount = ht.getNodeCount(); int prevDepth = ht.getDepth(); HTNode node = ht.getLatestLeaf(); int intervalSize = STRING_INTERVAL.getIntervalSizeOnDisk(); int nodeFreeSpace = node.getNodeFreeSpace(); int nbIntervals = nodeFreeSpace / intervalSize; long ret = fillValues(ht, STRING_VALUE, nbIntervals, leafNodeStart); assertEquals(prevCount, ht.getNodeCount()); assertEquals(prevDepth, ht.getDepth()); return ret; }
Source:
protected String getFileName(ITask task, Predicate<String> fileExists) { String encodedFileName = CoreUtil.asFileName(task.getTaskId()); if (encodedFileName.length() <= FILENAME_MAX_LEN && fileExists.test(encodedFileName)) { return encodedFileName; } String fileName; if (requiresEncoding(task.getTaskId())) { fileName = encodedFileName; } else { fileName = task.getTaskId(); } return trimFilenameIfRequired(fileName); }

Target:
protected String getFileName(ITask task, Predicate<String> fileExists) { String encodedFileName = CoreUtil.asFileName(task.getTaskId()); if (fileExists.test(encodedFileName)) { return encodedFileName; } String fileName; if (requiresEncoding(task.getTaskId())) { fileName = encodedFileName; } else { fileName = task.getTaskId(); } return trimFilenameIfRequired(fileName); }
Source:
public void badInstantiationTest() throws Exception { Set<ZkInfo> zkInfos = new HashSet<>(dcsToZkInfo.values()); zkInfos.iterator().next().port = 0; JSONObject invalidZkJson = constructZkLayoutJSON(zkInfos); Properties props = new Properties(); props.setProperty("clustermap.host.name", hostname); props.setProperty("clustermap.cluster.name", clusterNamePrefixInHelix + clusterNameStatic); props.setProperty("clustermap.datacenter.name", "DC0"); props.setProperty("clustermap.dcs.zk.connect.strings", invalidZkJson.toString(2)); ClusterMapConfig invalidClusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); metricRegistry = new MetricRegistry(); try { new HelixClusterManager(invalidClusterMapConfig, hostname, new MockHelixManagerFactory(helixCluster), metricRegistry); fail("Instantiation should have failed with invalid zk addresses"); } catch (IOException e) { assertEquals(true, metricRegistry.getGauges() .get(HelixClusterManager.class.getName() + ".helixClusterManagerInstantiationFailed") .getValue()); } }

Target:
public void badInstantiationTest() throws Exception { assertEquals(false, metricRegistry.getGauges() .get(HelixClusterManager.class.getName() + ".instantiationFailed") .getValue()); Set<ZkInfo> zkInfos = new HashSet<>(dcsToZkInfo.values()); zkInfos.iterator().next().port = 0; JSONObject invalidZkJson = constructZkLayoutJSON(zkInfos); Properties props = new Properties(); props.setProperty("clustermap.host.name", hostname); props.setProperty("clustermap.cluster.name", clusterNamePrefixInHelix + clusterNameStatic); props.setProperty("clustermap.datacenter.name", "DC0"); props.setProperty("clustermap.dcs.zk.connect.strings", invalidZkJson.toString(2)); ClusterMapConfig invalidClusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); metricRegistry = new MetricRegistry(); try { new HelixClusterManager(invalidClusterMapConfig, hostname, new MockHelixManagerFactory(helixCluster), metricRegistry); fail("Instantiation should have failed with invalid zk addresses"); } catch (IOException e) { assertEquals(true, metricRegistry.getGauges() .get(HelixClusterManager.class.getName() + ".instantiationFailed") .getValue()); } }
Source:
public void setupMenu() { adminPage.addScreen( "root", "Settings" ); adminPage.addPreference( "root", "LibraryPreferences", "Library", "fa-cubes", "preferences" ); final AbstractWorkbenchPerspectiveActivity defaultPerspective = menusHelper.getDefaultPerspectiveActivity(); menusHelper.addRolesMenuItems(); menusHelper.addUtilitiesMenuItems(); final Menus menus = MenuFactory .newTopLevelMenu( constants.Home() ) .respondsWith( () -> { if ( defaultPerspective != null ) { placeManager.goTo( new DefaultPlaceRequest( defaultPerspective.getIdentifier() ) ); } else { Window.alert( "Default perspective not found." ); } } ) .endMenu() .newTopLevelMenu( MenuFactory.newSimpleItem( "Admin - Preferences" ) .respondsWith( adminPageHelper.getAdminToolCommand( "root" ) ) .endMenu() .build().getItems().get( 0 ) ) .endMenu() .newTopLevelMenu( constants.Perspectives() ) .withItems( menusHelper.getPerspectivesMenuItems() ) .endMenu() .newTopLevelCustomMenu( iocManager.lookupBean( SearchMenuBuilder.class ).getInstance() ) .endMenu() .build(); menuBar.addMenus( menus ); }

Target:
public void setupMenu() { adminPage.addScreen( "root", AppConstants.INSTANCE.Settings() ); adminPage.addPreference( "root", "LibraryPreferences", AppConstants.INSTANCE.Library(), "fa-cubes", "preferences" ); final AbstractWorkbenchPerspectiveActivity defaultPerspective = menusHelper.getDefaultPerspectiveActivity(); menusHelper.addRolesMenuItems(); menusHelper.addUtilitiesMenuItems(); final Menus menus = MenuFactory .newTopLevelMenu( constants.Home() ) .respondsWith( () -> { if ( defaultPerspective != null ) { placeManager.goTo( new DefaultPlaceRequest( defaultPerspective.getIdentifier() ) ); } else { Window.alert( "Default perspective not found." ); } } ) .endMenu() .newTopLevelMenu( MenuFactory.newSimpleItem( AppConstants.INSTANCE.AdminPreferences() ) .respondsWith( adminPageHelper.getAdminToolCommand( "root" ) ) .endMenu() .build().getItems().get( 0 ) ) .endMenu() .newTopLevelMenu( constants.Perspectives() ) .withItems( menusHelper.getPerspectivesMenuItems() ) .endMenu() .newTopLevelCustomMenu( iocManager.lookupBean( SearchMenuBuilder.class ).getInstance() ) .endMenu() .build(); menuBar.addMenus( menus ); }
Source:
public static OptionSet prepareEoptions(OptionSet options) { OptionSet ret = new OptionSet(); for (Option o : options.asSortedList()) { switch (o.getNumber()) { case OptionNumberRegistry.OBSERVE: options.removeObserve(); break; case OptionNumberRegistry.URI_HOST: case OptionNumberRegistry.URI_PORT: case OptionNumberRegistry.PROXY_SCHEME: case OptionNumberRegistry.OSCORE: break; case OptionNumberRegistry.PROXY_URI: String proxyUri = o.getStringValue(); proxyUri = proxyUri.replace("coap://", ""); proxyUri = proxyUri.replace("coaps://", ""); int i = proxyUri.indexOf('/'); if (i >= 0) { proxyUri = proxyUri.substring(i + 1, proxyUri.length()); } else { break; } i = proxyUri.indexOf("?"); String uriPath = proxyUri; String uriQuery = null; if (i >= 0) { uriPath = proxyUri.substring(0, i); uriQuery = proxyUri.substring(i + 1, proxyUri.length()); } if (uriPath != null) { String[] uriPaths = uriPath.split("/"); for (int idx = 0; idx < uriPaths.length; idx++) { ret.addOption(new Option(OptionNumberRegistry.URI_PATH, uriPaths[idx])); } } if (uriQuery != null) { String[] uriQueries = uriQuery.split("&"); for (int idx = 0; idx < uriQueries.length; idx++) { ret.addOption(new Option(OptionNumberRegistry.URI_QUERY, uriQueries[idx])); } } break; default: ret.addOption(o); } } return ret; }

Target:
public static OptionSet prepareEoptions(OptionSet options) { OptionSet ret = new OptionSet(); for (Option o : options.asSortedList()) { switch (o.getNumber()) { case OptionNumberRegistry.OBSERVE: options.removeObserve(); break; case OptionNumberRegistry.URI_HOST: case OptionNumberRegistry.URI_PORT: case OptionNumberRegistry.PROXY_SCHEME: case OptionNumberRegistry.OSCORE: break; case OptionNumberRegistry.PROXY_URI: String proxyUri = o.getStringValue(); proxyUri = proxyUri.replace("coap://", ""); proxyUri = proxyUri.replace("coaps://", ""); int i = proxyUri.indexOf('/'); if (i >= 0) { proxyUri = proxyUri.substring(i + 1, proxyUri.length()); } else { break; } i = proxyUri.indexOf("?"); String uriPath = proxyUri; String uriQuery = null; if (i >= 0) { uriPath = proxyUri.substring(0, i); uriQuery = proxyUri.substring(i + 1, proxyUri.length()); } if (uriPath != null) { ret.setUriPath(uriPath); } if (uriQuery != null) { String[] uriQueries = uriQuery.split("&"); for (int idx = 0; idx < uriQueries.length; idx++) { ret.setUriQuery(uriQueries[idx]); } } break; default: ret.addOption(o); } } return ret; }
Source:
public void readFromNBT(NBTTagCompound nbt) { if (nbt.hasKey("activeAction")) { deactivateAction(VampirismAPI.entityActionManager().getRegistry().getValue(new ResourceLocation("vampirism", nbt.getString("activeAction")))); isPlayerTarget = true; } }

Target:
public void readFromNBT(NBTTagCompound nbt) { if (nbt.hasKey("activeAction")) { deactivateAction(VampirismAPI.entityActionManager().getRegistry().getValue(new ResourceLocation(nbt.getString("activeAction")))); isPlayerTarget = true; } }
Source:
private AbstractPlanNode handleWindowedOperators(AbstractPlanNode root) { SchemaColumn windowedSchemaColumn = null; for (ParsedColInfo colInfo : m_parsedSelect.m_displayColumns) { AbstractExpression colExpr = colInfo.expression; if (colExpr instanceof WindowedExpression) { windowedSchemaColumn = new SchemaColumn(colInfo.tableName, colInfo.tableAlias, colInfo.columnName, colInfo.alias, colExpr); break; } } assert(windowedSchemaColumn != null); PartitionByPlanNode pnode = new PartitionByPlanNode(windowedSchemaColumn); OrderByPlanNode onode = new OrderByPlanNode(); pnode.setWindowedColumn(windowedSchemaColumn); WindowedExpression windowedExpression = (WindowedExpression)windowedSchemaColumn.getExpression(); for (AbstractExpression partitionByExpr : windowedExpression.getPartitionByExpressions()) { SortDirectionType pdir = windowedExpression.getOrderByDirectionOfExpression(partitionByExpr); onode.addSort(partitionByExpr, pdir); } for (int idx = 0; idx < windowedExpression.getOrderbySize(); idx += 1) { AbstractExpression orderByExpr = windowedExpression.getOrderByExpressions().get(idx); SortDirectionType orderByDir = windowedExpression.getOrderByDirections().get(idx); if (false == windowedExpression.getPartitionByExpressions().contains(orderByExpr)) { onode.addSort(orderByExpr, orderByDir); } } onode.addAndLinkChild(root); pnode.addAndLinkChild(onode); return pnode; }

Target:
private AbstractPlanNode handleWindowedOperators(AbstractPlanNode root) { ParsedColInfo colInfo = m_parsedSelect.getWindowedColinfo(); assert(colInfo != null); SchemaColumn windowedSchemaColumn = colInfo.asSchemaColumn(); PartitionByPlanNode pnode = new PartitionByPlanNode(); pnode.setWindowedColumn(windowedSchemaColumn); OrderByPlanNode onode = new OrderByPlanNode(); WindowedExpression windowedExpression = (WindowedExpression)windowedSchemaColumn.getExpression(); List<AbstractExpression> partitionByExpressions = windowedExpression.getPartitionByExpressions(); for (AbstractExpression partitionByExpression : partitionByExpressions) { SortDirectionType pdir = SortDirectionType.DESC; onode.addSort(partitionByExpression, pdir); } for (int idx = 0; idx < windowedExpression.getOrderbySize(); idx += 1) { AbstractExpression orderByExpr = windowedExpression.getOrderByExpressions().get(idx); SortDirectionType orderByDir = windowedExpression.getOrderByDirections().get(idx); if (false == windowedExpression.getPartitionByExpressions().contains(orderByExpr)) { onode.addSort(orderByExpr, orderByDir); } } onode.addAndLinkChild(root); pnode.addAndLinkChild(onode); return pnode; }