Examples of TByteIntHashMap


Examples of org.elasticsearch.common.trove.map.hash.TByteIntHashMap

    @Override public Facet reduce(String name, List<Facet> facets) {
        if (facets.size() == 1) {
            return facets.get(0);
        }
        InternalByteTermsFacet first = (InternalByteTermsFacet) facets.get(0);
        TByteIntHashMap aggregated = CacheRecycler.popByteIntMap();

        long missing = 0;
        long total = 0;
        for (Facet facet : facets) {
            InternalByteTermsFacet mFacet = (InternalByteTermsFacet) facet;
            missing += mFacet.missingCount();
            total += mFacet.totalCount();
            for (ByteEntry entry : mFacet.entries) {
                aggregated.adjustOrPutValue(entry.term, entry.count(), entry.count());
            }
        }

        BoundedTreeSet<ByteEntry> ordered = new BoundedTreeSet<ByteEntry>(first.comparatorType.comparator(), first.requiredSize);
        for (TByteIntIterator it = aggregated.iterator(); it.hasNext(); ) {
            it.advance();
            ordered.add(new ByteEntry(it.key(), it.value()));
        }
        first.entries = ordered;
        first.missing = missing;
View Full Code Here

Examples of org.elasticsearch.common.trove.map.hash.TByteIntHashMap

    @Override protected void doCollect(int doc) throws IOException {
        fieldData.forEachValueInDoc(doc, aggregator);
    }

    @Override public Facet facet() {
        TByteIntHashMap facets = aggregator.facets();
        if (facets.isEmpty()) {
            CacheRecycler.pushByteIntMap(facets);
            return new InternalByteTermsFacet(facetName, comparatorType, size, ImmutableList.<InternalByteTermsFacet.ByteEntry>of(), aggregator.missing(), aggregator.total());
        } else {
            if (size < EntryPriorityQueue.LIMIT) {
                EntryPriorityQueue ordered = new EntryPriorityQueue(size, comparatorType.comparator());
                for (TByteIntIterator it = facets.iterator(); it.hasNext(); ) {
                    it.advance();
                    ordered.insertWithOverflow(new InternalByteTermsFacet.ByteEntry(it.key(), it.value()));
                }
                InternalByteTermsFacet.ByteEntry[] list = new InternalByteTermsFacet.ByteEntry[ordered.size()];
                for (int i = ordered.size() - 1; i >= 0; i--) {
                    list[i] = (InternalByteTermsFacet.ByteEntry) ordered.pop();
                }
                CacheRecycler.pushByteIntMap(facets);
                return new InternalByteTermsFacet(facetName, comparatorType, size, Arrays.asList(list), aggregator.missing(), aggregator.total());
            } else {
                BoundedTreeSet<InternalByteTermsFacet.ByteEntry> ordered = new BoundedTreeSet<InternalByteTermsFacet.ByteEntry>(comparatorType.comparator(), size);
                for (TByteIntIterator it = facets.iterator(); it.hasNext(); ) {
                    it.advance();
                    ordered.add(new InternalByteTermsFacet.ByteEntry(it.key(), it.value()));
                }
                CacheRecycler.pushByteIntMap(facets);
                return new InternalByteTermsFacet(facetName, comparatorType, size, ordered, aggregator.missing(), aggregator.total());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.