use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapSerialiserTest method canSerialiseEmptyFreqMap.
@Test
public void canSerialiseEmptyFreqMap() throws SerialisationException {
byte[] b = serialiser.serialise(new FreqMap());
Object o = serialiser.deserialise(b);
assertEquals(FreqMap.class, o.getClass());
assertEquals(0, ((FreqMap) o).size());
}
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 by gchq.
the class FreqMapSerialiserTest method shouldSkipEntryWithNullKey.
@Test
public void shouldSkipEntryWithNullKey() throws SerialisationException {
// Given
final FreqMap freqMap = new FreqMap();
freqMap.put(null, 10L);
freqMap.put("y", 5L);
freqMap.put("z", 20L);
// When
final byte[] serialised = serialiser.serialise(freqMap);
final FreqMap deserialised = (FreqMap) serialiser.deserialise(serialised);
assertFalse(deserialised.containsKey("x"));
assertEquals((Long) 5L, deserialised.get("y"));
assertEquals((Long) 20L, deserialised.get("z"));
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapSerialiserTest method shouldSkipEntryWithNullValues.
@Test
public void shouldSkipEntryWithNullValues() throws SerialisationException {
// Given
final FreqMap freqMap = new FreqMap();
freqMap.put("v", null);
freqMap.put("w", 5L);
freqMap.put("x", null);
freqMap.put("y", 20L);
freqMap.put("z", null);
// When
final byte[] serialised = serialiser.serialise(freqMap);
final FreqMap deserialised = (FreqMap) serialiser.deserialise(serialised);
assertFalse(deserialised.containsKey("v"));
assertEquals((Long) 5L, deserialised.get("w"));
assertFalse(deserialised.containsKey("x"));
assertEquals((Long) 20L, deserialised.get("y"));
assertFalse(deserialised.containsKey("z"));
}
Aggregations