Search in sources :

Example 1 with GraphFrame

use of org.graphframes.GraphFrame in project Gaffer by gchq.

the class GraphFrameToIterableRowTest method shouldConvertGraphFrameToIterableOfRows.

@Test
public void shouldConvertGraphFrameToIterableOfRows() {
    // Given
    final SparkSession sparkSession = SparkSessionProvider.getSparkSession();
    final Function<GraphFrame, Iterable<? extends Row>> function = new GraphFrameToIterableRow();
    final GraphFrame graphFrame = Graphs$.MODULE$.friends();
    // When
    final Iterable<? extends Row> result = function.apply(graphFrame);
    final List<Row> resultList = Lists.newArrayList(result);
    // Then
    assertThat(resultList).hasSize(15);
}
Also used : SparkSession(org.apache.spark.sql.SparkSession) GraphFrame(org.graphframes.GraphFrame) Row(org.apache.spark.sql.Row) Test(org.junit.jupiter.api.Test)

Example 2 with GraphFrame

use of org.graphframes.GraphFrame in project Gaffer by gchq.

the class GetGraphFrameOfElementsHandlerTest method shouldGetCorrectElementsInGraphFrameWithNoElements.

@Test
public void shouldGetCorrectElementsInGraphFrameWithNoElements() throws OperationException {
    // Given
    final Graph graph = getGraph("/schema-GraphFrame/elements.json", new ArrayList<>());
    final GetGraphFrameOfElements gfOperation = new GetGraphFrameOfElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).edge(TestGroups.EDGE_2).entity(TestGroups.ENTITY).entity(TestGroups.ENTITY_2).build()).build();
    // When
    final GraphFrame graphFrame = graph.execute(gfOperation, new User());
    // Then
    assertTrue(graphFrame.edges().javaRDD().isEmpty());
    assertTrue(graphFrame.vertices().javaRDD().isEmpty());
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) User(uk.gov.gchq.gaffer.user.User) GraphFrame(org.graphframes.GraphFrame) GetGraphFrameOfElements(uk.gov.gchq.gaffer.spark.operation.graphframe.GetGraphFrameOfElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Aggregations

GraphFrame (org.graphframes.GraphFrame)2 Test (org.junit.jupiter.api.Test)2 Row (org.apache.spark.sql.Row)1 SparkSession (org.apache.spark.sql.SparkSession)1 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 GetGraphFrameOfElements (uk.gov.gchq.gaffer.spark.operation.graphframe.GetGraphFrameOfElements)1 User (uk.gov.gchq.gaffer.user.User)1