use of java.util.Collections in project elasticsearch by elastic.
the class ZenDiscoveryUnitTests method buildZenDiscovery.
private ZenDiscovery buildZenDiscovery(Settings settings, TransportService service, ClusterService clusterService, ThreadPool threadPool) {
ZenDiscovery zenDiscovery = new ZenDiscovery(settings, threadPool, service, new NamedWriteableRegistry(ClusterModule.getNamedWriteables()), clusterService, Collections::emptyList);
zenDiscovery.start();
return zenDiscovery;
}
use of java.util.Collections in project Rocket.Chat.Android by RocketChat.
the class SidebarMainFragment method onSetupView.
@SuppressLint("RxLeakedSubscription")
@Override
protected void onSetupView() {
setupUserActionToggle();
setupUserStatusButtons();
setupLogoutButton();
setupVersionInfo();
adapter = new RoomListAdapter();
adapter.setOnItemClickListener(new RoomListAdapter.OnItemClickListener() {
@Override
public void onItemClick(Room room) {
searchView.clearFocus();
presenter.onRoomSelected(room);
}
@Override
public void onItemClick(SpotlightRoom spotlightRoom) {
searchView.setQuery(null, false);
searchView.clearFocus();
methodCallHelper.joinRoom(spotlightRoom.getId()).onSuccessTask(task -> {
presenter.onSpotlightRoomSelected(spotlightRoom);
return null;
});
}
});
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.room_list_container);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(adapter);
searchView = (SearchView) rootView.findViewById(R.id.search);
RxSearchView.queryTextChanges(searchView).compose(bindToLifecycle()).debounce(300, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).switchMap(it -> {
if (it.length() == 0) {
adapter.setMode(RoomListAdapter.MODE_ROOM);
return Observable.just(Collections.<SpotlightRoom>emptyList());
}
adapter.setMode(RoomListAdapter.MODE_SPOTLIGHT_ROOM);
final String queryString = it.toString();
methodCallHelper.searchSpotlightRooms(queryString);
return realmSpotlightRoomRepository.getSuggestionsFor(queryString, SortDirection.DESC, 10).toObservable();
}).subscribe(this::showSearchSuggestions, Logger::report);
}
use of java.util.Collections in project intellij-community by JetBrains.
the class BaseInjection method getInjectedArea.
@NotNull
public List<TextRange> getInjectedArea(final PsiElement element) {
final TextRange textRange = ElementManipulators.getValueTextRange(element);
if (myCompiledValuePattern == null) {
return Collections.singletonList(textRange);
} else {
final LiteralTextEscaper<? extends PsiLanguageInjectionHost> textEscaper = ((PsiLanguageInjectionHost) element).createLiteralTextEscaper();
final StringBuilder sb = new StringBuilder();
textEscaper.decode(textRange, sb);
final List<TextRange> ranges = getMatchingRanges(myCompiledValuePattern.matcher(StringPattern.newBombedCharSequence(sb)), sb.length());
return !ranges.isEmpty() ? ContainerUtil.map(ranges, s -> new TextRange(textEscaper.getOffsetInHost(s.getStartOffset(), textRange), textEscaper.getOffsetInHost(s.getEndOffset(), textRange))) : Collections.<TextRange>emptyList();
}
}
use of java.util.Collections in project gerrit by GerritCodeReview.
the class ChangeNotesParser method updatePatchSetStates.
private void updatePatchSetStates() {
Set<PatchSet.Id> missing = new TreeSet<>(ReviewDbUtil.intKeyOrdering());
for (Iterator<PatchSet> it = patchSets.values().iterator(); it.hasNext(); ) {
PatchSet ps = it.next();
if (ps.getRevision().equals(PARTIAL_PATCH_SET)) {
missing.add(ps.getId());
it.remove();
}
}
for (Map.Entry<PatchSet.Id, PatchSetState> e : patchSetStates.entrySet()) {
switch(e.getValue()) {
case PUBLISHED:
default:
break;
case DELETED:
patchSets.remove(e.getKey());
break;
case DRAFT:
PatchSet ps = patchSets.get(e.getKey());
if (ps != null) {
ps.setDraft(true);
}
break;
}
}
// Post-process other collections to remove items corresponding to deleted
// (or otherwise missing) patch sets. This is safer than trying to prevent
// insertion, as it will also filter out items racily added after the patch
// set was deleted.
changeMessagesByPatchSet.keys().retainAll(patchSets.keySet());
int pruned = pruneEntitiesForMissingPatchSets(allChangeMessages, ChangeMessage::getPatchSetId, missing);
pruned += pruneEntitiesForMissingPatchSets(comments.values(), c -> new PatchSet.Id(id, c.key.patchSetId), missing);
pruned += pruneEntitiesForMissingPatchSets(approvals.values(), PatchSetApproval::getPatchSetId, missing);
if (!missing.isEmpty()) {
log.warn("ignoring {} additional entities due to missing patch sets: {}", pruned, missing);
}
}
use of java.util.Collections in project nifi by apache.
the class QueryTask method readDocuments.
private Tuple<List<ProvenanceEventRecord>, Integer> readDocuments(final TopDocs topDocs, final IndexReader indexReader) {
// If no topDocs is supplied, just provide a Tuple that has no records and a hit count of 0.
if (topDocs == null || topDocs.totalHits == 0) {
return new Tuple<>(Collections.<ProvenanceEventRecord>emptyList(), 0);
}
final long start = System.nanoTime();
final List<Long> eventIds = Arrays.stream(topDocs.scoreDocs).mapToInt(scoreDoc -> scoreDoc.doc).mapToObj(docId -> {
try {
return indexReader.document(docId, LUCENE_FIELDS_TO_LOAD);
} catch (final Exception e) {
throw new SearchFailedException("Failed to read Provenance Events from Event File", e);
}
}).map(doc -> doc.getField(SearchableFields.Identifier.getSearchableFieldName()).numericValue().longValue()).collect(Collectors.toList());
final long endConvert = System.nanoTime();
final long ms = TimeUnit.NANOSECONDS.toMillis(endConvert - start);
logger.debug("Converting documents took {} ms", ms);
List<ProvenanceEventRecord> events;
try {
events = eventStore.getEvents(eventIds, authorizer, transformer);
} catch (IOException e) {
throw new SearchFailedException("Unable to retrieve events from the Provenance Store", e);
}
final long fetchEventNanos = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - endConvert);
logger.debug("Fetching {} events from Event Store took {} ms ({} events actually fetched)", eventIds.size(), fetchEventNanos, events.size());
final int totalHits = topDocs.totalHits;
return new Tuple<>(events, totalHits);
}
Aggregations