Search in sources :

Example 6 with JavaSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser in project Gaffer by gchq.

the class BloomFilter18IT method setup.

@Before
public void setup() {
    Schema schema = new Schema.Builder().type(TestTypes.PROP_INTEGER, Integer.class).vertexSerialiser(new JavaSerialiser()).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().property(AccumuloPropertyNames.INT, TestTypes.PROP_INTEGER).build()).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(AccumuloPropertyNames.INT, TestTypes.PROP_INTEGER).build()).build();
    byteEntityRangeFactory = new ByteEntityRangeFactory(schema);
    byteEntityElementConverter = new ByteEntityAccumuloElementConverter(schema);
    Gaffer1RangeFactory = new ClassicRangeFactory(schema);
    gafferV1ElementConverter = new ClassicAccumuloElementConverter(schema);
}
Also used : ByteEntityRangeFactory(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityRangeFactory) ClassicRangeFactory(uk.gov.gchq.gaffer.accumulostore.key.core.impl.classic.ClassicRangeFactory) JavaSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser) ClassicAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.classic.ClassicAccumuloElementConverter) Schema(uk.gov.gchq.gaffer.store.schema.Schema) SchemaEdgeDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Before(org.junit.Before)

Example 7 with JavaSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser in project Gaffer by gchq.

the class SchemaOptimiser method getDefaultVertexSerialiser.

private Serialisation getDefaultVertexSerialiser(final Schema schema, final boolean isStoreOrdered) {
    if (null != schema.getVertexSerialiser()) {
        return schema.getVertexSerialiser();
    }
    final Set<Class<?>> vertexClasses = new HashSet<>();
    for (final SchemaEntityDefinition definition : schema.getEntities().values()) {
        vertexClasses.add(definition.getIdentifierClass(IdentifierType.VERTEX));
    }
    for (final SchemaEdgeDefinition definition : schema.getEdges().values()) {
        vertexClasses.add(definition.getIdentifierClass(IdentifierType.SOURCE));
        vertexClasses.add(definition.getIdentifierClass(IdentifierType.DESTINATION));
    }
    vertexClasses.remove(null);
    if (!vertexClasses.isEmpty()) {
        Serialisation serialiser = null;
        if (vertexClasses.size() == 1) {
            serialiser = serialisationFactory.getSerialiser(vertexClasses.iterator().next(), isStoreOrdered);
        } else {
            for (final Class<?> clazz : vertexClasses) {
                serialiser = serialisationFactory.getSerialiser(clazz, isStoreOrdered);
                boolean canHandlerAll = true;
                for (final Class<?> clazz2 : vertexClasses) {
                    if (!serialiser.canHandle(clazz2)) {
                        canHandlerAll = false;
                        serialiser = null;
                        break;
                    }
                }
                if (canHandlerAll) {
                    break;
                }
            }
        }
        if (null == serialiser) {
            throw new IllegalArgumentException("No default serialiser could be found that would support all vertex class types " + vertexClasses.toString() + ", please implement your own or change your vertex class types.");
        }
        if (serialiser instanceof JavaSerialiser) {
            LOGGER.warn("Java serialisation is not recommended for vertex serialisation - it may cause aggregation to fail. Please implement your own or change your vertex class types.");
        }
        return serialiser;
    }
    return null;
}
Also used : JavaSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser) Serialisation(uk.gov.gchq.gaffer.serialisation.Serialisation) HashSet(java.util.HashSet)

Aggregations

JavaSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser)7 Before (org.junit.Before)4 Schema (uk.gov.gchq.gaffer.store.schema.Schema)4 ByteEntityAccumuloElementConverter (uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter)3 ClassicAccumuloElementConverter (uk.gov.gchq.gaffer.accumulostore.key.core.impl.classic.ClassicAccumuloElementConverter)3 Test (org.junit.Test)2 ByteEntityRangeFactory (uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityRangeFactory)2 ClassicRangeFactory (uk.gov.gchq.gaffer.accumulostore.key.core.impl.classic.ClassicRangeFactory)2 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)2 Serializable (java.io.Serializable)1 HashSet (java.util.HashSet)1 Serialisation (uk.gov.gchq.gaffer.serialisation.Serialisation)1 SerialisationFactory (uk.gov.gchq.gaffer.serialisation.implementation.SerialisationFactory)1 StringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser)1