Package org.elasticsearch.common.trove.map.hash

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


    @Override public Facet reduce(String name, List<Facet> facets) {
        if (facets.size() == 1) {
            return facets.get(0);
        }
        InternalFloatTermsFacet first = (InternalFloatTermsFacet) facets.get(0);
        TFloatIntHashMap aggregated = CacheRecycler.popFloatIntMap();
        long missing = 0;
        long total = 0;
        for (Facet facet : facets) {
            InternalFloatTermsFacet mFacet = (InternalFloatTermsFacet) facet;
            missing += mFacet.missingCount();
            total += mFacet.totalCount();
            for (FloatEntry entry : mFacet.entries) {
                aggregated.adjustOrPutValue(entry.term, entry.count(), entry.count());
            }
        }

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


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

    @Override public Facet facet() {
        TFloatIntHashMap facets = aggregator.facets();
        if (facets.isEmpty()) {
            CacheRecycler.pushFloatIntMap(facets);
            return new InternalFloatTermsFacet(facetName, comparatorType, size, ImmutableList.<InternalFloatTermsFacet.FloatEntry>of(), aggregator.missing(), aggregator.total());
        } else {
            if (size < EntryPriorityQueue.LIMIT) {
                EntryPriorityQueue ordered = new EntryPriorityQueue(size, comparatorType.comparator());
                for (TFloatIntIterator it = facets.iterator(); it.hasNext(); ) {
                    it.advance();
                    ordered.insertWithOverflow(new InternalFloatTermsFacet.FloatEntry(it.key(), it.value()));
                }
                InternalFloatTermsFacet.FloatEntry[] list = new InternalFloatTermsFacet.FloatEntry[ordered.size()];
                for (int i = ordered.size() - 1; i >= 0; i--) {
                    list[i] = (InternalFloatTermsFacet.FloatEntry) ordered.pop();
                }
                CacheRecycler.pushFloatIntMap(facets);
                return new InternalFloatTermsFacet(facetName, comparatorType, size, Arrays.asList(list), aggregator.missing(), aggregator.total());
            } else {
                BoundedTreeSet<InternalFloatTermsFacet.FloatEntry> ordered = new BoundedTreeSet<InternalFloatTermsFacet.FloatEntry>(comparatorType.comparator(), size);
                for (TFloatIntIterator it = facets.iterator(); it.hasNext(); ) {
                    it.advance();
                    ordered.add(new InternalFloatTermsFacet.FloatEntry(it.key(), it.value()));
                }
                CacheRecycler.pushFloatIntMap(facets);
                return new InternalFloatTermsFacet(facetName, comparatorType, size, ordered, aggregator.missing(), aggregator.total());
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.trove.map.hash.TFloatIntHashMap

Copyright © 2018 www.massapicom. 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.