Search in sources :

Example 11 with GetRDDOfElements

use of uk.gov.gchq.gaffer.spark.operation.scalardd.GetRDDOfElements in project Gaffer by gchq.

the class FilterToOperationConverterTest method testSpecifyDestination.

@Test
public void testSpecifyDestination() {
    final Schema schema = getSchema();
    final SparkSession sparkSession = SparkSessionProvider.getSparkSession();
    final Filter[] filters = new Filter[1];
    filters[0] = new EqualTo(SchemaToStructTypeConverter.DST_COL_NAME, "0");
    final FiltersToOperationConverter converter = new FiltersToOperationConverter(getViewFromSchema(schema), schema, filters);
    final Operation operation = converter.getOperation();
    assertTrue(operation instanceof GetRDDOfElements);
    assertEquals(0, ((GraphFilters) operation).getView().getEntityGroups().size());
    assertEquals(EDGE_GROUPS, ((GraphFilters) operation).getView().getEdgeGroups());
    final Set<EntityId> seeds = new HashSet<>();
    for (final Object seed : ((GetRDDOfElements) operation).getInput()) {
        seeds.add((EntitySeed) seed);
    }
    assertEquals(Collections.singleton(new EntitySeed("0")), seeds);
}
Also used : SparkSession(org.apache.spark.sql.SparkSession) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GraphFilters(uk.gov.gchq.gaffer.operation.graph.GraphFilters) Operation(uk.gov.gchq.gaffer.operation.Operation) EqualTo(org.apache.spark.sql.sources.EqualTo) EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Filter(org.apache.spark.sql.sources.Filter) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetRDDOfElements(uk.gov.gchq.gaffer.spark.operation.scalardd.GetRDDOfElements) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

GetRDDOfElements (uk.gov.gchq.gaffer.spark.operation.scalardd.GetRDDOfElements)11 HashSet (java.util.HashSet)9 Test (org.junit.jupiter.api.Test)8 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)8 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)7 ArrayList (java.util.ArrayList)6 EqualTo (org.apache.spark.sql.sources.EqualTo)6 Filter (org.apache.spark.sql.sources.Filter)6 Configuration (org.apache.hadoop.conf.Configuration)5 SparkSession (org.apache.spark.sql.SparkSession)5 Element (uk.gov.gchq.gaffer.data.element.Element)5 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)5 Graph (uk.gov.gchq.gaffer.graph.Graph)5 Operation (uk.gov.gchq.gaffer.operation.Operation)5 GraphFilters (uk.gov.gchq.gaffer.operation.graph.GraphFilters)5 Schema (uk.gov.gchq.gaffer.store.schema.Schema)5 User (uk.gov.gchq.gaffer.user.User)5 Edge (uk.gov.gchq.gaffer.data.element.Edge)4 Entity (uk.gov.gchq.gaffer.data.element.Entity)4 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)4