Search in sources :

Example 1 with FreqMapAggregator

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

the class AbstractAccumuloElementConverterTest method shouldSerialiseAndDeserialisePropertiesWhenAllAreEmpty.

@Test
public void shouldSerialiseAndDeserialisePropertiesWhenAllAreEmpty() {
    // 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.types.function.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.jupiter.api.Test)

Example 2 with FreqMapAggregator

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

the class ElementSerialisationTest method shouldSerialiseAndDeserialisePropertiesWhenAllAreEmpty.

@Test
public void shouldSerialiseAndDeserialisePropertiesWhenAllAreEmpty() throws Exception {
    // Given
    final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("string").property(HBasePropertyNames.PROP_1, "map").property(HBasePropertyNames.PROP_2, "map").build()).type("string", String.class).type("map", new TypeDefinition.Builder().clazz(FreqMap.class).aggregateFunction(new FreqMapAggregator()).serialiser(new FreqMapSerialiser()).build()).build();
    serialisation = new ElementSerialisation(schema);
    final Entity entity = new Entity.Builder().vertex("vertex1").property(HBasePropertyNames.PROP_1, new FreqMap()).property(HBasePropertyNames.PROP_2, new FreqMap()).build();
    // When 1
    final byte[] value = serialisation.getValue(TestGroups.ENTITY, entity.getProperties());
    // Then 1
    assertArrayEquals(new byte[] { ByteArrayEscapeUtils.DELIMITER, ByteArrayEscapeUtils.DELIMITER }, value);
    // When 2
    final Properties properties = serialisation.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.types.function.FreqMapAggregator) Properties(uk.gov.gchq.gaffer.data.element.Properties) FreqMapSerialiser(uk.gov.gchq.gaffer.serialisation.FreqMapSerialiser) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 Entity (uk.gov.gchq.gaffer.data.element.Entity)2 Properties (uk.gov.gchq.gaffer.data.element.Properties)2 FreqMapSerialiser (uk.gov.gchq.gaffer.serialisation.FreqMapSerialiser)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 FreqMap (uk.gov.gchq.gaffer.types.FreqMap)2 FreqMapAggregator (uk.gov.gchq.gaffer.types.function.FreqMapAggregator)2 Value (org.apache.accumulo.core.data.Value)1