use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapAggregatorTest method shouldMergeFreqMaps.
@Test
public void shouldMergeFreqMaps() {
// Given
final FreqMapAggregator aggregator = new FreqMapAggregator();
aggregator.init();
final FreqMap freqMap1 = new FreqMap();
freqMap1.put("1", 2L);
freqMap1.put("2", 3L);
final FreqMap freqMap2 = new FreqMap();
freqMap2.put("2", 4L);
freqMap2.put("3", 5L);
// When
aggregator._aggregate(freqMap1);
aggregator._aggregate(freqMap2);
// Then
final FreqMap mergedFreqMap = ((FreqMap) aggregator.state()[0]);
assertEquals((Long) 2L, mergedFreqMap.get("1"));
assertEquals((Long) 7L, mergedFreqMap.get("2"));
assertEquals((Long) 5L, mergedFreqMap.get("3"));
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapSerialiserTest method shouldDeserialiseEmptyBytes.
@Override
public void shouldDeserialiseEmptyBytes() throws SerialisationException {
// When
final FreqMap value = serialiser.deserialiseEmptyBytes();
// Then
assertEquals(new FreqMap(), value);
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class MapFilterExample method freqMapIsMoreThanOrEqualTo2.
public void freqMapIsMoreThanOrEqualTo2() {
// ---------------------------------------------------------
final MapFilter function = new MapFilter("key1", new IsMoreThan(2L, true));
// ---------------------------------------------------------
final FreqMap map1 = new FreqMap();
map1.put("key1", 1L);
final FreqMap map2 = new FreqMap();
map2.put("key1", 2L);
final FreqMap map3 = new FreqMap();
map3.put("key1", 3L);
final FreqMap map4 = new FreqMap();
map4.put("key1", 3L);
map4.put("key2", 0L);
final FreqMap map5 = new FreqMap();
map5.put("key2", 3L);
runExample(function, map1, map2, map3, map4, map5);
}
use of uk.gov.gchq.gaffer.types.FreqMap in project gaffer-doc by gchq.
the class FreqMapExtractorExample method multiplyAllMapValuesBy10.
public void multiplyAllMapValuesBy10() {
// ---------------------------------------------------------
final FreqMapExtractor function = new FreqMapExtractor("key1");
// ---------------------------------------------------------
final FreqMap map1 = new FreqMap();
map1.put("key1", 1L);
map1.put("key2", 2L);
map1.put("key3", 3L);
final FreqMap map2 = new FreqMap();
map2.put("key2", 2L);
map2.put("key3", 3L);
final Map<String, Long> map3 = new HashMap<>();
map3.put("key1", 1L);
map3.put("key2", 2L);
map3.put("key3", 3L);
runExample(function, null, map1, map2, map3, null);
}
use of uk.gov.gchq.gaffer.types.FreqMap in project gaffer-doc by gchq.
the class PredicateMapExample method freqMapIsMoreThanOrEqualTo2.
public void freqMapIsMoreThanOrEqualTo2() {
// ---------------------------------------------------------
final PredicateMap function = new PredicateMap("key1", new IsMoreThan(2L, true));
// ---------------------------------------------------------
final FreqMap map1 = new FreqMap();
map1.put("key1", 1L);
final FreqMap map2 = new FreqMap();
map2.put("key1", 2L);
final FreqMap map3 = new FreqMap();
map3.put("key1", 3L);
final FreqMap map4 = new FreqMap();
map4.put("key1", 3L);
map4.put("key2", 0L);
final FreqMap map5 = new FreqMap();
map5.put("key2", 3L);
runExample(function, null, map1, map2, map3, map4, map5);
}
Aggregations