use of uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore in project Gaffer by gchq.
the class AccumuloStoreRelationTest method testBuildScanSpecifyColumnsAndFiltersWithView.
private void testBuildScanSpecifyColumnsAndFiltersWithView(final View view, final String[] requiredColumns, final Filter[] filters, final Predicate<Element> returnElement) throws OperationException, StoreException {
// Given
final SparkSession sparkSession = SparkSessionProvider.getSparkSession();
final Schema schema = getSchema();
final AccumuloStore store = new SingleUseMiniAccumuloStore();
store.initialise("graphId", schema, PROPERTIES);
addElements(store);
// When
final AccumuloStoreRelation relation = new AccumuloStoreRelation(SparkContextUtil.createContext(new User(), sparkSession), Collections.emptyList(), view, store, null);
final RDD<Row> rdd = relation.buildScan(requiredColumns, filters);
final Row[] returnedElements = (Row[]) rdd.collect();
// Then
// - Actual results are:
final Set<Row> results = new HashSet<>(Arrays.asList(returnedElements));
// - Expected results are:
final SchemaToStructTypeConverter schemaConverter = new SchemaToStructTypeConverter(schema, view, new ArrayList<>());
final ConvertElementToRow elementConverter = new ConvertElementToRow(new LinkedHashSet<>(Arrays.asList(requiredColumns)), schemaConverter.getPropertyNeedsConversion(), schemaConverter.getConverterByProperty());
final Set<Row> expectedRows = new HashSet<>();
Streams.toStream(getElements()).filter(returnElement).map(elementConverter::apply).forEach(expectedRows::add);
assertEquals(expectedRows, results);
}
use of uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore in project Gaffer by gchq.
the class AccumuloStoreRelationTest method shouldReturnEmptyDataFrameWithNoResultsFromFilter.
@Test
public void shouldReturnEmptyDataFrameWithNoResultsFromFilter() throws StoreException, OperationException {
// Given
final SparkSession sparkSession = SparkSessionProvider.getSparkSession();
final Schema schema = getSchema();
final View view = getViewFromSchema(schema);
final AccumuloStore store = new SingleUseMiniAccumuloStore();
store.initialise("graphId", schema, PROPERTIES);
addElements(store);
final String[] requiredColumns = new String[1];
requiredColumns[0] = "property1";
final Filter[] filters = new Filter[1];
filters[0] = new EqualTo("group", "abc");
// When
final AccumuloStoreRelation relation = new AccumuloStoreRelation(SparkContextUtil.createContext(new User(), sparkSession), Collections.emptyList(), view, store, null);
final RDD<Row> rdd = relation.buildScan(requiredColumns, filters);
// Then
assertThat(rdd.isEmpty()).isTrue();
}
use of uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore in project Gaffer by gchq.
the class AccumuloSampleDataForSplitPointsJobFactoryTest method getStoreConfiguredWith.
@Override
protected Store getStoreConfiguredWith(final Class<JSONSerialiser> jsonSerialiserClass, final String jsonSerialiserModules, final Boolean strictJson) throws IOException, StoreException {
final AccumuloStore store = new SingleUseMiniAccumuloStore();
final Schema schema = Schema.fromJson(StreamUtil.schemas(AccumuloSampleDataForSplitPointsJobFactoryTest.class));
super.configureStoreProperties(PROPERTIES, jsonSerialiserClass, jsonSerialiserModules, strictJson);
store.initialise("graphId", schema, PROPERTIES);
final FileSystem fileSystem = FileSystem.getLocal(new Configuration());
fileSystem.mkdirs(new Path(outputDir));
fileSystem.mkdirs(new Path(splitsDir));
return store;
}
use of uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore in project Gaffer by gchq.
the class TableUtilsTest method shouldCreateTableWithCorrectLocalityGroups.
@Test
public void shouldCreateTableWithCorrectLocalityGroups() throws Exception {
final AccumuloStore store = new SingleUseMiniAccumuloStore();
final Schema schema = new Schema.Builder().type(TestTypes.ID_STRING, String.class).type(TestTypes.DIRECTED_TRUE, Boolean.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source(TestTypes.ID_STRING).destination(TestTypes.ID_STRING).directed(TestTypes.DIRECTED_TRUE).build()).build();
store.initialise(LOCALITY_GRAPH_ID, schema, PROPERTIES);
// When
TableUtils.createTable(store);
final Map<String, Set<Text>> localityGroups = store.getConnection().tableOperations().getLocalityGroups(LOCALITY_GRAPH_ID);
assertThat(localityGroups).hasSize(1);
Set<Text> localityGroup = localityGroups.get(TestGroups.EDGE);
assertThat(localityGroup).hasSize(1);
assertEquals(new Text(TestGroups.EDGE), localityGroup.toArray()[0]);
}
use of uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore in project Gaffer by gchq.
the class TableUtilsTest method shouldCreateTableWithAllRequiredIterators.
@Test
public void shouldCreateTableWithAllRequiredIterators() throws Exception {
// Given
final AccumuloStore store = new SingleUseMiniAccumuloStore();
final Schema schema = new Schema.Builder().type(TestTypes.ID_STRING, new TypeDefinition.Builder().aggregateFunction(new StringConcat()).clazz(String.class).build()).type(TestTypes.DIRECTED_TRUE, Boolean.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source(TestTypes.ID_STRING).destination(TestTypes.ID_STRING).directed(TestTypes.DIRECTED_TRUE).build()).build();
store.initialise(GRAPH_ID, schema, PROPERTIES);
// When
TableUtils.createTable(store);
// Then - this call will check the table is configured properly
TableUtils.ensureTableExists(store);
}
Aggregations