/** {@inheritDoc} */ @Override public Map<K, V> peekAll( @Nullable Collection<? extends K> keys, @Nullable GridPredicate<? super GridCacheEntry<K, V>>[] filter) { if (keys == null || keys.isEmpty()) return emptyMap(); final Collection<K> skipped = new GridLeanSet<K>(); final Map<K, V> map = peekAll0(keys, filter, skipped); if (map.size() + skipped.size() != keys.size()) { map.putAll( dht.peekAll( F.view( keys, new P1<K>() { @Override public boolean apply(K k) { return !map.containsKey(k) && !skipped.contains(k); } }), filter)); } return map; }
protected static void PrintUserInfoList() { Collection<UserID> collection = registeredUsers.values(); Iterator<UserID> it = collection.iterator(); while (it.hasNext()) { System.out.println(it.next()); } }
/** * Update index (delete and remove files) * * @param project the project * @param root a vcs root * @param added added/modified files to commit * @param removed removed files to commit * @param exceptions a list of exceptions to update * @return true if index was updated successfully */ private static boolean updateIndex( final Project project, final VirtualFile root, final Collection<FilePath> added, final Collection<FilePath> removed, final List<VcsException> exceptions) { boolean rc = true; if (!added.isEmpty()) { try { GitFileUtils.addPaths(project, root, added); } catch (VcsException ex) { exceptions.add(ex); rc = false; } } if (!removed.isEmpty()) { try { GitFileUtils.delete(project, root, removed, "--ignore-unmatch"); } catch (VcsException ex) { exceptions.add(ex); rc = false; } } return rc; }
/** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); if (writes != null) unmarshalTx(writes, false, ctx, ldr); if (reads != null) unmarshalTx(reads, false, ctx, ldr); if (grpLockKeyBytes != null && grpLockKey == null) grpLockKey = ctx.marshaller().unmarshal(grpLockKeyBytes, ldr); if (dhtVerKeys != null && dhtVers == null) { assert dhtVerVals != null; assert dhtVerKeys.size() == dhtVerVals.size(); Iterator<IgniteTxKey> keyIt = dhtVerKeys.iterator(); Iterator<GridCacheVersion> verIt = dhtVerVals.iterator(); dhtVers = U.newHashMap(dhtVerKeys.size()); while (keyIt.hasNext()) { IgniteTxKey key = keyIt.next(); key.finishUnmarshal(ctx.cacheContext(key.cacheId()), ldr); dhtVers.put(key, verIt.next()); } } if (txNodesBytes != null) txNodes = ctx.marshaller().unmarshal(txNodesBytes, ldr); }
/** * returns docs with ALL given sentiments. special cases: sentiments can be an array of length 1 * and be "None", in which case all documents with no sentiments are returned. special cases: * sentiments can be an array of length 1 and be "all", in which case all documents with any * sentiments are returned. * * @param captions */ public Collection<Document> getDocsWithSentiments( String sentiments[], Indexer indexer, Collection<Document> docs, int cluster, boolean originalContentOnly, String... captions) { Collection<Document> result = null; // note: multiple sentiments are possible, they are ANDED if (sentiments == null || sentiments.length == 0) return result; Set<Document> docs_set = Util.castOrCloneAsSet(docs); if (sentiments.length == 1 && "all".equalsIgnoreCase(sentiments[0])) return getDocsWithAnyEmotions(indexer, docs_set, originalContentOnly); // note: we'll pass in null for docs, and intersect with the given set of docs later // otherwise we'd just be doing it again and again for each category and lexer Map<String, Collection<Document>> map = getEmotions(indexer, null, false, originalContentOnly, captions); for (int i = 0; i < sentiments.length; i++) { Collection<Document> temp1 = ("None".equalsIgnoreCase(sentiments[i])) ? getDocsWithNoEmotions(indexer, docs_set, originalContentOnly) : map.get(sentiments[i]); if (temp1 == null) { // no matches, just return result = new LinkedHashSet<Document>(); return result; } if (result == null) result = temp1; else result.retainAll(temp1); } // result.retainAll(docs); return Util.setIntersection(result, docs_set); }
/** {@inheritDoc} */ @SuppressWarnings("TypeMayBeWeakened") @Nullable private Collection<Object> unmarshalFieldsCollection( @Nullable Collection<byte[]> byteCol, GridCacheContext<K, V> ctx, ClassLoader ldr) throws GridException { assert ctx != null; assert ldr != null; Collection<Object> col = unmarshalCollection(byteCol, ctx, ldr); Collection<Object> col0 = null; if (col != null) { col0 = new ArrayList<>(col.size()); for (Object o : col) { List<Object> list = (List<Object>) o; List<Object> list0 = new ArrayList<>(list.size()); for (Object obj : list) list0.add(obj != null ? ctx.marshaller().unmarshal((byte[]) obj, ldr) : null); col0.add(list0); } } return col0; }
/** {@inheritDoc} */ @Override protected Collection<GridComputeJobAdapter> split(int gridSize, Object arg) throws GridException { assert rsrc1 != null; assert rsrc2 != null; assert rsrc3 != null; assert rsrc4 != null; assert log != null; log.info("Injected shared resource1 into task: " + rsrc1); log.info("Injected shared resource2 into task: " + rsrc2); log.info("Injected shared resource3 into task: " + rsrc3); log.info("Injected shared resource4 into task: " + rsrc4); log.info("Injected log resource into task: " + log); task1Rsrc1 = rsrc1; task1Rsrc2 = rsrc2; task1Rsrc3 = rsrc3; task1Rsrc4 = rsrc4; Collection<GridComputeJobAdapter> jobs = new ArrayList<>(gridSize); for (int i = 0; i < gridSize; i++) { jobs.add(new GridSharedJob1()); } return jobs; }
/** Check if the getSubBuilders properly predicts the output. */ public static void testSubBuilders() throws Exception { Workspace ws = Workspace.getWorkspace(new File("test/ws")); Project project = ws.getProject("p4-sub"); Collection<? extends Builder> bs = project.getSubBuilders(); assertNotNull(bs); assertEquals(3, bs.size()); Set<String> names = new HashSet<String>(); for (Builder b : bs) { names.add(b.getBsn()); } assertTrue(names.contains("p4-sub.a")); assertTrue(names.contains("p4-sub.b")); assertTrue(names.contains("p4-sub.c")); File[] files = project.build(); assertTrue(project.check()); System.err.println(Processor.join(project.getErrors(), "\n")); System.err.println(Processor.join(project.getWarnings(), "\n")); assertEquals(0, project.getErrors().size()); assertEquals(0, project.getWarnings().size()); assertNotNull(files); assertEquals(3, files.length); for (File file : files) { Jar jar = new Jar(file); Manifest m = jar.getManifest(); assertTrue(names.contains(m.getMainAttributes().getValue("Bundle-SymbolicName"))); } }
public static Collection<Statistic> merge(Collection<Statistic>... results) { Collection<Statistic> newResults = new ArrayList<Statistic>(); if (results.length == 0) { return Collections.emptySet(); } else if (results.length == 1) { return results[0]; } else { List<String> indivNames = new ArrayList<String>(); for (Collection<Statistic> result : results) { for (Statistic individual : result) { if (!indivNames.contains(individual.name)) { indivNames.add(individual.name); } } } for (String indivName : indivNames) { Statistic indivStat = new Statistic(indivName); for (Collection<Statistic> result : results) { for (Statistic individual : result) { if (indivName.equals(individual.name)) { indivStat.add(individual); } } } newResults.add(indivStat); } return newResults; } }
private void remove() { Collection<SamplingTask> samplers = samplingTasks.get(samplingPeriod); if (samplers == null) { return; } samplers.remove(this); }
private void remove() { Collection<PerformanceProbe> probes = _perfProbes.get(outputPeriod); if (probes == null) { return; } probes.remove(this); }
/** * Retrieves multiple entries for a given logical directory, up to the complete catalog. * Retrieving full catalogs should be harmful, but may be helpful in online display or portal. * * <p> * * @param lfns is a set of logical directory strings to look up. * @param handle is the resource handle, restricting the LFNs. * @return a map indexed by the LFN. Each value is a set of physical filenames. */ public Map lookupNoAttributes(Set lfns, String handle) { Map result = new HashMap(); if (lfns == null || lfns.size() == 0) { return result; } for (Iterator i = lfns.iterator(); i.hasNext(); ) { String lfn = (String) i.next(); Collection c = (Collection) mLFNMap.get(lfn); if (c != null) { List value = new ArrayList(); for (Iterator j = c.iterator(); j.hasNext(); ) { ReplicaCatalogEntry rce = (ReplicaCatalogEntry) j.next(); String pool = rce.getResourceHandle(); if (pool == null && handle == null || pool != null && handle != null && pool.equals(handle)) { value.add(rce.getPFN()); } } // only put found LFNs into result result.put(lfn, value); } } // done return result; }
/** * Deletes a very specific mapping from the replica catalog. The LFN must be matches, the PFN, and * all PFN attributes specified in the replica catalog entry. More than one entry could * theoretically be removed. Upon removal of an entry, all attributes associated with the PFN also * evaporate (cascading deletion). * * @param lfn is the logical directory in the tuple. * @param tuple is a description of the PFN and its attributes. * @return the number of removed entries, either 0 or 1. */ public int delete(String lfn, ReplicaCatalogEntry tuple) { int result = 0; if (lfn == null || tuple == null) { return result; } Collection c = (Collection) mLFNMap.get(lfn); if (c == null) { return result; } List l = new ArrayList(); for (Iterator i = c.iterator(); i.hasNext(); ) { ReplicaCatalogEntry rce = (ReplicaCatalogEntry) i.next(); if (!matchMe(rce, tuple)) { l.add(rce); } } // anything removed? if (l.size() != c.size()) { result = c.size() - l.size(); mLFNMap.put(lfn, l); } // done return result; }
private void ConnectKnowledgeBaseBtnMouseClicked( java.awt.event.MouseEvent evt) { // GEN-FIRST:event_ConnectKnowledgeBaseBtnMouseClicked String sPrjFile = ProjectNameTF.getText().trim(); String sLocationURI = sURI + "Location"; Collection errors = new ArrayList(); Date d1 = new Date(); long l1 = d1.getTime(); prj = Project.loadProjectFromFile(sPrjFile, errors); owlModel = (OWLModel) prj.getKnowledgeBase(); kb = prj.getKnowledgeBase(); URI uri = prj.getActiveRootURI(); Collection colNumberOfInstance = kb.getInstances(); lNumberOfInstance = colNumberOfInstance.size(); Date d2 = new Date(); long l2 = d2.getTime(); lLoadedTime = (l2 - l1); theLogger.info("Connected to MySQL in " + lLoadedTime + " ms"); theLogger.info("KB has " + lNumberOfInstance + " instances"); LoggingAreaTA.append("Project has " + lNumberOfInstance + " in total\n"); LoggingAreaTA.append("Project is loaded in " + lLoadedTime + " ms\n"); } // GEN-LAST:event_ConnectKnowledgeBaseBtnMouseClicked
/** @param node Node to remove. */ public void removeMappedNode(GridNode node) { if (mappedDhtNodes.contains(node)) mappedDhtNodes = new ArrayList<>(F.view(mappedDhtNodes, F.notEqualTo(node))); if (mappedNearNodes != null && mappedNearNodes.contains(node)) mappedNearNodes = new ArrayList<>(F.view(mappedNearNodes, F.notEqualTo(node))); }
/** * JUnit. * * @throws Exception If failed. */ public void testGetAndIncrement() throws Exception { Collection<Long> res = new HashSet<>(); String seqName = UUID.randomUUID().toString(); for (int i = 0; i < GRID_CNT; i++) { Set<Long> retVal = compute(grid(i).cluster().forLocal()).call(new GetAndIncrementJob(seqName, RETRIES)); for (Long l : retVal) assert !res.contains(l) : "Value already was used " + l; res.addAll(retVal); } assert res.size() == GRID_CNT * RETRIES; int gapSize = 0; for (long i = 0; i < GRID_CNT * RETRIES; i++) { if (!res.contains(i)) gapSize++; else gapSize = 0; assert gapSize <= BATCH_SIZE + 1 : "Gap above id " + i + " is " + gapSize + " more than batch size: " + (BATCH_SIZE + 1); } }
/** * Sort changes by roots * * @param changes a change list * @param exceptions exceptions to collect * @return sorted changes */ private static Map<VirtualFile, Collection<Change>> sortChangesByGitRoot( @NotNull List<Change> changes, List<VcsException> exceptions) { Map<VirtualFile, Collection<Change>> result = new HashMap<VirtualFile, Collection<Change>>(); for (Change change : changes) { final ContentRevision afterRevision = change.getAfterRevision(); final ContentRevision beforeRevision = change.getBeforeRevision(); // nothing-to-nothing change cannot happen. assert beforeRevision != null || afterRevision != null; // note that any path will work, because changes could happen within single vcs root final FilePath filePath = afterRevision != null ? afterRevision.getFile() : beforeRevision.getFile(); final VirtualFile vcsRoot; try { // the parent paths for calculating roots in order to account for submodules that contribute // to the parent change. The path "." is never is valid change, so there should be no // problem // with it. vcsRoot = GitUtil.getGitRoot(filePath.getParentPath()); } catch (VcsException e) { exceptions.add(e); continue; } Collection<Change> changeList = result.get(vcsRoot); if (changeList == null) { changeList = new ArrayList<Change>(); result.put(vcsRoot, changeList); } changeList.add(change); } return result; }
/** {@inheritDoc} */ @Override public Map<K, V> peekAll( @Nullable Collection<? extends K> keys, @Nullable Collection<GridCachePeekMode> modes) throws GridException { if (keys == null || keys.isEmpty()) return emptyMap(); final Collection<K> skipped = new GridLeanSet<K>(); final Map<K, V> map = !modes.contains(PARTITIONED_ONLY) ? peekAll0(keys, modes, ctx.tm().localTxx(), skipped) : new GridLeanMap<K, V>(0); if (map.size() != keys.size() && !modes.contains(NEAR_ONLY)) { map.putAll( dht.peekAll( F.view( keys, new P1<K>() { @Override public boolean apply(K k) { return !map.containsKey(k) && !skipped.contains(k); } }), modes)); } return map; }
/** @throws Exception If failed. */ public void testCreateFileColocated() throws Exception { GridGgfsPath path = new GridGgfsPath("/colocated"); UUID uuid = UUID.randomUUID(); GridUuid affKey; long idx = 0; while (true) { affKey = new GridUuid(uuid, idx); if (grid(0).mapKeyToNode(DATA_CACHE_NAME, affKey).id().equals(grid(0).localNode().id())) break; idx++; } try (GridGgfsOutputStream out = fs.create(path, 1024, true, affKey, 0, 1024, null)) { // Write 5M, should be enough to test distribution. for (int i = 0; i < 15; i++) out.write(new byte[1024 * 1024]); } GridGgfsFile info = fs.info(path); Collection<GridGgfsBlockLocation> affNodes = fs.affinity(path, 0, info.length()); assertEquals(1, affNodes.size()); Collection<UUID> nodeIds = F.first(affNodes).nodeIds(); assertEquals(1, nodeIds.size()); assertEquals(grid(0).localNode().id(), F.first(nodeIds)); }
public ConfigFile(String path) throws IOException { filePath = path; charset = Charset.forName("UTF-8"); if (!new File(path).exists()) return; Collection<Line> currentLines = globalLines; InputStreamReader isr = new InputStreamReader(new FileInputStream(path), charset); BufferedReader br = new BufferedReader(isr); try { String l = br.readLine(); while (l != null) { // 解决跨平台文本文件换行符不同的问题 while (!l.isEmpty() && (l.charAt(l.length() - 1) == '\r' || l.charAt(l.length() - 1) == '\n')) l = l.substring(0, l.length() - 1); Sector sec = parseSectorName(l); if (sec != null) { currentLines = sec.lines; sectors.add(sec); } else { Line line = parseLine(l); currentLines.add(line); } l = br.readLine(); } } finally { br.close(); isr.close(); } }
/** * Returns the file representing the Git repository directory for the given file path or any of * its parent in the filesystem. If the file doesn't exits, is not a Git repository or an error * occurred while transforming the given path into a store <code>null</code> is returned. * * @param path expected format /file/{Workspace}/{projectName}[/{path}] * @return the .git folder if found or <code>null</code> the give path cannot be resolved to a * file or it's not under control of a git repository * @throws CoreException */ public static File getGitDir(IPath path) throws CoreException { Map<IPath, File> gitDirs = GitUtils.getGitDirs(path, Traverse.GO_UP); if (gitDirs == null) return null; Collection<File> values = gitDirs.values(); if (values.isEmpty()) return null; return values.toArray(new File[] {})[0]; }
@Test public void testCompactionLog() throws Exception { SystemKeyspace.discardCompactionsInProgress(); String cf = "Standard4"; ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(cf); insertData(KEYSPACE1, cf, 0, 1); cfs.forceBlockingFlush(); Collection<SSTableReader> sstables = cfs.getSSTables(); assert !sstables.isEmpty(); Set<Integer> generations = Sets.newHashSet( Iterables.transform( sstables, new Function<SSTableReader, Integer>() { public Integer apply(SSTableReader sstable) { return sstable.descriptor.generation; } })); UUID taskId = SystemKeyspace.startCompaction(cfs, sstables); SetMultimap<Pair<String, String>, Integer> compactionLogs = SystemKeyspace.getUnfinishedCompactions(); Set<Integer> unfinishedCompactions = compactionLogs.get(Pair.create(KEYSPACE1, cf)); assert unfinishedCompactions.containsAll(generations); SystemKeyspace.finishCompaction(taskId); compactionLogs = SystemKeyspace.getUnfinishedCompactions(); assert !compactionLogs.containsKey(Pair.create(KEYSPACE1, cf)); }
/** * @param sector 为 null 时指代文件起首的全局 sector(无名称) * @return null,则没有找到相应sector */ public Collection<String> listKeys(String sector) { Collection<Line> lines = getSectorLines(sector); if (lines == null) return null; Collection<String> ret = new ArrayList<String>(); for (Line l : lines) ret.add(l.key); return ret; }
/* * Parses the data in the given input stream as a sequence of DER encoded * X.509 CRLs (in binary or base 64 encoded format) OR as a single PKCS#7 * encoded blob (in binary or base 64 encoded format). */ private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { Collection<X509CRLImpl> coll = new ArrayList<>(); byte[] data = readOneBlock(is); if (data == null) { return new ArrayList<>(0); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(is); } } return coll; }
/* process call edge constraint */ public void process(CallConstraint c) { Node csrc = c.ncaller.getRep(); Node cdst = c.ncallee.getRep(); assert (cdst.graph == this); if (heapfix && csrc.graph == this && !csrc.isheap && cdst.isheap) w.addFirst(new UnifyConstraint(csrc, cdst)); Collection<CallEdge> ced = cedges.get(c.call); if (ced != null) for (CallEdge e : ced) { Node esrc = e.src.getRep(); Node edst = e.dst.getRep(); if (edst == cdst && e.call.equals(c.call)) { if (esrc != csrc) { Graph g = esrc.graph; assert (g != this || !Options.mergeGraphs.value); g.w.addFirst(new UnifyConstraint(esrc, csrc)); } return; } } else { ced = new ArrayList<CallEdge>(); cedges.put(c.call, ced); } ced.add(new CallEdge(csrc, cdst, c.call)); }
// look up and apply coarts for given rels to each sign in result private void applyCoarts(List<String> coartRels, Collection<Sign> result) { List<Sign> inputSigns = new ArrayList<Sign>(result); result.clear(); List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size()); // for each rel, lookup coarts and apply to input signs, storing results in output signs for (Iterator<String> it = coartRels.iterator(); it.hasNext(); ) { String rel = it.next(); Collection<String> preds = (Collection<String>) _coartRelsToPreds.get(rel); if (preds == null) continue; // not expected Collection<Sign> coartResult = getSignsFromRelAndPreds(rel, preds); if (coartResult == null) continue; for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) { Sign coartSign = it2.next(); // apply to each input for (int j = 0; j < inputSigns.size(); j++) { Sign sign = inputSigns.get(j); grammar.rules.applyCoart(sign, coartSign, outputSigns); } } // switch output to input for next iteration inputSigns.clear(); inputSigns.addAll(outputSigns); outputSigns.clear(); } // add results back result.addAll(inputSigns); }
/** INTERNAL: Transform the object-level value into a database-level value */ public Object getFieldValue(Object objectValue, AbstractSession session) { DatabaseMapping mapping = getMapping(); Object fieldValue = objectValue; if ((mapping != null) && (mapping.isDirectToFieldMapping() || mapping.isDirectCollectionMapping())) { // CR#3623207, check for IN Collection here not in mapping. if (objectValue instanceof Collection) { // This can actually be a collection for IN within expressions... however it would be better // for expressions to handle this. Collection values = (Collection) objectValue; Vector fieldValues = new Vector(values.size()); for (Iterator iterator = values.iterator(); iterator.hasNext(); ) { Object value = iterator.next(); if (!(value instanceof Expression)) { value = getFieldValue(value, session); } fieldValues.add(value); } fieldValue = fieldValues; } else { if (mapping.isDirectToFieldMapping()) { fieldValue = ((AbstractDirectMapping) mapping).getFieldValue(objectValue, session); } else if (mapping.isDirectCollectionMapping()) { fieldValue = ((DirectCollectionMapping) mapping).getFieldValue(objectValue, session); } } } return fieldValue; }
// get signs with additional args for a known special token const, target pred and target rel private SignHash getSignsFromWord( Word w, String specialTokenConst, String targetPred, String targetRel) throws LexException { Collection<MorphItem> morphItems = (specialTokenConst == null) ? (Collection<MorphItem>) _words.get(w) : null; if (morphItems == null) { // check for special tokens if (specialTokenConst == null) { specialTokenConst = tokenizer.getSpecialTokenConstant(tokenizer.isSpecialToken(w.getForm())); targetPred = w.getForm(); } if (specialTokenConst != null) { Word key = Word.createSurfaceWord(w, specialTokenConst); morphItems = (Collection<MorphItem>) _words.get(key); } // otherwise throw lex exception if (morphItems == null) throw new LexException(w + " not in lexicon"); } SignHash result = new SignHash(); for (Iterator<MorphItem> MI = morphItems.iterator(); MI.hasNext(); ) { getWithMorphItem(w, MI.next(), targetPred, targetRel, result); } return result; }
/** * Restart of the application server : * * <p>All running services are stopped. LookupManager is flushed. * * <p>Client code that started us should notice the special return value and restart us. */ protected final void doExecute(AdminCommandContext context) { try { // unfortunately we can't rely on constructors with HK2... if (registry == null) throw new NullPointerException( new LocalStringsImpl(getClass()) .get("restart.server.internalError", "registry was not set")); init(context); if (!verbose) { // do it now while we still have the Logging service running... reincarnate(); } // else we just return a special int from System.exit() Collection<Module> modules = registry.getModules("com.sun.enterprise.osgi-adapter"); if (modules.size() == 1) { final Module mgmtAgentModule = modules.iterator().next(); mgmtAgentModule.stop(); } else context.getLogger().warning(strings.get("restart.server.badNumModules", modules.size())); } catch (Exception e) { context.getLogger().severe(strings.get("restart.server.failure", e)); } int ret = RESTART_NORMAL; if (debug != null) ret = debug ? RESTART_DEBUG_ON : RESTART_DEBUG_OFF; System.exit(ret); }
/** * Core sentiment detection method. doNota = none of the above * * @param captions (null/none = all) */ public Map<String, Collection<Document>> getEmotions( Indexer indexer, Collection<Document> docs, boolean doNota, boolean originalContentOnly, String... captions) { Collection<Lexicon1Lang> lexicons = getRelevantLexicon1Langs(docs); Map<String, Collection<Document>> result = new LinkedHashMap<>(); Set<Document> docs_set = Util.castOrCloneAsSet(docs); // aggregate results for each lang into result for (Lexicon1Lang lex : lexicons) { Map<String, Collection<Document>> resultsForThisLang = (doNota ? lex.getEmotionsWithNOTA(indexer, docs_set, originalContentOnly) : lex.getEmotions(indexer, docs_set, originalContentOnly, captions)); if (resultsForThisLang == null) continue; for (String caption : resultsForThisLang.keySet()) { Collection<Document> resultDocsThisLang = resultsForThisLang.get(caption); Collection<Document> resultDocs = result.get(caption); // if caption doesn't exist already, create a new entry, or else add to the existing set of // docs that match this caption if (resultDocs == null) result.put(caption, resultDocsThisLang); else resultDocs.addAll(resultDocsThisLang); } } // TODO: the result can be cached at server to avoid redundant computation (by concurrent users, // which are few for now) return result; }