Search in sources :

Example 36 with FreqMap

use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.

the class ToFreqMapTest method shouldConvertObjectToFreqMap.

@Test
public void shouldConvertObjectToFreqMap() {
    // Given
    final ToFreqMap function = new ToFreqMap();
    final Object value = 1L;
    // When
    final FreqMap result = function.apply(value);
    // Then
    assertEquals(new FreqMap(value.toString()), result);
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) Test(org.junit.jupiter.api.Test) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest)

Example 37 with FreqMap

use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.

the class ToFreqMapTest method shouldConvertStringToFreqMap.

@Test
public void shouldConvertStringToFreqMap() {
    // Given
    final ToFreqMap function = new ToFreqMap();
    final String value = "value1";
    // When
    final FreqMap result = function.apply(value);
    // Then
    assertEquals(new FreqMap(value), result);
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) Test(org.junit.jupiter.api.Test) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest)

Example 38 with FreqMap

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 = serialiser.deserialise(serialised);
    assertFalse(deserialised.containsKey("x"));
    assertEquals((Long) 5L, deserialised.get("y"));
    assertEquals((Long) 20L, deserialised.get("z"));
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) Test(org.junit.jupiter.api.Test)

Example 39 with FreqMap

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 = 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"));
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) Test(org.junit.jupiter.api.Test)

Example 40 with FreqMap

use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.

the class FreqMapSerialiserTest method shouldSerialiseDeserialiseFreqMapWithAnEmptyKey.

@Test
public void shouldSerialiseDeserialiseFreqMapWithAnEmptyKey() throws SerialisationException {
    // Given
    final FreqMap freqMap = new FreqMap();
    freqMap.put("", 10L);
    freqMap.put("y", 5L);
    freqMap.put("z", 20L);
    // When
    final byte[] serialised = serialiser.serialise(freqMap);
    final FreqMap deserialised = serialiser.deserialise(serialised);
    assertEquals((Long) 10L, deserialised.get(""));
    assertEquals((Long) 5L, deserialised.get("y"));
    assertEquals((Long) 20L, deserialised.get("z"));
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) Test(org.junit.jupiter.api.Test)

Aggregations

FreqMap (uk.gov.gchq.gaffer.types.FreqMap)62 Test (org.junit.jupiter.api.Test)29 ArrayList (java.util.ArrayList)9 Edge (uk.gov.gchq.gaffer.data.element.Edge)9 Entity (uk.gov.gchq.gaffer.data.element.Entity)9 Date (java.util.Date)6 Schema (uk.gov.gchq.gaffer.store.schema.Schema)6 FunctionTest (uk.gov.gchq.koryphe.function.FunctionTest)6 Configuration (org.apache.hadoop.conf.Configuration)5 FileSystem (org.apache.hadoop.fs.FileSystem)5 Path (org.apache.hadoop.fs.Path)5 Row (org.apache.spark.sql.Row)5 SparkSession (org.apache.spark.sql.SparkSession)5 WrappedArray (scala.collection.mutable.WrappedArray)5 Element (uk.gov.gchq.gaffer.data.element.Element)5 HashMap (java.util.HashMap)4 Key (org.apache.accumulo.core.data.Key)4 Test (org.junit.Test)4 EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)4 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)4