Search in sources :

Example 1 with SerialisationFactory

use of uk.gov.gchq.gaffer.store.SerialisationFactory in project Gaffer by gchq.

the class SchemaOptimiserTest method shouldAddDefaultSerialisers.

@Test
public void shouldAddDefaultSerialisers() {
    // Given
    final SerialisationFactory serialisationFactory = mock(SerialisationFactory.class);
    final SchemaOptimiser optimiser = new SchemaOptimiser(serialisationFactory);
    final boolean isOrdered = true;
    final StringSerialiser stringSerialiser = mock(StringSerialiser.class);
    final OrderedIntegerSerialiser intSerialiser = mock(OrderedIntegerSerialiser.class);
    final JavaSerialiser javaSerialiser = mock(JavaSerialiser.class);
    given(serialisationFactory.getSerialiser(String.class, true, true)).willReturn(stringSerialiser);
    given(serialisationFactory.getSerialiser(Integer.class, false, false)).willReturn(intSerialiser);
    given(serialisationFactory.getSerialiser(Serializable.class, true, true)).willReturn(javaSerialiser);
    given(javaSerialiser.canHandle(Mockito.any(Class.class))).willReturn(true);
    schema = new Schema.Builder().merge(schema).type("obj", Serializable.class).entity(TestGroups.ENTITY_2, new SchemaEntityDefinition.Builder().vertex("obj").build()).build();
    // When
    final Schema optimisedSchema = optimiser.optimise(schema, isOrdered);
    // Then
    assertSame(stringSerialiser, optimisedSchema.getType("string").getSerialiser());
    assertSame(intSerialiser, optimisedSchema.getType("int").getSerialiser());
    assertSame(javaSerialiser, optimisedSchema.getVertexSerialiser());
    verify(serialisationFactory, never()).getSerialiser(String.class, false, true);
    verify(serialisationFactory, never()).getSerialiser(Serializable.class, false, true);
}
Also used : StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) Serializable(java.io.Serializable) JavaSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser) OrderedIntegerSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.ordered.OrderedIntegerSerialiser) SerialisationFactory(uk.gov.gchq.gaffer.store.SerialisationFactory) Test(org.junit.jupiter.api.Test)

Example 2 with SerialisationFactory

use of uk.gov.gchq.gaffer.store.SerialisationFactory in project Gaffer by gchq.

the class AccumuloSerialisationFactoryTest method shouldReturnCustomSerialiserForCustomClass.

@Test
public void shouldReturnCustomSerialiserForCustomClass() throws SerialisationException {
    // Given
    final SerialisationFactory factory = new AccumuloSerialisationFactory();
    final Class<?> clazz = HyperLogLogPlus.class;
    // When
    final Serialiser serialiser = factory.getSerialiser(clazz);
    // Then
    assertTrue(serialiser.canHandle(clazz));
    assertEquals(HyperLogLogPlusSerialiser.class, serialiser.getClass());
}
Also used : HyperLogLogPlus(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) HyperLogLogPlusSerialiser(uk.gov.gchq.gaffer.sketches.clearspring.cardinality.serialisation.HyperLogLogPlusSerialiser) SerialisationFactory(uk.gov.gchq.gaffer.store.SerialisationFactory) Test(org.junit.jupiter.api.Test)

Example 3 with SerialisationFactory

use of uk.gov.gchq.gaffer.store.SerialisationFactory in project Gaffer by gchq.

the class TestUtils method gafferSchema.

public static Schema gafferSchema(final String schemaFolder) {
    final Schema schema = Schema.fromJson(StreamUtil.openStreams(TestUtils.class, schemaFolder));
    final SchemaOptimiser schemaOptimiser = new SchemaOptimiser(new SerialisationFactory(ParquetStore.SERIALISERS));
    return schemaOptimiser.optimise(schema, true);
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) SchemaOptimiser(uk.gov.gchq.gaffer.store.schema.SchemaOptimiser) SerialisationFactory(uk.gov.gchq.gaffer.store.SerialisationFactory)

Example 4 with SerialisationFactory

use of uk.gov.gchq.gaffer.store.SerialisationFactory in project Gaffer by gchq.

the class HBaseSerialisationFactoryTest method shouldReturnCustomSerialiserForCustomClass.

@Test
public void shouldReturnCustomSerialiserForCustomClass() throws SerialisationException {
    // Given
    final SerialisationFactory factory = new HBaseSerialisationFactory();
    final Class<?> clazz = HyperLogLogPlus.class;
    // When
    final Serialiser serialiser = factory.getSerialiser(clazz);
    // Then
    assertTrue(serialiser.canHandle(clazz));
    assertEquals(HyperLogLogPlusSerialiser.class, serialiser.getClass());
}
Also used : HyperLogLogPlus(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) HyperLogLogPlusSerialiser(uk.gov.gchq.gaffer.sketches.clearspring.cardinality.serialisation.HyperLogLogPlusSerialiser) SerialisationFactory(uk.gov.gchq.gaffer.store.SerialisationFactory) Test(org.junit.jupiter.api.Test)

Aggregations

SerialisationFactory (uk.gov.gchq.gaffer.store.SerialisationFactory)4 Test (org.junit.jupiter.api.Test)3 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)2 Serialiser (uk.gov.gchq.gaffer.serialisation.Serialiser)2 HyperLogLogPlusSerialiser (uk.gov.gchq.gaffer.sketches.clearspring.cardinality.serialisation.HyperLogLogPlusSerialiser)2 Serializable (java.io.Serializable)1 JavaSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser)1 StringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser)1 OrderedIntegerSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.ordered.OrderedIntegerSerialiser)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1 SchemaOptimiser (uk.gov.gchq.gaffer.store.schema.SchemaOptimiser)1