auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void cancel(InterpreterContext context) { LOGGER.info("Cancel paragraph:" + context.getParagraphId()); PigScriptListener listener = listenerMap.get(context.getParagraphId()); if (listener != null) { Set<String> jobIds = listener.getJobIds(); if (jobIds.isEmpty()) { LOGGER.info("No job is started, so can not cancel paragraph:" + context.getParagraphId()); } for (String jobId : jobIds) { LOGGER.info("Kill jobId:" + jobId); HExecutionEngine engine = (HExecutionEngine) getPigServer().getPigContext().getExecutionEngine(); try { Field launcherField = HExecutionEngine.class.getDeclaredField("launcher"); launcherField.setAccessible(true); Launcher launcher = (Launcher) launcherField.get(engine); launcher.killJob(jobId, new Configuration()); } catch (NoSuchFieldException e) { LOGGER.error("", e); } catch (BackendException e) { LOGGER.error("", e); } catch (IllegalAccessException e) { LOGGER.error("", e); } } } else { LOGGER.warn("No PigScriptListener found, can not cancel paragraph:" + context.getParagraphId()); } }

Target:
public void cancel(InterpreterContext context) { LOGGER.info("Cancel paragraph:" + context.getParagraphId()); PigScriptListener listener = listenerMap.get(context.getParagraphId()); if (listener != null) { Set<String> jobIds = listener.getJobIds(); if (jobIds.isEmpty()) { LOGGER.info("No job is started, so can not cancel paragraph:" + context.getParagraphId()); } for (String jobId : jobIds) { LOGGER.info("Kill jobId:" + jobId); HExecutionEngine engine = (HExecutionEngine) getPigServer().getPigContext().getExecutionEngine(); try { Field launcherField = HExecutionEngine.class.getDeclaredField("launcher"); launcherField.setAccessible(true); Launcher launcher = (Launcher) launcherField.get(engine); launcher.killJob(jobId, new Configuration()); } catch (NoSuchFieldException | BackendException | IllegalAccessException e) { LOGGER.error("Fail to cancel paragraph:" + context.getParagraphId(), e); } } } else { LOGGER.warn("No PigScriptListener found, can not cancel paragraph:" + context.getParagraphId()); } }
Source:
public Object doTransform(Message<?> message) { Object source = (this.extractPayload) ? message.getPayload() : message; Object transformedPayload = null; Result result = this.resultFactory.createResult(source); if (result == null) { throw new MessagingException( "Unable to marshal payload, ResultFactory returned null."); } try { this.marshaller.marshal(source, result); transformedPayload = result; } catch (IOException e) { throw new MessagingException("Failed to marshal payload", e); } if (this.resultTransformer != null) { transformedPayload = this.resultTransformer.transformResult(result); } return transformedPayload; }

Target:
public Object doTransform(Message<?> message) { Object source = (this.extractPayload) ? message.getPayload() : message; Object transformedPayload = null; Result result = this.getResultFactory().createResult(source); if (result == null) { throw new MessagingException( "Unable to marshal payload, ResultFactory returned null."); } try { this.marshaller.marshal(source, result); transformedPayload = result; } catch (IOException e) { throw new MessagingException("Failed to marshal payload", e); } if (this.resultTransformer != null) { transformedPayload = this.resultTransformer.transformResult(result); } return transformedPayload; }
Source:
public void testImportSequeneFile_fromGcsWithDeleteMarker() throws Exception { final byte[] r1 = Bytes.toBytes("r1"); final byte[] r2 = Bytes.toBytes("r2"); final byte[] cf1 = Bytes.toBytes("cf1"); final byte[] cf2 = Bytes.toBytes("cf2"); final byte[] c1 = Bytes.toBytes("c1"); final byte[] c2 = Bytes.toBytes("c2"); final byte[] val = Bytes.toBytes("1"); Set<? extends Cell> expected = Sets.newHashSet( new KeyValue(r1, cf1, c1, 1050, val), new KeyValue(r1, cf1, c1, 1030, val), new KeyValue(r1, cf1, c1, 1020, val), new KeyValue(r1, cf1, c1, 1010, val), new KeyValue(r1, cf1, c2, 100, val), new KeyValue(r1, cf2, c1, 1050, val), new KeyValue(r1, cf2, c1, 1040, val), new KeyValue(r1, cf2, c1, 1030, val), new KeyValue(r1, cf2, c1, 1020, val), new KeyValue(r1, cf2, c1, 1010, val), new KeyValue(r1, cf2, c2, 1050, val), new KeyValue(r1, cf2, c2, 1040, val), new KeyValue(r1, cf2, c2, 1030, val), new KeyValue(r1, cf2, c2, 1020, val), new KeyValue(r1, cf2, c2, 1010, val), new KeyValue(r2, cf1, c1, 1000, val)); runImportFileTestFromGcs(CloudTestDataType.DELETE_MARKER, expected); }

Target:
public void testImportSequeneFile_fromGcsWithDeleteMarker() throws Exception { final byte[] r1 = Bytes.toBytes("r1"); final byte[] r2 = Bytes.toBytes("r2"); final byte[] cf1 = Bytes.toBytes("cf1"); final byte[] cf2 = Bytes.toBytes("cf2"); final byte[] c1 = Bytes.toBytes("c1"); final byte[] c2 = Bytes.toBytes("c2"); final byte[] val = Bytes.toBytes("1"); Set<? extends Cell> expected = Sets.newHashSet( new KeyValue(r1, cf1, c1, 1050, val), new KeyValue(r1, cf1, c1, 1030, val), new KeyValue(r1, cf1, c1, 1020, val), new KeyValue(r1, cf1, c1, 1010, val), new KeyValue(r1, cf1, c2, 100, val), new KeyValue(r1, cf2, c1, 1050, val), new KeyValue(r1, cf2, c1, 1040, val), new KeyValue(r1, cf2, c1, 1030, val), new KeyValue(r1, cf2, c1, 1020, val), new KeyValue(r1, cf2, c1, 1010, val), new KeyValue(r1, cf2, c2, 1050, val), new KeyValue(r1, cf2, c2, 1040, val), new KeyValue(r1, cf2, c2, 1030, val), new KeyValue(r1, cf2, c2, 1020, val), new KeyValue(r1, cf2, c2, 1010, val), new KeyValue(r2, cf1, c1, 1000, val)); runImportFileTestFromGcs(CloudTestDataType.CURRENT_FORMAT_WITH_DELETE_MARKER, expected); }
Source:
private static CompositeContinuationToken tryParseAsCompositeContinuationToken( final String providedContinuation) { try { final ObjectMapper mapper = Utils.getSimpleObjectMapper(); if (providedContinuation.trim().startsWith("[")) { final List<CompositeContinuationToken> compositeContinuationTokens = Arrays .asList(mapper.readValue(providedContinuation, CompositeContinuationToken[].class)); if (compositeContinuationTokens.size() > 0) { return compositeContinuationTokens.get(0); } return null; } else if (providedContinuation.trim().startsWith("{")) { return mapper.readValue(providedContinuation, CompositeContinuationToken.class); } return null; } catch (final IOException ioError) { return null; } }

Target:
private static CompositeContinuationToken tryParseAsCompositeContinuationToken( final String providedContinuation) { try { final ObjectMapper mapper = Utils.getSimpleObjectMapper(); if (providedContinuation.trim().startsWith("[")) { final List<CompositeContinuationToken> compositeContinuationTokens = Arrays .asList(mapper.readValue(providedContinuation, CompositeContinuationToken[].class)); if (compositeContinuationTokens.size() > 0) { return compositeContinuationTokens.get(0); } return null; } else if (providedContinuation.trim().startsWith("{")) { return mapper.readValue(providedContinuation, CompositeContinuationToken.class); } return null; } catch (final IOException ioError) { LOGGER.debug( "Failed to parse as composite continuation token JSON ", providedContinuation, ioError); return null; } }
Source:
private Summary ensureSummary(ProceedingJoinPoint pjp, String key) throws IllegalStateException { PrometheusTimeMethod annot; try { annot = getAnnotation(pjp); } catch (NoSuchMethodException e) { throw new IllegalStateException("Annotation could not be found for pjp \"" + pjp.toShortString() +"\"", e); } catch (NullPointerException e) { throw new IllegalStateException("Annotation could not be found for pjp \"" + pjp.toShortString() +"\"", e); } assert(annot != null); Summary summary; final Lock writeLock = summaryLock.writeLock(); writeLock.lock(); try { summary = summaries.get(key); if (summary != null) { return summary; } summary = Summary.build() .name(annot.name()) .help(annot.help()) .register();f summaries.put(key, summary); return summary; } finally { writeLock.unlock(); } }

Target:
private Summary ensureSummary(ProceedingJoinPoint pjp, String key) throws IllegalStateException { PrometheusTimeMethod annot; try { annot = getAnnotation(pjp); } catch (NoSuchMethodException e) { throw new IllegalStateException("Annotation could not be found for pjp \"" + pjp.toShortString() +"\"", e); } catch (NullPointerException e) { throw new IllegalStateException("Annotation could not be found for pjp \"" + pjp.toShortString() +"\"", e); } assert(annot != null); Summary summary; final Lock writeLock = summaryLock.writeLock(); writeLock.lock(); try { summary = summaries.get(key); if (summary != null) { return summary; } summary = Summary.build() .name(annot.name()) .help(annot.help()) .register(); summaries.put(key, summary); return summary; } finally { writeLock.unlock(); } }
Source:
public String createUniqueArticle() { String uniqueText = String.format("%s%s", PageContent.ARTICLE_NAME_PREFIX, new Date().getTime()); push(uniqueText, uniqueText); return uniqueText; }

Target:
public String createUniqueArticle() { String uniqueText = String.format("%s%s", PageContent.ARTICLE_NAME_PREFIX, LocalDateTime.now()); push(uniqueText, uniqueText); return uniqueText; }
Source:
public void executed(FrontendActionAsyncResult result) { VdcReturnValueBase returnValue = result.getReturnValue(); if (returnValue != null && returnValue.getSucceeded()) { doNetworkOperation(returnValue, (List<NicWithLogicalNetworks>) unitVmModel.getNicWithLogicalNetworks().getItems() ); } else { networkCreatingManager.getCallback().queryFaild(result.getState()); } }

Target:
public void executed(FrontendActionAsyncResult result) { VdcReturnValueBase returnValue = result.getReturnValue(); if (returnValue != null && returnValue.getSucceeded()) { doNetworkOperation(returnValue, (List<NicWithLogicalNetworks>) unitVmModel.getNicWithLogicalNetworks().getItems() ); } else { networkCreatingManager.getCallback().queryFailed(result.getState()); } }
Source:
public void oveflowMissingBackpressureExceptionDelayed() { TestSubscriber<Integer> ts = TestSubscriber.create(0); PublishSubject<Integer> ps = PublishSubject.create(); OperatorPublish.create(ps, new Func1<Observable<Integer>, Observable<Integer>>() { @Override public Observable<Integer> call(Observable<Integer> o) { return o; } }, true).unsafeSubscribe(ts); for (int i = 0; i < RxRingBuffer.SIZE * 2; i++) { ps.onNext(i); } ts.requestMore(RxRingBuffer.SIZE); ts.assertValueCount(128); ts.assertError(MissingBackpressureException.class); ts.assertNotCompleted(); Assert.assertEquals("Queue full?!", ts.getOnErrorEvents().get(0).getMessage()); Assert.assertFalse("Source has subscribers?", ps.hasObservers()); }

Target:
public void oveflowMissingBackpressureExceptionDelayed() { TestSubscriber<Integer> ts = TestSubscriber.create(0); PublishSubject<Integer> ps = PublishSubject.create(); OperatorPublish.create(ps, new Func1<Observable<Integer>, Observable<Integer>>() { @Override public Observable<Integer> call(Observable<Integer> o) { return o; } }, true).unsafeSubscribe(ts); for (int i = 0; i < RxRingBuffer.SIZE * 2; i++) { ps.onNext(i); } ts.requestMore(RxRingBuffer.SIZE); ts.assertValueCount(RxRingBuffer.SIZE); ts.assertError(MissingBackpressureException.class); ts.assertNotCompleted(); Assert.assertEquals("Queue full?!", ts.getOnErrorEvents().get(0).getMessage()); Assert.assertFalse("Source has subscribers?", ps.hasObservers()); }
Source:
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException { rsp.setStatus(HttpURLConnection.HTTP_UNAVAILABLE); req.getView(this,"index.jelly").forward(req,rsp); }

Target:
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException { rsp.setStatus(SC_SERVICE_UNAVAILABLE); req.getView(this,"index.jelly").forward(req,rsp); }
Source:
public void setUp() throws Exception { IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro(); if (intro != null) { PlatformUI.getWorkbench().getIntroManager().closeIntro(intro); } editor = (AbstractTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().openEditor(new FileEditorInput(file), "org.eclipse.ui.genericeditor.GenericEditor"); }

Target:
public void setUp() throws Exception { GenericEditorTestUtils.closeIntro(); editor = (AbstractTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().openEditor(new FileEditorInput(GenericEditorTestUtils.getFile()), "org.eclipse.ui.genericeditor.GenericEditor"); }
Source:
private DataStore findSnapshotImageStore(SnapshotInfo snapshot) { Boolean fullSnapshot = true; Object payload = snapshot.getFullBackup(); if (payload != null) { fullSnapshot = (Boolean)payload; } if (fullSnapshot) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } else { SnapshotInfo parentSnapshot = snapshot.getParent(); SnapshotDataStoreVO parentSnapshotOnBackupStore = null; if (parentSnapshot != null) { parentSnapshotOnBackupStore = _snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image); } if (parentSnapshotOnBackupStore == null) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } return dataStoreMgr.getDataStore(parentSnapshotOnBackupStore.getDataStoreId(), parentSnapshotOnBackupStore.getRole()); } }

Target:
private DataStore findSnapshotImageStore(SnapshotInfo snapshot) { Boolean fullSnapshot = true; Boolean snapshotFullBackup = snapshot.getFullBackup(); if (snapshotFullBackup != null) { fullSnapshot = snapshotFullBackup; } if (fullSnapshot) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } else { SnapshotInfo parentSnapshot = snapshot.getParent(); SnapshotDataStoreVO parentSnapshotOnBackupStore = null; if (parentSnapshot != null) { parentSnapshotOnBackupStore = _snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image); } if (parentSnapshotOnBackupStore == null) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } return dataStoreMgr.getDataStore(parentSnapshotOnBackupStore.getDataStoreId(), parentSnapshotOnBackupStore.getRole()); } }
Source:
public void execute() throws MojoExecutionException, MojoFailureException { String jsonContents = null; File jsonFile; JsonObject jsonObject; String baseDir = null; try { baseDir = project.getBasedir() .getCanonicalPath() .toString(); } catch (IOException e) { getLog().error("Could not find base directory for package.json", e); } if (baseDir != null) { String[] fileList = getListOfPackageJsonFiles(baseDir, FILE_NAME); for (String filepath : fileList) { jsonFile = Paths.get(baseDir, File.separator, filepath).toFile(); try { jsonContents = FileUtils.readFileToString(jsonFile, (Charset) null); } catch (IOException e) { getLog().error("Could not find file", e); } JsonReader jsonReader = Json.createReader(new StringReader(jsonContents)); jsonObject = jsonReader.readObject(); checkJsonForRangeSymbols(jsonObject.getJsonObject("devDependencies"), jsonFile); checkJsonForRangeSymbols(jsonObject.getJsonObject("dependencies"), jsonFile); } } }

Target:
public void execute() throws MojoExecutionException, MojoFailureException { String jsonContents; File jsonFile; boolean hasRangeChars = false; JsonObject jsonObject; String baseDir = null; try { baseDir = project.getBasedir() .getCanonicalPath(); } catch (IOException e) { getLog().error("Could not find base directory", e); } if (baseDir != null) { String[] fileList = getListOfPackageJsonFiles(baseDir, FILE_NAME); for (String filepath : fileList) { jsonFile = Paths.get(baseDir, File.separator, filepath) .toFile(); try { jsonContents = FileUtils.readFileToString(jsonFile, (Charset) null); JsonReader jsonReader = Json.createReader(new StringReader(jsonContents)); jsonObject = jsonReader.readObject(); hasRangeChars |= hasRangeChars(jsonObject.getJsonObject("devDependencies"), jsonFile.toString()); hasRangeChars |= hasRangeChars(jsonObject.getJsonObject("dependencies"), jsonFile.toString()); } catch (IOException e) { getLog().error("Could not find file", e); } } if (hasRangeChars) { throw new MojoFailureException(MOJO_EXCEPTION_MESSAGE); } } }
Source:
public void testInlineLinkWithTitle() { String html = parseToHtml("This is [ an example ](<LINK_0> \"Title\") inline link."); TestUtil.println("HTML: " + html); String expectedHtml = "<p>This is <a href=\"<LINK_0>\" title=\"Title\">an example</a> inline link.</p>\n"; assertEquals(expectedHtml, html); }

Target:
public void testInlineLinkWithTitle() { String markup = "This is [ an example ](<LINK_0> \"Title\") inline link."; String expectedHtml = "<p>This is <a href=\"<LINK_0>\" title=\"Title\">an example</a> inline link.</p>\n"; parseAndAssert(markup, expectedHtml); }
Source:
private Promise<Map<LinearRange, SnippetResult>> loadMatches(SearchResult element) { Map<LinearRange, SnippetResult> snippets = cache.get(element.getUri()); if (snippets != null) { return promiseProvider.resolve(snippets); } List<LinearRange> ranges = new ArrayList<>(); collectMatchRanges(element, ranges); SnippetParameters params = new org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls.SnippetParametersDto( new SnippetParameters(element.getUri(), ranges)); return textDocumentService .getSnippets(params) .then( (List<SnippetResult> results) -> { Map<LinearRange, SnippetResult> snippets2 = new HashMap<>(); cache.put(element.getUri(), snippets2); results.forEach( result -> { snippets2.put(result.getLinearRange(), result); }); return snippets2; }); }

Target:
private Promise<Map<LinearRange, SnippetResult>> loadMatches(SearchResult element) { Map<LinearRange, SnippetResult> snippets = cache.get(element.getUri()); if (snippets != null) { return promiseProvider.resolve(snippets); } List<LinearRange> ranges = new ArrayList<>(); collectMatchRanges(element, ranges); SnippetParameters params = new org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls.SnippetParametersDto( new SnippetParameters(element.getUri(), ranges)); return textDocumentService .getSnippets(params) .then( (List<SnippetResult> results) -> { Map<LinearRange, SnippetResult> snippetMap = new HashMap<>(); cache.put(element.getUri(), snippets); results.forEach( result -> { snippetMap.put(result.getLinearRange(), result); }); return snippetMap; }); }
Source:
private List<List<String>> parseCSVColumns(String source, int rows) { List<List<String>> columns = new ArrayList<List<String>>(); ByteArrayInputStream inputStream = new ByteArrayInputStream(source.getBytes()); CsvParser csvParser = new CsvParser(inputStream); for (int i = 0; i <= rows; ++i) { if (!csvParser.hasNext()) { break; } List<String> row = csvParser.next(); for (int j = 0; j < row.size(); ++j) { if (columns.size() <= j) { columns.add(new ArrayList<String>()); } columns.get(j).add(row.get(j)); } } return columns; }

Target:
private List<List<String>> parseCSVColumns(String source, int rows) { List<List<String>> columns = new ArrayList<List<String>>(); ByteArrayInputStream inputStream = new ByteArrayInputStream(source.getBytes()); CsvParser csvParser = new CsvParser(inputStream); for (int i = 0; i <= rows && csvParser.hasNext(); ++i) { List<String> row = csvParser.next(); for (int j = 0; j < row.size(); ++j) { if (columns.size() <= j) { columns.add(new ArrayList<String>()); } columns.get(j).add(row.get(j)); } } return columns; }
Source:
public void testOnlyConsiderRenditionUpToDateIfBlobsArePutInTransientStore() { checkInitialRendition(true); RenditionDefinition renditionDefinition = new RenditionDefinition(); renditionDefinition.setName(LAZY_AUTOMATION); AutomationLazyRenditionProvider lazyRenditionProvider = new AutomationLazyRenditionProvider(); String renditionKey = lazyRenditionProvider.buildRenditionKey(doc, renditionDefinition); TransientStore transientStore = transientStoreService.getStore(CACHE_NAME); String tsSourceDocumentModificationDate = (String) transientStore.getParameter(renditionKey, SOURCE_DOCUMENT_MODIFICATION_DATE_KEY); checkStaleRendition(true, false); String key; do { key = (String) transientStore.getParameter(renditionKey, SOURCE_DOCUMENT_MODIFICATION_DATE_KEY); } while (tsSourceDocumentModificationDate.equals(key)); checkUpToDateRendition(true); }

Target:
public void testOnlyConsiderRenditionUpToDateIfBlobsArePutInTransientStore() throws InterruptedException { checkInitialRendition(true); RenditionDefinition renditionDefinition = new RenditionDefinition(); renditionDefinition.setName(LAZY_AUTOMATION); AutomationLazyRenditionProvider lazyRenditionProvider = new AutomationLazyRenditionProvider(); String renditionKey = lazyRenditionProvider.buildRenditionKey(doc, renditionDefinition); TransientStore transientStore = transientStoreService.getStore(CACHE_NAME); String tsSourceDocumentModificationDate = (String) transientStore.getParameter(renditionKey, SOURCE_DOCUMENT_MODIFICATION_DATE_KEY); checkStaleRendition(true, false); await().until(() -> !tsSourceDocumentModificationDate.equals( transientStore.getParameter(renditionKey, SOURCE_DOCUMENT_MODIFICATION_DATE_KEY))); checkUpToDateRendition(true); }
Source:
public void requestResults( String query, Searcher searcher ) { String queryNormalized = StringNormalizer.normalize( query ); queryNormalized = queryNormalized.replaceAll("-", " "); FuzzyScore fuzzyScore = new FuzzyScore(); FuzzyScore.MatchInfo matchInfo = new FuzzyScore.MatchInfo(); for (ContactsPojo pojo : pojos) { boolean match = fuzzyScore.match( queryNormalized, pojo.nameNormalized, matchInfo ); pojo.relevance = matchInfo.score; if ( match && !matchInfo.matchedIndices.isEmpty() ) { List<Pair<Integer, Integer>> positions = matchInfo.getMatchedSequences(); try { pojo.setDisplayNameHighlightRegion( positions ); } catch( Exception e ) { StringBuilder sb = new StringBuilder(); for( Pair p : positions ) sb.append( "<" ) .append( p.first ) .append( "," ) .append( p.second ) .append( ">" ); Log.e( "TBog", sb.toString(), e ); pojo.setDisplayNameHighlightRegion( 0, pojo.nameNormalized.length() ); } } if ( !pojo.nickname.isEmpty() ) { if( fuzzyScore.match( queryNormalized, pojo.nickname, matchInfo ) ) { if( !match || (matchInfo.score > pojo.relevance) ) { match = true; pojo.relevance = matchInfo.score; pojo.displayName = pojo.name + " <small>({" + pojo.nickname + "})</small>"; } } } if ( !match && queryNormalized.length() > 2 ) { if( fuzzyScore.match( queryNormalized, pojo.phoneSimplified, matchInfo ) ) { match = true; pojo.relevance = matchInfo.score; pojo.setDisplayNameHighlightRegion(0, 0); } } if( match ) { if( !searcher.addResult( pojo ) ) return; } } }

Target:
public void requestResults( String query, Searcher searcher ) { StringNormalizer.Result queryNormalized = StringNormalizer.normalizeWithResult( query, false ); queryNormalized = queryNormalized.replaceAll(Character.codePointAt("-", 0), Character.codePointAt(" ", 0)); FuzzyScore fuzzyScore = new FuzzyScore( queryNormalized.codePoints ); FuzzyScore.MatchInfo matchInfo = new FuzzyScore.MatchInfo(); for (ContactsPojo pojo : pojos) { boolean match = fuzzyScore.match( pojo.normalizedName.codePoints, matchInfo ); pojo.relevance = matchInfo.score; if ( match ) { List<Pair<Integer, Integer>> positions = matchInfo.getMatchedSequences(); try { pojo.setDisplayNameHighlightRegion( positions ); } catch( Exception e ) { pojo.setDisplayNameHighlightRegion( 0, pojo.normalizedName.length() ); } } if ( !pojo.nickname.isEmpty() ) { if( fuzzyScore.match( pojo.nickname, matchInfo ) ) { if( !match || (matchInfo.score > pojo.relevance) ) { match = true; pojo.relevance = matchInfo.score; pojo.displayName = pojo.getName() + " <small>({" + pojo.nickname + "})</small>"; } } } if ( !match && queryNormalized.length() > 2 ) { if( fuzzyScore.match( pojo.phoneSimplified, matchInfo ) ) { match = true; pojo.relevance = matchInfo.score; pojo.setDisplayNameHighlightRegion(0, 0); } } if( match ) { if( !searcher.addResult( pojo ) ) return; } } }
Source:
private static Optional<String> getNpcDisplayNameFromTag(ItemStack stack) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey(NPC_STORED_DATA_TAG) && stack.getTagCompound().getCompoundTag(NPC_STORED_DATA_TAG).hasKey("name")) { return Optional.of(stack.getTagCompound().getCompoundTag(NPC_STORED_DATA_TAG).getString("name")); } else return Optional.empty(); }

Target:
private static Optional<String> getNpcDisplayNameFromTag(ItemStack stack) { if (stack.hasTagCompound()) { NBTTagCompound tag = stack.getTagCompound(); if (tag.hasKey(NPC_STORED_DATA_TAG) && tag.getCompoundTag(NPC_STORED_DATA_TAG).hasKey("name")) { return Optional.of(tag.getCompoundTag(NPC_STORED_DATA_TAG).getString("name")); } } return Optional.empty(); }
Source:
private Promise workItemIconLoader(final WorkItemDefinition wid) { Console.log("RUNING MY CODE MAN"); final String iconUri = wid.getIconDefinition().getUri(); log("Loading icon for URI [" + iconUri + "]"); if (nonEmpty(iconUri)) { return resourceContentService .get(iconUri, ResourceContentOptions.binary()) .then(iconData -> { log("Content for icon = [" + iconData + "]"); if (nonEmpty(iconData)) { wid.getIconDefinition().setIconData(iconDataUri(iconUri, iconData)); } return promises.resolve(DEFAULT_ICON_DATA); }).catch_(error -> { log("Not able to load icon for URI " + iconUri); return Promise.resolve(DEFAULT_ICON_DATA); }); } return promises.resolve(DEFAULT_ICON_DATA); }

Target:
private Promise workItemIconLoader(final WorkItemDefinition wid) { final String iconUri = wid.getIconDefinition().getUri(); log("Loading icon for URI [" + iconUri + "]"); if (nonEmpty(iconUri)) { return resourceContentService .get(iconUri, ResourceContentOptions.binary()) .then(iconData -> { log("Content for icon = [" + iconData + "]"); if (nonEmpty(iconData)) { if (!isIconDataUri(iconData)) { iconData = iconDataUri(iconUri, iconData); } wid.getIconDefinition().setIconData(iconData); } return promises.resolve(); }).catch_(error -> { log("Not able to load icon for URI " + iconUri); return Promise.resolve(""); }); } return promises.resolve(); }
Source:
private void fillImplicationsWithUMLSubsets(ReferenceChange diff) { EReference reference = diff.getReference(); for (EObject ref : UMLCompareUtil.getNonUnionSupersetReferences(reference)) { EReference superSet = (EReference)ref; Comparison comparison = diff.getMatch().getComparison(); for (Diff superSetDiff : diff.getMatch().getComparison().getDifferences(superSet)) { if (superSetDiff instanceof ReferenceChange && ((ReferenceChange)superSetDiff).getReference() == superSet && ((ReferenceChange)superSetDiff).getValue() == diff.getValue()) { if (isAdd(comparison, diff) && isAdd(comparison, superSetDiff)) { diff.getImplies().add(superSetDiff); } else if (isDelete(diff) && isDelete(superSetDiff)) { diff.getImpliedBy().add(superSetDiff); } } } } }

Target:
private void fillImplicationsWithUMLSubsets(ReferenceChange diff) { EReference reference = diff.getReference(); for (EReference superSet : UMLCompareUtil.getNonUnionSupersetReferences(reference)) { Comparison comparison = diff.getMatch().getComparison(); for (Diff superSetDiff : comparison.getDifferences(superSet)) { if (superSetDiff instanceof ReferenceChange && ((ReferenceChange)superSetDiff).getReference() == superSet && ((ReferenceChange)superSetDiff).getValue() == diff.getValue()) { if (isAddOrSetDiff(diff) && isAddOrSetDiff(superSetDiff)) { diff.getImplies().add(superSetDiff); } else if (isDeleteOrUnsetDiff(diff) && isDeleteOrUnsetDiff(superSetDiff)) { diff.getImpliedBy().add(superSetDiff); } } } } }
Source:
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException { TaggedValuePointable arg = args[0]; if (!(arg.getTag() == ValueTag.SEQUENCE_TAG || arg.getTag() == ValueTag.OBJECT_TAG)) { throw new SystemException(ErrorCode.FORG0006); } TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class); TaggedValuePointable tempValue = ppool.takeOne(TaggedValuePointable.class); try { abvs.reset(); ob.reset(abvs); tvps.clear(); if (arg.getTag() == ValueTag.SEQUENCE_TAG) { arg.getValue(sp); for (int i = 0; i < sp.getEntryCount(); ++i) { op = (ObjectPointable) ObjectPointable.FACTORY.createPointable(); sp.getEntry(i, tempTvp); tempTvp.getValue(op); op.getKeys(tempTvp); addPairs(tempTvp, tempValue); } } else { op = (ObjectPointable) ObjectPointable.FACTORY.createPointable(); arg.getValue(op); addPairs(tempTvp, tempValue); } ob.finish(); result.set(abvs); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); } finally { ppool.giveBack(tempTvp); for (TaggedValuePointable pointable : tvps) { ppool.giveBack(pointable); } } }

Target:
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException { TaggedValuePointable arg = args[0]; if (!(arg.getTag() == ValueTag.SEQUENCE_TAG || arg.getTag() == ValueTag.OBJECT_TAG)) { throw new SystemException(ErrorCode.FORG0006); } TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class); TaggedValuePointable tempValue = ppool.takeOne(TaggedValuePointable.class); try { abvs.reset(); ob.reset(abvs); tvps.clear(); if (arg.getTag() == ValueTag.SEQUENCE_TAG) { arg.getValue(sp); for (int i = 0; i < sp.getEntryCount(); ++i) { op = (ObjectPointable) ObjectPointable.FACTORY.createPointable(); sp.getEntry(i, tempTvp); tempTvp.getValue(op); op.getKeys(tempTvp); addPairs(tempTvp, tempValue); } } else if (arg.getTag() == ValueTag.OBJECT_TAG) { op = (ObjectPointable) ObjectPointable.FACTORY.createPointable(); arg.getValue(op); addPairs(tempTvp, tempValue); } ob.finish(); result.set(abvs); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); } finally { ppool.giveBack(tempTvp); for (TaggedValuePointable pointable : tvps) { ppool.giveBack(pointable); } } }
Source:
public void checkSpecificAccessControl() { String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL); if (studentEmail != null && courseId != null) { StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail); if (student == null) { throw new UnauthorizedAccessException(UNAUTHORIZED_ACCESS); } gateKeeper.verifyAccessibleForCurrentUserAsInstructorOrTeamMemberOrAdmin(logic.getAccount(userInfo.id), courseId, student.getSection(), student.getEmail()); } }

Target:
public void checkSpecificAccessControl() { String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL); if (studentEmail == null || courseId == null) { if (!userInfo.isStudent) { throw new UnauthorizedAccessException(UNAUTHORIZED_ACCESS); } } else { StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail); if (student == null) { throw new UnauthorizedAccessException(UNAUTHORIZED_ACCESS); } gateKeeper.verifyAccessibleForCurrentUserAsInstructorOrTeamMemberOrAdmin(userInfo.id, courseId, student.getSection(), student.getEmail()); } }
Source:
public UserDTO updateUser(UUID id, UserDTO userResource) { User originalUserEntity = getEntityByID(id); if (originalUserEntity.isCreatedOnBuddyRequest()) { throw new YonaException("User is created on buddy request, use other method"); } return handleUserUpdate(userResource, originalUserEntity); }

Target:
public UserDTO updateUser(UUID id, UserDTO userResource) { User originalUserEntity = getEntityByID(id); if (originalUserEntity.isCreatedOnBuddyRequest()) { throw new IllegalArgumentException("User is created on buddy request, use other method"); } return UserDTO.createInstanceWithPrivateData(User.getRepository().save(userResource.updateUser(originalUserEntity))); }
Source:
public AgentRegistryImpl(Set<Agent> agents) throws IOException { this.agents = new HashMap<>(agents.size()); agents.forEach(a -> this.agents.put(a.getId(), a)); }

Target:
public AgentRegistryImpl(Set<Agent> agents) throws IllegalArgumentException { this.agents = new HashMap<>(agents.size()); for (Agent agent : agents) { AgentKeyImpl key = new AgentKeyImpl(agent); Agent registeredAgent = this.agents.put(key, agent); if (registeredAgent != null) { throw new IllegalArgumentException(format("Agent with key %s has been registered already.", key)); } } }
Source:
public static Collection<DimensionSpec> extractionsToRewrite(GroupByQuery query) { return Collections2.filter( query.getDimensions(), new Predicate<DimensionSpec>() { @Override public boolean apply(@Nullable DimensionSpec input) { return input != null && input.getExtractionFn() != null && ExtractionFn.ExtractionType.ONE_TO_ONE.equals( input.getExtractionFn().getExtractionType() ); } } ); }

Target:
public static Collection<DimensionSpec> extractionsToRewrite(GroupByQuery query) { return Collections2.filter( query.getDimensions(), new Predicate<DimensionSpec>() { @Override public boolean apply(DimensionSpec input) { return input.getExtractionFn() != null && ExtractionFn.ExtractionType.ONE_TO_ONE.equals( input.getExtractionFn().getExtractionType() ); } } ); }
Source:
public void testGetRequirements() { try { File xmlValidFile = TmfXmlTestFiles.VALID_FILE.getFile(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document document; document = factory.newDocumentBuilder().parse(xmlValidFile); NodeList stateProviders = document.getElementsByTagName(TmfXmlStrings.STATE_PROVIDER); Node stateProvider = null; for (int i = 0; i < stateProviders.getLength(); i++) { stateProvider = stateProviders.item(i); String id = stateProvider.getAttributes().getNamedItem(TmfXmlStrings.ID).getNodeValue(); if (id != null && id.equals(SS_MODULE)) { break; } } assertNotNull(stateProvider); assertEquals(SS_MODULE, stateProvider.getAttributes().getNamedItem(TmfXmlStrings.ID).getNodeValue()); TmfAnalysisRequirement eventRequirement = null; for (TmfAnalysisRequirement req : fModule.getAnalysisRequirements()) { if (req.getType().equalsIgnoreCase(TmfXmlStrings.TYPE_EVENT_NAME)) { eventRequirement = req; } } assertNotNull(eventRequirement); NodeList eventHandlers = ((Element) stateProvider).getElementsByTagName(TmfXmlStrings.EVENT_HANDLER); int eventCount = 0; for (int i = 0; i < eventHandlers.getLength(); i++) { Node eventHandler = eventHandlers.item(i); String eventName = eventHandler.getAttributes().getNamedItem(TmfXmlStrings.TYPE_EVENT_NAME).getNodeValue(); assertTrue(eventRequirement.getValues().contains(eventName)); eventCount++; } assertEquals(eventCount, eventRequirement.getValues().size()); } catch (SAXException | IOException | ParserConfigurationException e) { fail(e.getMessage()); } }

Target:
public void testGetRequirements() { TmfAnalysisRequirement eventRequirement = null; for (TmfAnalysisRequirement req : fModule.getAnalysisRequirements()) { if (req.getType().equalsIgnoreCase(TmfXmlStrings.TYPE_EVENT_NAME)) { eventRequirement = req; } } assertNotNull(eventRequirement); assertEquals(13, eventRequirement.getValues().size()); Element stateProvider = XmlUtils.getElementInFile(TmfXmlTestFiles.VALID_FILE.getPath(), TmfXmlStrings.STATE_PROVIDER, SS_MODULE); assertNotNull(stateProvider); List<Element> eventHandlers = XmlUtils.getChildElements(stateProvider, TmfXmlStrings.EVENT_HANDLER); assertEquals(13, eventHandlers.size()); for (Element eventHandler : eventHandlers) { String eventName = eventHandler.getAttributes().getNamedItem(TmfXmlStrings.TYPE_EVENT_NAME).getNodeValue(); assertTrue(eventRequirement.getValues().contains(eventName)); } }
Source:
protected Control createDialogArea(Composite parent) { Composite dlgArea = (Composite) super.createDialogArea(parent); Composite composite = new Composite(dlgArea, SWT.NONE); GridLayout layout = new GridLayout(); composite.setLayout(layout); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); composite.setLayoutData(gd); createStatesGroup(composite); setTitle(Messages.TmfTimeLegend_LEGEND); setDialogHelpAvailable(false); setHelpAvailable(false); composite.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { fResourceManager.dispose(); } }); return composite; }

Target:
protected Control createDialogArea(Composite parent) { Composite dlgArea = (Composite) super.createDialogArea(parent); Composite composite = new Composite(dlgArea, SWT.NONE); GridLayout layout = new GridLayout(); composite.setLayout(layout); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); composite.setLayoutData(gd); createStatesGroup(composite); setTitle(Messages.TmfTimeLegend_LEGEND); setDialogHelpAvailable(false); setHelpAvailable(false); composite.addDisposeListener((e) -> { fResourceManager.dispose(); }); return composite; }
Source:
public void onClick(View view) { int id = view.getId(); String owner = mRepository.getOwner().getLogin(); String name = mRepository.getName(); Intent intent = null; Context c = getActivity(); switch (id) { case R.id.cell_pull_requests: intent = IssueListActivity.makeIntent(c, owner, name, true); break; case R.id.tv_contributors_label: intent = ContributorListActivity.makeIntent(c, owner, name); break; case R.id.tv_collaborators_label: intent = CollaboratorListActivity.makeIntent(c, owner, name); break; case R.id.cell_issues: intent = IssueListActivity.makeIntent(c, owner, name); break; case R.id.cell_stargazers: intent = WatcherListActivity.makeIntent(c, owner, name); break; case R.id.cell_forks: intent = ForkListActivity.makeIntent(c, owner, name); break; case R.id.tv_wiki_label: intent = WikiListActivity.makeIntent(c, owner, name, null); break; case R.id.tv_downloads_label: intent = DownloadsActivity.makeIntent(c, owner, name); break; case R.id.tv_releases_label: intent = ReleaseListActivity.makeIntent(c, owner, name); break; default: if (view.getTag() instanceof Repository) intent = RepositoryActivity.makeIntent(c, (Repository) view.getTag()); break; } if (intent != null) { startActivity(intent); } }

Target:
public void onClick(View view) { int id = view.getId(); String owner = mRepository.getOwner().getLogin(); String name = mRepository.getName(); Intent intent = null; if (id == R.id.cell_pull_requests) { intent = IssueListActivity.makeIntent(getActivity(), owner, name, true); } else if (id == R.id.tv_contributors_label) { intent = ContributorListActivity.makeIntent(getActivity(), owner, name); } else if (id == R.id.tv_collaborators_label) { intent = CollaboratorListActivity.makeIntent(getActivity(), owner, name); } else if (id == R.id.cell_issues) { intent = IssueListActivity.makeIntent(getActivity(), owner, name); } else if (id == R.id.cell_stargazers) { intent = WatcherListActivity.makeIntent(getActivity(), owner, name); } else if (id == R.id.cell_forks) { intent = ForkListActivity.makeIntent(getActivity(), owner, name); } else if (id == R.id.tv_wiki_label) { intent = WikiListActivity.makeIntent(getActivity(), owner, name, null); } else if (id == R.id.tv_downloads_label) { intent = DownloadsActivity.makeIntent(getActivity(), owner, name); } else if (id == R.id.tv_releases_label) { intent = ReleaseListActivity.makeIntent(getActivity(), owner, name); } else if (view.getTag() instanceof Repository) { intent = RepositoryActivity.makeIntent(getActivity(), (Repository) view.getTag()); } if (intent != null) { startActivity(intent); } }
Source:
private void addFullyLinkArchiveVariables(CcToolchainVariables.Builder builder) { builder.addStringVariable( FULLY_LINKED_ARCHIVE_PATH_VARIABLE_NAME, fullyLinkArchive.getExecPathString()); ImmutableSet<Artifact> ccLibs = new ImmutableSet.Builder() .addAll(objcProvider.getCcLibraries()) .build(); Predicate<Artifact> isNotCcLib = library -> !ccLibs.contains(library); Iterable<Artifact> objcLibraries = Iterables.filter(objcProvider.getObjcLibraries(), isNotCcLib); builder.addStringSequenceVariable( OBJC_LIBRARY_EXEC_PATHS_VARIABLE_NAME, Artifact.toExecPaths(objcLibraries)); builder.addStringSequenceVariable( CC_LIBRARY_EXEC_PATHS_VARIABLE_NAME, Artifact.toExecPaths(objcProvider.getCcLibraries())); builder.addStringSequenceVariable( IMPORTED_LIBRARY_EXEC_PATHS_VARIABLE_NAME, Artifact.toExecPaths(objcProvider.get(IMPORTED_LIBRARY).toList())); }

Target:
private void addFullyLinkArchiveVariables(CcToolchainVariables.Builder builder) { builder.addStringVariable( FULLY_LINKED_ARCHIVE_PATH_VARIABLE_NAME, fullyLinkArchive.getExecPathString()); ImmutableSet<Artifact> ccLibs = ImmutableSet.copyOf(objcProvider.getCcLibraries()); Predicate<Artifact> isNotCcLib = library -> !ccLibs.contains(library); Iterable<Artifact> objcLibraries = Iterables.filter(objcProvider.getObjcLibraries(), isNotCcLib); builder.addStringSequenceVariable( OBJC_LIBRARY_EXEC_PATHS_VARIABLE_NAME, Artifact.toExecPaths(objcLibraries)); builder.addStringSequenceVariable( CC_LIBRARY_EXEC_PATHS_VARIABLE_NAME, Artifact.toExecPaths(objcProvider.getCcLibraries())); builder.addStringSequenceVariable( IMPORTED_LIBRARY_EXEC_PATHS_VARIABLE_NAME, Artifact.toExecPaths(objcProvider.get(IMPORTED_LIBRARY).toList())); }
Source:
public void testWithFileWithoutParent() throws Exception { final DefaultConfiguration moduleConfig = createModuleConfig(JavadocPackageCheck.class); final File fileWithoutParent = spy(new File(getPath("annotation" + File.separator + "package-info.java"))); when(fileWithoutParent.getParent()).thenReturn(null); when(fileWithoutParent.getParentFile()).thenReturn(null); final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; verify(createChecker(moduleConfig), new File[] {fileWithoutParent}, getPath("annotation" + File.separator + "package-info.java"), expected); }

Target:
public void testWithFileWithoutParent() throws Exception { final DefaultConfiguration moduleConfig = createModuleConfig(JavadocPackageCheck.class); final File fileWithoutParent = spy(new File(getPath("noparentfile" + File.separator + "package-info.java"))); when(fileWithoutParent.getParent()).thenReturn(null); when(fileWithoutParent.getParentFile()).thenReturn(null); final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; verify(createChecker(moduleConfig), new File[] {fileWithoutParent}, getPath("annotation" + File.separator + "package-info.java"), expected); }
Source:
private void pullImage(DockerTemplate dockerTemplate) throws IOException { final String imageName = dockerTemplate.getDockerTemplateBase().getImage(); List<Image> images = getClient().listImagesCmd().exec(); NameParser.ReposTag repostag = NameParser.parseRepositoryTag(imageName); final String fullImageName = repostag.repos + ":" + (repostag.tag.isEmpty() ? "latest" : repostag.tag); boolean imageExists = Iterables.any(images, new Predicate<Image>() { @Override public boolean apply(Image image) { return Arrays.asList(image.getRepoTags()).contains(fullImageName); } }); boolean pull = imageExists ? dockerTemplate.getPullStrategy().pullIfExists(imageName) : dockerTemplate.getPullStrategy().pullIfNotExists(imageName); if (pull) { LOGGER.info("Pulling image '{}' {}. This may take awhile...", imageName, imageExists ? "again" : "since one was not found"); long startTime = System.currentTimeMillis(); try { getClient().pullImageCmd(imageName).exec(new PullImageResultCallback()).awaitSuccess(); long pullTime = System.currentTimeMillis() - startTime; LOGGER.info("Finished pulling image '{}', took ms", imageName, pullTime); } catch (DockerClientException e) { LOGGER.error("Error while pulling image '{}'", imageName, e); } } }

Target:
private void pullImage(DockerTemplate dockerTemplate) throws IOException { final String imageName = dockerTemplate.getDockerTemplateBase().getImage(); List<Image> images = getClient().listImagesCmd().exec(); NameParser.ReposTag repostag = NameParser.parseRepositoryTag(imageName); final String fullImageName = repostag.repos + ":" + (repostag.tag.isEmpty() ? "latest" : repostag.tag); boolean imageExists = Iterables.any(images, new Predicate<Image>() { @Override public boolean apply(Image image) { return Arrays.asList(image.getRepoTags()).contains(fullImageName); } }); boolean pull = imageExists ? dockerTemplate.getPullStrategy().pullIfExists(imageName) : dockerTemplate.getPullStrategy().pullIfNotExists(imageName); if (pull) { LOGGER.info("Pulling image '{}' {}. This may take awhile...", imageName, imageExists ? "again" : "since one was not found"); long startTime = System.currentTimeMillis(); getClient().pullImageCmd(imageName).exec(new PullImageResultCallback()).awaitSuccess(); long pullTime = System.currentTimeMillis() - startTime; LOGGER.info("Finished pulling image '{}', took ms", imageName, pullTime); } }
Source:
private static IndexMetadata build(ColumnMetadata column, Map<String, String> indexColumns) { if (indexColumns.isEmpty()) return null; String type = indexColumns.get(INDEX_TYPE); if (type == null) return null; if (!indexColumns.containsKey(INDEX_OPTIONS)) return new IndexMetadata(column, indexColumns.get(INDEX_NAME)); String indexOptionsCol = indexColumns.get(INDEX_OPTIONS); if (indexOptionsCol == null || indexOptionsCol.isEmpty() || indexOptionsCol.equals("null")) return new IndexMetadata(column, indexColumns.get(INDEX_NAME)); else { Map<String, String> indexOptions = SimpleJSONParser.parseStringMap(indexOptionsCol); return new IndexMetadata(column, indexColumns.get(INDEX_NAME), indexOptions); } }

Target:
private static IndexMetadata build(ColumnMetadata column, Map<String, String> indexColumns) { if (indexColumns.isEmpty()) return null; String type = indexColumns.get(INDEX_TYPE); if (type == null) return null; String indexOptionsCol = indexColumns.get(INDEX_OPTIONS); if (indexOptionsCol == null || indexOptionsCol.isEmpty() || indexOptionsCol.equals("null")) return new IndexMetadata(column, indexColumns.get(INDEX_NAME)); else { Map<String, String> indexOptions = SimpleJSONParser.parseStringMap(indexOptionsCol); return new IndexMetadata(column, indexColumns.get(INDEX_NAME), indexOptions); } }
Source:
public void onReceive(Iterable<EventData> events) { if (events != null) { events.forEach(event -> { byte[] decryptedBody = event.getBytes(); if (serde != null) { decryptedBody = serde.fromBytes(decryptedBody); } EventDataWrapper wrappedEvent = new EventDataWrapper(event, decryptedBody); try { updateMetrics(event); put(ssp, new IncomingMessageEnvelope(ssp, event.getSystemProperties().getOffset(), event.getSystemProperties().getPartitionKey(), wrappedEvent)); } catch (Exception e) { String msg = String.format("Exception while adding the event from ssp %s to dispatch queue.", ssp); LOG.error(msg, e); throw new SamzaException(msg, e); } }); } }

Target:
public void onReceive(Iterable<EventData> events) { if (events != null) { events.forEach(event -> { byte[] eventDataBody = event.getBytes(); if (interceptor != null) { eventDataBody = interceptor.intercept(eventDataBody); } String offset = event.getSystemProperties().getOffset(); Object partitionKey = event.getSystemProperties().getPartitionKey(); try { updateMetrics(event); put(ssp, new EventHubIncomingMessageEnvelope(ssp, offset, partitionKey, eventDataBody, event)); } catch (InterruptedException e) { String msg = String.format("Interrupted while adding the event from ssp %s to dispatch queue.", ssp); LOG.error(msg, e); throw new SamzaException(msg, e); } streamPartitionOffsets.put(ssp, offset); }); } }