Search in sources :

Example 1 with Collections

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;
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) Collections(java.util.Collections)

Example 2 with Collections

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);
}
Also used : Bundle(android.os.Bundle) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) DialogFragment(android.support.v4.app.DialogFragment) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) RealmSpotlightRoomRepository(chat.rocket.persistence.realm.repositories.RealmSpotlightRoomRepository) RocketChatAvatar(chat.rocket.android.widget.RocketChatAvatar) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) DirectMessageRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.DirectMessageRoomListHeader) View(android.view.View) TextUtils(chat.rocket.android.helper.TextUtils) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) User(chat.rocket.core.models.User) RocketChatAbsoluteUrl(chat.rocket.android.fragment.chatroom.RocketChatAbsoluteUrl) RealmServerInfoRepository(chat.rocket.persistence.realm.repositories.RealmServerInfoRepository) RoomListAdapter(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter) RxSearchView(com.jakewharton.rxbinding2.support.v7.widget.RxSearchView) UserRenderer(chat.rocket.android.renderer.UserRenderer) SessionInteractor(chat.rocket.core.interactors.SessionInteractor) List(java.util.List) TextView(android.widget.TextView) RealmSessionRepository(chat.rocket.persistence.realm.repositories.RealmSessionRepository) Room(chat.rocket.core.models.Room) BuildConfig(chat.rocket.android.BuildConfig) ChannelRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.ChannelRoomListHeader) Nullable(android.support.annotation.Nullable) RxCompoundButton(com.jakewharton.rxbinding2.widget.RxCompoundButton) AbstractFragment(chat.rocket.android.fragment.AbstractFragment) RocketChatCache(chat.rocket.android.RocketChatCache) NonNull(android.support.annotation.NonNull) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) Observable(io.reactivex.Observable) R(chat.rocket.android.R) RealmRoomRepository(chat.rocket.persistence.realm.repositories.RealmRoomRepository) AddDirectMessageDialogFragment(chat.rocket.android.fragment.sidebar.dialog.AddDirectMessageDialogFragment) AddChannelDialogFragment(chat.rocket.android.fragment.sidebar.dialog.AddChannelDialogFragment) FavoriteRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.FavoriteRoomListHeader) CompoundButton(android.widget.CompoundButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Logger(chat.rocket.android.helper.Logger) UnreadRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader) RoomInteractor(chat.rocket.core.interactors.RoomInteractor) TimeUnit(java.util.concurrent.TimeUnit) RecyclerView(android.support.v7.widget.RecyclerView) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) RealmUserRepository(chat.rocket.persistence.realm.repositories.RealmUserRepository) RoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListHeader) SortDirection(chat.rocket.core.SortDirection) Collections(java.util.Collections) RoomListAdapter(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Logger(chat.rocket.android.helper.Logger) Room(chat.rocket.core.models.Room) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) SuppressLint(android.annotation.SuppressLint)

Example 3 with Collections

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();
    }
}
Also used : Arrays(java.util.Arrays) ArrayUtil(com.intellij.util.ArrayUtil) PersistentStateComponent(com.intellij.openapi.components.PersistentStateComponent) NonNls(org.jetbrains.annotations.NonNls) ContainerUtil(com.intellij.util.containers.ContainerUtil) CDATA(org.jdom.CDATA) Matcher(java.util.regex.Matcher) Comparing(com.intellij.openapi.util.Comparing) SmartList(com.intellij.util.SmartList) PatternCompilerFactory(com.intellij.patterns.compiler.PatternCompilerFactory) PsiLanguageInjectionHost(com.intellij.psi.PsiLanguageInjectionHost) PsiElement(com.intellij.psi.PsiElement) Logger(com.intellij.openapi.diagnostic.Logger) LiteralTextEscaper(com.intellij.psi.LiteralTextEscaper) ElementManipulators(com.intellij.psi.ElementManipulators) ProgressManager(com.intellij.openapi.progress.ProgressManager) InjectorUtils(org.intellij.plugins.intelliLang.inject.InjectorUtils) StringUtil(com.intellij.openapi.util.text.StringUtil) Key(com.intellij.openapi.util.Key) TextRange(com.intellij.openapi.util.TextRange) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) RegExp(org.intellij.lang.annotations.RegExp) StringPattern(com.intellij.patterns.StringPattern) Pattern(java.util.regex.Pattern) PatternCompiler(com.intellij.patterns.compiler.PatternCompiler) NotNull(org.jetbrains.annotations.NotNull) Element(org.jdom.Element) Collections(java.util.Collections) PsiLanguageInjectionHost(com.intellij.psi.PsiLanguageInjectionHost) TextRange(com.intellij.openapi.util.TextRange) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with Collections

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);
    }
}
Also used : PatchLineComment(com.google.gerrit.reviewdb.client.PatchLineComment) FOOTER_SUBMITTED_WITH(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBMITTED_WITH) ListMultimap(com.google.common.collect.ListMultimap) MultimapBuilder(com.google.common.collect.MultimapBuilder) LoggerFactory(org.slf4j.LoggerFactory) FOOTER_HASHTAGS(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_HASHTAGS) HashBasedTable(com.google.common.collect.HashBasedTable) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval) ReviewerSet(com.google.gerrit.server.ReviewerSet) FooterKey(org.eclipse.jgit.revwalk.FooterKey) FOOTER_ASSIGNEE(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_ASSIGNEE) Comment(com.google.gerrit.reviewdb.client.Comment) InvalidObjectIdException(org.eclipse.jgit.errors.InvalidObjectIdException) FOOTER_PATCH_SET_DESCRIPTION(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PATCH_SET_DESCRIPTION) Tables(com.google.common.collect.Tables) Locale(java.util.Locale) Map(java.util.Map) GitDateParser(org.eclipse.jgit.util.GitDateParser) ParseException(java.text.ParseException) Splitter(com.google.common.base.Splitter) NoteMap(org.eclipse.jgit.notes.NoteMap) LinkedListMultimap(com.google.common.collect.LinkedListMultimap) Timer1(com.google.gerrit.metrics.Timer1) FOOTER_WORK_IN_PROGRESS(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_WORK_IN_PROGRESS) CHANGES(com.google.gerrit.server.notedb.NoteDbTable.CHANGES) ImmutableSet(com.google.common.collect.ImmutableSet) FOOTER_SUBJECT(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBJECT) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) RawParseUtils(org.eclipse.jgit.util.RawParseUtils) ChangeNotesRevWalk(com.google.gerrit.server.notedb.ChangeNotesCommit.ChangeNotesRevWalk) Set(java.util.Set) ReviewerStatusUpdate(com.google.gerrit.server.ReviewerStatusUpdate) LabelType(com.google.gerrit.common.data.LabelType) Collectors.joining(java.util.stream.Collectors.joining) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) PersonIdent(org.eclipse.jgit.lib.PersonIdent) List(java.util.List) FOOTER_STATUS(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_STATUS) RefNames(com.google.gerrit.reviewdb.client.RefNames) AutoValue(com.google.auto.value.AutoValue) Optional(java.util.Optional) FOOTER_LABEL(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_LABEL) LabelId(com.google.gerrit.reviewdb.client.LabelId) FOOTER_READ_ONLY_UNTIL(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_READ_ONLY_UNTIL) FOOTER_SUBMISSION_ID(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBMISSION_ID) FOOTER_COMMIT(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_COMMIT) FOOTER_CHANGE_ID(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CHANGE_ID) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) Change(com.google.gerrit.reviewdb.client.Change) HashMap(java.util.HashMap) Function(java.util.function.Function) TreeSet(java.util.TreeSet) Enums(com.google.common.base.Enums) SubmitRecord(com.google.gerrit.common.data.SubmitRecord) ArrayList(java.util.ArrayList) FOOTER_TAG(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TAG) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) FOOTER_REAL_USER(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_REAL_USER) Lists(com.google.common.collect.Lists) Charset(java.nio.charset.Charset) Account(com.google.gerrit.reviewdb.client.Account) FOOTER_BRANCH(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_BRANCH) FOOTER_PATCH_SET(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PATCH_SET) FOOTER_GROUPS(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_GROUPS) FOOTER_PRIVATE(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PRIVATE) FOOTER_TOPIC(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TOPIC) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) FOOTER_CURRENT(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CURRENT) ReviewDbUtil(com.google.gerrit.reviewdb.server.ReviewDbUtil) IOException(java.io.IOException) Ints(com.google.common.primitives.Ints) ObjectId(org.eclipse.jgit.lib.ObjectId) Address(com.google.gerrit.server.mail.Address) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) LabelVote(com.google.gerrit.server.util.LabelVote) ReviewerByEmailSet(com.google.gerrit.server.ReviewerByEmailSet) Table(com.google.common.collect.Table) Collections(java.util.Collections) ObjectReader(org.eclipse.jgit.lib.ObjectReader) RevId(com.google.gerrit.reviewdb.client.RevId) TreeSet(java.util.TreeSet) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) LabelId(com.google.gerrit.reviewdb.client.LabelId) ObjectId(org.eclipse.jgit.lib.ObjectId) RevId(com.google.gerrit.reviewdb.client.RevId) Map(java.util.Map) NoteMap(org.eclipse.jgit.notes.NoteMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with Collections

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);
}
Also used : Query(org.apache.lucene.search.Query) TopDocs(org.apache.lucene.search.TopDocs) EventIndexSearcher(org.apache.nifi.provenance.index.EventIndexSearcher) Arrays(java.util.Arrays) EventTransformer(org.apache.nifi.provenance.authorization.EventTransformer) Logger(org.slf4j.Logger) SearchFailedException(org.apache.nifi.provenance.index.SearchFailedException) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) IOException(java.io.IOException) SearchableFields(org.apache.nifi.provenance.SearchableFields) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) Tuple(org.apache.nifi.util.Tuple) IndexManager(org.apache.nifi.provenance.lucene.IndexManager) EventStore(org.apache.nifi.provenance.store.EventStore) ProgressiveResult(org.apache.nifi.provenance.ProgressiveResult) Collections(java.util.Collections) IndexReader(org.apache.lucene.index.IndexReader) EventAuthorizer(org.apache.nifi.provenance.authorization.EventAuthorizer) SearchFailedException(org.apache.nifi.provenance.index.SearchFailedException) ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) IOException(java.io.IOException) Tuple(org.apache.nifi.util.Tuple) SearchFailedException(org.apache.nifi.provenance.index.SearchFailedException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

Collections (java.util.Collections)113 List (java.util.List)59 ArrayList (java.util.ArrayList)41 Test (org.junit.Test)39 Map (java.util.Map)37 Collectors (java.util.stream.Collectors)34 Arrays (java.util.Arrays)28 HashMap (java.util.HashMap)26 Set (java.util.Set)25 HashSet (java.util.HashSet)23 IOException (java.io.IOException)19 Collection (java.util.Collection)19 Optional (java.util.Optional)19 TimeUnit (java.util.concurrent.TimeUnit)16 URI (java.net.URI)13 Assert (org.junit.Assert)13 Function (java.util.function.Function)12 Stream (java.util.stream.Stream)12 Before (org.junit.Before)12 Logger (org.slf4j.Logger)12