Package com.pearson.entech.elasticsearch.search.facet.approx.date.internal

Examples of com.pearson.entech.elasticsearch.search.facet.approx.date.internal.DistinctCountPayload


        while(hasNextTimestamp()) {
            final long time = nextTimestamp();
            while(sliceIter.hasNext()) {
                final BytesRef unsafeSlice = sliceIter.next();
                final DistinctCountPayload count = getSafely(_counts, time, unsafeSlice);
                while(distinctIter.hasNext()) {
                    final BytesRef unsafeTerm = distinctIter.next();
                    // Unsafe because the BytesRef may be changed if we continue reading,
                    // but the counter only needs to read it once immediately, so that's OK
                    count.update(unsafeTerm);
                }
            }
        }
    }
View Full Code Here


        ExtTHashMap<BytesRef, DistinctCountPayload> subMap = counts.get(key);
        if(subMap == null) {
            subMap = CacheRecycler.popHashMap();
            counts.put(key, subMap);
        }
        DistinctCountPayload payload = subMap.get(unsafe);
        if(payload == null) {
            final BytesRef safe = BytesRef.deepCopyOf(unsafe);
            payload = new DistinctCountPayload(_exactThreshold);
            subMap.put(safe, payload);
        }
        return payload;
    }
View Full Code Here

    public void testSerializingNonEmptyMixedDistinctFacet() throws Exception {
        testSerializingNonEmptyDistinctFacet(0, 999);
    }

    private void testSerializingNonEmptyDistinctFacet(final int threshold1, final int threshold2) throws Exception {
        final DistinctCountPayload payload1 = new DistinctCountPayload(threshold1);
        payload1.update(new BytesRef("marge"));
        payload1.update(new BytesRef("homer"));
        final DistinctCountPayload payload2 = new DistinctCountPayload(threshold2);
        payload2.update(new BytesRef("bart"));
        payload2.update(new BytesRef("lisa"));
        final ExtTLongObjectHashMap<DistinctCountPayload> counts = CacheRecycler.popLongObjectMap();
        counts.put(1, payload1);
        counts.put(2, payload2);
        final Map<Long, Integer> expectedCounts = newHashMap();
        expectedCounts.put(1l, 2);
View Full Code Here

    private void compareDistinctCounts(final Map<Long, Integer> expectedCounts,
            final Map<Long, Integer> expectedCardinalities, final ExtTLongObjectHashMap<DistinctCountPayload> receivedCounts) {
        assertEquals(expectedCounts.size(), receivedCounts.size());
        for(final long period : expectedCounts.keySet()) {
            final DistinctCountPayload payload = receivedCounts.get(period);
            assertEquals(expectedCounts.get(period).intValue(), payload.getCount());
            assertEquals(expectedCardinalities.get(period).intValue(), payload.getCardinality().cardinality());
        }
    }
View Full Code Here

    private void testSerializingNonEmptySlicedDistinctFacet(final int threshold1, final int threshold2) throws Exception {
        final ExtTLongObjectHashMap<ExtTHashMap<BytesRef, DistinctCountPayload>> counts = CacheRecycler.popLongObjectMap();
        final BytesRef label1 = new BytesRef("itchy");
        final BytesRef label2 = new BytesRef("scratchy");
        final ExtTHashMap<BytesRef, DistinctCountPayload> period1 = CacheRecycler.popHashMap();
        final DistinctCountPayload payload1 = new DistinctCountPayload(threshold1);
        payload1.update(new BytesRef("marge"));
        payload1.update(new BytesRef("homer"));
        final DistinctCountPayload payload2 = new DistinctCountPayload(threshold1);
        payload2.update(new BytesRef("marge"));
        payload2.update(new BytesRef("marge"));
        period1.put(label1, payload1);
        period1.put(label2, payload2);
        counts.put(1, period1);
        final ExtTHashMap<BytesRef, DistinctCountPayload> period2 = CacheRecycler.popHashMap();
        final DistinctCountPayload payload3 = new DistinctCountPayload(threshold2);
        payload3.update(new BytesRef("bart"));
        payload3.update(new BytesRef("lisa"));
        final DistinctCountPayload payload4 = new DistinctCountPayload(threshold2);
        payload4.update(new BytesRef("bart"));
        payload4.update(new BytesRef("bart"));
        period2.put(label1, payload3);
        period2.put(label2, payload4);
        counts.put(2, period2);
        final Map<Long, Map<BytesRef, Integer>> expectedCounts = newHashMap();
        final Map<BytesRef, Integer> period1Counts = newHashMap();
View Full Code Here

            final int timestampCount = timestampList.size();
            for(int i = 0; i < timestampCount; i++) {
                final long timestampSecs = timestampList.get(i);
                // Convert back to milliseconds resolution
                final long timestamp = timestampSecs * 1000;
                DistinctCountPayload payload = counts.get(timestamp);
                if(payload == null) {
                    payload = new DistinctCountPayload(_exactThreshold);
                    counts.put(timestamp, payload);
                }
                payload.update(fieldVal);
            }
            _occurrences.put(fieldVal, null); // Free this up for GC immediately
        }

        _occurrences = null;
View Full Code Here

TOP

Related Classes of com.pearson.entech.elasticsearch.search.facet.approx.date.internal.DistinctCountPayload

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.