Search in sources :

Example 16 with FreqMap

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

the class AbstractAccumuloElementConverterTest method shouldSerialiseAndDeserialisePropertiesWhenAllAreEmpty.

@Test
public void shouldSerialiseAndDeserialisePropertiesWhenAllAreEmpty() throws AccumuloElementConversionException {
    // Given

    final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("string").property(TestPropertyNames.PROP_1, "map").property(TestPropertyNames.PROP_2, "map").build()).type("string", String.class).type("map", new TypeDefinition.Builder().clazz(FreqMap.class).aggregateFunction(new FreqMapAggregator()).serialiser(new FreqMapSerialiser()).build()).build();
    converter = createConverter(schema);
    final Entity entity = new Entity.Builder().vertex("vertex1").property(TestPropertyNames.PROP_1, new FreqMap()).property(TestPropertyNames.PROP_2, new FreqMap()).build();
    // When 1

    final Value value = converter.getValueFromProperties(TestGroups.ENTITY, entity.getProperties());
    // Then 1
    assertTrue(value.getSize() > 0);
    // When 2
    final Properties properties = converter.getPropertiesFromValue(TestGroups.ENTITY, value);
    // Then 2
    assertEquals(entity.getProperties(), properties);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) FreqMap(uk.gov.gchq.gaffer.types.FreqMap) Schema(uk.gov.gchq.gaffer.store.schema.Schema) FreqMapAggregator(uk.gov.gchq.gaffer.function.aggregate.FreqMapAggregator) Value(org.apache.accumulo.core.data.Value) Properties(uk.gov.gchq.gaffer.data.element.Properties) FreqMapSerialiser(uk.gov.gchq.gaffer.serialisation.FreqMapSerialiser) Test(org.junit.Test)

Aggregations

FreqMap (uk.gov.gchq.gaffer.types.FreqMap)16 Test (org.junit.Test)10 Entity (uk.gov.gchq.gaffer.data.element.Entity)3 MapFilter (uk.gov.gchq.gaffer.function.MapFilter)3 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)2 ArrayList (java.util.ArrayList)2 Edge (uk.gov.gchq.gaffer.data.element.Edge)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 AggregateFunctionTest (uk.gov.gchq.gaffer.function.AggregateFunctionTest)2 IsMoreThan (uk.gov.gchq.gaffer.function.filter.IsMoreThan)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Value (org.apache.accumulo.core.data.Value)1 Properties (uk.gov.gchq.gaffer.data.element.Properties)1 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)1 FilterFunctionTest (uk.gov.gchq.gaffer.function.FilterFunctionTest)1 FreqMapAggregator (uk.gov.gchq.gaffer.function.aggregate.FreqMapAggregator)1 FreqMapSerialiser (uk.gov.gchq.gaffer.serialisation.FreqMapSerialiser)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1