GetJavaRDDOfElements

See javadoc - uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfElements

Available since Gaffer version 1.0.0

When executing a spark operation you can either let Gaffer create a SparkSession for you or you can add it yourself to the Context object and provide it when you execute the operation. e.g:

Context context = SparkContextUtil.createContext(new User("User01"), sparkSession);
graph.execute(operation, context);

Required fields

No required fields

Examples

Get java RDD of elements

Java
JSON
Full JSON
final GetJavaRDDOfElements operation = new GetJavaRDDOfElements.Builder()
        .input(new EdgeSeed(1, 2, true), new EdgeSeed(2, 3, true))
        .build();
{
  "class" : "GetJavaRDDOfElements",
  "input" : [ {
    "class" : "EdgeSeed",
    "source" : 1,
    "destination" : 2,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  }, {
    "class" : "EdgeSeed",
    "source" : 2,
    "destination" : 3,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  } ]
}
{
  "class" : "uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfElements",
  "input" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed",
    "source" : 1,
    "destination" : 2,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed",
    "source" : 2,
    "destination" : 3,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  } ]
}


The results are:

Entity[vertex=1,group=entity,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=1,destination=2,directed=true,group=edge,properties=Properties[count=<java.lang.Integer>3]]
Entity[vertex=2,group=entity,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=2,destination=3,directed=true,group=edge,properties=Properties[count=<java.lang.Integer>2]]
Entity[vertex=3,group=entity,properties=Properties[count=<java.lang.Integer>2]]

Get java RDD of elements with hadoop conf

Java
JSON
Full JSON
final Configuration conf = new Configuration();
conf.set("AN_OPTION", "A_VALUE");

final String encodedConf;
try {
    encodedConf = AbstractGetRDDHandler.convertConfigurationToString(conf);
} catch (final IOException e) {
    throw new RuntimeException("Unable to convert conf to string", e);
}

final GetJavaRDDOfElements operation = new GetJavaRDDOfElements.Builder()
        .input(new EdgeSeed(1, 2, true), new EdgeSeed(2, 3, true))
        .option(AbstractGetRDDHandler.HADOOP_CONFIGURATION_KEY, encodedConf)
        .build();
{
  "class" : "GetJavaRDDOfElements",
  "input" : [ {
    "class" : "EdgeSeed",
    "source" : 1,
    "destination" : 2,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  }, {
    "class" : "EdgeSeed",
    "source" : 2,
    "destination" : 3,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  } ],
  "options" : {
    "Hadoop_Configuration_Key" : "config removed for readability"
  }
}
{
  "class" : "uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfElements",
  "input" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed",
    "source" : 1,
    "destination" : 2,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed",
    "source" : 2,
    "destination" : 3,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  } ],
  "options" : {
    "Hadoop_Configuration_Key" : "config removed for readability"
  }
}


Get java RDD of elements returning edges only

Java
JSON
Full JSON
final GetJavaRDDOfElements operation = new GetJavaRDDOfElements.Builder()
        .input(new EdgeSeed(1, 2, true), new EdgeSeed(2, 3, true))
        .view(new View.Builder()
                .edge("edge")
                .build())
        .build();
{
  "class" : "GetJavaRDDOfElements",
  "input" : [ {
    "class" : "EdgeSeed",
    "source" : 1,
    "destination" : 2,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  }, {
    "class" : "EdgeSeed",
    "source" : 2,
    "destination" : 3,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  } ],
  "view" : {
    "edges" : {
      "edge" : { }
    }
  }
}
{
  "class" : "uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfElements",
  "input" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed",
    "source" : 1,
    "destination" : 2,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed",
    "source" : 2,
    "destination" : 3,
    "matchedVertex" : "SOURCE",
    "directedType" : "DIRECTED"
  } ],
  "view" : {
    "edges" : {
      "edge" : { }
    }
  }
}


The results are:

Edge[source=1,destination=2,directed=true,group=edge,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=2,destination=3,directed=true,group=edge,properties=Properties[count=<java.lang.Integer>2]]

results matching ""

    No results matching ""