use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class AccumuloKeyValueReducer method setup.
@Override
protected void setup(final Context context) {
try {
schema = Schema.fromJson(context.getConfiguration().get(AddElementsFromHdfsJobFactory.SCHEMA).getBytes(CommonConstants.UTF_8));
} catch (final UnsupportedEncodingException e) {
throw new SchemaException("Unable to deserialise schema from JSON", e);
}
try {
final Class<?> elementConverterClass = Class.forName(context.getConfiguration().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
elementConverter = (AccumuloElementConverter) elementConverterClass.getConstructor(Schema.class).newInstance(schema);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new IllegalArgumentException("Failed to create accumulo element converter from class", e);
}
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class InputFormatTest method shouldReturnCorrectDataToMapReduceJobRespectingAuthorizations.
@Test
public void shouldReturnCorrectDataToMapReduceJobRespectingAuthorizations() throws Exception {
final Schema schema = getSchemaWithVisibilities();
final View view = new View.Builder().build();
final Set<String> expectedResultsPublicNotPrivate = new HashSet<>();
final Set<String> expectedResultsPrivate = new HashSet<>();
for (final Element element : DATA_WITH_VISIBILITIES) {
expectedResultsPrivate.add(element.toString());
if (element.getProperty("visibility").equals("public")) {
expectedResultsPublicNotPrivate.add(element.toString());
}
}
final Set<String> privateAuth = new HashSet<>();
privateAuth.add("public");
privateAuth.add("private");
final Set<String> publicNotPrivate = new HashSet<>();
publicNotPrivate.add("public");
final User userWithPrivate = new User("user1", privateAuth);
final User userWithPublicNotPrivate = new User("user1", publicNotPrivate);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.BYTE_ENTITY_KEY_PACKAGE, DATA_WITH_VISIBILITIES, view, userWithPublicNotPrivate, "instance5", expectedResultsPublicNotPrivate);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.BYTE_ENTITY_KEY_PACKAGE, DATA_WITH_VISIBILITIES, view, userWithPrivate, "instance6", expectedResultsPrivate);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.CLASSIC_KEY_PACKAGE, DATA_WITH_VISIBILITIES, view, userWithPublicNotPrivate, "instance7", expectedResultsPublicNotPrivate);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.CLASSIC_KEY_PACKAGE, DATA_WITH_VISIBILITIES, view, userWithPrivate, "instance8", expectedResultsPrivate);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class InputFormatTest method shouldReturnCorrectDataToMapReduceJobWithView.
@Test
public void shouldReturnCorrectDataToMapReduceJobWithView() throws Exception {
final Schema schema = getSchema();
final View view = new View.Builder().edge(TestGroups.EDGE).build();
final Set<String> expectedResults = new HashSet<>();
for (final Element element : DATA) {
if (element.getGroup().equals(TestGroups.EDGE)) {
expectedResults.add(element.toString());
}
}
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.BYTE_ENTITY_KEY_PACKAGE, DATA, view, new User(), "instance3", expectedResults);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.CLASSIC_KEY_PACKAGE, DATA, view, new User(), "instance4", expectedResults);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class AddElementsFromHdfsIT method createGraph.
private Graph createGraph(final Class<? extends AccumuloKeyPackage> keyPackageClass) throws StoreException {
final Schema schema = Schema.fromJson(StreamUtil.schemas(getClass()));
final AccumuloProperties properties = AccumuloProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
properties.setKeyPackageClass(keyPackageClass.getName());
properties.setInstance("instance_" + keyPackageClass.getName());
final AccumuloStore store = new MockAccumuloStore();
store.initialise(schema, properties);
store.updateConfiguration(createLocalConf(), new View(), new User());
return new Graph.Builder().store(store).build();
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class BloomFilterIT 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);
}
Aggregations