use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class ElementInputFormat method createRecordReader.
@Override
public RecordReader<Element, NullWritable> createRecordReader(final InputSplit split, final TaskAttemptContext context) throws IOException, InterruptedException {
log.setLevel(getLogLevel(context));
final Configuration conf = context.getConfiguration();
final String keyPackageClass = conf.get(KEY_PACKAGE);
final Schema schema = Schema.fromJson(conf.get(SCHEMA).getBytes(CommonConstants.UTF_8));
final View view = View.fromJson(conf.get(VIEW).getBytes(CommonConstants.UTF_8));
try {
return new ElementWithPropertiesRecordReader(keyPackageClass, schema, view);
} catch (final StoreException | SchemaException | SerialisationException e) {
throw new IOException("Exception creating RecordReader", e);
}
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnTrueWhenEmptyFunctions.
@Test
public void shouldValidateAndReturnTrueWhenEmptyFunctions() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().build();
final Schema schema = new Schema();
// When
final boolean isValid = validator.validate(view, schema, false);
// Then
assertTrue(isValid);
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnFalseWhenEdgeTransformerProjectsToMissingProperty.
@Test
public void shouldValidateAndReturnFalseWhenEdgeTransformerProjectsToMissingProperty() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().transformer(new ElementTransformer.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).project(TestPropertyNames.PROP_3).execute(new ExampleTransformFunction()).build()).build()).build();
final Schema schema = new Schema.Builder().type("int", Integer.class).type("string", String.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().property(TestPropertyNames.PROP_1, "int").property(TestPropertyNames.PROP_2, "string").build()).build();
// When
final boolean isValid = validator.validate(view, schema, false);
// Then
assertFalse(isValid);
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnFalseWhenEntityTransformerSelectionMissingProperty.
@Test
public void shouldValidateAndReturnFalseWhenEntityTransformerSelectionMissingProperty() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_3, String.class).transformer(new ElementTransformer.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).project(TestPropertyNames.PROP_3).execute(new ExampleTransformFunction()).build()).build()).build();
final Schema schema = new Schema.Builder().type("obj", Object.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, "obj").build()).build();
// When
final boolean isValid = validator.validate(view, schema, false);
// Then
assertFalse(isValid);
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnTrueNoGroupByProperties.
@Test
public void shouldValidateAndReturnTrueNoGroupByProperties() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().entity(TestGroups.ENTITY).edge(TestGroups.EDGE).build();
final Schema schema = new Schema.Builder().type("vertex", String.class).type("true", Boolean.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("vertex").build()).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").directed("true").build()).build();
// When
final boolean isValid = validator.validate(view, schema, false);
// Then
assertTrue(isValid);
}
Aggregations