use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapSerialiserTest method getHistoricSerialisationPairs.
@Override
public Pair<FreqMap, byte[]>[] getHistoricSerialisationPairs() {
final FreqMap freqMap = new FreqMap();
freqMap.put("x", 10L);
freqMap.put("y", 5L);
freqMap.put("z", 20L);
return new Pair[] { new Pair(freqMap, new byte[] { 120, 0, 10, 0, 121, 0, 5, 0, 122, 0, 20 }) };
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapPredicatorTest method shouldFilterMapWithMultipleResults.
@Test
public void shouldFilterMapWithMultipleResults() {
// given
final Regex predicate = new Regex("^\\wo\\w$");
final FreqMapPredicator fRegexPredicator = new FreqMapPredicator(predicate);
// when
final FreqMap fRegex = fRegexPredicator.apply(freqMap);
// then
assertEquals(fRegex.size(), 2);
assertTrue(fRegex.containsKey("cow"));
assertTrue(fRegex.containsKey("dog"));
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapPredicatorTest method shouldNotMutateOriginalValue.
@Test
public void shouldNotMutateOriginalValue() {
// given
final Regex predicate = new Regex("^\\wo\\w$");
final FreqMapPredicator fRegexPredicator = new FreqMapPredicator(predicate);
// when
final FreqMap fRegex = fRegexPredicator.apply(freqMap);
// then
assertEquals(fRegex.size(), 2);
assertTrue(fRegex.containsKey("cow"));
assertTrue(fRegex.containsKey("dog"));
assertEquals(freqMap.size(), 4);
assertTrue(freqMap.containsKey("cat"));
assertTrue(freqMap.containsKey("dog"));
assertTrue(freqMap.containsKey("catdog"));
assertTrue(freqMap.containsKey("cow"));
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapPredicatorTest method initFreqMap.
@BeforeEach
public void initFreqMap() {
this.freqMap = new FreqMap();
freqMap.upsert("cat");
freqMap.upsert("cat");
freqMap.upsert("dog");
freqMap.upsert("cow");
freqMap.upsert("cow");
freqMap.upsert("catdog");
freqMap.upsert("catdog");
freqMap.upsert("catdog");
freqMap.upsert("cat");
freqMap.upsert("cat");
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class IterableToFreqMapTest method shouldIncrementTheValueOfTheKeyByOne.
@Test
public void shouldIncrementTheValueOfTheKeyByOne() {
// Given
Iterable<String> strings = (Iterable<String>) Arrays.asList("one", "one");
final IterableToFreqMap iterableToFreqMap = new IterableToFreqMap();
// When
FreqMap result = iterableToFreqMap.apply(strings);
// Then
HashMap<String, Long> input = new HashMap<>();
input.put("one", 2L);
FreqMap expected = new FreqMap(input);
assertEquals(expected, result);
}
Aggregations