GenerateObjects

See javadoc - uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects

Available since Gaffer version 1.0.0

Required fields

The following fields are required:

  • elementGenerator

Examples

Generate strings from elements

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final GenerateObjects<String> operation = new GenerateObjects.Builder<String>()
        .input(new Entity.Builder()
                        .group("entity")
                        .vertex(6)
                        .property("count", 1)
                        .build(),
                new Edge.Builder()
                        .group("edge")
                        .source(5).dest(6).directed(true)
                        .property("count", 1)
                        .build())
        .generator(new ObjectGenerator())
        .build();
{
  "class" : "GenerateObjects",
  "input" : [ {
    "class" : "Entity",
    "group" : "entity",
    "vertex" : 6,
    "properties" : {
      "count" : 1
    }
  }, {
    "class" : "Edge",
    "group" : "edge",
    "source" : 5,
    "destination" : 6,
    "directed" : true,
    "properties" : {
      "count" : 1
    }
  } ],
  "elementGenerator" : {
    "class" : "ObjectGenerator"
  }
}
{
  "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects",
  "input" : [ {
    "class" : "uk.gov.gchq.gaffer.data.element.Entity",
    "group" : "entity",
    "vertex" : 6,
    "properties" : {
      "count" : 1
    }
  }, {
    "class" : "uk.gov.gchq.gaffer.data.element.Edge",
    "group" : "edge",
    "source" : 5,
    "destination" : 6,
    "directed" : true,
    "properties" : {
      "count" : 1
    }
  } ],
  "elementGenerator" : {
    "class" : "uk.gov.gchq.gaffer.doc.operation.generator.ObjectGenerator"
  }
}
g.GenerateObjects( 
  input=[ 
    g.Entity( 
      group="entity", 
      properties={'count': 1}, 
      vertex=6 
    ), 
    g.Edge( 
      group="edge", 
      properties={'count': 1}, 
      source=5, 
      directed=True, 
      destination=6 
    ) 
  ], 
  element_generator=g.ElementGenerator( 
    class_name="uk.gov.gchq.gaffer.doc.operation.generator.ObjectGenerator", 
    fields={'class': 'uk.gov.gchq.gaffer.doc.operation.generator.ObjectGenerator'} 
  ) 
)

Result:

Java
JSON
6,1
5,6,1
[ "6,1", "5,6,1" ]


Generate domain objects from elements

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final GenerateObjects<Object> operation = new GenerateObjects.Builder<>()
        .input(new Entity.Builder()
                        .group("entity")
                        .vertex(6)
                        .property("count", 1)
                        .build(),
                new Edge.Builder()
                        .group("edge")
                        .source(5).dest(6).directed(true)
                        .property("count", 1)
                        .build())
        .generator(new DomainObjectGenerator())
        .build();
{
  "class" : "GenerateObjects",
  "input" : [ {
    "class" : "Entity",
    "group" : "entity",
    "vertex" : 6,
    "properties" : {
      "count" : 1
    }
  }, {
    "class" : "Edge",
    "group" : "edge",
    "source" : 5,
    "destination" : 6,
    "directed" : true,
    "properties" : {
      "count" : 1
    }
  } ],
  "elementGenerator" : {
    "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateObjectsExample$DomainObjectGenerator"
  }
}
{
  "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects",
  "input" : [ {
    "class" : "uk.gov.gchq.gaffer.data.element.Entity",
    "group" : "entity",
    "vertex" : 6,
    "properties" : {
      "count" : 1
    }
  }, {
    "class" : "uk.gov.gchq.gaffer.data.element.Edge",
    "group" : "edge",
    "source" : 5,
    "destination" : 6,
    "directed" : true,
    "properties" : {
      "count" : 1
    }
  } ],
  "elementGenerator" : {
    "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateObjectsExample$DomainObjectGenerator"
  }
}
g.GenerateObjects( 
  input=[ 
    g.Entity( 
      properties={'count': 1}, 
      group="entity", 
      vertex=6 
    ), 
    g.Edge( 
      properties={'count': 1}, 
      group="edge", 
      directed=True, 
      destination=6, 
      source=5 
    ) 
  ], 
  element_generator=g.ElementGenerator( 
    fields={'class': 'uk.gov.gchq.gaffer.doc.operation.GenerateObjectsExample$DomainObjectGenerator'}, 
    class_name="uk.gov.gchq.gaffer.doc.operation.GenerateObjectsExample$DomainObjectGenerator" 
  ) 
)

Result:

Java
JSON
GenerateObjectsExample.DomainObject1[a=6,c=1]
GenerateObjectsExample.DomainObject2[a=5,b=6,c=1]
[ {
  "a" : 6,
  "c" : 1
}, {
  "a" : 5,
  "b" : 6,
  "c" : 1
} ]


results matching ""

    No results matching ""