use of uk.gov.gchq.gaffer.serialisation.Serialiser in project Gaffer by gchq.
the class Store method validateSchemas.
public void validateSchemas() {
final ValidationResult validationResult = new ValidationResult();
if (null == schema) {
validationResult.addError("Schema is missing");
} else {
validationResult.add(schema.validate());
getSchemaElements().forEach((key, value) -> value.getProperties().forEach(propertyName -> {
final Class propertyClass = value.getPropertyClass(propertyName);
final Serialiser serialisation = value.getPropertyTypeDef(propertyName).getSerialiser();
if (null == serialisation) {
validationResult.addError(String.format("Could not find a serialiser for property '%s' in the group '%s'.", propertyName, key));
} else if (!serialisation.canHandle(propertyClass)) {
validationResult.addError(String.format("Schema serialiser (%s) for property '%s' in the group '%s' cannot handle property found in the schema", serialisation.getClass().getName(), propertyName, key));
}
}));
validateSchema(validationResult, getSchema().getVertexSerialiser());
getSchema().getTypes().forEach((k, v) -> validateSchema(validationResult, v.getSerialiser()));
}
if (!validationResult.isValid()) {
throw new SchemaException("Schema is not valid. " + validationResult.getErrorString());
}
}
use of uk.gov.gchq.gaffer.serialisation.Serialiser in project Gaffer by gchq.
the class Store method validateSchemaElementDefinition.
protected void validateSchemaElementDefinition(final Map.Entry<String, SchemaElementDefinition> schemaElementDefinitionEntry, final ValidationResult validationResult) {
schemaElementDefinitionEntry.getValue().getProperties().forEach(propertyName -> {
final Class propertyClass = schemaElementDefinitionEntry.getValue().getPropertyClass(propertyName);
final Serialiser serialisation = schemaElementDefinitionEntry.getValue().getPropertyTypeDef(propertyName).getSerialiser();
if (null == serialisation) {
validationResult.addError(String.format("Could not find a serialiser for property '%s' in the group '%s'.", propertyName, schemaElementDefinitionEntry.getKey()));
} else if (!serialisation.canHandle(propertyClass)) {
validationResult.addError(String.format("Schema serialiser (%s) for property '%s' in the group '%s' cannot handle property found in the schema", serialisation.getClass().getName(), propertyName, schemaElementDefinitionEntry.getKey()));
}
});
}
use of uk.gov.gchq.gaffer.serialisation.Serialiser in project Gaffer by gchq.
the class AccumuloStoreTest method shouldAllowRangeScanOperationsWhenVertexSerialiserDoesPreserveObjectOrdering.
@Test
public void shouldAllowRangeScanOperationsWhenVertexSerialiserDoesPreserveObjectOrdering() throws StoreException {
// Given
final AccumuloStore store = new AccumuloStore();
final Serialiser serialiser = new StringSerialiser();
store.preInitialise(BYTE_ENTITY_GRAPH, new Schema.Builder().vertexSerialiser(serialiser).build(), PROPERTIES);
// When
final boolean isGetElementsInRangesSupported = store.isSupported(GetElementsInRanges.class);
final boolean isSummariseGroupOverRangesSupported = store.isSupported(SummariseGroupOverRanges.class);
// Then
assertTrue(isGetElementsInRangesSupported);
assertTrue(isSummariseGroupOverRangesSupported);
}
use of uk.gov.gchq.gaffer.serialisation.Serialiser in project Gaffer by gchq.
the class AccumuloStoreTest method shouldNotAllowRangeScanOperationsWhenVertexSerialiserDoesNotPreserveObjectOrdering.
@Test
public void shouldNotAllowRangeScanOperationsWhenVertexSerialiserDoesNotPreserveObjectOrdering() throws StoreException {
// Given
final AccumuloStore store = new AccumuloStore();
final Serialiser serialiser = new CompactRawLongSerialiser();
store.preInitialise(BYTE_ENTITY_GRAPH, new Schema.Builder().vertexSerialiser(serialiser).build(), PROPERTIES);
// When
final boolean isGetElementsInRangesSupported = store.isSupported(GetElementsInRanges.class);
final boolean isSummariseGroupOverRangesSupported = store.isSupported(SummariseGroupOverRanges.class);
// Then
assertFalse(isGetElementsInRangesSupported);
assertFalse(isSummariseGroupOverRangesSupported);
}
use of uk.gov.gchq.gaffer.serialisation.Serialiser 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());
}
Aggregations